mirror of https://gitlab.com/bashrc2/epicyon
Add nickname to tag url
parent
619cc2b9cb
commit
a19e61c90d
|
@ -1635,7 +1635,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
return
|
||||
hashtagStr= \
|
||||
htmlHashtagSearch(self.server.recentPostsCache, \
|
||||
htmlHashtagSearch(self.server.domain, \
|
||||
self.server.recentPostsCache, \
|
||||
self.server.maxRecentPosts, \
|
||||
self.server.translate, \
|
||||
self.server.baseDir,hashtag,pageNumber, \
|
||||
|
@ -4648,7 +4649,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if searchStr.startswith('#'):
|
||||
# hashtag search
|
||||
hashtagStr= \
|
||||
htmlHashtagSearch(self.server.recentPostsCache, \
|
||||
htmlHashtagSearch(self.server.domain, \
|
||||
self.server.recentPostsCache, \
|
||||
self.server.maxRecentPosts, \
|
||||
self.server.translate, \
|
||||
self.server.baseDir,searchStr[1:],1, \
|
||||
|
|
8
inbox.py
8
inbox.py
|
@ -60,7 +60,7 @@ from webinterface import individualPostAsHtml
|
|||
from webinterface import getIconsDir
|
||||
from question import questionUpdateVotes
|
||||
|
||||
def storeHashTags(baseDir: str,postJsonObject: {}) -> None:
|
||||
def storeHashTags(baseDir: str,nickname: str,postJsonObject: {}) -> None:
|
||||
"""Extracts hashtags from an incoming post and updates the
|
||||
relevant tags files.
|
||||
"""
|
||||
|
@ -90,7 +90,7 @@ def storeHashTags(baseDir: str,postJsonObject: {}) -> None:
|
|||
if not os.path.isfile(tagsFilename):
|
||||
tagsFile=open(tagsFilename, "w+")
|
||||
if tagsFile:
|
||||
tagsFile.write(postUrl+'\n')
|
||||
tagsFile.write(nickname+' '+postUrl+'\n')
|
||||
tagsFile.close()
|
||||
else:
|
||||
if postUrl not in open(tagsFilename).read():
|
||||
|
@ -98,7 +98,7 @@ def storeHashTags(baseDir: str,postJsonObject: {}) -> None:
|
|||
with open(tagsFilename, 'r+') as tagsFile:
|
||||
content = tagsFile.read()
|
||||
tagsFile.seek(0, 0)
|
||||
tagsFile.write(postUrl+'\n'+content)
|
||||
tagsFile.write(nickname+' '+postUrl+'\n'+content)
|
||||
except Exception as e:
|
||||
print('WARN: Failed to write entry to tags file '+ \
|
||||
tagsFilename+' '+str(e))
|
||||
|
@ -1920,7 +1920,7 @@ def inboxAfterCapabilities(recentPostsCache: {},maxRecentPosts: int, \
|
|||
|
||||
inboxUpdateCalendar(baseDir,handle,postJsonObject)
|
||||
|
||||
storeHashTags(baseDir,postJsonObject)
|
||||
storeHashTags(baseDir,handle.split('@')[0],postJsonObject)
|
||||
|
||||
if not unitTest:
|
||||
if debug:
|
||||
|
|
|
@ -345,9 +345,11 @@ def htmlModerationInfo(translate: {},baseDir: str,httpPrefix: str) -> str:
|
|||
infoForm+=htmlFooter()
|
||||
return infoForm
|
||||
|
||||
def htmlHashtagSearch(recentPostsCache: {},maxRecentPosts: int, \
|
||||
def htmlHashtagSearch(domain: str, \
|
||||
recentPostsCache: {},maxRecentPosts: int, \
|
||||
translate: {}, \
|
||||
baseDir: str,hashtag: str,pageNumber: int,postsPerPage: int, \
|
||||
baseDir: str,hashtag: str,pageNumber: int, \
|
||||
postsPerPage: int, \
|
||||
session,wfRequest: {},personCache: {}, \
|
||||
httpPrefix: str,projectVersion: str) -> str:
|
||||
"""Show a page containing search results for a hashtag
|
||||
|
@ -381,18 +383,22 @@ def htmlHashtagSearch(recentPostsCache: {},maxRecentPosts: int, \
|
|||
hashtagSearchForm+='<center><h1>#'+hashtag+'</h1></center>'
|
||||
if startIndex!=len(lines)-1:
|
||||
# previous page link
|
||||
hashtagSearchForm+='<center><a href="/tags/'+hashtag+'?page='+str(pageNumber-1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pageup.png" title="'+translate['Page up']+'" alt="'+translate['Page up']+'"></a></center>'
|
||||
hashtagSearchForm+= \
|
||||
'<center><a href="/tags/'+hashtag+'?page='+ \
|
||||
str(pageNumber-1)+'"><img loading="lazy" class="pageicon" src="/'+ \
|
||||
iconsDir+'/pageup.png" title="'+translate['Page up']+ \
|
||||
'" alt="'+translate['Page up']+'"></a></center>'
|
||||
index=startIndex
|
||||
while index>=endIndex:
|
||||
postId=lines[index].strip('\n')
|
||||
nickname=getNicknameFromActor(postId)
|
||||
if not nickname:
|
||||
index-=1
|
||||
continue
|
||||
domain,port=getDomainFromActor(postId)
|
||||
if not domain:
|
||||
index-=1
|
||||
continue
|
||||
if ' ' not in postId:
|
||||
nickname=getNicknameFromActor(postId)
|
||||
if not nickname:
|
||||
index-=1
|
||||
continue
|
||||
else:
|
||||
nickname=postId.split(' ')[0]
|
||||
postId=postId.split(' ')[1]
|
||||
postFilename=locatePost(baseDir,nickname,domain,postId)
|
||||
if not postFilename:
|
||||
index-=1
|
||||
|
@ -414,7 +420,11 @@ def htmlHashtagSearch(recentPostsCache: {},maxRecentPosts: int, \
|
|||
|
||||
if endIndex>0:
|
||||
# next page link
|
||||
hashtagSearchForm+='<center><a href="/tags/'+hashtag+'?page='+str(pageNumber+1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pagedown.png" title="'+translate['Page down']+'" alt="'+translate['Page down']+'"></a></center>'
|
||||
hashtagSearchForm+= \
|
||||
'<center><a href="/tags/'+hashtag+'?page='+str(pageNumber+1)+ \
|
||||
'"><img loading="lazy" class="pageicon" src="/'+iconsDir+ \
|
||||
'/pagedown.png" title="'+translate['Page down']+ \
|
||||
'" alt="'+translate['Page down']+'"></a></center>'
|
||||
hashtagSearchForm+=htmlFooter()
|
||||
return hashtagSearchForm
|
||||
|
||||
|
|
Loading…
Reference in New Issue