Replace titles on blog replies

main
Bob Mottram 2020-02-25 21:40:13 +00:00
parent 2c671727ea
commit 2d179afefc
1 changed files with 14 additions and 6 deletions

20
blog.py
View File

@ -71,7 +71,7 @@ def getBlogReplies(baseDir: str,httpPrefix: str,translate: {}, \
continue continue
with open(postFilename, "r") as postFile: with open(postFilename, "r") as postFile:
repliesStr+=postFile.read()+'\n' repliesStr+=postFile.read()+'\n'
return repliesStr return repliesStr.replace(translate['SHOW MORE'],'')
return '' return ''
@ -88,8 +88,10 @@ def htmlBlogPostContent(authorized: bool, \
messageLink='' messageLink=''
if postJsonObject['object'].get('id'): if postJsonObject['object'].get('id'):
messageLink=postJsonObject['object']['id'].replace('/statuses/','/') messageLink=postJsonObject['object']['id'].replace('/statuses/','/')
titleStr=''
if postJsonObject['object'].get('summary'): if postJsonObject['object'].get('summary'):
blogStr+='<h1><a href="'+messageLink+'">'+postJsonObject['object']['summary']+'</a></h1>\n' titleStr=postJsonObject['object']['summary']
blogStr+='<h1><a href="'+messageLink+'">'+titleStr+'</a></h1>\n'
# get the handle of the author # get the handle of the author
if postJsonObject['object'].get('attributedTo'): if postJsonObject['object'].get('attributedTo'):
@ -170,10 +172,16 @@ def htmlBlogPostContent(authorized: bool, \
else: else:
blogStr+='<h1>'+translate['Replies']+'</h1>\n' blogStr+='<h1>'+translate['Replies']+'</h1>\n'
blogStr+='<script>'+contentWarningScriptOpen()+'</script>\n' blogStr+='<script>'+contentWarningScriptOpen()+'</script>\n'
blogStr+= \ if not titleStr:
getBlogReplies(baseDir,httpPrefix,translate, \ blogStr+= \
nickname,domain,domainFull, \ getBlogReplies(baseDir,httpPrefix,translate, \
postJsonObject) nickname,domain,domainFull, \
postJsonObject)
else:
blogStr+= \
getBlogReplies(baseDir,httpPrefix,translate, \
nickname,domain,domainFull, \
postJsonObject).replace('>'+titleStr+'<','')
blogStr+='<br><hr>\n' blogStr+='<br><hr>\n'
return blogStr return blogStr