Function to show announce title without display name

main
Bob Mottram 2020-12-01 11:43:13 +00:00
parent 2c3d3d2c11
commit d4a834196b
1 changed files with 26 additions and 14 deletions

View File

@ -661,7 +661,8 @@ def boostOwnTootHtml(translate: {}, iconsPath) -> str:
'/repeat_inactive.png" class="announceOrReply"/>\n' '/repeat_inactive.png" class="announceOrReply"/>\n'
def announceUnattributedHtml(translate: {}, iconsPath: str) -> str: def announceUnattributedHtml(translate: {}, iconsPath: str,
postJsonObject: {}) -> str:
"""Returns the html for an announce title where there """Returns the html for an announce title where there
is no attribution on the announced post is no attribution on the announced post
""" """
@ -675,6 +676,22 @@ def announceUnattributedHtml(translate: {}, iconsPath: str) -> str:
'" class="announceOrReply">@unattributed</a>\n' '" class="announceOrReply">@unattributed</a>\n'
def announceWithoutDisplayNameHtml(translate: {}, iconsPath: str,
announceNickname: str,
announceDomain: str,
postJsonObject: {}) -> str:
"""Returns html for an announce title where there is no display name
only a handle nick@domain
"""
return ' <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'
def getPostTitleAnnounceHtml(baseDir: str, def getPostTitleAnnounceHtml(baseDir: str,
httpPrefix: str, httpPrefix: str,
nickname: str, domain: str, nickname: str, domain: str,
@ -734,6 +751,7 @@ def getPostTitleAnnounceHtml(baseDir: str,
print('TIMING INDIV ' + boxName + print('TIMING INDIV ' + boxName +
' 13.3 = ' + str(timeDiff)) ' 13.3 = ' + str(timeDiff))
# add any emoji to the display name
if ':' in announceDisplayName: if ':' in announceDisplayName:
announceDisplayName = \ announceDisplayName = \
addEmojiToDisplayName(baseDir, httpPrefix, addEmojiToDisplayName(baseDir, httpPrefix,
@ -796,23 +814,17 @@ def getPostTitleAnnounceHtml(baseDir: str,
'/></a>\n </div>\n' '/></a>\n </div>\n'
else: else:
titleStr += \ titleStr += \
' <img loading="lazy" title="' + \ announceWithoutDisplayNameHtml(translate, iconsPath,
translate['announces'] + \ announceNickname,
'" alt="' + translate['announces'] + \ announceDomain,
'" src="/' + iconsPath + \ postJsonObject)
'/repeat_inactive.png" ' + \
'class="announceOrReply"/>\n' + \
' <a href="' + \
postJsonObject['object']['id'] + '" ' + \
'class="announceOrReply">@' + \
announceNickname + '@' + \
announceDomain + '</a>\n'
else: else:
titleStr += \ titleStr += \
announceUnattributedHtml(translate, iconsPath) announceUnattributedHtml(translate, iconsPath,
postJsonObject)
else: else:
titleStr += \ titleStr += \
announceUnattributedHtml(translate, iconsPath) announceUnattributedHtml(translate, iconsPath, postJsonObject)
return (titleStr, replyAvatarImageInPost, return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass) containerClassIcons, containerClass)