mirror of https://gitlab.com/bashrc2/epicyon
Extra emoji fields
parent
a7b0634d1e
commit
cc0b6f48e2
|
@ -11,6 +11,7 @@ import time
|
||||||
import email.parser
|
import email.parser
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
|
from utils import fileLastModified
|
||||||
|
|
||||||
def switchWords(baseDir: str,nickname: str,domain: str,content: str) -> str:
|
def switchWords(baseDir: str,nickname: str,domain: str,content: str) -> str:
|
||||||
"""Performs word replacements. eg. Trump -> The Orange Menace
|
"""Performs word replacements. eg. Trump -> The Orange Menace
|
||||||
|
@ -174,7 +175,10 @@ def loadEmojiDict(emojiDataFilename: str,emojiDict: {}) -> None:
|
||||||
emojiName=emojiName.split('..')[0]
|
emojiName=emojiName.split('..')[0]
|
||||||
emojiDict[emojiName.lower()]=emojiUnicode
|
emojiDict[emojiName.lower()]=emojiUnicode
|
||||||
|
|
||||||
def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji: {},postTags: {},emojiDict: {}) -> bool:
|
def addEmoji(baseDir: str,wordStr: str, \
|
||||||
|
httpPrefix: str,domain: str, \
|
||||||
|
replaceEmoji: {},postTags: {}, \
|
||||||
|
emojiDict: {}) -> bool:
|
||||||
"""Detects Emoji and adds them to the replacements dict
|
"""Detects Emoji and adds them to the replacements dict
|
||||||
Also updates the tags list to be added to the post
|
Also updates the tags list to be added to the post
|
||||||
"""
|
"""
|
||||||
|
@ -205,6 +209,8 @@ def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji:
|
||||||
'url': emojiUrl
|
'url': emojiUrl
|
||||||
},
|
},
|
||||||
'name': ':'+emoji+':',
|
'name': ':'+emoji+':',
|
||||||
|
"updated": fileLastModified(emojiFilename),
|
||||||
|
"id": emojiUrl.replace('.png',''),
|
||||||
'type': 'Emoji'
|
'type': 'Emoji'
|
||||||
}
|
}
|
||||||
return True
|
return True
|
||||||
|
|
1
tests.py
1
tests.py
|
@ -1388,6 +1388,7 @@ def testAddEmoji(content: str,emojiStr:str):
|
||||||
tags=[]
|
tags=[]
|
||||||
for tagName,tag in hashtags.items():
|
for tagName,tag in hashtags.items():
|
||||||
tags.append(tag)
|
tags.append(tag)
|
||||||
|
print(str(tags))
|
||||||
content=contentModified
|
content=contentModified
|
||||||
contentModified=replaceEmojiFromTags(content,tags,'content')
|
contentModified=replaceEmojiFromTags(content,tags,'content')
|
||||||
assert 'img src' in contentModified
|
assert 'img src' in contentModified
|
||||||
|
|
7
utils.py
7
utils.py
|
@ -562,3 +562,10 @@ def updateRecentPostsCache(recentPostsCache: {},maxRecentPosts: int, \
|
||||||
recentPostsCache['html']={}
|
recentPostsCache['html']={}
|
||||||
recentPostsCache['json'][postId]=json.dumps(postJsonObject)
|
recentPostsCache['json'][postId]=json.dumps(postJsonObject)
|
||||||
recentPostsCache['html'][postId]=htmlStr
|
recentPostsCache['html'][postId]=htmlStr
|
||||||
|
|
||||||
|
def fileLastModified(filename: str) -> str:
|
||||||
|
"""Returns the date when a file was last modified
|
||||||
|
"""
|
||||||
|
t = os.path.getmtime(filename)
|
||||||
|
modifiedTime=datetime.datetime.fromtimestamp(t)
|
||||||
|
return modifiedTime.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
Loading…
Reference in New Issue