Snake case

main
Bob Mottram 2021-12-26 10:08:06 +00:00
parent 6abe5d83fe
commit efa481ad39
2 changed files with 71 additions and 71 deletions

View File

@ -100,7 +100,7 @@ def htmlFrontScreen(signing_priv_key_pem: str,
recentPostsCache: {}, max_recent_posts: int, recentPostsCache: {}, max_recent_posts: int,
translate: {}, project_version: str, translate: {}, project_version: str,
base_dir: str, http_prefix: str, authorized: bool, base_dir: str, http_prefix: str, authorized: bool,
profileJson: {}, selected: str, profile_json: {}, selected: str,
session, cached_webfingers: {}, person_cache: {}, session, cached_webfingers: {}, person_cache: {},
yt_replace_domain: str, yt_replace_domain: str,
twitter_replacement_domain: str, twitter_replacement_domain: str,
@ -117,12 +117,12 @@ def htmlFrontScreen(signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str) -> str: cw_lists: {}, lists_enabled: str) -> str:
"""Show the news instance front screen """Show the news instance front screen
""" """
nickname = profileJson['preferredUsername'] nickname = profile_json['preferredUsername']
if not nickname: if not nickname:
return "" return ""
if not isSystemAccount(nickname): if not isSystemAccount(nickname):
return "" return ""
domain, port = getDomainFromActor(profileJson['id']) domain, port = getDomainFromActor(profile_json['id'])
if not domain: if not domain:
return "" return ""
domain_full = domain domain_full = domain

View File

