Module groups

main
Bob Mottram 2021-06-26 12:16:41 +01:00
parent d7ad3733ff
commit a194ada543
24 changed files with 79 additions and 68 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

2
git.py
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ __version__ = "1.2.0"
__maintainer__ = "Bob Mottram" __maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net" __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
__module_group__ = "ActivityPu" __module_group__ = "Core"
import os import os
import re import re
@ -2403,3 +2403,53 @@ def hasObjectDict(postJsonObject: {}) -> bool:
if isinstance(postJsonObject['object'], dict): if isinstance(postJsonObject['object'], dict):
return True return True
return False 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 ''

View File

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

View File

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

View File

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

View File

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

View File

@ -150,20 +150,6 @@ def headerButtonsFrontScreen(translate: {},
return headerStr 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: {}, def getContentWarningButton(postID: str, translate: {},
content: str) -> str: content: str) -> str:
"""Returns the markup for a content warning button """Returns the markup for a content warning button
@ -174,48 +160,6 @@ def getContentWarningButton(postID: str, translate: {},
'</div></details>\n' '</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: def _setActorPropertyUrl(actorJson: {}, propertyName: str, url: str) -> None:
"""Sets a url for the given actor property """Sets a url for the given actor property
""" """