From afb0050bcad65270ff95f1bb5c958a99cabb54d1 Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Tue, 25 Feb 2020 21:20:51 +0000
Subject: [PATCH] Open content wardings when replies are shown on a blog
---
blog.py | 8 +++++---
webinterface.py | 14 ++++++++++++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/blog.py b/blog.py
index 68d0b55d..2641ec5b 100644
--- a/blog.py
+++ b/blog.py
@@ -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+= \
''+ \
- translate['Replies'].lower()+': '+str(replies)+'
'
+ translate['Replies'].lower()+': '+str(replies)+'
\n'
else:
- blogStr+=''+translate['Replies']+'
'
+ blogStr+=''+translate['Replies']+'
\n'
+ blogStr+='\n'
blogStr+= \
getBlogReplies(baseDir,httpPrefix,translate, \
nickname,domain,domainFull, \
diff --git a/webinterface.py b/webinterface.py
index 7ad3d389..247dc03f 100644
--- a/webinterface.py
+++ b/webinterface.py
@@ -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
"""