Function to generate announce icon html

merge-requests/30/head
Bob Mottram 2020-11-30 16:57:59 +00:00
parent 431f8f9ddb
commit 8c6b09ee0c
1 changed files with 48 additions and 25 deletions

View File

@ -352,6 +352,45 @@ def getEditIconHtml(baseDir: str, nickname: str, domainFull: str,
return editStr return editStr
def getAnnounceIconHtml(nickname: str, domainFull: str,
postJsonObject: {},
isPublicRepeat: bool,
isModerationPost: bool,
showRepeatIcon: bool,
translate: {},
pageNumberParam: str,
timelinePostBookmark: str,
boxName: str, iconsPath: str) -> str:
"""Returns html for announce icon/button
"""
announceStr = ''
if not isModerationPost and showRepeatIcon:
# don't allow announce/repeat of your own posts
announceIcon = 'repeat_inactive.png'
announceLink = 'repeat'
if not isPublicRepeat:
announceLink = 'repeatprivate'
announceTitle = translate['Repeat this post']
if announcedByPerson(postJsonObject, nickname, domainFull):
announceIcon = 'repeat.png'
if not isPublicRepeat:
announceLink = 'unrepeatprivate'
announceTitle = translate['Undo the repeat']
announceStr = \
' <a class="imageAnchor" href="/users/' + \
nickname + '?' + announceLink + \
'=' + postJsonObject['object']['id'] + pageNumberParam + \
'?actor=' + postJsonObject['actor'] + \
'?bm=' + timelinePostBookmark + \
'?tl=' + boxName + '" title="' + announceTitle + '">\n'
announceStr += \
' ' + \
'<img loading="lazy" title="' + translate['Repeat this post'] + \
'" alt="' + translate['Repeat this post'] + \
' |" src="/' + iconsPath + '/' + announceIcon + '"/></a>\n'
return announceStr
def individualPostAsHtml(allowDownloads: bool, def individualPostAsHtml(allowDownloads: bool,
recentPostsCache: {}, maxRecentPosts: int, recentPostsCache: {}, maxRecentPosts: int,
iconsPath: str, translate: {}, iconsPath: str, translate: {},
@ -624,31 +663,15 @@ def individualPostAsHtml(allowDownloads: bool,
postJsonObject, actorNickname, postJsonObject, actorNickname,
translate, iconsPath, isEvent) translate, iconsPath, isEvent)
announceStr = '' announceStr = getAnnounceIconHtml(nickname,
if not isModerationPost and showRepeatIcon: postJsonObject,
# don't allow announce/repeat of your own posts isPublicRepeat,
announceIcon = 'repeat_inactive.png' isModerationPost,
announceLink = 'repeat' showRepeatIcon,
if not isPublicRepeat: translate,
announceLink = 'repeatprivate' pageNumberParam,
announceTitle = translate['Repeat this post'] timelinePostBookmark,
if announcedByPerson(postJsonObject, nickname, domainFull): boxName, iconsPath)
announceIcon = 'repeat.png'
if not isPublicRepeat:
announceLink = 'unrepeatprivate'
announceTitle = translate['Undo the repeat']
announceStr = \
' <a class="imageAnchor" href="/users/' + \
nickname + '?' + announceLink + \
'=' + postJsonObject['object']['id'] + pageNumberParam + \
'?actor=' + postJsonObject['actor'] + \
'?bm=' + timelinePostBookmark + \
'?tl=' + boxName + '" title="' + announceTitle + '">\n'
announceStr += \
' ' + \
'<img loading="lazy" title="' + translate['Repeat this post'] + \
'" alt="' + translate['Repeat this post'] + \
' |" src="/' + iconsPath + '/' + announceIcon + '"/></a>\n'
# benchmark 12 # benchmark 12
if enableTimingLog: if enableTimingLog: