diff --git a/webapp_post.py b/webapp_post.py index b0376c44d..a2dc068e2 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -646,8 +646,7 @@ def getBlogCitationsHtml(boxName: str, '' + tagJson['name'] + '\n' if citationsStr: - citationsStr = '

' + translate['Citations'] + \ - ':

' + \ + citationsStr = '

' + translate['Citations'] + ':

' + \ '\n' return citationsStr @@ -676,302 +675,305 @@ def getPostTitleHtml(baseDir: str, """ titleStr = '' replyAvatarImageInPost = '' - if showRepeatIcon: - if isAnnounced: - if postJsonObject['object'].get('attributedTo'): - attributedTo = '' - if isinstance(postJsonObject['object']['attributedTo'], str): - attributedTo = postJsonObject['object']['attributedTo'] - if attributedTo.startswith(postActor): - titleStr += \ - ' ' + translate['announces'] + \
-                        '\n' - else: - # benchmark 13.2 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 13.2 = ' + str(timeDiff)) - announceNickname = None - if attributedTo: - announceNickname = getNicknameFromActor(attributedTo) - if announceNickname: - announceDomain, announcePort = \ - getDomainFromActor(attributedTo) - getPersonFromCache(baseDir, attributedTo, - personCache, allowDownloads) - announceDisplayName = \ - getDisplayName(baseDir, attributedTo, personCache) - if announceDisplayName: - # benchmark 13.3 - if enableTimingLog: - timeDiff = \ - int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 13.3 = ' + str(timeDiff)) + if not showRepeatIcon: + return (titleStr, replyAvatarImageInPost, + containerClassIcons, containerClass) - if ':' in announceDisplayName: - announceDisplayName = \ - addEmojiToDisplayName(baseDir, httpPrefix, - nickname, domain, - announceDisplayName, - False) - # benchmark 13.3.1 - if enableTimingLog: - timeDiff = \ - int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 13.3.1 = ' + str(timeDiff)) + if isAnnounced: + if postJsonObject['object'].get('attributedTo'): + attributedTo = '' + if isinstance(postJsonObject['object']['attributedTo'], str): + attributedTo = postJsonObject['object']['attributedTo'] + if attributedTo.startswith(postActor): + titleStr += \ + ' ' + translate['announces'] + \
+                    '\n' + else: + # benchmark 13.2 + if enableTimingLog: + timeDiff = int((time.time() - postStartTime) * 1000) + if timeDiff > 100: + print('TIMING INDIV ' + boxName + + ' 13.2 = ' + str(timeDiff)) + announceNickname = None + if attributedTo: + announceNickname = getNicknameFromActor(attributedTo) + if announceNickname: + announceDomain, announcePort = \ + getDomainFromActor(attributedTo) + getPersonFromCache(baseDir, attributedTo, + personCache, allowDownloads) + announceDisplayName = \ + getDisplayName(baseDir, attributedTo, personCache) + if announceDisplayName: + # benchmark 13.3 + if enableTimingLog: + timeDiff = \ + int((time.time() - postStartTime) * 1000) + if timeDiff > 100: + print('TIMING INDIV ' + boxName + + ' 13.3 = ' + str(timeDiff)) - titleStr += \ - ' ' + \ - '' + \
-                                translate['announces'] + '\n' + \ - ' ' + \ - announceDisplayName + '\n' - # show avatar of person replied to - announceActor = \ - postJsonObject['object']['attributedTo'] - announceAvatarUrl = \ - getPersonAvatarUrl(baseDir, announceActor, - personCache, allowDownloads) + if ':' in announceDisplayName: + announceDisplayName = \ + addEmojiToDisplayName(baseDir, httpPrefix, + nickname, domain, + announceDisplayName, + False) + # benchmark 13.3.1 + if enableTimingLog: + timeDiff = \ + int((time.time() - postStartTime) * 1000) + if timeDiff > 100: + print('TIMING INDIV ' + boxName + + ' 13.3.1 = ' + str(timeDiff)) - # benchmark 13.4 - if enableTimingLog: - timeDiff = \ - int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 13.4 = ' + str(timeDiff)) + titleStr += \ + ' ' + \ + '' + \
+                            translate['announces'] + '\n' + \ + ' ' + \ + announceDisplayName + '\n' + # show avatar of person replied to + announceActor = \ + postJsonObject['object']['attributedTo'] + announceAvatarUrl = \ + getPersonAvatarUrl(baseDir, announceActor, + personCache, allowDownloads) - if announceAvatarUrl: - idx = 'Show options for this person' - if '/users/news/' not in announceAvatarUrl: - replyAvatarImageInPost = \ - ' ' \ - '
\n' \ - ' ' + \ - '' \ - ' \n
\n' - else: - titleStr += \ - ' ' + translate['announces'] + \
-                                '\n' + \ - ' @' + \ - announceNickname + '@' + \ - announceDomain + '\n' + # benchmark 13.4 + if enableTimingLog: + timeDiff = \ + int((time.time() - postStartTime) * 1000) + if timeDiff > 100: + print('TIMING INDIV ' + boxName + + ' 13.4 = ' + str(timeDiff)) + + if announceAvatarUrl: + idx = 'Show options for this person' + if '/users/news/' not in announceAvatarUrl: + replyAvatarImageInPost = \ + ' ' \ + '
\n' \ + ' ' + \ + '' \ + ' \n
\n' else: titleStr += \ ' ' + \
-                            translate['announces'] + '\n' + \ ' @unattributed\n' - else: - titleStr += \ - ' ' + \ - '' + translate['announces'] + \
-                    '\n' + \ - ' @unattributed\n' - else: - if postJsonObject['object'].get('inReplyTo'): - containerClassIcons = 'containericons darker' - containerClass = 'container darker' - if postJsonObject['object']['inReplyTo'].startswith(postActor): + postJsonObject['object']['id'] + '" ' + \ + 'class="announceOrReply">@' + \ + announceNickname + '@' + \ + announceDomain + '\n' + else: titleStr += \ ' ' + translate['replying to themselves'] + \
-                        '\n' - else: - if '/statuses/' in postJsonObject['object']['inReplyTo']: - inReplyTo = postJsonObject['object']['inReplyTo'] - replyActor = inReplyTo.split('/statuses/')[0] - replyNickname = getNicknameFromActor(replyActor) - if replyNickname: - replyDomain, replyPort = \ - getDomainFromActor(replyActor) - if replyNickname and replyDomain: - getPersonFromCache(baseDir, replyActor, - personCache, - allowDownloads) - replyDisplayName = \ - getDisplayName(baseDir, replyActor, - personCache) - if replyDisplayName: - if ':' in replyDisplayName: - # benchmark 13.5 - if enableTimingLog: - timeDiff = \ - int((time.time() - - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + - boxName + ' 13.5 = ' + - str(timeDiff)) - repDisp = replyDisplayName - replyDisplayName = \ - addEmojiToDisplayName(baseDir, - httpPrefix, - nickname, - domain, - repDisp, - False) - # benchmark 13.6 - if enableTimingLog: - timeDiff = \ - int((time.time() - - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + - boxName + ' 13.6 = ' + - str(timeDiff)) - titleStr += \ - ' ' + \ - '' + \
-                                        translate['replying to'] + \
-                                        '\n' + \ - ' ' + \ - '' + \ - replyDisplayName + '\n' - - # benchmark 13.7 + translate['announces'] + '" alt="' + \ + translate['announces'] + '" src="/' + iconsPath + \ + '/repeat_inactive.png" ' + \ + 'class="announceOrReply"/>\n' + \ + ' @unattributed\n' + else: + titleStr += \ + ' ' + \ + '' + translate['announces'] + \
+                '\n' + \ + ' @unattributed\n' + else: + if postJsonObject['object'].get('inReplyTo'): + containerClassIcons = 'containericons darker' + containerClass = 'container darker' + if postJsonObject['object']['inReplyTo'].startswith(postActor): + titleStr += \ + ' ' + translate['replying to themselves'] + \
+                    '\n' + else: + if '/statuses/' in postJsonObject['object']['inReplyTo']: + inReplyTo = postJsonObject['object']['inReplyTo'] + replyActor = inReplyTo.split('/statuses/')[0] + replyNickname = getNicknameFromActor(replyActor) + if replyNickname: + replyDomain, replyPort = \ + getDomainFromActor(replyActor) + if replyNickname and replyDomain: + getPersonFromCache(baseDir, replyActor, + personCache, + allowDownloads) + replyDisplayName = \ + getDisplayName(baseDir, replyActor, + personCache) + if replyDisplayName: + if ':' in replyDisplayName: + # benchmark 13.5 if enableTimingLog: - timeDiff = int((time.time() - - postStartTime) * 1000) + timeDiff = \ + int((time.time() - + postStartTime) * 1000) if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 13.7 = ' + str(timeDiff)) - - # show avatar of person replied to - replyAvatarUrl = \ - getPersonAvatarUrl(baseDir, - replyActor, - personCache, - allowDownloads) - - # benchmark 13.8 + print('TIMING INDIV ' + + boxName + ' 13.5 = ' + + str(timeDiff)) + repDisp = replyDisplayName + replyDisplayName = \ + addEmojiToDisplayName(baseDir, + httpPrefix, + nickname, + domain, + repDisp, + False) + # benchmark 13.6 if enableTimingLog: - timeDiff = int((time.time() - - postStartTime) * 1000) + timeDiff = \ + int((time.time() - + postStartTime) * 1000) if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 13.8 = ' + str(timeDiff)) + print('TIMING INDIV ' + + boxName + ' 13.6 = ' + + str(timeDiff)) + titleStr += \ + ' ' + \ + '' + \
+                                    translate['replying to'] + \
+                                    '\n' + \ + ' ' + \ + '' + \ + replyDisplayName + '\n' - if replyAvatarUrl: - replyAvatarImageInPost = \ - '
\n' - replyAvatarImageInPost += \ - ' ' + \ - '\n' - replyAvatarImageInPost += \ - ' ' + \ - ' \n' + \ - '
\n' - else: - inReplyTo = \ - postJsonObject['object']['inReplyTo'] - titleStr += \ - ' ' + \ - '' + \
-                                        translate['replying to'] + \
-                                        '\n' + \ - ' @' + \ - replyNickname + '@' + \ - replyDomain + '\n' - else: - titleStr += \ - ' ' + \
-                                translate['replying to'] + \
-                                '\n' + \ - ' @unknown\n' + # benchmark 13.7 + if enableTimingLog: + timeDiff = int((time.time() - + postStartTime) * 1000) + if timeDiff > 100: + print('TIMING INDIV ' + boxName + + ' 13.7 = ' + str(timeDiff)) + + # show avatar of person replied to + replyAvatarUrl = \ + getPersonAvatarUrl(baseDir, + replyActor, + personCache, + allowDownloads) + + # benchmark 13.8 + if enableTimingLog: + timeDiff = int((time.time() - + postStartTime) * 1000) + if timeDiff > 100: + print('TIMING INDIV ' + boxName + + ' 13.8 = ' + str(timeDiff)) + + if replyAvatarUrl: + replyAvatarImageInPost = \ + '
\n' + replyAvatarImageInPost += \ + ' ' + \ + '\n' + replyAvatarImageInPost += \ + ' ' + \ + ' \n' + \ + '
\n' + else: + inReplyTo = \ + postJsonObject['object']['inReplyTo'] + titleStr += \ + ' ' + \ + '' + \
+                                    translate['replying to'] + \
+                                    '\n' + \ + ' @' + \ + replyNickname + '@' + \ + replyDomain + '\n' else: - postDomain = \ - postJsonObject['object']['inReplyTo'] - prefixes = getProtocolPrefixes() - for prefix in prefixes: - postDomain = postDomain.replace(prefix, '') - if '/' in postDomain: - postDomain = postDomain.split('/', 1)[0] - if postDomain: - titleStr += \ - ' ' + translate['replying to'] + \
-                                '\n' + \ - ' ' + \ - postDomain + '\n' + titleStr += \ + ' ' + \
+                            translate['replying to'] + \
+                            '\n' + \ + ' @unknown\n' + else: + postDomain = \ + postJsonObject['object']['inReplyTo'] + prefixes = getProtocolPrefixes() + for prefix in prefixes: + postDomain = postDomain.replace(prefix, '') + if '/' in postDomain: + postDomain = postDomain.split('/', 1)[0] + if postDomain: + titleStr += \ + ' ' + translate['replying to'] + \
+                            '\n' + \ + ' ' + \ + postDomain + '\n' return (titleStr, replyAvatarImageInPost, containerClassIcons, containerClass)