diff --git a/webapp_post.py b/webapp_post.py index 121b2e66..4b9eb926 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -299,6 +299,59 @@ def getReplyIconHtml(nickname: str, isPublicRepeat: bool, return replyStr +def getEditIconHtml(baseDir: str, nickname: str, domainFull: str, + postJsonObject: {}, actorNickname: str, + translate: {}, iconsPath: str, isEvent: bool) -> str: + """Returns html for the edit icon/button + """ + editStr = '' + if (postJsonObject['actor'].endswith(domainFull + '/users/' + nickname) or + (isEditor(baseDir, nickname) and + postJsonObject['actor'].endswith(domainFull + '/users/news'))): + if '/statuses/' in postJsonObject['object']['id']: + if isBlogPost(postJsonObject): + blogPostId = postJsonObject['object']['id'] + if not isNewsPost(postJsonObject): + editStr += \ + ' ' + \ + '' + \ + '' + \
+                        translate['Edit blog post'] + \
+                        ' |\n' + else: + editStr += \ + ' ' + \ + '' + \ + '' + \
+                        translate['Edit blog post'] + \
+                        ' |\n' + elif isEvent: + eventPostId = postJsonObject['object']['id'] + editStr += \ + ' ' + \ + '' + \ + '' + \
+                    translate['Edit event'] + \
+                    ' |\n' + return editStr + + def individualPostAsHtml(allowDownloads: bool, recentPostsCache: {}, maxRecentPosts: int, iconsPath: str, translate: {}, @@ -567,51 +620,9 @@ def individualPostAsHtml(allowDownloads: bool, if timeDiff > 100: print('TIMING INDIV ' + boxName + ' 11 = ' + str(timeDiff)) - editStr = '' - if (postJsonObject['actor'].endswith(domainFull + '/users/' + nickname) or - (isEditor(baseDir, nickname) and - postJsonObject['actor'].endswith(domainFull + '/users/news'))): - if '/statuses/' in postJsonObject['object']['id']: - if isBlogPost(postJsonObject): - blogPostId = postJsonObject['object']['id'] - if not isNewsPost(postJsonObject): - editStr += \ - ' ' + \ - '' + \ - '' + \
-                        translate['Edit blog post'] + \
-                        ' |\n' - else: - editStr += \ - ' ' + \ - '' + \ - '' + \
-                        translate['Edit blog post'] + \
-                        ' |\n' - elif isEvent: - eventPostId = postJsonObject['object']['id'] - editStr += \ - ' ' + \ - '' + \ - '' + \
-                    translate['Edit event'] + \
-                    ' |\n' + editStr = getEditIconHtml(baseDir, nickname, domainFull, + postJsonObject, actorNickname, + translate, iconsPath, isEvent) announceStr = '' if not isModerationPost and showRepeatIcon: