Replace javascript with html

main
Bob Mottram 2020-06-25 13:47:57 +01:00
parent a17e2b1ad2
commit e1da050f3f
2 changed files with 5 additions and 42 deletions

View File

@ -10,7 +10,6 @@ import os
from datetime import datetime from datetime import datetime
from content import replaceEmojiFromTags from content import replaceEmojiFromTags
from webinterface import contentWarningScriptOpen
from webinterface import getIconsDir from webinterface import getIconsDir
from webinterface import getPostAttachmentsAsHtml from webinterface import getPostAttachmentsAsHtml
from webinterface import htmlHeader from webinterface import htmlHeader
@ -256,7 +255,6 @@ def htmlBlogPostContent(authorized: bool,
blogStr += '<br><br><br>' + blogSeparator + '\n' blogStr += '<br><br><br>' + blogSeparator + '\n'
else: else:
blogStr += blogSeparator + '<h1>' + translate['Replies'] + '</h1>\n' blogStr += blogSeparator + '<h1>' + translate['Replies'] + '</h1>\n'
blogStr += '<script>' + contentWarningScriptOpen() + '</script>\n'
if not titleStr: if not titleStr:
blogStr += getBlogReplies(baseDir, httpPrefix, translate, blogStr += getBlogReplies(baseDir, httpPrefix, translate,
nickname, domain, domainFull, nickname, domain, domainFull,

View File

@ -79,10 +79,10 @@ def getContentWarningButton(postID: str, translate: {},
content: str) -> str: content: str) -> str:
"""Returns the markup for a content warning button """Returns the markup for a content warning button
""" """
return '<button class="cwButton" onclick="showContentWarning(' + \ return '<details><summary class="cwButton">' + \
"'" + postID + "'" + ')">' + translate['SHOW MORE'] + '</button>' + \ translate['SHOW MORE'] + '</summary>' + \
'<div class="cwText" id="' + postID + '">' + \ '<div class="cwText" id="' + postID + '">' + content + \
content + '</div>' '</div></details>'
def getBlogAddress(actorJson: {}) -> str: def getBlogAddress(actorJson: {}) -> str:
@ -653,7 +653,6 @@ def htmlHashtagSearch(nickname: str, domain: str, port: int,
# add the page title # add the page title
hashtagSearchForm = htmlHeader(cssFilename, hashtagSearchCSS) hashtagSearchForm = htmlHeader(cssFilename, hashtagSearchCSS)
hashtagSearchForm += '<script>' + contentWarningScript() + '</script>'
hashtagSearchForm += '<center><h1>#' + hashtag + '</h1></center>' hashtagSearchForm += '<center><h1>#' + hashtag + '</h1></center>'
if startIndex > 0: if startIndex > 0:
@ -883,7 +882,6 @@ def htmlHistorySearch(translate: {}, baseDir: str,
historySearchCSS.replace('https://', historySearchCSS.replace('https://',
httpPrefix + '://') httpPrefix + '://')
historySearchForm = htmlHeader(cssFilename, historySearchCSS) historySearchForm = htmlHeader(cssFilename, historySearchCSS)
historySearchForm += '<script>' + contentWarningScript() + '</script>'
# add the page title # add the page title
historySearchForm += \ historySearchForm += \
@ -2118,7 +2116,6 @@ def htmlProfilePosts(recentPostsCache: {}, maxRecentPosts: int,
iconsDir = getIconsDir(baseDir) iconsDir = getIconsDir(baseDir)
profileStr = '' profileStr = ''
maxItems = 4 maxItems = 4
profileStr += '<script>' + contentWarningScript() + '</script>'
ctr = 0 ctr = 0
currPage = 1 currPage = 1
while ctr < maxItems and currPage < 4: while ctr < maxItems and currPage < 4:
@ -2761,31 +2758,6 @@ def cursorToEndOfMessageScript() -> str:
return script return script
def contentWarningScript() -> str:
"""Returns a script used for content warnings
"""
script = 'function showContentWarning(postID) {\n'
script += ' var x=document.getElementById(postID);\n'
script += ' if (x.style.display !== "block") {\n'
script += ' x.style.display="block";\n'
script += ' } else {\n'
script += ' x.style.display="none";\n'
script += ' }\n'
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 += ' x.style.display="block";\n'
script += '}\n'
return script
def addEmbeddedAudio(translate: {}, content: str) -> str: def addEmbeddedAudio(translate: {}, content: str) -> str:
"""Adds embedded audio for mp3/ogg """Adds embedded audio for mp3/ogg
""" """
@ -4580,9 +4552,6 @@ def htmlTimeline(defaultTimeline: str,
maxSharesPerAccount, httpPrefix) + maxSharesPerAccount, httpPrefix) +
htmlFooter()) htmlFooter())
# add the javascript for content warnings
tlStr += '<script>' + contentWarningScript() + '</script>'
# show todays events buttons on the first inbox page # show todays events buttons on the first inbox page
if boxName == 'inbox' and pageNumber == 1: if boxName == 'inbox' and pageNumber == 1:
if todaysEventsCheck(baseDir, nickname, domain): if todaysEventsCheck(baseDir, nickname, domain):
@ -4861,8 +4830,7 @@ def htmlIndividualPost(recentPostsCache: {}, maxRecentPosts: int,
"""Show an individual post as html """Show an individual post as html
""" """
iconsDir = getIconsDir(baseDir) iconsDir = getIconsDir(baseDir)
postStr = '<script>' + contentWarningScript() + '</script>' postStr = \
postStr += \
individualPostAsHtml(recentPostsCache, maxRecentPosts, individualPostAsHtml(recentPostsCache, maxRecentPosts,
iconsDir, translate, None, iconsDir, translate, None,
baseDir, session, wfRequest, personCache, baseDir, session, wfRequest, personCache,
@ -5059,7 +5027,6 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int,
profileStyle = profileStyle.replace('https://', profileStyle = profileStyle.replace('https://',
httpPrefix + '://') httpPrefix + '://')
deletePostStr = htmlHeader(cssFilename, profileStyle) deletePostStr = htmlHeader(cssFilename, profileStyle)
deletePostStr += '<script>' + contentWarningScript() + '</script>'
deletePostStr += \ deletePostStr += \
individualPostAsHtml(recentPostsCache, maxRecentPosts, individualPostAsHtml(recentPostsCache, maxRecentPosts,
iconsDir, translate, pageNumber, iconsDir, translate, pageNumber,
@ -6136,8 +6103,6 @@ def htmlProfileAfterSearch(recentPostsCache: {}, maxRecentPosts: int,
profileStr += ' </form>' profileStr += ' </form>'
profileStr += '</div>' profileStr += '</div>'
profileStr += '<script>' + contentWarningScript() + '</script>'
iconsDir = getIconsDir(baseDir) iconsDir = getIconsDir(baseDir)
i = 0 i = 0
for item in parseUserFeed(session, outboxUrl, asHeader, for item in parseUserFeed(session, outboxUrl, asHeader,