forked from indymedia/epicyon
Separate function for post title html
parent
95042c3d1d
commit
f7ccde8606
645
webapp_post.py
645
webapp_post.py
|
@ -632,6 +632,330 @@ def getBlogCitationsHtml(boxName: str,
|
||||||
return citationsStr
|
return citationsStr
|
||||||
|
|
||||||
|
|
||||||
|
def getPostTitleHtml(baseDir: str,
|
||||||
|
httpPrefix: str,
|
||||||
|
nickname: str, domain: str,
|
||||||
|
showRepeatIcon: bool,
|
||||||
|
isAnnounced: bool,
|
||||||
|
postJsonObject: {},
|
||||||
|
postActor: str,
|
||||||
|
translate: {},
|
||||||
|
iconsPath: str,
|
||||||
|
enableTimingLog: bool,
|
||||||
|
postStartTime,
|
||||||
|
boxName: str,
|
||||||
|
personCache: {},
|
||||||
|
allowDownloads: bool,
|
||||||
|
avatarPosition: str,
|
||||||
|
pageNumber: int,
|
||||||
|
messageIdStr: str,
|
||||||
|
containerClassIcons: str,
|
||||||
|
containerClass: str) -> (str, str):
|
||||||
|
"""Returns the title of a post containing names of participants
|
||||||
|
x replies to y, x announces y, etc
|
||||||
|
"""
|
||||||
|
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 += \
|
||||||
|
' <img loading="lazy" title="' + \
|
||||||
|
translate['announces'] + \
|
||||||
|
'" alt="' + translate['announces'] + \
|
||||||
|
'" src="/' + iconsPath + \
|
||||||
|
'/repeat_inactive.png" class="announceOrReply"/>\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 ':' 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))
|
||||||
|
|
||||||
|
titleStr += \
|
||||||
|
' ' + \
|
||||||
|
'<img loading="lazy" title="' + \
|
||||||
|
translate['announces'] + '" alt="' + \
|
||||||
|
translate['announces'] + '" src="/' + \
|
||||||
|
iconsPath + '/repeat_inactive.png" ' + \
|
||||||
|
'class="announceOrReply"/>\n' + \
|
||||||
|
' <a href="' + \
|
||||||
|
postJsonObject['object']['id'] + '" ' + \
|
||||||
|
'class="announceOrReply">' + \
|
||||||
|
announceDisplayName + '</a>\n'
|
||||||
|
# show avatar of person replied to
|
||||||
|
announceActor = \
|
||||||
|
postJsonObject['object']['attributedTo']
|
||||||
|
announceAvatarUrl = \
|
||||||
|
getPersonAvatarUrl(baseDir, announceActor,
|
||||||
|
personCache, allowDownloads)
|
||||||
|
|
||||||
|
# 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 = \
|
||||||
|
' ' \
|
||||||
|
'<div class=' + \
|
||||||
|
'"timeline-avatar-reply">\n' \
|
||||||
|
' ' + \
|
||||||
|
'<a class="imageAnchor" ' + \
|
||||||
|
'href="/users/' + nickname + \
|
||||||
|
'?options=' + \
|
||||||
|
announceActor + ';' + \
|
||||||
|
str(pageNumber) + \
|
||||||
|
';' + announceAvatarUrl + \
|
||||||
|
messageIdStr + '">' \
|
||||||
|
'<img loading="lazy" src="' + \
|
||||||
|
announceAvatarUrl + '" ' \
|
||||||
|
'title="' + translate[idx] + \
|
||||||
|
'" alt=" "' + avatarPosition + \
|
||||||
|
'/></a>\n </div>\n'
|
||||||
|
else:
|
||||||
|
titleStr += \
|
||||||
|
' <img loading="lazy" title="' + \
|
||||||
|
translate['announces'] + \
|
||||||
|
'" alt="' + translate['announces'] + \
|
||||||
|
'" src="/' + iconsPath + \
|
||||||
|
'/repeat_inactive.png" ' + \
|
||||||
|
'class="announceOrReply"/>\n' + \
|
||||||
|
' <a href="' + \
|
||||||
|
postJsonObject['object']['id'] + '" ' + \
|
||||||
|
'class="announceOrReply">@' + \
|
||||||
|
announceNickname + '@' + \
|
||||||
|
announceDomain + '</a>\n'
|
||||||
|
else:
|
||||||
|
titleStr += \
|
||||||
|
' <img loading="lazy" title="' + \
|
||||||
|
translate['announces'] + '" alt="' + \
|
||||||
|
translate['announces'] + '" src="/' + iconsPath + \
|
||||||
|
'/repeat_inactive.png" ' + \
|
||||||
|
'class="announceOrReply"/>\n' + \
|
||||||
|
' <a href="' + \
|
||||||
|
postJsonObject['object']['id'] + \
|
||||||
|
'" class="announceOrReply">@unattributed</a>\n'
|
||||||
|
else:
|
||||||
|
titleStr += \
|
||||||
|
' ' + \
|
||||||
|
'<img loading="lazy" title="' + translate['announces'] + \
|
||||||
|
'" alt="' + translate['announces'] + \
|
||||||
|
'" src="/' + iconsPath + \
|
||||||
|
'/repeat_inactive.png" ' + \
|
||||||
|
'class="announceOrReply"/>\n' + \
|
||||||
|
' <a href="' + \
|
||||||
|
postJsonObject['object']['id'] + '" ' + \
|
||||||
|
'class="announceOrReply">@unattributed</a>\n'
|
||||||
|
else:
|
||||||
|
if postJsonObject['object'].get('inReplyTo'):
|
||||||
|
containerClassIcons = 'containericons darker'
|
||||||
|
containerClass = 'container darker'
|
||||||
|
if postJsonObject['object']['inReplyTo'].startswith(postActor):
|
||||||
|
titleStr += \
|
||||||
|
' <img loading="lazy" title="' + \
|
||||||
|
translate['replying to themselves'] + \
|
||||||
|
'" alt="' + translate['replying to themselves'] + \
|
||||||
|
'" src="/' + iconsPath + \
|
||||||
|
'/reply.png" class="announceOrReply"/>\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 += \
|
||||||
|
' ' + \
|
||||||
|
'<img loading="lazy" title="' + \
|
||||||
|
translate['replying to'] + \
|
||||||
|
'" alt="' + \
|
||||||
|
translate['replying to'] + \
|
||||||
|
'" src="/' + \
|
||||||
|
iconsPath + '/reply.png" ' + \
|
||||||
|
'class="announceOrReply"/>\n' + \
|
||||||
|
' ' + \
|
||||||
|
'<a href="' + inReplyTo + \
|
||||||
|
'" class="announceOrReply">' + \
|
||||||
|
replyDisplayName + '</a>\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 = \
|
||||||
|
' <div class=' + \
|
||||||
|
'"timeline-avatar-reply">\n'
|
||||||
|
replyAvatarImageInPost += \
|
||||||
|
' ' + \
|
||||||
|
'<a class="imageAnchor" ' + \
|
||||||
|
'href="/users/' + nickname + \
|
||||||
|
'?options=' + replyActor + \
|
||||||
|
';' + str(pageNumber) + ';' + \
|
||||||
|
replyAvatarUrl + \
|
||||||
|
messageIdStr + '">\n'
|
||||||
|
replyAvatarImageInPost += \
|
||||||
|
' ' + \
|
||||||
|
'<img loading="lazy" src="' + \
|
||||||
|
replyAvatarUrl + '" '
|
||||||
|
replyAvatarImageInPost += \
|
||||||
|
'title="' + \
|
||||||
|
translate['Show profile']
|
||||||
|
replyAvatarImageInPost += \
|
||||||
|
'" alt=" "' + \
|
||||||
|
avatarPosition + '/></a>\n' + \
|
||||||
|
' </div>\n'
|
||||||
|
else:
|
||||||
|
inReplyTo = \
|
||||||
|
postJsonObject['object']['inReplyTo']
|
||||||
|
titleStr += \
|
||||||
|
' ' + \
|
||||||
|
'<img loading="lazy" title="' + \
|
||||||
|
translate['replying to'] + \
|
||||||
|
'" alt="' + \
|
||||||
|
translate['replying to'] + \
|
||||||
|
'" src="/' + \
|
||||||
|
iconsPath + '/reply.png" ' + \
|
||||||
|
'class="announceOrReply"/>\n' + \
|
||||||
|
' <a href="' + \
|
||||||
|
inReplyTo + '" ' + \
|
||||||
|
'class="announceOrReply">@' + \
|
||||||
|
replyNickname + '@' + \
|
||||||
|
replyDomain + '</a>\n'
|
||||||
|
else:
|
||||||
|
titleStr += \
|
||||||
|
' <img loading="lazy" title="' + \
|
||||||
|
translate['replying to'] + \
|
||||||
|
'" alt="' + \
|
||||||
|
translate['replying to'] + \
|
||||||
|
'" src="/' + \
|
||||||
|
iconsPath + \
|
||||||
|
'/reply.png" class="announceOrReply"/>\n' + \
|
||||||
|
' <a href="' + \
|
||||||
|
postJsonObject['object']['inReplyTo'] + \
|
||||||
|
'" class="announceOrReply">@unknown</a>\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 += \
|
||||||
|
' <img loading="lazy" title="' + \
|
||||||
|
translate['replying to'] + \
|
||||||
|
'" alt="' + translate['replying to'] + \
|
||||||
|
'" src="/' + \
|
||||||
|
iconsPath + '/reply.png" ' + \
|
||||||
|
'class="announceOrReply"/>\n' + \
|
||||||
|
' <a href="' + \
|
||||||
|
postJsonObject['object']['inReplyTo'] + \
|
||||||
|
'" class="announceOrReply">' + \
|
||||||
|
postDomain + '</a>\n'
|
||||||
|
return (titleStr, replyAvatarImageInPost,
|
||||||
|
containerClassIcons, containerClass)
|
||||||
|
|
||||||
|
|
||||||
def individualPostAsHtml(allowDownloads: bool,
|
def individualPostAsHtml(allowDownloads: bool,
|
||||||
recentPostsCache: {}, maxRecentPosts: int,
|
recentPostsCache: {}, maxRecentPosts: int,
|
||||||
iconsPath: str, translate: {},
|
iconsPath: str, translate: {},
|
||||||
|
@ -997,303 +1321,30 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
if timeDiff > 100:
|
if timeDiff > 100:
|
||||||
print('TIMING INDIV ' + boxName + ' 13.1 = ' + str(timeDiff))
|
print('TIMING INDIV ' + boxName + ' 13.1 = ' + str(timeDiff))
|
||||||
|
|
||||||
replyAvatarImageInPost = ''
|
# get the title: x replies to y, x announces y, etc
|
||||||
if showRepeatIcon:
|
(titleStr2,
|
||||||
if isAnnounced:
|
replyAvatarImageInPost,
|
||||||
if postJsonObject['object'].get('attributedTo'):
|
containerClassIcons,
|
||||||
attributedTo = ''
|
containerClass) = getPostTitleHtml(baseDir,
|
||||||
if isinstance(postJsonObject['object']['attributedTo'], str):
|
httpPrefix,
|
||||||
attributedTo = postJsonObject['object']['attributedTo']
|
nickname, domain,
|
||||||
if attributedTo.startswith(postActor):
|
showRepeatIcon,
|
||||||
titleStr += \
|
isAnnounced,
|
||||||
' <img loading="lazy" title="' + \
|
postJsonObject,
|
||||||
translate['announces'] + \
|
postActor,
|
||||||
'" alt="' + translate['announces'] + \
|
translate,
|
||||||
'" src="/' + iconsPath + \
|
iconsPath,
|
||||||
'/repeat_inactive.png" class="announceOrReply"/>\n'
|
enableTimingLog,
|
||||||
else:
|
postStartTime,
|
||||||
# benchmark 13.2
|
boxName,
|
||||||
if enableTimingLog:
|
personCache,
|
||||||
timeDiff = int((time.time() - postStartTime) * 1000)
|
allowDownloads,
|
||||||
if timeDiff > 100:
|
avatarPosition,
|
||||||
print('TIMING INDIV ' + boxName +
|
pageNumber,
|
||||||
' 13.2 = ' + str(timeDiff))
|
messageIdStr,
|
||||||
announceNickname = None
|
containerClassIcons,
|
||||||
if attributedTo:
|
containerClass)
|
||||||
announceNickname = getNicknameFromActor(attributedTo)
|
titleStr += titleStr2
|
||||||
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 ':' 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))
|
|
||||||
|
|
||||||
titleStr += \
|
|
||||||
' ' + \
|
|
||||||
'<img loading="lazy" title="' + \
|
|
||||||
translate['announces'] + '" alt="' + \
|
|
||||||
translate['announces'] + '" src="/' + \
|
|
||||||
iconsPath + '/repeat_inactive.png" ' + \
|
|
||||||
'class="announceOrReply"/>\n' + \
|
|
||||||
' <a href="' + \
|
|
||||||
postJsonObject['object']['id'] + '" ' + \
|
|
||||||
'class="announceOrReply">' + \
|
|
||||||
announceDisplayName + '</a>\n'
|
|
||||||
# show avatar of person replied to
|
|
||||||
announceActor = \
|
|
||||||
postJsonObject['object']['attributedTo']
|
|
||||||
announceAvatarUrl = \
|
|
||||||
getPersonAvatarUrl(baseDir, announceActor,
|
|
||||||
personCache, allowDownloads)
|
|
||||||
|
|
||||||
# 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 = \
|
|
||||||
' ' \
|
|
||||||
'<div class=' + \
|
|
||||||
'"timeline-avatar-reply">\n' \
|
|
||||||
' ' + \
|
|
||||||
'<a class="imageAnchor" ' + \
|
|
||||||
'href="/users/' + nickname + \
|
|
||||||
'?options=' + \
|
|
||||||
announceActor + ';' + \
|
|
||||||
str(pageNumber) + \
|
|
||||||
';' + announceAvatarUrl + \
|
|
||||||
messageIdStr + '">' \
|
|
||||||
'<img loading="lazy" src="' + \
|
|
||||||
announceAvatarUrl + '" ' \
|
|
||||||
'title="' + translate[idx] + \
|
|
||||||
'" alt=" "' + avatarPosition + \
|
|
||||||
'/></a>\n </div>\n'
|
|
||||||
else:
|
|
||||||
titleStr += \
|
|
||||||
' <img loading="lazy" title="' + \
|
|
||||||
translate['announces'] + \
|
|
||||||
'" alt="' + translate['announces'] + \
|
|
||||||
'" src="/' + iconsPath + \
|
|
||||||
'/repeat_inactive.png" ' + \
|
|
||||||
'class="announceOrReply"/>\n' + \
|
|
||||||
' <a href="' + \
|
|
||||||
postJsonObject['object']['id'] + '" ' + \
|
|
||||||
'class="announceOrReply">@' + \
|
|
||||||
announceNickname + '@' + \
|
|
||||||
announceDomain + '</a>\n'
|
|
||||||
else:
|
|
||||||
titleStr += \
|
|
||||||
' <img loading="lazy" title="' + \
|
|
||||||
translate['announces'] + '" alt="' + \
|
|
||||||
translate['announces'] + '" src="/' + iconsPath + \
|
|
||||||
'/repeat_inactive.png" ' + \
|
|
||||||
'class="announceOrReply"/>\n' + \
|
|
||||||
' <a href="' + \
|
|
||||||
postJsonObject['object']['id'] + \
|
|
||||||
'" class="announceOrReply">@unattributed</a>\n'
|
|
||||||
else:
|
|
||||||
titleStr += \
|
|
||||||
' ' + \
|
|
||||||
'<img loading="lazy" title="' + translate['announces'] + \
|
|
||||||
'" alt="' + translate['announces'] + \
|
|
||||||
'" src="/' + iconsPath + \
|
|
||||||
'/repeat_inactive.png" ' + \
|
|
||||||
'class="announceOrReply"/>\n' + \
|
|
||||||
' <a href="' + \
|
|
||||||
postJsonObject['object']['id'] + '" ' + \
|
|
||||||
'class="announceOrReply">@unattributed</a>\n'
|
|
||||||
else:
|
|
||||||
if postJsonObject['object'].get('inReplyTo'):
|
|
||||||
containerClassIcons = 'containericons darker'
|
|
||||||
containerClass = 'container darker'
|
|
||||||
if postJsonObject['object']['inReplyTo'].startswith(postActor):
|
|
||||||
titleStr += \
|
|
||||||
' <img loading="lazy" title="' + \
|
|
||||||
translate['replying to themselves'] + \
|
|
||||||
'" alt="' + translate['replying to themselves'] + \
|
|
||||||
'" src="/' + iconsPath + \
|
|
||||||
'/reply.png" class="announceOrReply"/>\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 += \
|
|
||||||
' ' + \
|
|
||||||
'<img loading="lazy" title="' + \
|
|
||||||
translate['replying to'] + \
|
|
||||||
'" alt="' + \
|
|
||||||
translate['replying to'] + \
|
|
||||||
'" src="/' + \
|
|
||||||
iconsPath + '/reply.png" ' + \
|
|
||||||
'class="announceOrReply"/>\n' + \
|
|
||||||
' ' + \
|
|
||||||
'<a href="' + inReplyTo + \
|
|
||||||
'" class="announceOrReply">' + \
|
|
||||||
replyDisplayName + '</a>\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 = \
|
|
||||||
' <div class=' + \
|
|
||||||
'"timeline-avatar-reply">\n'
|
|
||||||
replyAvatarImageInPost += \
|
|
||||||
' ' + \
|
|
||||||
'<a class="imageAnchor" ' + \
|
|
||||||
'href="/users/' + nickname + \
|
|
||||||
'?options=' + replyActor + \
|
|
||||||
';' + str(pageNumber) + ';' + \
|
|
||||||
replyAvatarUrl + \
|
|
||||||
messageIdStr + '">\n'
|
|
||||||
replyAvatarImageInPost += \
|
|
||||||
' ' + \
|
|
||||||
'<img loading="lazy" src="' + \
|
|
||||||
replyAvatarUrl + '" '
|
|
||||||
replyAvatarImageInPost += \
|
|
||||||
'title="' + \
|
|
||||||
translate['Show profile']
|
|
||||||
replyAvatarImageInPost += \
|
|
||||||
'" alt=" "' + \
|
|
||||||
avatarPosition + '/></a>\n' + \
|
|
||||||
' </div>\n'
|
|
||||||
else:
|
|
||||||
inReplyTo = \
|
|
||||||
postJsonObject['object']['inReplyTo']
|
|
||||||
titleStr += \
|
|
||||||
' ' + \
|
|
||||||
'<img loading="lazy" title="' + \
|
|
||||||
translate['replying to'] + \
|
|
||||||
'" alt="' + \
|
|
||||||
translate['replying to'] + \
|
|
||||||
'" src="/' + \
|
|
||||||
iconsPath + '/reply.png" ' + \
|
|
||||||
'class="announceOrReply"/>\n' + \
|
|
||||||
' <a href="' + \
|
|
||||||
inReplyTo + '" ' + \
|
|
||||||
'class="announceOrReply">@' + \
|
|
||||||
replyNickname + '@' + \
|
|
||||||
replyDomain + '</a>\n'
|
|
||||||
else:
|
|
||||||
titleStr += \
|
|
||||||
' <img loading="lazy" title="' + \
|
|
||||||
translate['replying to'] + \
|
|
||||||
'" alt="' + \
|
|
||||||
translate['replying to'] + \
|
|
||||||
'" src="/' + \
|
|
||||||
iconsPath + \
|
|
||||||
'/reply.png" class="announceOrReply"/>\n' + \
|
|
||||||
' <a href="' + \
|
|
||||||
postJsonObject['object']['inReplyTo'] + \
|
|
||||||
'" class="announceOrReply">@unknown</a>\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 += \
|
|
||||||
' <img loading="lazy" title="' + \
|
|
||||||
translate['replying to'] + \
|
|
||||||
'" alt="' + translate['replying to'] + \
|
|
||||||
'" src="/' + \
|
|
||||||
iconsPath + '/reply.png" ' + \
|
|
||||||
'class="announceOrReply"/>\n' + \
|
|
||||||
' <a href="' + \
|
|
||||||
postJsonObject['object']['inReplyTo'] + \
|
|
||||||
'" class="announceOrReply">' + \
|
|
||||||
postDomain + '</a>\n'
|
|
||||||
|
|
||||||
# benchmark 14
|
# benchmark 14
|
||||||
if enableTimingLog:
|
if enableTimingLog:
|
||||||
|
|
Loading…
Reference in New Issue