From 099040db7594391eb2d93716322a03f4d1256f33 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 19 Aug 2019 12:49:34 +0100 Subject: [PATCH] Add mention tags --- content.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/content.py b/content.py index 1ad40327e..7b9d02063 100644 --- a/content.py +++ b/content.py @@ -97,7 +97,7 @@ def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji: "\""+emoji+"\"" return True -def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},recipients: []) -> bool: +def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},recipients: [],tags: {}) -> bool: """Detects mentions and adds them to the replacements dict and recipients list """ if not wordStr.startswith('@'): @@ -117,6 +117,11 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r recipientActor=httpPrefix+"://"+replaceDomain+"/users/"+possibleNickname if recipientActor not in recipients: recipients.append(recipientActor) + tags[wordStr]= { + 'href': recipientActor, + 'name': wordStr, + 'type': 'Mention' + } replaceMentions[wordStr]="@"+possibleNickname+"" return True return False @@ -129,6 +134,11 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname if recipientActor not in recipients: recipients.append(recipientActor) + tags[wordStr]= { + 'href': recipientActor, + 'name': wordStr, + 'type': 'Mention' + } replaceMentions[wordStr]="@"+possibleNickname+"" return True # @nick@domain @@ -138,6 +148,11 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname if recipientActor not in recipients: recipients.append(recipientActor) + tags[wordStr]= { + 'href': recipientActor, + 'name': wordStr, + 'type': 'Mention' + } replaceMentions[wordStr]="@"+possibleNickname+"" return True return False @@ -184,7 +199,7 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \ # extract mentions and tags from words for wordStr in words: - if addMention(wordStr,httpPrefix,following,replaceMentions,recipients): + if addMention(wordStr,httpPrefix,following,replaceMentions,recipients,hashtags): continue if addHashTags(wordStr,httpPrefix,originalDomain,replaceHashTags,hashtags): continue