@ -149,13 +149,13 @@ def htmlProfileAfterSearch(cssCache: {},
http = True http = True
elif http_prefix == 'gnunet': elif http_prefix == 'gnunet':
gnunet = True gnunet = True
profileJson, asHeader = \ profile_json, asHeader = \
getActorJson(domain, profileHandle, http, gnunet, debug, False, getActorJson(domain, profileHandle, http, gnunet, debug, False,
signing_priv_key_pem, session) signing_priv_key_pem, session)
if not profileJson: if not profile_json:
return None return None
personUrl = profileJson['id'] personUrl = profile_json['id']
searchDomain, searchPort = getDomainFromActor(personUrl) searchDomain, searchPort = getDomainFromActor(personUrl)
if not searchDomain: if not searchDomain:
return None return None
@ -170,27 +170,27 @@ def htmlProfileAfterSearch(cssCache: {},
cssFilename = base_dir + '/epicyon.css' cssFilename = base_dir + '/epicyon.css'
isGroup = False isGroup = False
if profileJson.get('type'): if profile_json.get('type'):
if profileJson['type'] == 'Group': if profile_json['type'] == 'Group':
isGroup = True isGroup = True
avatarUrl = '' avatarUrl = ''
if profileJson.get('icon'): if profile_json.get('icon'):
if profileJson['icon'].get('url'): if profile_json['icon'].get('url'):
avatarUrl = profileJson['icon']['url'] avatarUrl = profile_json['icon']['url']
if not avatarUrl: if not avatarUrl:
avatarUrl = getPersonAvatarUrl(base_dir, personUrl, avatarUrl = getPersonAvatarUrl(base_dir, personUrl,
person_cache, True) person_cache, True)
displayName = searchNickname displayName = searchNickname
if profileJson.get('name'): if profile_json.get('name'):
displayName = profileJson['name'] displayName = profile_json['name']
lockedAccount = getLockedAccount(profileJson) lockedAccount = getLockedAccount(profile_json)
if lockedAccount: if lockedAccount:
displayName += '🔒' displayName += '🔒'
movedTo = '' movedTo = ''
if profileJson.get('movedTo'): if profile_json.get('movedTo'):
movedTo = profileJson['movedTo'] movedTo = profile_json['movedTo']
if '"' in movedTo: if '"' in movedTo:
movedTo = movedTo.split('"')[1] movedTo = movedTo.split('"')[1]
displayName += '' displayName += ''
@ -202,20 +202,20 @@ def htmlProfileAfterSearch(cssCache: {},
searchDomainFull) searchDomainFull)
profileDescription = '' profileDescription = ''
if profileJson.get('summary'): if profile_json.get('summary'):
profileDescription = profileJson['summary'] profileDescription = profile_json['summary']
outboxUrl = None outboxUrl = None
if not profileJson.get('outbox'): if not profile_json.get('outbox'):
if debug: if debug:
pprint(profileJson) pprint(profile_json)
print('DEBUG: No outbox found') print('DEBUG: No outbox found')
return None return None
outboxUrl = profileJson['outbox'] outboxUrl = profile_json['outbox']
# profileBackgroundImage = '' # profileBackgroundImage = ''
# if profileJson.get('image'): # if profile_json.get('image'):
# if profileJson['image'].get('url'): # if profile_json['image'].get('url'):
# profileBackgroundImage = profileJson['image']['url'] # profileBackgroundImage = profile_json['image']['url']
# url to return to # url to return to
backUrl = path backUrl = path
@ -235,28 +235,28 @@ def htmlProfileAfterSearch(cssCache: {},
profileDescriptionShort = '' profileDescriptionShort = ''
# remove formatting from profile description used on title # remove formatting from profile description used on title
avatarDescription = '' avatarDescription = ''
if profileJson.get('summary'): if profile_json.get('summary'):
if isinstance(profileJson['summary'], str): if isinstance(profile_json['summary'], str):
avatarDescription = \ avatarDescription = \
profileJson['summary'].replace('<br>', '\n') profile_json['summary'].replace('<br>', '\n')
avatarDescription = avatarDescription.replace('<p>', '') avatarDescription = avatarDescription.replace('<p>', '')
avatarDescription = avatarDescription.replace('</p>', '') avatarDescription = avatarDescription.replace('</p>', '')
if '<' in avatarDescription: if '<' in avatarDescription:
avatarDescription = removeHtml(avatarDescription) avatarDescription = removeHtml(avatarDescription)
imageUrl = '' imageUrl = ''
if profileJson.get('image'): if profile_json.get('image'):
if profileJson['image'].get('url'): if profile_json['image'].get('url'):
imageUrl = profileJson['image']['url'] imageUrl = profile_json['image']['url']
alsoKnownAs = None alsoKnownAs = None
if profileJson.get('alsoKnownAs'): if profile_json.get('alsoKnownAs'):
alsoKnownAs = profileJson['alsoKnownAs'] alsoKnownAs = profile_json['alsoKnownAs']
joinedDate = None joinedDate = None
if profileJson.get('published'): if profile_json.get('published'):
if 'T' in profileJson['published']: if 'T' in profile_json['published']:
joinedDate = profileJson['published'] joinedDate = profile_json['published']
profileStr = \ profileStr = \
_getProfileHeaderAfterSearch(base_dir, _getProfileHeaderAfterSearch(base_dir,
@ -267,14 +267,14 @@ def htmlProfileAfterSearch(cssCache: {},
displayName, followsYou, displayName, followsYou,
profileDescriptionShort, profileDescriptionShort,
avatarUrl, imageUrl, avatarUrl, imageUrl,
movedTo, profileJson['id'], movedTo, profile_json['id'],
alsoKnownAs, accessKeys, alsoKnownAs, accessKeys,
joinedDate) joinedDate)
domain_full = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
followIsPermitted = True followIsPermitted = True
if not profileJson.get('followers'): if not profile_json.get('followers'):
# no followers collection specified within actor # no followers collection specified within actor
followIsPermitted = False followIsPermitted = False
elif searchNickname == 'news' and searchDomainFull == domain_full: elif searchNickname == 'news' and searchDomainFull == domain_full:
@ -548,7 +548,7 @@ def htmlProfile(signing_priv_key_pem: str,
recentPostsCache: {}, max_recent_posts: int, recentPostsCache: {}, max_recent_posts: int,
translate: {}, project_version: str, translate: {}, project_version: str,
base_dir: str, http_prefix: str, authorized: bool, base_dir: str, http_prefix: str, authorized: bool,
profileJson: {}, selected: str, profile_json: {}, selected: str,
session, cached_webfingers: {}, person_cache: {}, session, cached_webfingers: {}, person_cache: {},
yt_replace_domain: str, yt_replace_domain: str,
twitter_replacement_domain: str, twitter_replacement_domain: str,
@ -566,7 +566,7 @@ def htmlProfile(signing_priv_key_pem: str,
content_license_url: str) -> str: content_license_url: str) -> str:
"""Show the profile page as html """Show the profile page as html
""" """
nickname = profileJson['preferredUsername'] nickname = profile_json['preferredUsername']
if not nickname: if not nickname:
return "" return ""
if isSystemAccount(nickname): if isSystemAccount(nickname):
@ -577,7 +577,7 @@ def htmlProfile(signing_priv_key_pem: str,
recentPostsCache, max_recent_posts, recentPostsCache, max_recent_posts,
translate, project_version, translate, project_version,
base_dir, http_prefix, authorized, base_dir, http_prefix, authorized,
profileJson, selected, profile_json, selected,
session, cached_webfingers, person_cache, session, cached_webfingers, person_cache,
yt_replace_domain, yt_replace_domain,
twitter_replacement_domain, twitter_replacement_domain,
@ -589,18 +589,18 @@ def htmlProfile(signing_priv_key_pem: str,
pageNumber, maxItemsPerPage, cw_lists, pageNumber, maxItemsPerPage, cw_lists,
lists_enabled) lists_enabled)
domain, port = getDomainFromActor(profileJson['id']) domain, port = getDomainFromActor(profile_json['id'])
if not domain: if not domain:
return "" return ""
displayName = \ displayName = \
addEmojiToDisplayName(session, base_dir, http_prefix, addEmojiToDisplayName(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
profileJson['name'], True) profile_json['name'], True)
domain_full = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
profileDescription = \ profileDescription = \
addEmojiToDisplayName(session, base_dir, http_prefix, addEmojiToDisplayName(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
profileJson['summary'], False) profile_json['summary'], False)
postsButton = 'button' postsButton = 'button'
followingButton = 'button' followingButton = 'button'
followersButton = 'button' followersButton = 'button'
@ -628,24 +628,24 @@ def htmlProfile(signing_priv_key_pem: str,
followApprovals = False followApprovals = False
editProfileStr = '' editProfileStr = ''
logoutStr = '' logoutStr = ''
actor = profileJson['id'] actor = profile_json['id']
usersPath = '/users/' + actor.split('/users/')[1] usersPath = '/users/' + actor.split('/users/')[1]
donateSection = '' donateSection = ''
donateUrl = getDonationUrl(profileJson) donateUrl = getDonationUrl(profile_json)
websiteUrl = getWebsite(profileJson, translate) websiteUrl = getWebsite(profile_json, translate)
blogAddress = getBlogAddress(profileJson) blogAddress = getBlogAddress(profile_json)
EnigmaPubKey = getEnigmaPubKey(profileJson) EnigmaPubKey = getEnigmaPubKey(profile_json)
PGPpubKey = getPGPpubKey(profileJson) PGPpubKey = getPGPpubKey(profile_json)
PGPfingerprint = getPGPfingerprint(profileJson) PGPfingerprint = getPGPfingerprint(profile_json)
emailAddress = getEmailAddress(profileJson) emailAddress = getEmailAddress(profile_json)
xmppAddress = getXmppAddress(profileJson) xmppAddress = getXmppAddress(profile_json)
matrixAddress = getMatrixAddress(profileJson) matrixAddress = getMatrixAddress(profile_json)
ssbAddress = getSSBAddress(profileJson) ssbAddress = getSSBAddress(profile_json)
toxAddress = getToxAddress(profileJson) toxAddress = getToxAddress(profile_json)
briarAddress = getBriarAddress(profileJson) briarAddress = getBriarAddress(profile_json)
jamiAddress = getJamiAddress(profileJson) jamiAddress = getJamiAddress(profile_json)
cwtchAddress = getCwtchAddress(profileJson) cwtchAddress = getCwtchAddress(profile_json)
if donateUrl or websiteUrl or xmppAddress or matrixAddress or \ if donateUrl or websiteUrl or xmppAddress or matrixAddress or \
ssbAddress or toxAddress or briarAddress or \ ssbAddress or toxAddress or briarAddress or \
jamiAddress or cwtchAddress or PGPpubKey or EnigmaPubKey or \ jamiAddress or cwtchAddress or PGPpubKey or EnigmaPubKey or \
@ -803,30 +803,30 @@ def htmlProfile(signing_priv_key_pem: str,
profileDescriptionShort = '' profileDescriptionShort = ''
# remove formatting from profile description used on title # remove formatting from profile description used on title
avatarDescription = '' avatarDescription = ''
if profileJson.get('summary'): if profile_json.get('summary'):
avatarDescription = profileJson['summary'].replace('<br>', '\n') avatarDescription = profile_json['summary'].replace('<br>', '\n')
avatarDescription = avatarDescription.replace('<p>', '') avatarDescription = avatarDescription.replace('<p>', '')
avatarDescription = avatarDescription.replace('</p>', '') avatarDescription = avatarDescription.replace('</p>', '')
movedTo = '' movedTo = ''
if profileJson.get('movedTo'): if profile_json.get('movedTo'):
movedTo = profileJson['movedTo'] movedTo = profile_json['movedTo']
if '"' in movedTo: if '"' in movedTo:
movedTo = movedTo.split('"')[1] movedTo = movedTo.split('"')[1]
alsoKnownAs = None alsoKnownAs = None
if profileJson.get('alsoKnownAs'): if profile_json.get('alsoKnownAs'):
alsoKnownAs = profileJson['alsoKnownAs'] alsoKnownAs = profile_json['alsoKnownAs']
joinedDate = None joinedDate = None
if profileJson.get('published'): if profile_json.get('published'):
if 'T' in profileJson['published']: if 'T' in profile_json['published']:
joinedDate = profileJson['published'] joinedDate = profile_json['published']
occupationName = None occupationName = None
if profileJson.get('hasOccupation'): if profile_json.get('hasOccupation'):
occupationName = getOccupationName(profileJson) occupationName = getOccupationName(profile_json)
avatarUrl = profileJson['icon']['url'] avatarUrl = profile_json['icon']['url']
# use alternate path for local avatars to avoid any caching issues # use alternate path for local avatars to avoid any caching issues
if '://' + domain_full + '/system/accounts/avatars/' in avatarUrl: if '://' + domain_full + '/system/accounts/avatars/' in avatarUrl:
avatarUrl = \ avatarUrl = \
@ -1019,7 +1019,7 @@ def htmlProfile(signing_priv_key_pem: str,
getConfigParam(base_dir, 'instanceTitle') getConfigParam(base_dir, 'instanceTitle')
profileStr = \ profileStr = \
htmlHeaderWithPersonMarkup(cssFilename, instanceTitle, htmlHeaderWithPersonMarkup(cssFilename, instanceTitle,
profileJson, city, profile_json, city,
content_license_url) + \ content_license_url) + \
profileStr + htmlFooter() profileStr + htmlFooter()
return profileStr return profileStr