diff --git a/daemon.py b/daemon.py index e070ac6fc..e14552156 100644 --- a/daemon.py +++ b/daemon.py @@ -87,6 +87,7 @@ from webinterface import htmlGetLoginCredentials from webinterface import htmlNewPost from webinterface import htmlFollowConfirm from webinterface import htmlSearch +from webinterface import htmlSearchEmoji from webinterface import htmlUnfollowConfirm from webinterface import htmlProfileAfterSearch from webinterface import htmlEditProfile @@ -2404,6 +2405,20 @@ class PubServer(BaseHTTPRequestHandler): self.wfile.write(msg) self.server.POSTbusy=False return + elif searchStr.startswith(':') or \ + searchStr.lower().strip('\n').endswith(' emoji'): + # eg. "cat emoji" + if searchStr.lower().strip('\n').endswith(' emoji'): + searchStr=searchStr.lower().strip('\n').replace(' emoji','') + # emoji search + emojiStr= \ + htmlSearchEmoji(self.server.baseDir,searchStr) + if emojiStr: + msg=sharedItemsStr.encode('utf-8') + self._login_headers('text/html',len(msg)) + self.wfile.write(msg) + self.server.POSTbusy=False + return else: # shared items search sharedItemsStr= \ diff --git a/webinterface.py b/webinterface.py index 4ab0fff0a..62dbd39c3 100644 --- a/webinterface.py +++ b/webinterface.py @@ -46,6 +46,46 @@ def getPersonAvatarUrl(personUrl: str,personCache: {}) -> str: return personJson['icon']['url'] return None +def htmlSearchEmoji(baseDir: str,searchStr: str) -> str: + """Search results for emoji + """ + + searchStr=searchStr.lower().replace(':','').strip('\n') + with open(baseDir+'/epicyon-profile.css', 'r') as cssFile: + emojiCSS=cssFile.read() + emojiLookupFilename=baseDir+'/emoji/emoji.json' + + # create header + emojiForm=htmlHeader(emojiCSS) + emojiForm+='