diff --git a/daemon.py b/daemon.py index d9ff7226..4dfcbd51 100644 --- a/daemon.py +++ b/daemon.py @@ -165,6 +165,7 @@ from webapp_search import htmlSearchSharedItems from webapp_search import htmlSearchEmojiTextEntry from webapp_search import htmlSearch from webapp_hashtagswarm import getHashtagCategoriesFeed +from webapp_hashtagswarm import htmlSearchHashtagCategory from shares import getSharesFeedForPerson from shares import addShare from shares import removeShare @@ -10141,6 +10142,23 @@ class PubServer(BaseHTTPRequestHandler): 'search screen shown') 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, 'hashtag search done', 'search screen shown done') diff --git a/utils.py b/utils.py index 17255d2e..f4d5f4be 100644 --- a/utils.py +++ b/utils.py @@ -1083,7 +1083,7 @@ def validNickname(domain: str, nickname: str) -> bool: if nickname == domain: return False reservedNames = ('inbox', 'dm', 'outbox', 'following', - 'public', 'followers', + 'public', 'followers', 'category', 'channel', 'calendar', 'tlreplies', 'tlmedia', 'tlblogs', 'tlevents', 'tlblogs', 'tlfeatures', diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py index 9f11f7c7..4025cec2 100644 --- a/webapp_hashtagswarm.py +++ b/webapp_hashtagswarm.py @@ -7,10 +7,14 @@ __email__ = "bob@freedombone.net" __status__ = "Production" import os +from shutil import copyfile from datetime import datetime +# from utils import getNicknameFromActor from utils import getHashtagCategories from utils import getHashtagCategory from webapp_utils import getContentWarningButton +from webapp_utils import htmlHeaderWithExternalStyle +from webapp_utils import htmlFooter def getHashtagCategoriesFeed(baseDir: str, @@ -220,3 +224,37 @@ def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str: tagSwarmHtml = categorySwarmStr + tagSwarmStr.strip() + '\n' # tagSwarmHtml += getHashtagDomainHistogram(domainHistogram, translate) 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 += '

' + categoryStr + '

' + + hashtagsDict = getHashtagCategories(baseDir, categoryStr) + if hashtagsDict: + for categoryStr2, hashtagList in hashtagsDict.items(): + hashtagList.sort() + for tagName in hashtagList: + htmlStr += \ + '' + tagName + '\n' + + htmlStr += htmlFooter() + return htmlStr