forked from indymedia/epicyon
Dedicated emoji search screen
parent
d10295c814
commit
e5b988aa3c
20
daemon.py
20
daemon.py
|
@ -88,6 +88,7 @@ from webinterface import htmlNewPost
|
||||||
from webinterface import htmlFollowConfirm
|
from webinterface import htmlFollowConfirm
|
||||||
from webinterface import htmlSearch
|
from webinterface import htmlSearch
|
||||||
from webinterface import htmlSearchEmoji
|
from webinterface import htmlSearchEmoji
|
||||||
|
from webinterface import htmlSearchEmojiTextEntry
|
||||||
from webinterface import htmlUnfollowConfirm
|
from webinterface import htmlUnfollowConfirm
|
||||||
from webinterface import htmlProfileAfterSearch
|
from webinterface import htmlProfileAfterSearch
|
||||||
from webinterface import htmlEditProfile
|
from webinterface import htmlEditProfile
|
||||||
|
@ -799,7 +800,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
return
|
return
|
||||||
|
|
||||||
# search for a fediverse address from the web interface by selecting search icon
|
# search for a fediverse address, shared item or emoji from the web interface by selecting search icon
|
||||||
if htmlGET and '/users/' in self.path:
|
if htmlGET and '/users/' in self.path:
|
||||||
if self.path.endswith('/search'):
|
if self.path.endswith('/search'):
|
||||||
# show the search screen
|
# show the search screen
|
||||||
|
@ -809,6 +810,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# search for emoji by name
|
||||||
|
if htmlGET and '/users/' in self.path:
|
||||||
|
if self.path.endswith('/searchemoji'):
|
||||||
|
# show the search screen
|
||||||
|
msg=htmlSearchEmojiTextEntry(self.server.baseDir,self.path).encode()
|
||||||
|
self._set_headers('text/html',len(msg),cookie)
|
||||||
|
self.wfile.write(msg)
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
|
|
||||||
# Unfollow a person from the web interface by selecting Unfollow on the dropdown
|
# Unfollow a person from the web interface by selecting Unfollow on the dropdown
|
||||||
if htmlGET and '/users/' in self.path:
|
if htmlGET and '/users/' in self.path:
|
||||||
if '?unfollow=' in self.path:
|
if '?unfollow=' in self.path:
|
||||||
|
@ -2345,6 +2356,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.POSTbusy=False
|
self.server.POSTbusy=False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
searchForEmoji=False
|
||||||
|
if authorized and self.path.endswith('/searchhandleemoji':
|
||||||
|
searchForEmoji=True
|
||||||
|
self.path=self.path.replace('/searchhandleemoji','/searchhandle')
|
||||||
|
|
||||||
# a search was made
|
# a search was made
|
||||||
if authorized and \
|
if authorized and \
|
||||||
(self.path.endswith('/searchhandle') or '/searchhandle?page=' in self.path):
|
(self.path.endswith('/searchhandle') or '/searchhandle?page=' in self.path):
|
||||||
|
@ -2364,6 +2380,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '&' in searchStr:
|
if '&' in searchStr:
|
||||||
searchStr=searchStr.split('&')[0]
|
searchStr=searchStr.split('&')[0]
|
||||||
searchStr=searchStr.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip()
|
searchStr=searchStr.replace('+',' ').replace('%40','@').replace('%3A',':').replace('%23','#').strip()
|
||||||
|
if searchForEmoji:
|
||||||
|
searchStr=':'+searchStr+':'
|
||||||
if searchStr.startswith('#'):
|
if searchStr.startswith('#'):
|
||||||
# hashtag search
|
# hashtag search
|
||||||
hashtagStr= \
|
hashtagStr= \
|
||||||
|
|
|
@ -1535,6 +1535,37 @@ def htmlUnblockConfirm(baseDir: str,originPathStr: str,blockActor: str,blockProf
|
||||||
blockStr+=htmlFooter()
|
blockStr+=htmlFooter()
|
||||||
return blockStr
|
return blockStr
|
||||||
|
|
||||||
|
def htmlSearchEmojiTextEntry(baseDir: str,path: str) -> str:
|
||||||
|
"""Search for an emoji by name
|
||||||
|
"""
|
||||||
|
actor=path.replace('/search','')
|
||||||
|
nickname=getNicknameFromActor(actor)
|
||||||
|
domain,port=getDomainFromActor(actor)
|
||||||
|
|
||||||
|
if os.path.isfile(baseDir+'/img/search-background.png'):
|
||||||
|
if not os.path.isfile(baseDir+'/accounts/search-background.png'):
|
||||||
|
copyfile(baseDir+'/img/search-background.png',baseDir+'/accounts/search-background.png')
|
||||||
|
|
||||||
|
with open(baseDir+'/epicyon-follow.css', 'r') as cssFile:
|
||||||
|
profileStyle = cssFile.read()
|
||||||
|
emojiStr=htmlHeader(profileStyle)
|
||||||
|
emojiStr+='<div class="follow">'
|
||||||
|
emojiStr+=' <div class="followAvatar">'
|
||||||
|
emojiStr+=' <center>'
|
||||||
|
emojiStr+=' <p class="followText">Enter an emoji name to search for</p>'
|
||||||
|
emojiStr+= \
|
||||||
|
' <form method="POST" action="'+actor+'/searchhandleemoji">' \
|
||||||
|
' <input type="hidden" name="actor" value="'+actor+'">' \
|
||||||
|
' <input type="text" name="searchtext" autofocus><br>' \
|
||||||
|
' <button type="submit" class="button" name="submitSearch">Submit</button>' \
|
||||||
|
' <a href="'+actor+'"><button class="button">Go Back</button></a>' \
|
||||||
|
' </form>'
|
||||||
|
emojiStr+=' </center>'
|
||||||
|
emojiStr+=' </div>'
|
||||||
|
emojiStr+='</div>'
|
||||||
|
emojiStr+=htmlFooter()
|
||||||
|
return emojiStr
|
||||||
|
|
||||||
def htmlSearch(baseDir: str,path: str) -> str:
|
def htmlSearch(baseDir: str,path: str) -> str:
|
||||||
"""Search called from the timeline icon
|
"""Search called from the timeline icon
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue