Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2021-11-07 15:33:54 +00:00
commit a54e9c4d0c
22 changed files with 248 additions and 74 deletions

View File

@ -487,7 +487,7 @@ def htmlBlogPage(authorized: bool, session,
cssFilename = baseDir + '/epicyon.css' cssFilename = baseDir + '/epicyon.css'
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
_htmlBlogRemoveCwButton(blogStr, translate) _htmlBlogRemoveCwButton(blogStr, translate)
blogsIndex = acctDir(baseDir, nickname, domain) + '/tlblogs.index' blogsIndex = acctDir(baseDir, nickname, domain) + '/tlblogs.index'
@ -707,7 +707,7 @@ def htmlBlogView(authorized: bool,
cssFilename = baseDir + '/epicyon.css' cssFilename = baseDir + '/epicyon.css'
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
if _noOfBlogAccounts(baseDir) <= 1: if _noOfBlogAccounts(baseDir) <= 1:
nickname = _singleBlogAccountNickname(baseDir) nickname = _singleBlogAccountNickname(baseDir)
@ -810,7 +810,8 @@ def htmlEditBlog(mediaInstance: bool, translate: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
editBlogForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) editBlogForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
editBlogForm += \ editBlogForm += \
'<form enctype="multipart/form-data" method="POST" ' + \ '<form enctype="multipart/form-data" method="POST" ' + \

View File

@ -76,7 +76,7 @@ def htmlWatchPointsGraph(baseDir: str, fitness: {}, fitnessId: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
htmlStr += \ htmlStr += \
'<table class="graph">\n' + \ '<table class="graph">\n' + \
'<caption>Watchpoints for ' + fitnessId + '</caption>\n' + \ '<caption>Watchpoints for ' + fitnessId + '</caption>\n' + \

View File

@ -60,7 +60,8 @@ def htmlAccessKeys(cssCache: {}, baseDir: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
accessKeysForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) accessKeysForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
accessKeysForm += '<div class="container">\n' accessKeysForm += '<div class="container">\n'
accessKeysForm += \ accessKeysForm += \

View File

@ -58,7 +58,8 @@ def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, baseDir: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
deletePostStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) deletePostStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
deletePostStr += \ deletePostStr += \
'<center><h1>' + postTime + ' ' + str(year) + '/' + \ '<center><h1>' + postTime + ' ' + str(year) + '/' + \
str(monthNumber) + \ str(monthNumber) + \
@ -120,7 +121,7 @@ def _htmlCalendarDay(personCache: {}, cssCache: {}, translate: {},
calActor = '/users/' + actor.split('/users/')[1] calActor = '/users/' + actor.split('/users/')[1]
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
calendarStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) calendarStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
calendarStr += '<main><table class="calendar">\n' calendarStr += '<main><table class="calendar">\n'
calendarStr += '<caption class="calendar__banner--month">\n' calendarStr += '<caption class="calendar__banner--month">\n'
calendarStr += \ calendarStr += \
@ -340,7 +341,7 @@ def htmlCalendar(personCache: {}, cssCache: {}, translate: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
headerStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) headerStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# the main graphical calendar as a table # the main graphical calendar as a table
calendarStr = '<main><table class="calendar">\n' calendarStr = '<main><table class="calendar">\n'

View File

@ -364,7 +364,7 @@ def htmlLinksMobile(cssCache: {}, baseDir: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
bannerFile, bannerFilename = \ bannerFile, bannerFilename = \
getBannerFile(baseDir, nickname, domain, theme) getBannerFile(baseDir, nickname, domain, theme)
htmlStr += \ htmlStr += \
@ -430,7 +430,8 @@ def htmlEditLinks(cssCache: {}, translate: {}, baseDir: str, path: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
editLinksForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) editLinksForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# top banner # top banner
editLinksForm += \ editLinksForm += \

View File

@ -361,7 +361,7 @@ def htmlCitations(baseDir: str, nickname: str, domain: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# top banner # top banner
bannerFile, bannerFilename = \ bannerFile, bannerFilename = \
@ -476,7 +476,7 @@ def htmlNewswireMobile(cssCache: {}, baseDir: str, nickname: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
bannerFile, bannerFilename = \ bannerFile, bannerFilename = \
getBannerFile(baseDir, nickname, domain, theme) getBannerFile(baseDir, nickname, domain, theme)
@ -545,7 +545,8 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
editNewswireForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) editNewswireForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# top banner # top banner
editNewswireForm += \ editNewswireForm += \
@ -667,7 +668,8 @@ def htmlEditNewsPost(cssCache: {}, translate: {}, baseDir: str, path: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
editNewsPostForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) editNewsPostForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
editNewsPostForm += \ editNewsPostForm += \
'<form enctype="multipart/form-data" method="POST" ' + \ '<form enctype="multipart/form-data" method="POST" ' + \
'accept-charset="UTF-8" action="' + path + '/newseditdata">\n' 'accept-charset="UTF-8" action="' + path + '/newseditdata">\n'

View File

@ -62,7 +62,8 @@ def htmlConfirmDelete(cssCache: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
deletePostStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) deletePostStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
deletePostStr += \ deletePostStr += \
individualPostAsHtml(signingPrivateKeyPem, individualPostAsHtml(signingPrivateKeyPem,
True, recentPostsCache, maxRecentPosts, True, recentPostsCache, maxRecentPosts,
@ -137,7 +138,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, baseDir: str,
cssFilename = baseDir + '/follow.css' cssFilename = baseDir + '/follow.css'
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
sharesStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) sharesStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
sharesStr += '<div class="follow">\n' sharesStr += '<div class="follow">\n'
sharesStr += ' <div class="followAvatar">\n' sharesStr += ' <div class="followAvatar">\n'
sharesStr += ' <center>\n' sharesStr += ' <center>\n'
@ -190,7 +191,7 @@ def htmlConfirmFollow(cssCache: {}, translate: {}, baseDir: str,
cssFilename = baseDir + '/follow.css' cssFilename = baseDir + '/follow.css'
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
followStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) followStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
followStr += '<div class="follow">\n' followStr += '<div class="follow">\n'
followStr += ' <div class="followAvatar">\n' followStr += ' <div class="followAvatar">\n'
followStr += ' <center>\n' followStr += ' <center>\n'
@ -235,7 +236,7 @@ def htmlConfirmUnfollow(cssCache: {}, translate: {}, baseDir: str,
cssFilename = baseDir + '/follow.css' cssFilename = baseDir + '/follow.css'
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
followStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) followStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
followStr += '<div class="follow">\n' followStr += '<div class="follow">\n'
followStr += ' <div class="followAvatar">\n' followStr += ' <div class="followAvatar">\n'
followStr += ' <center>\n' followStr += ' <center>\n'
@ -278,7 +279,7 @@ def htmlConfirmUnblock(cssCache: {}, translate: {}, baseDir: str,
cssFilename = baseDir + '/follow.css' cssFilename = baseDir + '/follow.css'
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
blockStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) blockStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
blockStr += '<div class="block">\n' blockStr += '<div class="block">\n'
blockStr += ' <div class="blockAvatar">\n' blockStr += ' <div class="blockAvatar">\n'
blockStr += ' <center>\n' blockStr += ' <center>\n'

View File

@ -597,7 +597,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
dateAndLocation += '</div>\n' dateAndLocation += '</div>\n'
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
newPostForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) newPostForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
newPostForm += \ newPostForm += \
'<header>\n' + \ '<header>\n' + \

View File

@ -207,6 +207,6 @@ def htmlFrontScreen(signingPrivateKeyPem: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
profileStr = \ profileStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) + \
profileStr + profileFooterStr + htmlFooter() profileStr + profileFooterStr + htmlFooter()
return profileStr return profileStr

View File

@ -209,7 +209,7 @@ def htmlSearchHashtagCategory(cssCache: {}, translate: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# show a banner above the search box # show a banner above the search box
searchBannerFile, searchBannerFilename = \ searchBannerFile, searchBannerFilename = \

View File

@ -95,7 +95,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
infoForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) infoForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
searchNickname = getNicknameFromActor(searchHandle) searchNickname = getNicknameFromActor(searchHandle)
searchDomain, searchPort = getDomainFromActor(searchHandle) searchDomain, searchPort = getDomainFromActor(searchHandle)
@ -282,7 +282,7 @@ def htmlModerationInfo(cssCache: {}, translate: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
infoForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) infoForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
infoForm += \ infoForm += \
'<center><h1><a href="/users/' + nickname + '/moderation">' + \ '<center><h1><a href="/users/' + nickname + '/moderation">' + \

View File

@ -129,7 +129,7 @@ def htmlPersonOptions(defaultTimeline: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
optionsStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) optionsStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
optionsStr += htmlKeyboardNavigation(textModeBanner, {}, {}) optionsStr += htmlKeyboardNavigation(textModeBanner, {}, {})
optionsStr += '<br><br>\n' optionsStr += '<br><br>\n'
optionsStr += '<div class="options">\n' optionsStr += '<div class="options">\n'

View File

@ -22,6 +22,7 @@ from posts import postIsMuted
from posts import getPersonBox from posts import getPersonBox
from posts import downloadAnnounce from posts import downloadAnnounce
from posts import populateRepliesJson from posts import populateRepliesJson
from utils import removeHtml
from utils import getActorLanguagesList from utils import getActorLanguagesList
from utils import getBaseContentFromPost from utils import getBaseContentFromPost
from utils import getContentFromPost from utils import getContentFromPost
@ -80,6 +81,94 @@ from blocking import isBlocked
from blocking import addCWfromLists from blocking import addCWfromLists
def _htmlPostMetadataOpenGraph(domain: str, postJsonObject: {}) -> str:
"""Returns html OpenGraph metadata for a post
"""
metadata = \
" <meta content=\"" + domain + "\" property=\"og:site_name\" />\n"
metadata += \
" <meta content=\"article\" property=\"og:type\" />\n"
objJson = postJsonObject
if hasObjectDict(postJsonObject):
objJson = postJsonObject['object']
if objJson.get('attributedTo'):
if isinstance(objJson['attributedTo'], str):
attrib = objJson['attributedTo']
actorNick = getNicknameFromActor(attrib)
actorDomain, _ = getDomainFromActor(attrib)
actorHandle = actorNick + '@' + actorDomain
metadata += \
" <meta content=\"@" + actorHandle + \
"\" property=\"og:title\" />\n"
if objJson.get('url'):
metadata += \
" <meta content=\"" + objJson['url'] + \
"\" property=\"og:url\" />\n"
if objJson.get('published'):
metadata += \
" <meta content=\"" + objJson['published'] + \
"\" property=\"og:published_time\" />\n"
if not objJson.get('attachment'):
if objJson.get('content'):
description = removeHtml(objJson['content'])
metadata += \
" <meta content=\"" + description + \
"\" name=\"description\">\n"
metadata += \
" <meta content=\"" + description + \
"\" name=\"og:description\">\n"
return metadata
# metadata for attachment
for attachJson in objJson['attachment']:
if not isinstance(attachJson, dict):
continue
if not attachJson.get('mediaType'):
continue
if not attachJson.get('url'):
continue
if not attachJson.get('name'):
continue
description = None
if attachJson['mediaType'].startswith('image/'):
description = 'Attached: 1 image'
elif attachJson['mediaType'].startswith('video/'):
description = 'Attached: 1 video'
elif attachJson['mediaType'].startswith('audio/'):
description = 'Attached: 1 audio'
if description:
if objJson.get('content'):
description += '\n\n' + removeHtml(objJson['content'])
metadata += \
" <meta content=\"" + description + \
"\" name=\"description\">\n"
metadata += \
" <meta content=\"" + description + \
"\" name=\"og:description\">\n"
metadata += \
" <meta content=\"" + attachJson['url'] + \
"\" property=\"og:image\" />\n"
metadata += \
" <meta content=\"" + attachJson['mediaType'] + \
"\" property=\"og:image:type\" />\n"
if attachJson.get('width'):
metadata += \
" <meta content=\"" + str(attachJson['width']) + \
"\" property=\"og:image:width\" />\n"
if attachJson.get('height'):
metadata += \
" <meta content=\"" + str(attachJson['height']) + \
"\" property=\"og:image:height\" />\n"
metadata += \
" <meta content=\"" + attachJson['name'] + \
"\" property=\"og:image:alt\" />\n"
if attachJson['mediaType'].startswith('image/'):
metadata += \
" <meta content=\"summary_large_image\" " + \
"property=\"twitter:card\" />\n"
return metadata
def _logPostTiming(enableTimingLog: bool, postStartTime, debugId: str) -> None: def _logPostTiming(enableTimingLog: bool, postStartTime, debugId: str) -> None:
"""Create a log of timings for performance tuning """Create a log of timings for performance tuning
""" """
@ -1835,6 +1924,7 @@ def htmlIndividualPost(cssCache: {},
CWlists: {}, listsEnabled: str) -> str: CWlists: {}, listsEnabled: str) -> str:
"""Show an individual post as html """Show an individual post as html
""" """
originalPostJson = postJsonObject
postStr = '' postStr = ''
if likedBy: if likedBy:
likedByNickname = getNicknameFromActor(likedBy) likedByNickname = getNicknameFromActor(likedBy)
@ -1961,8 +2051,10 @@ def htmlIndividualPost(cssCache: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \ metadataStr = _htmlPostMetadataOpenGraph(domain, originalPostJson)
postStr + htmlFooter() headerStr = htmlHeaderWithExternalStyle(cssFilename,
instanceTitle, metadataStr)
return headerStr + postStr + htmlFooter()
def htmlPostReplies(cssCache: {}, def htmlPostReplies(cssCache: {},
@ -2011,5 +2103,8 @@ def htmlPostReplies(cssCache: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \ # TODO
repliesStr + htmlFooter() metadata = ''
headerStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, metadata)
return headerStr + repliesStr + htmlFooter()

View File

@ -336,7 +336,7 @@ def htmlProfileAfterSearch(cssCache: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \ return htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) + \
profileStr + htmlFooter() profileStr + htmlFooter()
@ -2131,7 +2131,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
systemMonitorStr = _htmlSystemMonitor(nickname, translate) systemMonitorStr = _htmlSystemMonitor(nickname, translate)
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
editProfileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) editProfileForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# keyboard navigation # keyboard navigation
userPathStr = '/users/' + nickname userPathStr = '/users/' + nickname

View File

@ -64,7 +64,7 @@ def htmlSearchEmoji(cssCache: {}, translate: {},
# create header # create header
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
emojiForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) emojiForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
emojiForm += '<center><h1>' + \ emojiForm += '<center><h1>' + \
translate['Emoji Search'] + \ translate['Emoji Search'] + \
'</h1></center>' '</h1></center>'
@ -241,7 +241,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
sharedItemsForm = \ sharedItemsForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
if sharesFileType == 'shares': if sharesFileType == 'shares':
titleStr = translate['Shared Items Search'] titleStr = translate['Shared Items Search']
else: else:
@ -347,7 +347,7 @@ def htmlSearchEmojiTextEntry(cssCache: {}, translate: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
emojiStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) emojiStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
emojiStr += '<div class="follow">\n' emojiStr += '<div class="follow">\n'
emojiStr += ' <div class="followAvatar">\n' emojiStr += ' <div class="followAvatar">\n'
emojiStr += ' <center>\n' emojiStr += ' <center>\n'
@ -386,7 +386,7 @@ def htmlSearch(cssCache: {}, translate: {},
cssFilename = baseDir + '/search.css' cssFilename = baseDir + '/search.css'
instanceTitle = getConfigParam(baseDir, 'instanceTitle') instanceTitle = getConfigParam(baseDir, 'instanceTitle')
followStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) followStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# show a banner above the search box # show a banner above the search box
searchBannerFile, searchBannerFilename = \ searchBannerFile, searchBannerFilename = \
@ -550,7 +550,8 @@ def htmlSkillsSearch(actor: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
skillSearchForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) skillSearchForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
skillSearchForm += \ skillSearchForm += \
'<center><h1><a href = "' + actor + '/search">' + \ '<center><h1><a href = "' + actor + '/search">' + \
translate['Skills search'] + ': ' + \ translate['Skills search'] + ': ' + \
@ -627,7 +628,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
historySearchForm = \ historySearchForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# add the page title # add the page title
domainFull = getFullDomain(domain, port) domainFull = getFullDomain(domain, port)
@ -769,7 +770,7 @@ def htmlHashtagSearch(cssCache: {},
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
hashtagSearchForm = \ hashtagSearchForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle) htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
if nickname: if nickname:
hashtagSearchForm += '<center>\n' + \ hashtagSearchForm += '<center>\n' + \
'<h1><a href="/users/' + nickname + '/search">#' + \ '<h1><a href="/users/' + nickname + '/search">#' + \

View File

@ -23,7 +23,8 @@ def htmlSuspended(cssCache: {}, baseDir: str) -> str:
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
suspendedForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) suspendedForm = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
suspendedForm += \ suspendedForm += \
'<div><center>\n' + \ '<div><center>\n' + \
' <p class="screentitle">Account Suspended</p>\n' + \ ' <p class="screentitle">Account Suspended</p>\n' + \

View File

@ -677,7 +677,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
tlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) tlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
_logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '4') _logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '4')

View File

@ -42,7 +42,7 @@ def htmlTermsOfService(cssCache: {}, baseDir: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
TOSForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) TOSForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
TOSForm += '<div class="container">' + TOSText + '</div>\n' TOSForm += '<div class="container">' + TOSText + '</div>\n'
if adminNickname: if adminNickname:
adminActor = localActorUrl(httpPrefix, adminNickname, domainFull) adminActor = localActorUrl(httpPrefix, adminNickname, domainFull)

View File

@ -55,8 +55,8 @@ def htmlFollowingList(cssCache: {}, baseDir: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
followingListHtml = htmlHeaderWithExternalStyle(cssFilename, followingListHtml = \
instanceTitle) htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
for followingAddress in followingList: for followingAddress in followingList:
if followingAddress: if followingAddress:
followingListHtml += \ followingListHtml += \
@ -77,8 +77,8 @@ def htmlHashtagBlocked(cssCache: {}, baseDir: str, translate: {}) -> str:
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
blockedHashtagForm = htmlHeaderWithExternalStyle(cssFilename, blockedHashtagForm = \
instanceTitle) htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
blockedHashtagForm += '<div><center>\n' blockedHashtagForm += '<div><center>\n'
blockedHashtagForm += \ blockedHashtagForm += \
' <p class="screentitle">' + \ ' <p class="screentitle">' + \
@ -524,7 +524,9 @@ def getRightImageFile(baseDir: str,
def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str, def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str,
lang='en') -> str: metadata: str, lang='en') -> str:
if metadata is None:
metadata = ''
cssFile = '/' + cssFilename.split('/')[-1] cssFile = '/' + cssFilename.split('/')[-1]
htmlStr = \ htmlStr = \
'<!DOCTYPE html>\n' + \ '<!DOCTYPE html>\n' + \
@ -534,6 +536,7 @@ def htmlHeaderWithExternalStyle(cssFilename: str, instanceTitle: str,
' <link rel="stylesheet" href="' + cssFile + '">\n' + \ ' <link rel="stylesheet" href="' + cssFile + '">\n' + \
' <link rel="manifest" href="/manifest.json">\n' + \ ' <link rel="manifest" href="/manifest.json">\n' + \
' <meta name="theme-color" content="grey">\n' + \ ' <meta name="theme-color" content="grey">\n' + \
metadata + \
' <title>' + instanceTitle + '</title>\n' + \ ' <title>' + instanceTitle + '</title>\n' + \
' </head>\n' + \ ' </head>\n' + \
' <body>\n' ' <body>\n'
@ -546,8 +549,9 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
"""html header which includes person markup """html header which includes person markup
https://schema.org/Person https://schema.org/Person
""" """
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, lang)
if not actorJson: if not actorJson:
htmlStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None, lang)
return htmlStr return htmlStr
cityMarkup = '' cityMarkup = ''
@ -559,19 +563,19 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
country = city.split(',', 1)[1].strip().title() country = city.split(',', 1)[1].strip().title()
city = city.split(',', 1)[0] city = city.split(',', 1)[0]
countryMarkup = \ countryMarkup = \
' "addressCountry": "' + country + '"\n' ' "addressCountry": "' + country + '"\n'
addComma = ',' addComma = ','
cityMarkup = \ cityMarkup = \
' "address": {\n' + \ ' "address": {\n' + \
' "@type": "PostalAddress",\n' + \ ' "@type": "PostalAddress",\n' + \
' "addressLocality": "' + city + '"' + addComma + '\n' + \ ' "addressLocality": "' + city + '"' + addComma + '\n' + \
countryMarkup + \ countryMarkup + \
' },\n' ' },\n'
skillsMarkup = '' skillsMarkup = ''
if actorJson.get('hasOccupation'): if actorJson.get('hasOccupation'):
if isinstance(actorJson['hasOccupation'], list): if isinstance(actorJson['hasOccupation'], list):
skillsMarkup = ' "hasOccupation": [\n' skillsMarkup = ' "hasOccupation": [\n'
firstEntry = True firstEntry = True
for skillDict in actorJson['hasOccupation']: for skillDict in actorJson['hasOccupation']:
if skillDict['@type'] == 'Role': if skillDict['@type'] == 'Role':
@ -637,23 +641,90 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
' "skills": ' + skillsListStr + '\n' + \ ' "skills": ' + skillsListStr + '\n' + \
' }' ' }'
firstEntry = False firstEntry = False
skillsMarkup += '\n ],\n' skillsMarkup += '\n ],\n'
description = removeHtml(actorJson['summary']) description = removeHtml(actorJson['summary'])
nameStr = removeHtml(actorJson['name']) nameStr = removeHtml(actorJson['name'])
domainFull = actorJson['id'].split('://')[1].split('/')[0]
handle = actorJson['preferredUsername'] + '@' + domainFull
personMarkup = \ personMarkup = \
' <script type="application/ld+json">\n' + \ ' "about": {\n' + \
' "@type" : "Person",\n' + \
' "name": "' + nameStr + '",\n' + \
' "image": "' + actorJson['icon']['url'] + '",\n' + \
' "description": "' + description + '",\n' + \
cityMarkup + skillsMarkup + \
' "url": "' + actorJson['id'] + '"\n' + \
' },\n'
licenseUrl = 'https://creativecommons.org/licenses/by/4.0'
profileMarkup = \
' <script id="initial-state" type="application/ld+json">\n' + \
' {\n' + \ ' {\n' + \
' "@context" : "http://schema.org",\n' + \ ' "@context":"https://schema.org",\n' + \
' "@type" : "Person",\n' + \ ' "@type": "ProfilePage",\n' + \
' "mainEntityOfPage": {\n' + \
' "@type": "WebPage",\n' + \
" \"@id\": \"" + actorJson['id'] + "\"\n" + \
' },\n' + personMarkup + \
' "accountablePerson": {\n' + \
' "@type": "Person",\n' + \
' "name": "' + nameStr + '"\n' + \
' },\n' + \
' "copyrightHolder": {\n' + \
' "@type": "Person",\n' + \
' "name": "' + nameStr + '"\n' + \
' },\n' + \
' "name": "' + nameStr + '",\n' + \ ' "name": "' + nameStr + '",\n' + \
' "image": "' + actorJson['icon']['url'] + '",\n' + \ ' "image": "' + actorJson['icon']['url'] + '",\n' + \
' "description": "' + description + '",\n' + \ ' "description": "' + description + '",\n' + \
cityMarkup + skillsMarkup + \ ' "license": "' + licenseUrl + '"\n' + \
' "url": "' + actorJson['id'] + '"\n' + \
' }\n' + \ ' }\n' + \
' </script>\n' ' </script>\n'
htmlStr = htmlStr.replace('<head>\n', '<head>\n' + personMarkup)
description = removeHtml(description)
ogMetadata = \
" <meta content=\"profile\" property=\"og:type\" />\n" + \
" <meta content=\"" + description + \
"\" name='description'>\n" + \
" <meta content=\"" + actorJson['url'] + \
"\" property=\"og:url\" />\n" + \
" <meta content=\"" + domainFull + \
"\" property=\"og:site_name\" />\n" + \
" <meta content=\"" + nameStr + " (@" + handle + \
")\" property=\"og:title\" />\n" + \
" <meta content=\"" + description + \
"\" property=\"og:description\" />\n" + \
" <meta content=\"" + actorJson['icon']['url'] + \
"\" property=\"og:image\" />\n" + \
" <meta content=\"400\" property=\"og:image:width\" />\n" + \
" <meta content=\"400\" property=\"og:image:height\" />\n" + \
" <meta content=\"summary\" property=\"twitter:card\" />\n" + \
" <meta content=\"" + handle + \
"\" property=\"profile:username\" />\n"
if actorJson.get('attachment'):
ogTags = (
'email', 'openpgp', 'blog', 'xmpp', 'matrix', 'briar',
'jami', 'cwtch', 'languages'
)
for attachJson in actorJson['attachment']:
if not attachJson.get('name'):
continue
if not attachJson.get('value'):
continue
name = attachJson['name'].lower()
value = attachJson['value']
for ogTag in ogTags:
if name != ogTag:
continue
ogMetadata += \
" <meta content=\"" + value + \
"\" property=\"og:" + ogTag + "\" />\n"
htmlStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle,
ogMetadata + profileMarkup, lang)
return htmlStr return htmlStr
@ -663,16 +734,13 @@ def htmlHeaderWithWebsiteMarkup(cssFilename: str, instanceTitle: str,
"""html header which includes website markup """html header which includes website markup
https://schema.org/WebSite https://schema.org/WebSite
""" """
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle,
systemLanguage)
licenseUrl = 'https://www.gnu.org/licenses/agpl-3.0.rdf' licenseUrl = 'https://www.gnu.org/licenses/agpl-3.0.rdf'
# social networking category # social networking category
genreUrl = 'http://vocab.getty.edu/aat/300312270' genreUrl = 'http://vocab.getty.edu/aat/300312270'
websiteMarkup = \ websiteMarkup = \
' <script type="application/ld+json">\n' + \ ' <script id="initial-state" type="application/ld+json">\n' + \
' {\n' + \ ' {\n' + \
' "@context" : "http://schema.org",\n' + \ ' "@context" : "http://schema.org",\n' + \
' "@type" : "WebSite",\n' + \ ' "@type" : "WebSite",\n' + \
@ -696,7 +764,9 @@ def htmlHeaderWithWebsiteMarkup(cssFilename: str, instanceTitle: str,
' ]\n' + \ ' ]\n' + \
' }\n' + \ ' }\n' + \
' </script>\n' ' </script>\n'
htmlStr = htmlStr.replace('<head>\n', '<head>\n' + websiteMarkup) htmlStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, websiteMarkup,
systemLanguage)
return htmlStr return htmlStr
@ -707,9 +777,6 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
"""html header which includes blog post markup """html header which includes blog post markup
https://schema.org/BlogPosting https://schema.org/BlogPosting
""" """
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle,
systemLanguage)
authorUrl = localActorUrl(httpPrefix, nickname, domain) authorUrl = localActorUrl(httpPrefix, nickname, domain)
aboutUrl = httpPrefix + '://' + domain + '/about.html' aboutUrl = httpPrefix + '://' + domain + '/about.html'
@ -718,7 +785,7 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
contentLicenseUrl = 'https://creativecommons.org/licenses/by/3.0' contentLicenseUrl = 'https://creativecommons.org/licenses/by/3.0'
blogMarkup = \ blogMarkup = \
' <script type="application/ld+json">\n' + \ ' <script id="initial-state" type="application/ld+json">\n' + \
' {\n' + \ ' {\n' + \
' "@context" : "http://schema.org",\n' + \ ' "@context" : "http://schema.org",\n' + \
' "@type" : "BlogPosting",\n' + \ ' "@type" : "BlogPosting",\n' + \
@ -739,7 +806,9 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
' "description": "' + snippet + '"\n' + \ ' "description": "' + snippet + '"\n' + \
' }\n' + \ ' }\n' + \
' </script>\n' ' </script>\n'
htmlStr = htmlStr.replace('<head>\n', '<head>\n' + blogMarkup) htmlStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, blogMarkup,
systemLanguage)
return htmlStr return htmlStr
@ -1458,7 +1527,7 @@ def htmlShowShare(baseDir: str, domain: str, nickname: str,
instanceTitle = \ instanceTitle = \
getConfigParam(baseDir, 'instanceTitle') getConfigParam(baseDir, 'instanceTitle')
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \ return htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) + \
shareStr + htmlFooter() shareStr + htmlFooter()

