mirror of https://gitlab.com/bashrc2/epicyon
Return tags as a list
parent
099040db75
commit
e9df539727
20
content.py
20
content.py
|
@ -97,7 +97,7 @@ def addEmoji(baseDir: str,wordStr: str,httpPrefix: str,domain: str,replaceEmoji:
|
||||||
"<img src=\""+emojiUrl+"\" alt=\""+emoji+"\" align=\"middle\" class=\"emoji\"/>"
|
"<img src=\""+emojiUrl+"\" alt=\""+emoji+"\" align=\"middle\" class=\"emoji\"/>"
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},recipients: [],tags: {}) -> bool:
|
def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},recipients: [],tagsList: []) -> bool:
|
||||||
"""Detects mentions and adds them to the replacements dict and recipients list
|
"""Detects mentions and adds them to the replacements dict and recipients list
|
||||||
"""
|
"""
|
||||||
if not wordStr.startswith('@'):
|
if not wordStr.startswith('@'):
|
||||||
|
@ -117,11 +117,11 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r
|
||||||
recipientActor=httpPrefix+"://"+replaceDomain+"/users/"+possibleNickname
|
recipientActor=httpPrefix+"://"+replaceDomain+"/users/"+possibleNickname
|
||||||
if recipientActor not in recipients:
|
if recipientActor not in recipients:
|
||||||
recipients.append(recipientActor)
|
recipients.append(recipientActor)
|
||||||
tags[wordStr]= {
|
tagsList.append({
|
||||||
'href': recipientActor,
|
'href': recipientActor,
|
||||||
'name': wordStr,
|
'name': wordStr,
|
||||||
'type': 'Mention'
|
'type': 'Mention'
|
||||||
}
|
})
|
||||||
replaceMentions[wordStr]="<span class=\"h-card\"><a href=\""+httpPrefix+"://"+replaceDomain+"/@"+possibleNickname+"\" class=\"u-url mention\">@<span>"+possibleNickname+"</span></a></span>"
|
replaceMentions[wordStr]="<span class=\"h-card\"><a href=\""+httpPrefix+"://"+replaceDomain+"/@"+possibleNickname+"\" class=\"u-url mention\">@<span>"+possibleNickname+"</span></a></span>"
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -134,11 +134,11 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r
|
||||||
recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname
|
recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname
|
||||||
if recipientActor not in recipients:
|
if recipientActor not in recipients:
|
||||||
recipients.append(recipientActor)
|
recipients.append(recipientActor)
|
||||||
tags[wordStr]= {
|
tagsList.append({
|
||||||
'href': recipientActor,
|
'href': recipientActor,
|
||||||
'name': wordStr,
|
'name': wordStr,
|
||||||
'type': 'Mention'
|
'type': 'Mention'
|
||||||
}
|
})
|
||||||
replaceMentions[wordStr]="<span class=\"h-card\"><a href=\""+httpPrefix+"://"+possibleDomain+"/@"+possibleNickname+"\" class=\"u-url mention\">@<span>"+possibleNickname+"</span></a></span>"
|
replaceMentions[wordStr]="<span class=\"h-card\"><a href=\""+httpPrefix+"://"+possibleDomain+"/@"+possibleNickname+"\" class=\"u-url mention\">@<span>"+possibleNickname+"</span></a></span>"
|
||||||
return True
|
return True
|
||||||
# @nick@domain
|
# @nick@domain
|
||||||
|
@ -148,11 +148,11 @@ def addMention(wordStr: str,httpPrefix: str,following: str,replaceMentions: {},r
|
||||||
recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname
|
recipientActor=httpPrefix+"://"+possibleDomain+"/users/"+possibleNickname
|
||||||
if recipientActor not in recipients:
|
if recipientActor not in recipients:
|
||||||
recipients.append(recipientActor)
|
recipients.append(recipientActor)
|
||||||
tags[wordStr]= {
|
tagsList.append({
|
||||||
'href': recipientActor,
|
'href': recipientActor,
|
||||||
'name': wordStr,
|
'name': wordStr,
|
||||||
'type': 'Mention'
|
'type': 'Mention'
|
||||||
}
|
})
|
||||||
replaceMentions[wordStr]="<span class=\"h-card\"><a href=\""+httpPrefix+"://"+possibleDomain+"/@"+possibleNickname+"\" class=\"u-url mention\">@<span>"+possibleNickname+"</span></a></span>"
|
replaceMentions[wordStr]="<span class=\"h-card\"><a href=\""+httpPrefix+"://"+possibleDomain+"/@"+possibleNickname+"\" class=\"u-url mention\">@<span>"+possibleNickname+"</span></a></span>"
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -199,8 +199,12 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \
|
||||||
|
|
||||||
# extract mentions and tags from words
|
# extract mentions and tags from words
|
||||||
for wordStr in words:
|
for wordStr in words:
|
||||||
if addMention(wordStr,httpPrefix,following,replaceMentions,recipients,hashtags):
|
tagsList=[]
|
||||||
|
if addMention(wordStr,httpPrefix,following,replaceMentions,recipients,tagsList):
|
||||||
|
for tag in tagsList:
|
||||||
|
hashtags[tag['name']]=tag
|
||||||
continue
|
continue
|
||||||
|
tagsList=[]
|
||||||
if addHashTags(wordStr,httpPrefix,originalDomain,replaceHashTags,hashtags):
|
if addHashTags(wordStr,httpPrefix,originalDomain,replaceHashTags,hashtags):
|
||||||
continue
|
continue
|
||||||
if len(wordStr)>2 and wordStr.startswith(':') and wordStr.endswith(':') and not emojiDict:
|
if len(wordStr)>2 and wordStr.startswith(':') and wordStr.endswith(':') and not emojiDict:
|
||||||
|
|
Loading…
Reference in New Issue