From fc636182aca22fffb9523f7ddfda68c70e61167d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 1 Dec 2020 13:32:08 +0000 Subject: [PATCH] Function to get reply title as html --- webapp_post.py | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/webapp_post.py b/webapp_post.py index c41767aac..fba4cafd3 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -864,9 +864,9 @@ def replyToUnknownHtml(translate: {}, iconsPath: str, '" class="announceOrReply">@unknown\n' -def replyWithUnknownPath(translate: {}, iconsPath: str, - postJsonObject: {}, - postDomain: str) -> str: +def replyWithUnknownPathHtml(translate: {}, iconsPath: str, + postJsonObject: {}, + postDomain: str) -> str: """Returns html title for a reply with an unknown path eg. does not contain /statuses/ """ @@ -882,6 +882,21 @@ def replyWithUnknownPath(translate: {}, iconsPath: str, postDomain + '\n' +def getReplyHtml(translate: {}, iconsPath: str, + inReplyTo: str, replyDisplayName: str) -> str: + """Returns html title for a reply + """ + return ' ' + \ + '' + \
+        translate['replying to'] + '\n' + \ + ' ' + \ + replyDisplayName + '\n' + + def getPostTitleReplyHtml(baseDir: str, httpPrefix: str, nickname: str, domain: str, @@ -933,6 +948,7 @@ def getPostTitleReplyHtml(baseDir: str, getDisplayName(baseDir, replyActor, personCache) if replyDisplayName: + # add emoji to the display name if ':' in replyDisplayName: # benchmark 13.5 if enableTimingLog: @@ -940,16 +956,14 @@ def getPostTitleReplyHtml(baseDir: str, int((time.time() - postStartTime) * 1000) if timeDiff > 100: - print('TIMING INDIV ' + - boxName + ' 13.5 = ' + + print('TIMING INDIV ' + boxName + ' 13.5 = ' + str(timeDiff)) - repDisp = replyDisplayName replyDisplayName = \ addEmojiToDisplayName(baseDir, httpPrefix, nickname, domain, - repDisp, + replyDisplayName, False) # benchmark 13.6 if enableTimingLog: @@ -957,22 +971,12 @@ def getPostTitleReplyHtml(baseDir: str, int((time.time() - postStartTime) * 1000) if timeDiff > 100: - print('TIMING INDIV ' + - boxName + ' 13.6 = ' + + print('TIMING INDIV ' + boxName + ' 13.6 = ' + str(timeDiff)) + titleStr += \ - ' ' + \ - '' + \
-                        translate['replying to'] + \
-                        '\n' + \ - ' ' + \ - '' + \ - replyDisplayName + '\n' + getReplyHtml(translate, iconsPath, + inReplyTo, replyDisplayName) # benchmark 13.7 if enableTimingLog: @@ -1050,8 +1054,8 @@ def getPostTitleReplyHtml(baseDir: str, postDomain = postDomain.split('/', 1)[0] if postDomain: titleStr += \ - replyWithUnknownPath(translate, iconsPath, - postJsonObject, postDomain) + replyWithUnknownPathHtml(translate, iconsPath, + postJsonObject, postDomain) return (titleStr, replyAvatarImageInPost, containerClassIcons, containerClass)