forked from indymedia/epicyon
Insert emoji
parent
2918582753
commit
10d239ef2e
25
content.py
25
content.py
|
@ -11,6 +11,31 @@ import time
|
||||||
import commentjson
|
import commentjson
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
|
||||||
|
def replaceEmojiFromTags(content: str,tag: [],messageType: str) -> str:
|
||||||
|
"""Uses the tags to replace :emoji: with html image markup
|
||||||
|
"""
|
||||||
|
for tagItem in tag:
|
||||||
|
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="<img src=\""+tagItem['icon']['url']+"\" alt=\""+tagItem['name'].replace(':','')+"\" align=\"middle\" class=\""+htmlClass+"\"/>"
|
||||||
|
content=content.replace(tagItem['name'],emojiHtml)
|
||||||
|
return content
|
||||||
|
|
||||||
def addMusicTag(content: str,tag: str) -> str:
|
def addMusicTag(content: str,tag: str) -> str:
|
||||||
"""If a music link is found then ensure that the post is tagged appropriately
|
"""If a music link is found then ensure that the post is tagged appropriately
|
||||||
"""
|
"""
|
||||||
|
|
2
posts.py
2
posts.py
|
@ -459,6 +459,8 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \
|
||||||
nickname,domain,content, \
|
nickname,domain,content, \
|
||||||
mentionedRecipients, \
|
mentionedRecipients, \
|
||||||
hashtagsDict)
|
hashtagsDict)
|
||||||
|
content= \
|
||||||
|
replaceEmojiFromTags(content,hashtagsDict,'content')
|
||||||
|
|
||||||
statusNumber,published = getStatusNumber()
|
statusNumber,published = getStatusNumber()
|
||||||
postTo='https://www.w3.org/ns/activitystreams#Public'
|
postTo='https://www.w3.org/ns/activitystreams#Public'
|
||||||
|
|
|
@ -40,6 +40,7 @@ from announce import announcedByPerson
|
||||||
from blocking import isBlocked
|
from blocking import isBlocked
|
||||||
from content import getMentionsFromHtml
|
from content import getMentionsFromHtml
|
||||||
from content import addHtmlTags
|
from content import addHtmlTags
|
||||||
|
from content import replaceEmojiFromTags
|
||||||
from config import getConfigParam
|
from config import getConfigParam
|
||||||
from skills import getSkills
|
from skills import getSkills
|
||||||
from cache import getPersonFromCache
|
from cache import getPersonFromCache
|
||||||
|
@ -1423,31 +1424,6 @@ def contentWarningScript() -> str:
|
||||||
'}\n'
|
'}\n'
|
||||||
return script
|
return script
|
||||||
|
|
||||||
def htmlReplaceEmojiFromTags(content: str,tag: [],messageType: str) -> str:
|
|
||||||
"""Uses the tags to replace :emoji: with html image markup
|
|
||||||
"""
|
|
||||||
for tagItem in tag:
|
|
||||||
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="<img src=\""+tagItem['icon']['url']+"\" alt=\""+tagItem['name'].replace(':','')+"\" align=\"middle\" class=\""+htmlClass+"\"/>"
|
|
||||||
content=content.replace(tagItem['name'],emojiHtml)
|
|
||||||
return content
|
|
||||||
|
|
||||||
def addEmbeddedAudio(translate: {},content: str) -> str:
|
def addEmbeddedAudio(translate: {},content: str) -> str:
|
||||||
"""Adds embedded audio for mp3/ogg
|
"""Adds embedded audio for mp3/ogg
|
||||||
"""
|
"""
|
||||||
|
@ -1632,9 +1608,9 @@ def addEmojiToDisplayName(baseDir: str,httpPrefix: str, \
|
||||||
for tagName,tag in emojiTags.items():
|
for tagName,tag in emojiTags.items():
|
||||||
emojiTagsList.append(tag)
|
emojiTagsList.append(tag)
|
||||||
if not inProfileName:
|
if not inProfileName:
|
||||||
displayName=htmlReplaceEmojiFromTags(displayName,emojiTagsList,'post header')
|
displayName=replaceEmojiFromTags(displayName,emojiTagsList,'post header')
|
||||||
else:
|
else:
|
||||||
displayName=htmlReplaceEmojiFromTags(displayName,emojiTagsList,'profile')
|
displayName=replaceEmojiFromTags(displayName,emojiTagsList,'profile')
|
||||||
return displayName
|
return displayName
|
||||||
|
|
||||||
def individualPostAsHtml(iconsDir: str,translate: {}, \
|
def individualPostAsHtml(iconsDir: str,translate: {}, \
|
||||||
|
@ -1995,7 +1971,7 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \
|
||||||
contentStr+='</div>'
|
contentStr+='</div>'
|
||||||
|
|
||||||
if postJsonObject['object'].get('tag'):
|
if postJsonObject['object'].get('tag'):
|
||||||
contentStr=htmlReplaceEmojiFromTags(contentStr,postJsonObject['object']['tag'],'content')
|
contentStr=replaceEmojiFromTags(contentStr,postJsonObject['object']['tag'],'content')
|
||||||
|
|
||||||
contentStr='<div class="message">'+contentStr+'</div>'
|
contentStr='<div class="message">'+contentStr+'</div>'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue