From 981421ba8212a5d0539777e1a8e743d536c9c526 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 12 Dec 2019 20:39:49 +0000 Subject: [PATCH] Show today's hashtags on search screen --- webinterface.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/webinterface.py b/webinterface.py index bac4dc2a..d82fb238 100644 --- a/webinterface.py +++ b/webinterface.py @@ -3744,6 +3744,42 @@ def htmlCalendar(translate: {}, \ calendarStr+=htmlFooter() return calendarStr +def htmlHashTagCloud(baseDir: str,path: str) -> str: + """Returns a tag cloud of today's hashtags + """ + daysSinceEpoch=str((datetime.datetime.utcnow() - datetime.datetime(1970,1,1)).days)+' ' + nickname=getNicknameFromActor(path) + tagCloud=[] + for subdir, dirs, files in os.walk(baseDir+'/tags'): + for f in files: + tagsFilename=os.path.join(baseDir+'/tags',f) + if not os.path.isfile(tagsFilename): + continue + if daysSinceEpoch not in open(tagsFilename).read(): + continue + with open(tagsFilename, 'r') as tagsFile: + lines=tagsFile.readlines() + for l in lines: + if ' ' not in l: + continue + postDaysSinceEpochStr=l.split(' ')[0] + if not postDaysSinceEpochStr.isdigit(): + continue + postDaysSinceEpoch=int(postDaysSinceEpochStr) + if postDaysSinceEpoch'+tagName+' ' + tagCloudHtml+=tagCloudStr.strip()+'\n\n' + return tagCloudHtml + def htmlSearch(translate: {}, \ baseDir: str,path: str) -> str: """Search called from the timeline icon @@ -3772,6 +3808,7 @@ def htmlSearch(translate: {}, \ followStr+=' ' followStr+=' ' followStr+=' ' + followStr+=htmlHashTagCloud(baseDir,path) followStr+=' ' followStr+='' followStr+=htmlFooter()