From bacc06f416398cabe1c61c90bef5458fff962434 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 29 Sep 2019 18:42:51 +0100 Subject: [PATCH] emoji replacement --- content.py | 25 ------------------------- posts.py | 7 ++++--- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/content.py b/content.py index 305eef5e..56a92bfa 100644 --- a/content.py +++ b/content.py @@ -36,31 +36,6 @@ def replaceEmojiFromTags(content: str,tag: [],messageType: str) -> str: content=content.replace(tagItem['name'],emojiHtml) return content -def replaceEmojiFromTagsDict(content: str,tag: {},messageType: str) -> str: - """Uses the tags dictionary to replace :emoji: with html image markup - """ - for tagName,tagItem in tag.items(): - if not tagItem.get('type'): - continue - if tagItem['type']!='Emoji': - continue - if not tagItem.get('name'): - continue - if not tagItem.get('icon'): - continue - if not tagItem['icon'].get('url'): - continue - if tagItem['name'] not in content: - continue - htmlClass='emoji' - if messageType=='post header': - htmlClass='emojiheader' - if messageType=='profile': - htmlClass='emojiprofile' - emojiHtml="\""+tagItem['name'].replace(':','')+"\"" - content=content.replace(tagItem['name'],emojiHtml) - return content - def addMusicTag(content: str,tag: str) -> str: """If a music link is found then ensure that the post is tagged appropriately """ diff --git a/posts.py b/posts.py index 71402658..9c03e89b 100644 --- a/posts.py +++ b/posts.py @@ -41,7 +41,7 @@ from capabilities import getOcapFilename from capabilities import capabilitiesUpdate from media import attachMedia from content import addHtmlTags -from content import replaceEmojiFromTagsDict +from content import replaceEmojiFromTags from auth import createBasicAuthHeader from config import getConfigParam from blocking import isBlocked @@ -455,12 +455,12 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ domain=domain+':'+str(port) # convert content to html + emojisDict={} content= \ addHtmlTags(baseDir,httpPrefix, \ nickname,domain,content, \ mentionedRecipients, \ hashtagsDict) - content=replaceEmojiFromTagsDict(content,hashtagsDict,'content') statusNumber,published = getStatusNumber() postTo='https://www.w3.org/ns/activitystreams#Public' @@ -501,7 +501,8 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ tags.append(tag) if isPublic: updateHashtagsIndex(baseDir,tag,newPostId) - + content=replaceEmojiFromTags(content,tags,'content') + if not clientToServer: actorUrl=httpPrefix+'://'+domain+'/users/'+nickname