mirror of https://gitlab.com/bashrc2/epicyon
opengraph metadata on blog posts
parent
afa3e99260
commit
d18b97e850
10
blog.py
10
blog.py
|
@ -431,12 +431,18 @@ def htmlBlogPost(session, authorized: bool,
|
||||||
instanceTitle = \
|
instanceTitle = \
|
||||||
getConfigParam(baseDir, 'instanceTitle')
|
getConfigParam(baseDir, 'instanceTitle')
|
||||||
published = postJsonObject['object']['published']
|
published = postJsonObject['object']['published']
|
||||||
|
modified = published
|
||||||
|
if postJsonObject['object'].get('updated'):
|
||||||
|
modified = postJsonObject['object']['updated']
|
||||||
title = postJsonObject['object']['summary']
|
title = postJsonObject['object']['summary']
|
||||||
|
url = ''
|
||||||
|
if postJsonObject['object'].get('url'):
|
||||||
|
url = postJsonObject['object']['url']
|
||||||
snippet = _getSnippetFromBlogContent(postJsonObject, systemLanguage)
|
snippet = _getSnippetFromBlogContent(postJsonObject, systemLanguage)
|
||||||
blogStr = htmlHeaderWithBlogMarkup(cssFilename, instanceTitle,
|
blogStr = htmlHeaderWithBlogMarkup(cssFilename, instanceTitle,
|
||||||
httpPrefix, domainFull, nickname,
|
httpPrefix, domainFull, nickname,
|
||||||
systemLanguage, published,
|
systemLanguage, published, modified,
|
||||||
title, snippet)
|
title, snippet, translate, url)
|
||||||
_htmlBlogRemoveCwButton(blogStr, translate)
|
_htmlBlogRemoveCwButton(blogStr, translate)
|
||||||
|
|
||||||
blogStr += _htmlBlogPostContent(debug, session, authorized, baseDir,
|
blogStr += _htmlBlogPostContent(debug, session, authorized, baseDir,
|
||||||
|
|
|
@ -795,8 +795,10 @@ def htmlHeaderWithWebsiteMarkup(cssFilename: str, instanceTitle: str,
|
||||||
|
|
||||||
def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
|
def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
|
||||||
httpPrefix: str, domain: str, nickname: str,
|
httpPrefix: str, domain: str, nickname: str,
|
||||||
systemLanguage: str, published: str,
|
systemLanguage: str,
|
||||||
title: str, snippet: str) -> str:
|
published: str, modified: str,
|
||||||
|
title: str, snippet: str,
|
||||||
|
translate: {}, url: str) -> str:
|
||||||
"""html header which includes blog post markup
|
"""html header which includes blog post markup
|
||||||
https://schema.org/BlogPosting
|
https://schema.org/BlogPosting
|
||||||
"""
|
"""
|
||||||
|
@ -814,7 +816,7 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
|
||||||
' "@type" : "BlogPosting",\n' + \
|
' "@type" : "BlogPosting",\n' + \
|
||||||
' "headline": "' + title + '",\n' + \
|
' "headline": "' + title + '",\n' + \
|
||||||
' "datePublished": "' + published + '",\n' + \
|
' "datePublished": "' + published + '",\n' + \
|
||||||
' "dateModified": "' + published + '",\n' + \
|
' "dateModified": "' + modified + '",\n' + \
|
||||||
' "author": {\n' + \
|
' "author": {\n' + \
|
||||||
' "@type": "Person",\n' + \
|
' "@type": "Person",\n' + \
|
||||||
' "name": "' + nickname + '",\n' + \
|
' "name": "' + nickname + '",\n' + \
|
||||||
|
@ -829,9 +831,23 @@ def htmlHeaderWithBlogMarkup(cssFilename: str, instanceTitle: str,
|
||||||
' "description": "' + snippet + '"\n' + \
|
' "description": "' + snippet + '"\n' + \
|
||||||
' }\n' + \
|
' }\n' + \
|
||||||
' </script>\n'
|
' </script>\n'
|
||||||
|
|
||||||
|
ogMetadata = \
|
||||||
|
' <meta property="og:locale" content="' + \
|
||||||
|
systemLanguage + '" />\n' + \
|
||||||
|
' <meta property="og:type" content="article" />\n' + \
|
||||||
|
' <meta property="og:title" content="' + title + '" />\n' + \
|
||||||
|
' <meta property="og:url" content="' + url + '" />\n' + \
|
||||||
|
' <meta content="Epicyon hosted on ' + domain + \
|
||||||
|
'" property="og:site_name" />\n' + \
|
||||||
|
' <meta property="article:published_time" content="' + \
|
||||||
|
published + '" />\n' + \
|
||||||
|
' <meta property="article:modified_time" content="' + \
|
||||||
|
modified + '" />'
|
||||||
|
|
||||||
htmlStr = \
|
htmlStr = \
|
||||||
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, blogMarkup,
|
htmlHeaderWithExternalStyle(cssFilename, instanceTitle,
|
||||||
systemLanguage)
|
ogMetadata + blogMarkup, systemLanguage)
|
||||||
return htmlStr
|
return htmlStr
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue