From 15cf3f9ee00a2c2592ebb3b808cf15e9eacd314b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 25 Oct 2020 12:00:55 +0000 Subject: [PATCH] Add all hashtags to posts imported from feeds --- newsdaemon.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/newsdaemon.py b/newsdaemon.py index 2d69be9f..eb5b358e 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -610,6 +610,9 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, # save the post and update the index if savePost: + # ensure that all hashtags are stored in the json + # and appended to the content + blog['object']['tag'] = [] for tagName in hashtags: htId = tagName.replace('#', '') hashtagUrl = \ @@ -620,13 +623,24 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, 'type': 'Hashtag' } blog['object']['tag'].append(newTag) + hashtagHtml = \ + "#" + \ + htId + "" if tagName in blog['object']['content']: - hashtagHtml = \ - "#" + \ - htId + "" blog['object']['content'].replace(tagName, hashtagHtml) + else: + content = blog['object']['content'] + if hashtagHtml not in content: + if content.endswith('

'): + content = \ + content[:len(content) - len('

')] + \ + hashtagHtml + '

' + else: + content += hashtagHtml + blog['object']['content'] = content + storeHashTags(baseDir, 'news', blog) newswire[originalDateStr][6] = hashtags