forked from indymedia/epicyon
Replace tags with unicode characters
parent
322ba251f4
commit
205ff8b5cb
|
@ -56,8 +56,16 @@ def replaceEmojiFromTags(content: str,tag: [],messageType: str) -> str:
|
|||
continue
|
||||
if not tagItem['icon'].get('url'):
|
||||
continue
|
||||
if '/' not in tagItem['icon']['url']:
|
||||
continue
|
||||
if tagItem['name'] not in content:
|
||||
continue
|
||||
iconName=tagItem['icon']['url'].split('/')[-1]
|
||||
if iconName:
|
||||
if iconName.startswith('1'):
|
||||
if '.' in iconName:
|
||||
iconName=iconName.split('.')[0]
|
||||
content=content.replace(tagItem['name'],'\\u'+iconName)
|
||||
htmlClass='emoji'
|
||||
if messageType=='post header':
|
||||
htmlClass='emojiheader'
|
||||
|
@ -67,6 +75,7 @@ def replaceEmojiFromTags(content: str,tag: [],messageType: str) -> str:
|
|||
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
|
||||
"""
|
||||
|
|
4
posts.py
4
posts.py
|
@ -527,15 +527,13 @@ def createPostBase(baseDir: str,nickname: str,domain: str,port: int, \
|
|||
# convert content to html
|
||||
emojisDict={}
|
||||
|
||||
# replace 's
|
||||
content=content.replace("\ufffd\ufffd\ufffds","'s").replace("’","'")
|
||||
|
||||
# add tags
|
||||
content= \
|
||||
addHtmlTags(baseDir,httpPrefix, \
|
||||
nickname,domain,content, \
|
||||
mentionedRecipients, \
|
||||
hashtagsDict,True)
|
||||
content=replaceEmojiFromTags(content,hashtagsDict,'content')
|
||||
|
||||
statusNumber,published = getStatusNumber()
|
||||
postTo='https://www.w3.org/ns/activitystreams#Public'
|
||||
|
|
15
tests.py
15
tests.py
|
@ -1352,8 +1352,9 @@ def testWebLinks():
|
|||
assert resultText=='<p>ABCABCABCABCABCABCABCABCABCABCABCABCABCA<\p>'
|
||||
|
||||
|
||||
def testAddEmoji(content: str,emojiStr:str):
|
||||
print('testAddEmoji: '+emojiStr)
|
||||
def testAddEmoji():
|
||||
print('testAddEmoji')
|
||||
content="Emoji :lemon: :strawberry: :banana:"
|
||||
httpPrefix='http'
|
||||
nickname='testuser'
|
||||
domain='testdomain.net'
|
||||
|
@ -1382,17 +1383,15 @@ def testAddEmoji(content: str,emojiStr:str):
|
|||
addHtmlTags(baseDir,httpPrefix, \
|
||||
nickname,domain,content, \
|
||||
recipients,hashtags,True)
|
||||
assert ':'+emojiStr+':' in contentModified
|
||||
assert ':lemon:' in contentModified
|
||||
assert contentModified.startswith('<p>')
|
||||
assert contentModified.endswith('</p>')
|
||||
tags=[]
|
||||
for tagName,tag in hashtags.items():
|
||||
tags.append(tag)
|
||||
print(str(tags))
|
||||
content=contentModified
|
||||
contentModified=replaceEmojiFromTags(content,tags,'content')
|
||||
assert 'img src' in contentModified
|
||||
assert ':'+emojiStr+':' not in contentModified
|
||||
assert contentModified=='<p>Emoji \\u1F34B \\u1F353 \\u1F34C</p>'
|
||||
|
||||
os.chdir(baseDirOriginal)
|
||||
shutil.rmtree(baseDirOriginal+'/.tests')
|
||||
|
@ -1474,9 +1473,7 @@ def runAllTests():
|
|||
testSaveLoadJson()
|
||||
testCommentJson()
|
||||
testGetStatusNumber()
|
||||
testAddEmoji("Emoji :lemon: :strawberry: :banana:","lemon")
|
||||
testAddEmoji("Emoji :lemon: :strawberry: :banana:","banana")
|
||||
testAddEmoji("G'day world :worldmap:","worldmap")
|
||||
testAddEmoji()
|
||||
testActorParsing()
|
||||
testHttpsig()
|
||||
testCache()
|
||||
|
|
Loading…
Reference in New Issue