From 220f5683b9b241749c393dfef7703e0cacfa0c8c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 10 Aug 2019 17:55:17 +0100 Subject: [PATCH] Fix tags --- content.py | 15 +++++++-------- posts.py | 12 ++++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/content.py b/content.py index 1ef2729ad..5b94509d1 100644 --- a/content.py +++ b/content.py @@ -147,20 +147,19 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \ if ':' in domain: domain=domain.split(':')[0] followingFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/following.txt' - if not os.path.isfile(followingFilename): - content=content.replace('\n','

') - content='

'+content+'

' - return content.replace('

','') # read the following list so that we can detect just @nick # in addition to @nick@domain - with open(followingFilename, "r") as f: - following = f.readlines() + following=None + if os.path.isfile(followingFilename): + with open(followingFilename, "r") as f: + following = f.readlines() # extract mentions and tags from words for wordStr in words: - if addMention(wordStr,httpPrefix,following,replaceMentions,recipients): - continue + if following: + if addMention(wordStr,httpPrefix,following,replaceMentions,recipients): + continue if addHashTags(wordStr,httpPrefix,originalDomain,replaceHashTags,hashtags): continue if len(wordStr)>2 and wordStr.startswith(':') and wordStr.endswith(':') and not emojiDict: diff --git a/posts.py b/posts.py index 764ff254a..292347382 100644 --- a/posts.py +++ b/posts.py @@ -432,14 +432,14 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ toRecipients=[toUrl] + mentionedRecipients # create a list of hashtags - if hashtagsDict: + if hashtagsDict: + isPublic=False + for recipient in toRecipients: + if recipient.endswith('#Public'): + isPublic=True + break for tagName,tag in hashtagsDict.items(): tags.append(tag) - isPublic=False - for recipient in toRecipients: - if recipient.endswith('#Public'): - isPublic=True - break if isPublic: updateHashtagsIndex(baseDir,tag,newPostId)