Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon

main
Bob Mottram 2021-06-26 16:57:51 +01:00
commit a0ca4c075b
54 changed files with 259 additions and 184 deletions

View File

@ -7,7 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "ActivityPub"
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import hasObjectDict
from utils import removeIdEnding
from utils import hasUsersPath

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
__module_group__ = "Profile Metadata"
import os
from webfinger import webfingerHandle

View File

@ -11,7 +11,7 @@ import os
import json
import time
from datetime import datetime
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import hasObjectDict
from utils import isAccountDir
from utils import getCachedPostFilename

View File

@ -26,6 +26,7 @@ from utils import getDomainFromActor
from utils import locatePost
from utils import loadJson
from utils import firstParagraphFromString
from utils import getActorPropertyUrl
from posts import createBlogsTimeline
from newswire import rss2Header
from newswire import rss2Footer
@ -884,3 +885,9 @@ def pathContainsBlogLink(baseDir: str,
messageId = httpPrefix + '://' + domainFull + \
'/users/' + nickname + '/statuses/' + userEnding2[1]
return locatePost(baseDir, nickname, domain, messageId), nickname
def getBlogAddress(actorJson: {}) -> str:
"""Returns blog address for the given actor
"""
return getActorPropertyUrl(actorJson, 'Blog')

View File

@ -11,7 +11,7 @@ import os
from pprint import pprint
from webfinger import webfingerHandle
from auth import createBasicAuthHeader
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import hasUsersPath
from utils import getFullDomain
from utils import removeIdEnding

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "ActivityPub"
__module_group__ = "Core"
import os
import datetime

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Spoofing"
__module_group__ = "Metadata"
import os
import datetime

View File

@ -11,7 +11,7 @@ import os
import email.parser
import urllib.parse
from shutil import copyfile
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import isValidLanguage
from utils import getImageExtensions
from utils import loadJson

View File

@ -140,13 +140,13 @@ from blog import htmlBlogView
from blog import htmlBlogPage
from blog import htmlBlogPost
from blog import htmlEditBlog
from blog import getBlogAddress
from webapp_minimalbutton import setMinimal
from webapp_minimalbutton import isMinimal
from webapp_utils import getAvatarImageUrl
from webapp_utils import htmlHashtagBlocked
from webapp_utils import htmlFollowingList
from webapp_utils import setBlogAddress
from webapp_utils import getBlogAddress
from webapp_calendar import htmlCalendarDeleteConfirm
from webapp_calendar import htmlCalendar
from webapp_about import htmlAbout

View File

@ -9,7 +9,7 @@ __module_group__ = "ActivityPub"
import os
from datetime import datetime
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import hasUsersPath
from utils import getFullDomain
from utils import removeIdEnding

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Security"
# REST API overview
#

View File

@ -1,32 +0,0 @@
__filename__ = "domainhandler.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
def removeDomainPort(domain: str) -> str:
"""If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com
"""
if ':' in domain:
if domain.startswith('did:'):
return domain
domain = domain.split(':')[0]
return domain
def getPortFromDomain(domain: str) -> int:
"""If the domain has a port number appended then return it
eg. mydomain.com:80 returns 80
"""
if ':' in domain:
if domain.startswith('did:'):
return None
portStr = domain.split(':')[1]
if portStr.isdigit():
return int(portStr)
return None

View File

@ -61,8 +61,8 @@ from tests import testUpdateActor
from tests import runAllTests
from auth import storeBasicCredentials
from auth import createPassword
from domainhandler import removeDomainPort
from domainhandler import getPortFromDomain
from utils import removeDomainPort
from utils import getPortFromDomain
from utils import hasUsersPath
from utils import getFullDomain
from utils import setConfigParam

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Moderation"
import os

View File

@ -9,7 +9,7 @@ __module_group__ = "ActivityPub"
from pprint import pprint
import os
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import hasObjectDict
from utils import hasUsersPath
from utils import getFullDomain

View File

@ -8,7 +8,18 @@ __status__ = "Production"
__module_group__ = "Calendar"
import os
from domainhandler import removeDomainPort
def _portDomainRemove(domain: str) -> str:
"""If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com
same as removeDomainPort in utils.py
"""
if ':' in domain:
if domain.startswith('did:'):
return domain
domain = domain.split(':')[0]
return domain
def receivingCalendarEvents(baseDir: str, nickname: str, domain: str,
@ -44,7 +55,7 @@ def _receiveCalendarEvents(baseDir: str, nickname: str, domain: str,
indicating whether to receive calendar events from that account
"""
# check that a following file exists
domain = removeDomainPort(domain)
domain = _portDomainRemove(domain)
followingFilename = baseDir + '/accounts/' + \
nickname + '@' + domain + '/following.txt'
if not os.path.isfile(followingFilename):

2
git.py
View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
__module_group__ = "Profile Metadata"
import os
import html

View File

@ -13,8 +13,8 @@ import datetime
import time
import random
from linked_data_sig import verifyJsonSignature
from domainhandler import removeDomainPort
from domainhandler import getPortFromDomain
from utils import removeDomainPort
from utils import getPortFromDomain
from utils import hasObjectDict
from utils import dmAllowedFromDomain
from utils import isRecentPost

View File

@ -7,7 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "ActivityPub"
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import hasObjectDict
from utils import hasUsersPath
from utils import getFullDomain

View File

@ -12,8 +12,8 @@ from follow import followedAccountAccepts
from follow import followedAccountRejects
from follow import removeFromFollowRequests
from utils import loadJson
from domainhandler import removeDomainPort
from domainhandler import getPortFromDomain
from utils import removeDomainPort
from utils import getPortFromDomain
def manualDenyFollowRequest(session, baseDir: str,

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
__module_group__ = "API"
import os
from utils import loadJson

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "RSS Feeds"
__module_group__ = "Web Interface Columns"
# Example hashtag logic:
#

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "RSS Feeds"
__module_group__ = "Web Interface Columns"
import os
import json

View File

@ -38,7 +38,7 @@ from roles import setRole
from roles import setRolesFromList
from roles import getActorRolesList
from media import processMetaData
from domainhandler import removeDomainPort
from utils import removeDomainPort
from utils import getStatusNumber
from utils import getFullDomain
from utils import validNickname

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
import os

View File

@ -32,8 +32,8 @@ from session import postImage
from webfinger import webfingerHandle
from httpsig import createSignedHeader
from siteactive import siteIsActive
from domainhandler import removeDomainPort
from domainhandler import getPortFromDomain
from utils import removeDomainPort
from utils import getPortFromDomain
from utils import hasObjectDict
from utils import rejectPostId
from utils import removeInvalidChars

View File

@ -15,7 +15,7 @@ JSON-LD.
__copyright__ = 'Copyright (c) 2011-2014 Digital Bazaar, Inc.'
__license__ = 'New BSD license'
__version__ = '0.6.8'
__module_group__ = "ActivityPub"
__module_group__ = "Security"
__all__ = [
'compact', 'expand', 'flatten', 'frame', 'link', 'from_rdf', 'to_rdf',

View File

@ -5,12 +5,13 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Profile Metadata"
import os
from utils import loadJson
from utils import saveJson
from utils import getStatusNumber
from domainhandler import removeDomainPort
from utils import removeDomainPort
def _clearRoleStatus(baseDir: str, role: str) -> None:

View File

@ -20,7 +20,7 @@ from utils import loadJson
from utils import saveJson
from utils import getImageExtensions
from utils import hasObjectDict
from domainhandler import removeDomainPort
from utils import removeDomainPort
from media import processMetaData

View File

@ -6,6 +6,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
import http.client
from urllib.parse import urlparse

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Profile Metadata"
import os
from webfinger import webfingerHandle

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Moderation"
from session import createSession
from webfinger import webfingerHandle

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Accessibility"
import os
import html

153
tests.py
View File

@ -2890,6 +2890,91 @@ def _functionArgsMatch(callArgs: [], funcArgs: []):
return callArgsCtr >= funcArgsCtr
def _moduleInGroups(modName: str, includeGroups: [], modGroups: {}) -> bool:
"""Is the given module within the included groups list?
"""
for groupName in includeGroups:
if modName in modGroups[groupName]:
return True
return False
def _diagramGroups(includeGroups: [],
excludeExtraModules: [],
modules: {}, modGroups: {},
maxModuleCalls: int) -> None:
"""Draws a dot diagram containing only the given module groups
"""
callGraphStr = 'digraph EpicyonGroups {\n\n'
callGraphStr += ' graph [fontsize=10 fontname="Verdana" compound=true];\n'
callGraphStr += ' node [fontsize=10 fontname="Verdana"];\n\n'
excludeModulesFromDiagram = [
'setup', 'tests', '__init__', 'pyjsonld'
]
excludeModulesFromDiagram += excludeExtraModules
# colors of modules nodes
for modName, modProperties in modules.items():
if modName in excludeModulesFromDiagram:
continue
if not _moduleInGroups(modName, includeGroups, modGroups):
continue
if not modProperties.get('calls'):
callGraphStr += ' "' + modName + \
'" [fillcolor=yellow style=filled];\n'
continue
if len(modProperties['calls']) <= int(maxModuleCalls / 8):
callGraphStr += ' "' + modName + \
'" [fillcolor=green style=filled];\n'
elif len(modProperties['calls']) < int(maxModuleCalls / 4):
callGraphStr += ' "' + modName + \
'" [fillcolor=orange style=filled];\n'
else:
callGraphStr += ' "' + modName + \
'" [fillcolor=red style=filled];\n'
callGraphStr += '\n'
# connections between modules
for modName, modProperties in modules.items():
if modName in excludeModulesFromDiagram:
continue
if not _moduleInGroups(modName, includeGroups, modGroups):
continue
if not modProperties.get('calls'):
continue
for modCall in modProperties['calls']:
if modCall in excludeModulesFromDiagram:
continue
if not _moduleInGroups(modCall, includeGroups, modGroups):
continue
callGraphStr += ' "' + modName + '" -> "' + modCall + '";\n'
# module groups/clusters
clusterCtr = 1
for groupName, groupModules in modGroups.items():
if groupName not in includeGroups:
continue
callGraphStr += '\n'
callGraphStr += \
' subgraph cluster_' + str(clusterCtr) + ' {\n'
callGraphStr += ' node [style=filled];\n'
for modName in groupModules:
if modName not in excludeModulesFromDiagram:
callGraphStr += ' ' + modName + ';\n'
callGraphStr += ' label = "' + groupName + '";\n'
callGraphStr += ' color = blue;\n'
callGraphStr += ' }\n'
clusterCtr += 1
callGraphStr += '\n}\n'
filename = 'epicyon_groups'
for groupName in includeGroups:
filename += '_' + groupName.replace(' ', '-')
filename += '.dot'
with open(filename, 'w+') as fp:
fp.write(callGraphStr)
print('Graph saved to ' + filename)
print('Plot using: ' +
'sfdp -x -Goverlap=false -Goverlap_scaling=2 ' +
'-Gsep=+100 -Tx11 epicyon_modules.dot')
def _testFunctions():
print('testFunctions')
function = {}
@ -3139,51 +3224,29 @@ def _testFunctions():
else:
modules[modName]['calls'] = [modCall]
lineCtr += 1
callGraphStr = 'digraph EpicyonModules {\n\n'
callGraphStr += ' graph [fontsize=10 fontname="Verdana" compound=true];\n'
callGraphStr += ' node [shape=record fontsize=10 fontname="Verdana"];\n\n'
# colors of modules nodes
for modName, modProperties in modules.items():
if not modProperties.get('calls'):
callGraphStr += ' "' + modName + \
'" [fillcolor=yellow style=filled];\n'
continue
if len(modProperties['calls']) <= int(maxModuleCalls / 8):
callGraphStr += ' "' + modName + \
'" [fillcolor=green style=filled];\n'
elif len(modProperties['calls']) < int(maxModuleCalls / 4):
callGraphStr += ' "' + modName + \
'" [fillcolor=orange style=filled];\n'
else:
callGraphStr += ' "' + modName + \
'" [fillcolor=red style=filled];\n'
callGraphStr += '\n'
# connections between modules
for modName, modProperties in modules.items():
if not modProperties.get('calls'):
continue
for modCall in modProperties['calls']:
callGraphStr += ' "' + modName + '" -> "' + modCall + '";\n'
# module groups/clusters
clusterCtr = 1
for groupName, groupModules in modGroups.items():
callGraphStr += '\n'
callGraphStr += \
' subgraph cluster_' + str(clusterCtr) + ' {\n'
callGraphStr += ' node [style=filled];\n'
for modName in groupModules:
callGraphStr += ' ' + modName + ';\n'
callGraphStr += ' label = "' + groupName + '";\n'
callGraphStr += ' color = blue;\n'
callGraphStr += ' }\n'
clusterCtr += 1
callGraphStr += '\n}\n'
with open('epicyon_modules.dot', 'w+') as fp:
fp.write(callGraphStr)
print('Modules call graph saved to epicyon_modules.dot')
print('Plot using: ' +
'sfdp -x -Goverlap=false -Goverlap_scaling=2 ' +
'-Gsep=+100 -Tx11 epicyon_modules.dot')
_diagramGroups(['Commandline Interface', 'ActivityPub'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Commandline Interface', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Timeline', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Web Interface', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Web Interface Columns', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Core'], [],
modules, modGroups, maxModuleCalls)
_diagramGroups(['ActivityPub'], [],
modules, modGroups, maxModuleCalls)
_diagramGroups(['ActivityPub', 'Core'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['ActivityPub', 'Security'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Core', 'Security'], ['utils'],
modules, modGroups, maxModuleCalls)
_diagramGroups(['Timeline', 'Security'], ['utils'],
modules, modGroups, maxModuleCalls)
callGraphStr = 'digraph Epicyon {\n\n'
callGraphStr += ' size="8,6"; ratio=fill;\n'

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
import os
from utils import isAccountDir

View File

@ -5,6 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Core"
import threading
import sys

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "ActivityPu"
__module_group__ = "Core"
import os
import re
@ -16,8 +16,6 @@ import json
import idna
import locale
from pprint import pprint
from domainhandler import removeDomainPort
from domainhandler import getPortFromDomain
from followingCalendar import addPersonToCalendar
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
@ -2403,3 +2401,77 @@ def hasObjectDict(postJsonObject: {}) -> bool:
if isinstance(postJsonObject['object'], dict):
return True
return False
def getAltPath(actor: str, domainFull: str, callingDomain: str) -> str:
"""Returns alternate path from the actor
eg. https://clearnetdomain/path becomes http://oniondomain/path
"""
postActor = actor
if callingDomain not in actor and domainFull in actor:
if callingDomain.endswith('.onion') or \
callingDomain.endswith('.i2p'):
postActor = \
'http://' + callingDomain + actor.split(domainFull)[1]
print('Changed POST domain from ' + actor + ' to ' + postActor)
return postActor
def getActorPropertyUrl(actorJson: {}, propertyName: str) -> str:
"""Returns a url property from an actor
"""
if not actorJson.get('attachment'):
return ''
propertyName = propertyName.lower()
for propertyValue in actorJson['attachment']:
if not propertyValue.get('name'):
continue
if not propertyValue['name'].lower().startswith(propertyName):
continue
if not propertyValue.get('type'):
continue
if not propertyValue.get('value'):
continue
if propertyValue['type'] != 'PropertyValue':
continue
propertyValue['value'] = propertyValue['value'].strip()
prefixes = getProtocolPrefixes()
prefixFound = False
for prefix in prefixes:
if propertyValue['value'].startswith(prefix):
prefixFound = True
break
if not prefixFound:
continue
if '.' not in propertyValue['value']:
continue
if ' ' in propertyValue['value']:
continue
if ',' in propertyValue['value']:
continue
return propertyValue['value']
return ''
def removeDomainPort(domain: str) -> str:
"""If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com
"""
if ':' in domain:
if domain.startswith('did:'):
return domain
domain = domain.split(':')[0]
return domain
def getPortFromDomain(domain: str) -> int:
"""If the domain has a port number appended then return it
eg. mydomain.com:80 returns 80
"""
if ':' in domain:
if domain.startswith('did:'):
return None
portStr = domain.split(':')[1]
if portStr.isdigit():
return int(portStr)
return None

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Accessibility"
import os
from utils import isAccountDir

View File

@ -18,12 +18,12 @@ from utils import getDomainFromActor
from utils import locatePost
from utils import loadJson
from utils import weekDayOfMonthStart
from domainhandler import removeDomainPort
from utils import getAltPath
from utils import removeDomainPort
from happening import getTodaysEvents
from happening import getCalendarEvents
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_utils import getAltPath
from webapp_utils import htmlHideFromScreenReader
from webapp_utils import htmlKeyboardNavigation

View File

@ -5,13 +5,13 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Web Interface Columns"
import os
from utils import getConfigParam
from utils import getNicknameFromActor
from utils import isEditor
from domainhandler import removeDomainPort
from utils import removeDomainPort
from webapp_utils import sharesTimelineJson
from webapp_utils import htmlPostSeparator
from webapp_utils import getLeftImageFile

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Web Interface Columns"
import os
from datetime import datetime
@ -17,7 +17,7 @@ from utils import votesOnNewswireItem
from utils import getNicknameFromActor
from utils import isEditor
from utils import getConfigParam
from domainhandler import removeDomainPort
from utils import removeDomainPort
from posts import isModerator
from webapp_utils import getRightImageFile
from webapp_utils import htmlHeaderWithExternalStyle

View File

@ -15,7 +15,7 @@ from utils import getDomainFromActor
from utils import locatePost
from utils import loadJson
from utils import getConfigParam
from webapp_utils import getAltPath
from utils import getAltPath
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_post import individualPostAsHtml

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Timeline"
import os
from utils import isSystemAccount

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Timeline"
import os

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Timeline"
import os

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Timeline"
import os

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Moderation"
import os
from utils import isAccountDir

View File

@ -52,7 +52,7 @@ from webapp_utils import htmlFooter
from webapp_utils import addEmojiToDisplayName
from webapp_utils import getBannerFile
from webapp_utils import htmlPostSeparator
from webapp_utils import getBlogAddress
from blog import getBlogAddress
from webapp_post import individualPostAsHtml
from webapp_timeline import htmlIndividualShare

View File

@ -22,13 +22,13 @@ from utils import locatePost
from utils import isPublicPost
from utils import firstParagraphFromString
from utils import searchBoxPosts
from utils import getAltPath
from skills import noOfActorSkills
from skills import getSkillsFromList
from categories import getHashtagCategory
from feeds import rss2TagHeader
from feeds import rss2TagFooter
from webapp_utils import htmlKeyboardNavigation
from webapp_utils import getAltPath
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_utils import getSearchBannerFile

View File

@ -150,20 +150,6 @@ def headerButtonsFrontScreen(translate: {},
return headerStr
def getAltPath(actor: str, domainFull: str, callingDomain: str) -> str:
"""Returns alternate path from the actor
eg. https://clearnetdomain/path becomes http://oniondomain/path
"""
postActor = actor
if callingDomain not in actor and domainFull in actor:
if callingDomain.endswith('.onion') or \
callingDomain.endswith('.i2p'):
postActor = \
'http://' + callingDomain + actor.split(domainFull)[1]
print('Changed POST domain from ' + actor + ' to ' + postActor)
return postActor
def getContentWarningButton(postID: str, translate: {},
content: str) -> str:
"""Returns the markup for a content warning button
@ -174,48 +160,6 @@ def getContentWarningButton(postID: str, translate: {},
'</div></details>\n'
def _getActorPropertyUrl(actorJson: {}, propertyName: str) -> str:
"""Returns a url property from an actor
"""
if not actorJson.get('attachment'):
return ''
propertyName = propertyName.lower()
for propertyValue in actorJson['attachment']:
if not propertyValue.get('name'):
continue
if not propertyValue['name'].lower().startswith(propertyName):
continue
if not propertyValue.get('type'):
continue
if not propertyValue.get('value'):
continue
if propertyValue['type'] != 'PropertyValue':
continue
propertyValue['value'] = propertyValue['value'].strip()
prefixes = getProtocolPrefixes()
prefixFound = False
for prefix in prefixes:
if propertyValue['value'].startswith(prefix):
prefixFound = True
break
if not prefixFound:
continue
if '.' not in propertyValue['value']:
continue
if ' ' in propertyValue['value']:
continue
if ',' in propertyValue['value']:
continue
return propertyValue['value']
return ''
def getBlogAddress(actorJson: {}) -> str:
"""Returns blog address for the given actor
"""
return _getActorPropertyUrl(actorJson, 'Blog')
def _setActorPropertyUrl(actorJson: {}, propertyName: str, url: str) -> None:
"""Sets a url for the given actor property
"""

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Onboarding"
import os
from shutil import copyfile

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Onboarding"
import os
from shutil import copyfile

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
__module_group__ = "Web Interface"
__module_group__ = "Onboarding"
import os
from shutil import copyfile

View File

@ -17,7 +17,7 @@ from utils import loadJson
from utils import loadJsonOnionify
from utils import saveJson
from utils import getProtocolPrefixes
from domainhandler import removeDomainPort
from utils import removeDomainPort
def _parseHandle(handle: str) -> (str, str):