Function for showing title on reply posts

main
Bob Mottram 2020-12-01 12:30:17 +00:00
parent c6e947f22e
commit 1942679172
1 changed files with 221 additions and 164 deletions

View File

@ -840,7 +840,17 @@ def getPostTitleAnnounceHtml(baseDir: str,
containerClassIcons, containerClass)
def getPostTitleHtml(baseDir: str,
def replyToYourselfHtml(translate: {}, iconsPath: str) -> str:
"""Returns html for a title which is a reply to yourself
"""
return ' <img loading="lazy" title="' + \
translate['replying to themselves'] + \
'" alt="' + translate['replying to themselves'] + \
'" src="/' + iconsPath + \
'/reply.png" class="announceOrReply"/>\n'
def getPostTitleReplyHtml(baseDir: str,
httpPrefix: str,
nickname: str, domain: str,
showRepeatIcon: bool,
@ -859,47 +869,23 @@ def getPostTitleHtml(baseDir: str,
messageIdStr: str,
containerClassIcons: str,
containerClass: str) -> (str, str, str, str):
"""Returns the title of a post containing names of participants
x replies to y, x announces y, etc
"""Returns the reply title of a post containing names of participants
x replies to y
"""
titleStr = ''
replyAvatarImageInPost = ''
if not showRepeatIcon:
if not postJsonObject['object'].get('inReplyTo'):
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
if isAnnounced:
return getPostTitleAnnounceHtml(baseDir,
httpPrefix,
nickname, domain,
showRepeatIcon,
isAnnounced,
postJsonObject,
postActor,
translate,
iconsPath,
enableTimingLog,
postStartTime,
boxName,
personCache,
allowDownloads,
avatarPosition,
pageNumber,
messageIdStr,
containerClassIcons,
containerClass)
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:
titleStr += replyToYourselfHtml(translate, iconsPath)
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
if '/statuses/' in postJsonObject['object']['inReplyTo']:
inReplyTo = postJsonObject['object']['inReplyTo']
replyActor = inReplyTo.split('/statuses/')[0]
@ -1051,10 +1037,81 @@ def getPostTitleHtml(baseDir: str,
postJsonObject['object']['inReplyTo'] + \
'" class="announceOrReply">' + \
postDomain + '</a>\n'
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
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, str, str):
"""Returns the title of a post containing names of participants
x replies to y, x announces y, etc
"""
titleStr = ''
replyAvatarImageInPost = ''
if not showRepeatIcon:
return (titleStr, replyAvatarImageInPost,
containerClassIcons, containerClass)
if isAnnounced:
return getPostTitleAnnounceHtml(baseDir,
httpPrefix,
nickname, domain,
showRepeatIcon,
isAnnounced,
postJsonObject,
postActor,
translate,
iconsPath,
enableTimingLog,
postStartTime,
boxName,
personCache,
allowDownloads,
avatarPosition,
pageNumber,
messageIdStr,
containerClassIcons,
containerClass)
return getPostTitleReplyHtml(baseDir,
httpPrefix,
nickname, domain,
showRepeatIcon,
isAnnounced,
postJsonObject,
postActor,
translate,
iconsPath,
enableTimingLog,
postStartTime,
boxName,
personCache,
allowDownloads,
avatarPosition,
pageNumber,
messageIdStr,
containerClassIcons,
containerClass)
def individualPostAsHtml(allowDownloads: bool,
recentPostsCache: {}, maxRecentPosts: int,
iconsPath: str, translate: {},