Open content wardings when replies are shown on a blog

main
Bob Mottram 2020-02-25 21:20:51 +00:00
parent 8462adbe14
commit afb0050bca
2 changed files with 19 additions and 3 deletions

View File

@ -18,6 +18,7 @@ from shutil import copyfileobj
from pprint import pprint
from content import replaceEmojiFromTags
from webinterface import contentWarningScriptOpen
from webinterface import getIconsDir
from webinterface import getPostAttachmentsAsHtml
from webinterface import htmlHeader
@ -69,7 +70,7 @@ def getBlogReplies(baseDir: str,httpPrefix: str,translate: {}, \
if not os.path.isfile(postFilename):
continue
with open(postFilename, "r") as postFile:
repliesStr+=postFile.read()
repliesStr+=postFile.read()+'\n'
return repliesStr
return ''
@ -165,9 +166,10 @@ def htmlBlogPostContent(authorized: bool, \
if replies>0:
blogStr+= \
'<p class="blogreplies">'+ \
translate['Replies'].lower()+': '+str(replies)+'</p>'
translate['Replies'].lower()+': '+str(replies)+'</p>\n'
else:
blogStr+='<h1>'+translate['Replies']+'</h1>'
blogStr+='<h1>'+translate['Replies']+'</h1>\n'
blogStr+='<script>'+contentWarningScriptOpen()+'</script>\n'
blogStr+= \
getBlogReplies(baseDir,httpPrefix,translate, \
nickname,domain,domainFull, \

View File

@ -2141,6 +2141,20 @@ def contentWarningScript() -> str:
script+='}\n'
return script
def contentWarningScriptOpen() -> str:
"""Returns a script used for content warnings
The warning is open by default. This is used on blog replies.
"""
script='function showContentWarning(postID) {\n'
script+=' var x = document.getElementById(postID);\n'
script+=' if (x.style.display !== "none") {\n'
script+=' x.style.display = "none";\n'
script+=' } else {\n'
script+=' x.style.display = "block";\n'
script+=' }\n'
script+='}\n'
return script
def addEmbeddedAudio(translate: {},content: str) -> str:
"""Adds embedded audio for mp3/ogg
"""