opengraph metadata on html profile

merge-requests/30/head
Bob Mottram 2021-11-07 11:32:08 +00:00
parent 996a9f2c6b
commit d69b57e0ae
2 changed files with 31 additions and 5 deletions

View File

@ -119,7 +119,7 @@ def _htmlPostMetadataOpenGraph(domain: str, postJsonObject: {}) -> str:
"\" name=\"og:description\">\n"
return metadata
# metadata for attachment
# metadata for attachment
for attachJson in objJson['attachment']:
if not isinstance(attachJson, dict):
continue
@ -153,11 +153,11 @@ def _htmlPostMetadataOpenGraph(domain: str, postJsonObject: {}) -> str:
"\" property=\"og:image:type\" />\n"
if attachJson.get('width'):
metadata += \
" <meta content=\"" + attachJson['width'] + \
" <meta content=\"" + str(attachJson['width']) + \
"\" property=\"og:image:width\" />\n"
if attachJson.get('height'):
metadata += \
" <meta content=\"" + attachJson['height'] + \
" <meta content=\"" + str(attachJson['height']) + \
"\" property=\"og:image:height\" />\n"
metadata += \
" <meta content=\"" + attachJson['name'] + \

View File

@ -549,9 +549,9 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
"""html header which includes person markup
https://schema.org/Person
"""
htmlStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None, lang)
if not actorJson:
htmlStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None, lang)
return htmlStr
cityMarkup = ''
@ -645,6 +645,8 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
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' + \
' {\n' + \
@ -657,6 +659,30 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
' "url": "' + actorJson['id'] + '"\n' + \
' }\n' + \
' </script>\n'
description = removeHtml(description)
ogMetadata = \
" <meta content=\"profile\" property=\"og:type\" />\n" + \
" <meta content=\"" + description + \
"\" name='description'>\n" + \
" <meta content=\"" + actorJson['url'] + \
"\" property=\"og:url\" />" + \
" <meta content=\"" + domainFull + \
"\" property=\"og:site_name\" />" + \
" <meta content=\"" + nameStr + " (@" + handle + \
")\" property=\"og:title\" />" + \
" <meta content=\"" + description + \
"\" property=\"og:description\" />" + \
" <meta content=\"" + actorJson['icon']['url'] + \
"\" property=\"og:image\" />" + \
" <meta content=\"400\" property=\"og:image:width\" />\n" + \
" <meta content=\"400\" property=\"og:image:height\" />" + \
" <meta content=\"summary\" property=\"twitter:card\" />" + \
" <meta content=\"" + handle + "\" property=\"profile:username\" />"
htmlStr = \
htmlHeaderWithExternalStyle(cssFilename, instanceTitle,
ogMetadata, lang)
htmlStr = htmlStr.replace('<head>\n', '<head>\n' + personMarkup)
return htmlStr