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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@ from posts import postIsMuted
from posts import getPersonBox
from posts import downloadAnnounce
from posts import populateRepliesJson
from utils import removeHtml
from utils import getActorLanguagesList
from utils import getBaseContentFromPost
from utils import getContentFromPost
@ -80,6 +81,94 @@ from blocking import isBlocked
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:
"""Create a log of timings for performance tuning
"""
@ -1835,6 +1924,7 @@ def htmlIndividualPost(cssCache: {},
CWlists: {}, listsEnabled: str) -> str:
"""Show an individual post as html
"""
originalPostJson = postJsonObject
postStr = ''
if likedBy:
likedByNickname = getNicknameFromActor(likedBy)
@ -1961,8 +2051,10 @@ def htmlIndividualPost(cssCache: {},
instanceTitle = \
getConfigParam(baseDir, 'instanceTitle')
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \
postStr + htmlFooter()
metadataStr = _htmlPostMetadataOpenGraph(domain, originalPostJson)
headerStr = htmlHeaderWithExternalStyle(cssFilename,
instanceTitle, metadataStr)
return headerStr + postStr + htmlFooter()
def htmlPostReplies(cssCache: {},
@ -2011,5 +2103,8 @@ def htmlPostReplies(cssCache: {},
instanceTitle = \
getConfigParam(baseDir, 'instanceTitle')
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \
repliesStr + htmlFooter()
# TODO
metadata = ''
headerStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, metadata)
return headerStr + repliesStr + htmlFooter()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -86,7 +86,7 @@ def htmlWelcomeScreen(baseDir: str, nickname: str,
if os.path.isfile(baseDir + '/welcome.css'):
cssFilename = baseDir + '/welcome.css'
welcomeForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
welcomeForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
welcomeForm += \
'<form enctype="multipart/form-data" method="POST" ' + \
'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'):
cssFilename = baseDir + '/welcome.css'
finalForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
finalForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
finalForm += \
'<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'):
cssFilename = baseDir + '/welcome.css'
profileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
profileForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# get the url of the avatar
for ext in getImageExtensions():