diff --git a/daemon.py b/daemon.py index ea3b07d3..9f1da4c6 100644 --- a/daemon.py +++ b/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) diff --git a/webinterface.py b/webinterface.py index 473fc0d5..1632f2ab 100644 --- a/webinterface.py +++ b/webinterface.py @@ -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+=''+tagName+' ' + tagCloudStr+=''+tagName+' ' tagCloudHtml=tagCloudStr.strip()+'\n' return tagCloudHtml @@ -3813,7 +3822,7 @@ def htmlSearch(translate: {}, \ followStr+='
' followStr+=' ' followStr+=' ' - followStr+='

'+htmlHashTagCloud(baseDir,path)+'

' + followStr+='

'+htmlHashTagCloud(baseDir,actor)+'

' followStr+=' ' followStr+=' ' followStr+=''