From 372edabd3d9b1845ab0f8657e3e2feaf731f3a4c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Sep 2019 12:44:43 +0100 Subject: [PATCH] Tidying --- webinterface.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/webinterface.py b/webinterface.py index 496db069..3c875b40 100644 --- a/webinterface.py +++ b/webinterface.py @@ -1609,6 +1609,21 @@ def rejectAnnounce(announceFilename: str): rejectAnnounceFile.write('\n') rejectAnnounceFile.close() +def addEmojiToDisplayName(baseDir: str,httpPrefix: str, \ + nickname: str,domain: str, \ + displayName: str) -> str: + """Adds emoji icons to display names on individual posts + """ + if ':' in displayName: + displayName=displayName.replace('

','').replace('

','') + emojiTags=[] + displayName= \ + addHtmlTags(baseDir,httpPrefix, \ + nickname,domain,displayName,emojiTags,{}) + displayName=displayName.replace('

','').replace('

','') + displayName=htmlReplaceEmojiFromTags(displayName,emojiTags) + return displayName + def individualPostAsHtml(iconsDir: str,translate: {}, \ pageNumber: int,baseDir: str, \ session,wfRequest: {},personCache: {}, \ @@ -1743,14 +1758,10 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \ displayName=getDisplayName(postJsonObject['actor'],personCache) if displayName: - if ':' in displayName: - displayName=displayName.replace('

','').replace('

','') - emojiTags=[] - displayName= \ - addHtmlTags(baseDir,httpPrefix, \ - nickname,domain,displayName,emojiTags,{}) - displayName=displayName.replace('

','').replace('

','') - displayName=htmlReplaceEmojiFromTags(displayName,emojiTags) + displayName= \ + addEmojiToDisplayName(baseDir,httpPrefix, \ + nickname,domain, \ + displayName) titleStr+=''+displayName+'' else: titleStr+='@'+actorNickname+'@'+actorDomain+'' @@ -1873,14 +1884,10 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \ if avatarUrl2: avatarUrl=avatarUrl2 if displayName: - if ':' in displayName: - displayName=displayName.replace('

','').replace('

','') - emojiTags=[] - displayName= \ - addHtmlTags(baseDir,httpPrefix, \ - nickname,domain,displayName,emojiTags,{}) - displayName=displayName.replace('

','').replace('

','') - displayName=htmlReplaceEmojiFromTags(displayName,emojiTags) + displayName= \ + addEmojiToDisplayName(baseDir,httpPrefix, \ + nickname,domain, \ + displayName) titleStr=displayName+' '+titleStr avatarImageInPost= \