mirror of https://gitlab.com/bashrc2/epicyon
tags path including nickname
parent
08b98516f9
commit
cc99ebf527
17
daemon.py
17
daemon.py
|
@ -1619,7 +1619,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._benchmarkGETtimings(GETstartTime,GETtimings,27)
|
||||
|
||||
# hashtag search
|
||||
if self.path.startswith('/tags/'):
|
||||
if self.path.startswith('/tags/') or \
|
||||
(authorized and '/tags/' in self.path):
|
||||
pageNumber=1
|
||||
if '?page=' in self.path:
|
||||
pageNumberStr=self.path.split('?page=')[1]
|
||||
|
@ -1634,8 +1635,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
return
|
||||
nickname=None
|
||||
if '/users/' in self.path:
|
||||
actor=self.server.httpPrefix+'://'+self.server.domainFull+self.path
|
||||
nickname= \
|
||||
getNicknameFromActor(actor)
|
||||
hashtagStr= \
|
||||
htmlHashtagSearch(self.server.domain,self.server.port, \
|
||||
htmlHashtagSearch(nickname, \
|
||||
self.server.domain,self.server.port, \
|
||||
self.server.recentPostsCache, \
|
||||
self.server.maxRecentPosts, \
|
||||
self.server.translate, \
|
||||
|
@ -4647,9 +4654,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if searchForEmoji:
|
||||
searchStr=':'+searchStr+':'
|
||||
if searchStr.startswith('#'):
|
||||
nickname=getNicknameFromActor(actorStr)
|
||||
# hashtag search
|
||||
hashtagStr= \
|
||||
htmlHashtagSearch(self.server.domain,self.server.port, \
|
||||
htmlHashtagSearch(nickname, \
|
||||
self.server.domain,self.server.port, \
|
||||
self.server.recentPostsCache, \
|
||||
self.server.maxRecentPosts, \
|
||||
self.server.translate, \
|
||||
|
@ -4683,7 +4692,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return
|
||||
elif '@' in searchStr:
|
||||
# profile search
|
||||
nickname=getNicknameFromActor(self.path)
|
||||
nickname=getNicknameFromActor(actorStr)
|
||||
if not self.server.session:
|
||||
self.server.session= \
|
||||
createSession(self.server.useTor)
|
||||
|
|
|
@ -346,7 +346,7 @@ def htmlModerationInfo(translate: {},baseDir: str,httpPrefix: str) -> str:
|
|||
infoForm+=htmlFooter()
|
||||
return infoForm
|
||||
|
||||
def htmlHashtagSearch(domain: str,port: int, \
|
||||
def htmlHashtagSearch(nickname: str,domain: str,port: int, \
|
||||
recentPostsCache: {},maxRecentPosts: int, \
|
||||
translate: {}, \
|
||||
baseDir: str,hashtag: str,pageNumber: int, \
|
||||
|
@ -362,6 +362,11 @@ def htmlHashtagSearch(domain: str,port: int, \
|
|||
if not os.path.isfile(hashtagIndexFile):
|
||||
return None
|
||||
|
||||
# check that the directory for the nickname exists
|
||||
if nickname:
|
||||
if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
|
||||
nickname=None
|
||||
|
||||
# read the index
|
||||
with open(hashtagIndexFile, "r") as f:
|
||||
lines = f.readlines()
|
||||
|
@ -414,15 +419,19 @@ def htmlHashtagSearch(domain: str,port: int, \
|
|||
if postJsonObject:
|
||||
if not isPublicPost(postJsonObject):
|
||||
index-=1
|
||||
continue
|
||||
continue
|
||||
showIndividualPostIcons=False
|
||||
if nickname:
|
||||
showIndividualPostIcons=True
|
||||
allowDeletion=False
|
||||
hashtagSearchForm+= \
|
||||
individualPostAsHtml(recentPostsCache,maxRecentPosts, \
|
||||
iconsDir,translate,None, \
|
||||
baseDir,session,wfRequest,personCache, \
|
||||
nickname,domain,port,postJsonObject, \
|
||||
None,True,False, \
|
||||
None,True,allowDeletion, \
|
||||
httpPrefix,projectVersion,'inbox', \
|
||||
False,False,False,False,False)
|
||||
False,showIndividualPostIcons,False,False,False)
|
||||
index-=1
|
||||
|
||||
if endIndex>0:
|
||||
|
@ -3746,12 +3755,12 @@ def htmlCalendar(translate: {}, \
|
|||
calendarStr+=htmlFooter()
|
||||
return calendarStr
|
||||
|
||||
def htmlHashTagCloud(baseDir: str,path: str) -> str:
|
||||
def htmlHashTagCloud(baseDir: str,actor: str) -> str:
|
||||
"""Returns a tag cloud of today's hashtags
|
||||
"""
|
||||
daysSinceEpoch=(datetime.utcnow() - datetime(1970,1,1)).days
|
||||
daysSinceEpochStr=str(daysSinceEpoch)+' '
|
||||
nickname=getNicknameFromActor(path)
|
||||
nickname=getNicknameFromActor(actor)
|
||||
tagCloud=[]
|
||||
for subdir, dirs, files in os.walk(baseDir+'/tags'):
|
||||
for f in files:
|
||||
|
@ -3782,7 +3791,7 @@ def htmlHashTagCloud(baseDir: str,path: str) -> str:
|
|||
tagCloud.sort()
|
||||
tagCloudStr=''
|
||||
for tagName in tagCloud:
|
||||
tagCloudStr+='<a href="/tags/'+tagName+'" class="hashtagcloud">'+tagName+'</a> '
|
||||
tagCloudStr+='<a href="'+actor+'/tags/'+tagName+'" class="hashtagcloud">'+tagName+'</a> '
|
||||
tagCloudHtml=tagCloudStr.strip()+'\n'
|
||||
return tagCloudHtml
|
||||
|
||||
|
@ -3813,7 +3822,7 @@ def htmlSearch(translate: {}, \
|
|||
followStr+=' <input type="text" name="searchtext" autofocus><br>'
|
||||
followStr+=' <button type="submit" class="button" name="submitSearch">'+translate['Submit']+'</button>'
|
||||
followStr+=' </form>'
|
||||
followStr+=' <p class="hashtagcloud">'+htmlHashTagCloud(baseDir,path)+'</p>'
|
||||
followStr+=' <p class="hashtagcloud">'+htmlHashTagCloud(baseDir,actor)+'</p>'
|
||||
followStr+=' </center>'
|
||||
followStr+=' </div>'
|
||||
followStr+='</div>'
|
||||
|
|
Loading…
Reference in New Issue