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