Function to get reply title as html

merge-requests/30/head
Bob Mottram 2020-12-01 13:32:08 +00:00
parent d628dfd9c6
commit fc636182ac
1 changed files with 27 additions and 23 deletions

View File

@ -864,7 +864,7 @@ def replyToUnknownHtml(translate: {}, iconsPath: str,
'" class="announceOrReply">@unknown</a>\n' '" class="announceOrReply">@unknown</a>\n'
def replyWithUnknownPath(translate: {}, iconsPath: str, def replyWithUnknownPathHtml(translate: {}, iconsPath: str,
postJsonObject: {}, postJsonObject: {},
postDomain: str) -> str: postDomain: str) -> str:
"""Returns html title for a reply with an unknown path """Returns html title for a reply with an unknown path
@ -882,6 +882,21 @@ def replyWithUnknownPath(translate: {}, iconsPath: str,
postDomain + '</a>\n' postDomain + '</a>\n'
def getReplyHtml(translate: {}, iconsPath: str,
inReplyTo: str, replyDisplayName: str) -> str:
"""Returns html title for a reply
"""
return ' ' + \
'<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'
def getPostTitleReplyHtml(baseDir: str, def getPostTitleReplyHtml(baseDir: str,
httpPrefix: str, httpPrefix: str,
nickname: str, domain: str, nickname: str, domain: str,
@ -933,6 +948,7 @@ def getPostTitleReplyHtml(baseDir: str,
getDisplayName(baseDir, replyActor, getDisplayName(baseDir, replyActor,
personCache) personCache)
if replyDisplayName: if replyDisplayName:
# add emoji to the display name
if ':' in replyDisplayName: if ':' in replyDisplayName:
# benchmark 13.5 # benchmark 13.5
if enableTimingLog: if enableTimingLog:
@ -940,16 +956,14 @@ def getPostTitleReplyHtml(baseDir: str,
int((time.time() - int((time.time() -
postStartTime) * 1000) postStartTime) * 1000)
if timeDiff > 100: if timeDiff > 100:
print('TIMING INDIV ' + print('TIMING INDIV ' + boxName + ' 13.5 = ' +
boxName + ' 13.5 = ' +
str(timeDiff)) str(timeDiff))
repDisp = replyDisplayName
replyDisplayName = \ replyDisplayName = \
addEmojiToDisplayName(baseDir, addEmojiToDisplayName(baseDir,
httpPrefix, httpPrefix,
nickname, nickname,
domain, domain,
repDisp, replyDisplayName,
False) False)
# benchmark 13.6 # benchmark 13.6
if enableTimingLog: if enableTimingLog:
@ -957,22 +971,12 @@ def getPostTitleReplyHtml(baseDir: str,
int((time.time() - int((time.time() -
postStartTime) * 1000) postStartTime) * 1000)
if timeDiff > 100: if timeDiff > 100:
print('TIMING INDIV ' + print('TIMING INDIV ' + boxName + ' 13.6 = ' +
boxName + ' 13.6 = ' +
str(timeDiff)) str(timeDiff))
titleStr += \ titleStr += \
' ' + \ getReplyHtml(translate, iconsPath,
'<img loading="lazy" title="' + \ inReplyTo, replyDisplayName)
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 # benchmark 13.7
if enableTimingLog: if enableTimingLog:
@ -1050,7 +1054,7 @@ def getPostTitleReplyHtml(baseDir: str,
postDomain = postDomain.split('/', 1)[0] postDomain = postDomain.split('/', 1)[0]
if postDomain: if postDomain:
titleStr += \ titleStr += \
replyWithUnknownPath(translate, iconsPath, replyWithUnknownPathHtml(translate, iconsPath,
postJsonObject, postDomain) postJsonObject, postDomain)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,