mirror of https://gitlab.com/bashrc2/epicyon
Show hashtag gategory from search screen
parent
dd796e84ae
commit
4a8ceda973
18
daemon.py
18
daemon.py
|
@ -165,6 +165,7 @@ from webapp_search import htmlSearchSharedItems
|
||||||
from webapp_search import htmlSearchEmojiTextEntry
|
from webapp_search import htmlSearchEmojiTextEntry
|
||||||
from webapp_search import htmlSearch
|
from webapp_search import htmlSearch
|
||||||
from webapp_hashtagswarm import getHashtagCategoriesFeed
|
from webapp_hashtagswarm import getHashtagCategoriesFeed
|
||||||
|
from webapp_hashtagswarm import htmlSearchHashtagCategory
|
||||||
from shares import getSharesFeedForPerson
|
from shares import getSharesFeedForPerson
|
||||||
from shares import addShare
|
from shares import addShare
|
||||||
from shares import removeShare
|
from shares import removeShare
|
||||||
|
@ -10141,6 +10142,23 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'search screen shown')
|
'search screen shown')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# show a hashtag category from the search screen
|
||||||
|
if htmlGET and '/category/' in self.path:
|
||||||
|
msg = htmlSearchHashtagCategory(self.server.cssCache,
|
||||||
|
self.server.translate,
|
||||||
|
self.server.baseDir, self.path,
|
||||||
|
self.server.domain,
|
||||||
|
self.server.defaultTimeline)
|
||||||
|
if msg:
|
||||||
|
msg = msg.encode('utf-8')
|
||||||
|
self._set_headers('text/html', len(msg), cookie, callingDomain)
|
||||||
|
self._write(msg)
|
||||||
|
self.server.GETbusy = False
|
||||||
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
|
'hashtag category done',
|
||||||
|
'hashtag category screen shown')
|
||||||
|
return
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
'hashtag search done',
|
'hashtag search done',
|
||||||
'search screen shown done')
|
'search screen shown done')
|
||||||
|
|
2
utils.py
2
utils.py
|
@ -1083,7 +1083,7 @@ def validNickname(domain: str, nickname: str) -> bool:
|
||||||
if nickname == domain:
|
if nickname == domain:
|
||||||
return False
|
return False
|
||||||
reservedNames = ('inbox', 'dm', 'outbox', 'following',
|
reservedNames = ('inbox', 'dm', 'outbox', 'following',
|
||||||
'public', 'followers',
|
'public', 'followers', 'category',
|
||||||
'channel', 'calendar',
|
'channel', 'calendar',
|
||||||
'tlreplies', 'tlmedia', 'tlblogs',
|
'tlreplies', 'tlmedia', 'tlblogs',
|
||||||
'tlevents', 'tlblogs', 'tlfeatures',
|
'tlevents', 'tlblogs', 'tlfeatures',
|
||||||
|
|
|
@ -7,10 +7,14 @@ __email__ = "bob@freedombone.net"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from shutil import copyfile
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
# from utils import getNicknameFromActor
|
||||||
from utils import getHashtagCategories
|
from utils import getHashtagCategories
|
||||||
from utils import getHashtagCategory
|
from utils import getHashtagCategory
|
||||||
from webapp_utils import getContentWarningButton
|
from webapp_utils import getContentWarningButton
|
||||||
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
|
from webapp_utils import htmlFooter
|
||||||
|
|
||||||
|
|
||||||
def getHashtagCategoriesFeed(baseDir: str,
|
def getHashtagCategoriesFeed(baseDir: str,
|
||||||
|
@ -220,3 +224,37 @@ def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str:
|
||||||
tagSwarmHtml = categorySwarmStr + tagSwarmStr.strip() + '\n'
|
tagSwarmHtml = categorySwarmStr + tagSwarmStr.strip() + '\n'
|
||||||
# tagSwarmHtml += getHashtagDomainHistogram(domainHistogram, translate)
|
# tagSwarmHtml += getHashtagDomainHistogram(domainHistogram, translate)
|
||||||
return tagSwarmHtml
|
return tagSwarmHtml
|
||||||
|
|
||||||
|
|
||||||
|
def htmlSearchHashtagCategory(cssCache: {}, translate: {},
|
||||||
|
baseDir: str, path: str, domain: str) -> str:
|
||||||
|
"""Show hashtags after selecting a category on the main search screen
|
||||||
|
"""
|
||||||
|
actor = path.split('/category/')[0]
|
||||||
|
categoryStr = path.split('/category/')[1].strip()
|
||||||
|
# searchNickname = getNicknameFromActor(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')
|
||||||
|
|
||||||
|
cssFilename = baseDir + '/epicyon-search.css'
|
||||||
|
if os.path.isfile(baseDir + '/search.css'):
|
||||||
|
cssFilename = baseDir + '/search.css'
|
||||||
|
|
||||||
|
htmlStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
|
htmlStr += '<h1><a href="/search">' + categoryStr + '</a></h1>'
|
||||||
|
|
||||||
|
hashtagsDict = getHashtagCategories(baseDir, categoryStr)
|
||||||
|
if hashtagsDict:
|
||||||
|
for categoryStr2, hashtagList in hashtagsDict.items():
|
||||||
|
hashtagList.sort()
|
||||||
|
for tagName in hashtagList:
|
||||||
|
htmlStr += \
|
||||||
|
'<a href="' + actor + '/tags/' + tagName + \
|
||||||
|
'" class="hashtagswarm">' + tagName + '</a>\n'
|
||||||
|
|
||||||
|
htmlStr += htmlFooter()
|
||||||
|
return htmlStr
|
||||||
|
|
Loading…
Reference in New Issue