From 89ad584eb8db09793d83de9fd42467156ac65e3d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 24 Jan 2021 10:09:36 +0000 Subject: [PATCH] Maximum hashtag length on search screen Very long tags distrupt the UI layout, especially on mobile --- webapp_hashtagswarm.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py index 68c7ec220..96a20a6bd 100644 --- a/webapp_hashtagswarm.py +++ b/webapp_hashtagswarm.py @@ -114,6 +114,7 @@ def _getHashtagDomainHistogram(domainHistogram: {}, translate: {}) -> str: def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str: """Returns a tag swarm of today's hashtags """ + maxTagLength = 42 currTime = datetime.utcnow() daysSinceEpoch = (currTime - datetime(1970, 1, 1)).days daysSinceEpochStr = str(daysSinceEpoch) + ' ' @@ -150,6 +151,9 @@ def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str: continue hashTagName = f.split('.')[0] + if len(hashTagName) > maxTagLength: + # NoIncrediblyLongAndBoringHashtagsShownHere + continue if '#' + hashTagName + '\n' in blockedStr: continue with open(tagsFilename, 'r') as fp: @@ -193,8 +197,9 @@ def htmlHashTagSwarm(baseDir: str, actor: str, translate: {}) -> str: if os.path.isfile(categoryFilename): categoryStr = \ getHashtagCategory(baseDir, hashTagName) - if categoryStr not in categorySwarm: - categorySwarm.append(categoryStr) + if len(categoryStr) < maxTagLength: + if categoryStr not in categorySwarm: + categorySwarm.append(categoryStr) break break