forked from indymedia/epicyon
Adding and removing tags
parent
086826b9a1
commit
10d4010cd8
|
@ -269,11 +269,23 @@ def newswireHashtagProcessing(session, baseDir: str, postJsonObject: {},
|
||||||
if validHashTag(htId):
|
if validHashTag(htId):
|
||||||
hashtagUrl = \
|
hashtagUrl = \
|
||||||
httpPrefix + "://" + domainFull + "/tags/" + htId
|
httpPrefix + "://" + domainFull + "/tags/" + htId
|
||||||
postJsonObject['object']['tag'][htId] = {
|
newTag = {
|
||||||
'href': hashtagUrl,
|
'href': hashtagUrl,
|
||||||
'name': addHashtag,
|
'name': addHashtag,
|
||||||
'type': 'Hashtag'
|
'type': 'Hashtag'
|
||||||
}
|
}
|
||||||
|
# does the tag already exist?
|
||||||
|
addTagObject = None
|
||||||
|
for t in postJsonObject['object']['tag']:
|
||||||
|
if t.get('type') and t.get('name'):
|
||||||
|
if t['type'] == 'Hashtag' and \
|
||||||
|
t['name'] == addHashtag:
|
||||||
|
addTagObject = t
|
||||||
|
break
|
||||||
|
# append the tag if it wasn't found
|
||||||
|
if not addTagObject:
|
||||||
|
postJsonObject['object']['tag'].append(newTag)
|
||||||
|
# add corresponding html to the post content
|
||||||
hashtagHtml = \
|
hashtagHtml = \
|
||||||
" <a href=\"" + hashtagUrl + \
|
" <a href=\"" + hashtagUrl + \
|
||||||
"\" class=\"mention hashtag\" " + \
|
"\" class=\"mention hashtag\" " + \
|
||||||
|
@ -296,9 +308,10 @@ def newswireHashtagProcessing(session, baseDir: str, postJsonObject: {},
|
||||||
if rmHashtag.startswith('#'):
|
if rmHashtag.startswith('#'):
|
||||||
if rmHashtag in hashtags:
|
if rmHashtag in hashtags:
|
||||||
hashtags.remove(rmHashtag)
|
hashtags.remove(rmHashtag)
|
||||||
htId = addHashtag.replace('#', '')
|
htId = rmHashtag.replace('#', '')
|
||||||
hashtagUrl = \
|
hashtagUrl = \
|
||||||
httpPrefix + "://" + domainFull + "/tags/" + htId
|
httpPrefix + "://" + domainFull + "/tags/" + htId
|
||||||
|
# remove tag html from the post content
|
||||||
hashtagHtml = \
|
hashtagHtml = \
|
||||||
"<a href=\"" + hashtagUrl + \
|
"<a href=\"" + hashtagUrl + \
|
||||||
"\" class=\"mention hashtag\" " + \
|
"\" class=\"mention hashtag\" " + \
|
||||||
|
@ -309,8 +322,16 @@ def newswireHashtagProcessing(session, baseDir: str, postJsonObject: {},
|
||||||
content = \
|
content = \
|
||||||
content.replace(hashtagHtml, '').replace(' ', ' ')
|
content.replace(hashtagHtml, '').replace(' ', ' ')
|
||||||
postJsonObject['object']['content'] = content
|
postJsonObject['object']['content'] = content
|
||||||
del postJsonObject['object']['tag'][htId]
|
rmTagObject = None
|
||||||
# actionOccurred = True
|
for t in postJsonObject['object']['tag']:
|
||||||
|
if t.get('type') and t.get('name'):
|
||||||
|
if t['type'] == 'Hashtag' and \
|
||||||
|
t['name'] == rmHashtag:
|
||||||
|
rmTagObject = t
|
||||||
|
break
|
||||||
|
if rmTagObject:
|
||||||
|
postJsonObject['object']['tag'].remove(rmTagObject)
|
||||||
|
# actionOccurred = True
|
||||||
|
|
||||||
# Block this item
|
# Block this item
|
||||||
if actionStr.startswith('block') or actionStr.startswith('drop'):
|
if actionStr.startswith('block') or actionStr.startswith('drop'):
|
||||||
|
|
Loading…
Reference in New Issue