Separate function for content warning button

main
Bob Mottram 2020-06-03 10:16:53 +01:00
parent 20a24edaa8
commit 6084fbcce9
1 changed files with 17 additions and 9 deletions

View File

@ -73,6 +73,16 @@ from git import isGitPatch
from theme import getThemesList from theme import getThemesList
def getContentWarningButton(postID: str, translate: {},
content: str) -> str:
"""Returns the markup for a content warning button
"""
return '<button class="cwButton" onclick="showContentWarning(' + \
"'" + postID + "'" + ')">' + translate['SHOW MORE'] + '</button>' + \
'<div class="cwText" id="' + postID + '">' + \
content + '</div>'
def getBlogAddress(actorJson: {}) -> str: def getBlogAddress(actorJson: {}) -> str:
"""Returns blog address for the given actor """Returns blog address for the given actor
""" """
@ -4095,17 +4105,15 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
'<b>' + postJsonObject['object']['summary'] + '</b> ' '<b>' + postJsonObject['object']['summary'] + '</b> '
if isModerationPost: if isModerationPost:
containerClass = 'container report' containerClass = 'container report'
contentStr += \ # get the content warning text
'<button class="cwButton" onclick="showContentWarning(' + \ cwContentStr = objectContent + attachmentStr
"'" + postID + "'" + ')">' + translate['SHOW MORE'] + '</button>'
contentStr += '<div class="cwText" id="' + postID + '">'
contentStr += objectContent + attachmentStr
if not isPatch: if not isPatch:
contentStr = addEmbeddedElements(translate, contentStr) cwContentStr = addEmbeddedElements(translate, cwContentStr)
contentStr = \ cwContentStr = \
insertQuestion(baseDir, translate, nickname, domain, port, insertQuestion(baseDir, translate, nickname, domain, port,
contentStr, postJsonObject, pageNumber) cwContentStr, postJsonObject, pageNumber)
contentStr += '</div>' # get the content warning button
contentStr += getContentWarningButton(postID, translate, cwContentStr)
if postJsonObject['object'].get('tag') and not isPatch: if postJsonObject['object'].get('tag') and not isPatch:
contentStr = \ contentStr = \