Less indentation

main
Bob Mottram 2020-12-01 09:51:55 +00:00
parent c135486059
commit ac531e1b74
1 changed files with 43 additions and 41 deletions

View File

@ -249,53 +249,55 @@ def getReplyIconHtml(nickname: str, isPublicRepeat: bool,
"""Returns html for the reply icon/button """Returns html for the reply icon/button
""" """
replyStr = '' replyStr = ''
if showIcons and commentsEnabled: if not (showIcons and commentsEnabled):
# reply is permitted - create reply icon return replyStr
replyToLink = postJsonObject['object']['id']
if postJsonObject['object'].get('attributedTo'):
if isinstance(postJsonObject['object']['attributedTo'], str):
replyToLink += \
'?mention=' + postJsonObject['object']['attributedTo']
if postJsonObject['object'].get('content'):
mentionedActors = \
getMentionsFromHtml(postJsonObject['object']['content'])
if mentionedActors:
for actorUrl in mentionedActors:
if '?mention=' + actorUrl not in replyToLink:
replyToLink += '?mention=' + actorUrl
if len(replyToLink) > 500:
break
replyToLink += pageNumberParam
replyStr = '' # reply is permitted - create reply icon
if isPublicRepeat: replyToLink = postJsonObject['object']['id']
if postJsonObject['object'].get('attributedTo'):
if isinstance(postJsonObject['object']['attributedTo'], str):
replyToLink += \
'?mention=' + postJsonObject['object']['attributedTo']
if postJsonObject['object'].get('content'):
mentionedActors = \
getMentionsFromHtml(postJsonObject['object']['content'])
if mentionedActors:
for actorUrl in mentionedActors:
if '?mention=' + actorUrl not in replyToLink:
replyToLink += '?mention=' + actorUrl
if len(replyToLink) > 500:
break
replyToLink += pageNumberParam
replyStr = ''
if isPublicRepeat:
replyStr += \
' <a class="imageAnchor" href="/users/' + \
nickname + '?replyto=' + replyToLink + \
'?actor=' + postJsonObject['actor'] + \
'" title="' + translate['Reply to this post'] + '">\n'
else:
if isDM(postJsonObject):
replyStr += \ replyStr += \
' <a class="imageAnchor" href="/users/' + \ ' ' + \
nickname + '?replyto=' + replyToLink + \ '<a class="imageAnchor" href="/users/' + nickname + \
'?replydm=' + replyToLink + \
'?actor=' + postJsonObject['actor'] + \ '?actor=' + postJsonObject['actor'] + \
'" title="' + translate['Reply to this post'] + '">\n' '" title="' + translate['Reply to this post'] + '">\n'
else: else:
if isDM(postJsonObject): replyStr += \
replyStr += \ ' ' + \
' ' + \ '<a class="imageAnchor" href="/users/' + nickname + \
'<a class="imageAnchor" href="/users/' + nickname + \ '?replyfollowers=' + replyToLink + \
'?replydm=' + replyToLink + \ '?actor=' + postJsonObject['actor'] + \
'?actor=' + postJsonObject['actor'] + \ '" title="' + translate['Reply to this post'] + '">\n'
'" title="' + translate['Reply to this post'] + '">\n'
else:
replyStr += \
' ' + \
'<a class="imageAnchor" href="/users/' + nickname + \
'?replyfollowers=' + replyToLink + \
'?actor=' + postJsonObject['actor'] + \
'" title="' + translate['Reply to this post'] + '">\n'
replyStr += \ replyStr += \
' ' + \ ' ' + \
'<img loading="lazy" title="' + \ '<img loading="lazy" title="' + \
translate['Reply to this post'] + '" alt="' + \ translate['Reply to this post'] + '" alt="' + \
translate['Reply to this post'] + \ translate['Reply to this post'] + \
' |" src="/' + iconsPath + '/reply.png"/></a>\n' ' |" src="/' + iconsPath + '/reply.png"/></a>\n'
return replyStr return replyStr