View File

@ -86,7 +86,7 @@ def htmlWelcomeScreen(baseDir: str, nickname: str,
if os.path.isfile(baseDir + '/welcome.css'): if os.path.isfile(baseDir + '/welcome.css'):
cssFilename = baseDir + '/welcome.css' cssFilename = baseDir + '/welcome.css'
welcomeForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) welcomeForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
welcomeForm += \ welcomeForm += \
'<form enctype="multipart/form-data" method="POST" ' + \ '<form enctype="multipart/form-data" method="POST" ' + \
'accept-charset="UTF-8" ' + \ 'accept-charset="UTF-8" ' + \

View File

@ -61,7 +61,7 @@ def htmlWelcomeFinal(baseDir: str, nickname: str, domain: str,
if os.path.isfile(baseDir + '/welcome.css'): if os.path.isfile(baseDir + '/welcome.css'):
cssFilename = baseDir + '/welcome.css' cssFilename = baseDir + '/welcome.css'
finalForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) finalForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
finalForm += \ finalForm += \
'<div class="container">' + finalText + '</div>\n' + \ '<div class="container">' + finalText + '</div>\n' + \

View File

@ -67,7 +67,7 @@ def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str,
if os.path.isfile(baseDir + '/welcome.css'): if os.path.isfile(baseDir + '/welcome.css'):
cssFilename = baseDir + '/welcome.css' cssFilename = baseDir + '/welcome.css'
profileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) profileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# get the url of the avatar # get the url of the avatar
for ext in getImageExtensions(): for ext in getImageExtensions():