forked from indymedia/epicyon
Emoji image replacement
parent
ec6dea1c58
commit
bc7f1ef8dd
|
@ -89,12 +89,12 @@ def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji:
|
||||||
return False
|
return False
|
||||||
emojiUrl=httpPrefix+"://"+domain+"/emoji/"+emojiDict[emoji]+'.png'
|
emojiUrl=httpPrefix+"://"+domain+"/emoji/"+emojiDict[emoji]+'.png'
|
||||||
postTags[emoji]= {
|
postTags[emoji]= {
|
||||||
'href': emojiUrl,
|
'id': emojiUrl,
|
||||||
'name': ':'+emoji+':',
|
'name': ':'+emoji+':',
|
||||||
'type': 'Emoji'
|
'type': 'Emoji'
|
||||||
}
|
}
|
||||||
replaceEmoji[wordStr]= \
|
#replaceEmoji[wordStr]= \
|
||||||
"<img src=\""+emojiUrl+"\" alt=\""+emoji+"\" align=\"middle\" class=\"emoji\"/>"
|
# "<img src=\""+emojiUrl+"\" alt=\""+emoji+"\" align=\"middle\" class=\"emoji\"/>"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},recipients: [],tags: {}) -> bool:
|
def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},recipients: [],tags: {}) -> bool:
|
||||||
|
|
|
@ -940,6 +940,24 @@ def contentWarningScript() -> str:
|
||||||
'}'
|
'}'
|
||||||
return script
|
return script
|
||||||
|
|
||||||
|
def htmlRemplaceEmojiFromTags(content: str,tag: {}) -> str:
|
||||||
|
"""Uses the tags to replace :emoji: with html image markup
|
||||||
|
"""
|
||||||
|
for tagItem in tag:
|
||||||
|
if not tagItem.get('id'):
|
||||||
|
continue
|
||||||
|
if not tagItem.get('type'):
|
||||||
|
continue
|
||||||
|
if not tagItem.get('name'):
|
||||||
|
continue
|
||||||
|
if tagItem['type']!='Emoji':
|
||||||
|
continue
|
||||||
|
if tagItem['name'] not in content:
|
||||||
|
continue
|
||||||
|
emojiHtml="<img src=\""+tagItem['id']+"\" alt=\""+tagItem['name'].replace(':','')+"\" align=\"middle\" class=\"emoji\"/>"
|
||||||
|
content=content.replace(tagItem['name'],emojiHtml)
|
||||||
|
return content
|
||||||
|
|
||||||
def individualPostAsHtml(baseDir: str, \
|
def individualPostAsHtml(baseDir: str, \
|
||||||
session,wfRequest: {},personCache: {}, \
|
session,wfRequest: {},personCache: {}, \
|
||||||
nickname: str,domain: str,port: int, \
|
nickname: str,domain: str,port: int, \
|
||||||
|
@ -1158,6 +1176,9 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
contentStr+=postJsonObject['object']['content']+attachmentStr
|
contentStr+=postJsonObject['object']['content']+attachmentStr
|
||||||
contentStr+='</div>'
|
contentStr+='</div>'
|
||||||
|
|
||||||
|
if postJsonObject['object'].get('tag'):
|
||||||
|
contentStr=htmlRemplaceEmojiFromTags(contentStr,postJsonObject['object']['tag'])
|
||||||
|
|
||||||
return \
|
return \
|
||||||
'<div class="'+containerClass+'">\n'+ \
|
'<div class="'+containerClass+'">\n'+ \
|
||||||
avatarDropdown+ \
|
avatarDropdown+ \
|
||||||
|
|
Loading…
Reference in New Issue