diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py index c1a24e4f3..4867e32a5 100644 --- a/webapp_hashtagswarm.py +++ b/webapp_hashtagswarm.py @@ -9,9 +9,12 @@ __status__ = "Production" import os from shutil import copyfile from datetime import datetime -# from utils import getNicknameFromActor +from utils import getConfigParam +from utils import getNicknameFromActor from utils import getHashtagCategories from utils import getHashtagCategory +from webapp_utils import getSearchBannerFile +from webapp_utils import getImageFile from webapp_utils import getContentWarningButton from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlFooter @@ -232,7 +235,7 @@ def htmlSearchHashtagCategory(cssCache: {}, translate: {}, """ actor = path.split('/category/')[0] categoryStr = path.split('/category/')[1].strip() - # searchNickname = getNicknameFromActor(actor) + searchNickname = getNicknameFromActor(actor) if os.path.isfile(baseDir + '/img/search-background.png'): if not os.path.isfile(baseDir + '/accounts/search-background.png'): @@ -245,10 +248,36 @@ def htmlSearchHashtagCategory(cssCache: {}, translate: {}, htmlStr = htmlHeaderWithExternalStyle(cssFilename) + # show a banner above the search box + searchBannerFile, searchBannerFilename = \ + getSearchBannerFile(baseDir, searchNickname, domain) + if not os.path.isfile(searchBannerFilename): + # get the default search banner for the theme + theme = getConfigParam(baseDir, 'theme').lower() + if theme == 'default': + theme = '' + else: + theme = '_' + theme + themeSearchImageFile, themeSearchBannerFilename = \ + getImageFile(baseDir, 'search_banner', baseDir + '/img', + searchNickname, domain) + if os.path.isfile(themeSearchBannerFilename): + searchBannerFilename = \ + baseDir + '/accounts/' + \ + searchNickname + '@' + domain + '/' + themeSearchImageFile + copyfile(themeSearchBannerFilename, + searchBannerFilename) + searchBannerFile = themeSearchImageFile + + if os.path.isfile(searchBannerFilename): + htmlStr += '\n' + htmlStr += '\n' + htmlStr += '
' htmlStr += '



' htmlStr += '

' - htmlStr += translate['Category'] + ': ' + categoryStr + '

' + htmlStr += translate['Category'] + ': ' + categoryStr + '' hashtagsDict = getHashtagCategories(baseDir, categoryStr) if hashtagsDict: