forked from indymedia/epicyon
Announce titles
parent
33150046ba
commit
57d957dbef
|
@ -1020,6 +1020,7 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
""" Shows a single post as html
|
""" Shows a single post as html
|
||||||
"""
|
"""
|
||||||
titleStr=''
|
titleStr=''
|
||||||
|
isAnnounced=False
|
||||||
if postJsonObject['type']=='Announce':
|
if postJsonObject['type']=='Announce':
|
||||||
if postJsonObject.get('object'):
|
if postJsonObject.get('object'):
|
||||||
if isinstance(postJsonObject['object'], str):
|
if isinstance(postJsonObject['object'], str):
|
||||||
|
@ -1032,30 +1033,31 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
print('Reading cached Announce content for '+postJsonObject['object'])
|
print('Reading cached Announce content for '+postJsonObject['object'])
|
||||||
with open(announceFilename, 'r') as fp:
|
with open(announceFilename, 'r') as fp:
|
||||||
postJsonObject=commentjson.load(fp)
|
postJsonObject=commentjson.load(fp)
|
||||||
|
isAnnounced=True
|
||||||
else:
|
else:
|
||||||
print('Downloading Announce content for '+postJsonObject['object'])
|
print('Downloading Announce content for '+postJsonObject['object'])
|
||||||
asHeader = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'}
|
asHeader = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'}
|
||||||
announcedJson = getJson(session,postJsonObject['object'],asHeader,None,projectVersion,httpPrefix,domain)
|
announcedJson = getJson(session,postJsonObject['object'],asHeader,None,projectVersion,httpPrefix,domain)
|
||||||
if announcedJson:
|
if announcedJson:
|
||||||
pprint(announcedJson)
|
|
||||||
if not announcedJson.get('actor'):
|
if not announcedJson.get('actor'):
|
||||||
return ''
|
return ''
|
||||||
if not announcedJson.get('type'):
|
if not announcedJson.get('type'):
|
||||||
return ''
|
return ''
|
||||||
if announcedJson['type']=='Note':
|
if announcedJson['type']!='Note':
|
||||||
# wrap in create to be consistent with other posts
|
return ''
|
||||||
announcedJson= \
|
# wrap in create to be consistent with other posts
|
||||||
outboxMessageCreateWrap(httpPrefix, \
|
actorNickname=getNicknameFromActor(announcedJson['actor'])
|
||||||
nickname,domain,port, \
|
actorDomain,actorPort=getDomainFromActor(announcedJson['actor'])
|
||||||
announcedJson)
|
announcedJson= \
|
||||||
|
outboxMessageCreateWrap(httpPrefix, \
|
||||||
|
actorNickname,actorDomain,actorPort, \
|
||||||
|
announcedJson)
|
||||||
if announcedJson['type']!='Create':
|
if announcedJson['type']!='Create':
|
||||||
return ''
|
return ''
|
||||||
actorNickname=getNicknameFromActor(postJsonObject['actor'])
|
|
||||||
actorDomain,actorPort=getDomainFromActor(postJsonObject['actor'])
|
|
||||||
titleStr+='@'+actorNickname+'@'+actorDomain+' announced:<br>'
|
|
||||||
postJsonObject=announcedJson
|
postJsonObject=announcedJson
|
||||||
with open(announceFilename, 'w') as fp:
|
with open(announceFilename, 'w') as fp:
|
||||||
commentjson.dump(postJsonObject, fp, indent=4, sort_keys=False)
|
commentjson.dump(postJsonObject, fp, indent=4, sort_keys=False)
|
||||||
|
isAnnounced=True
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
else:
|
else:
|
||||||
|
@ -1074,22 +1076,35 @@ def individualPostAsHtml(baseDir: str, \
|
||||||
messageId=''
|
messageId=''
|
||||||
if postJsonObject.get('id'):
|
if postJsonObject.get('id'):
|
||||||
messageId=postJsonObject['id'].replace('/activity','')
|
messageId=postJsonObject['id'].replace('/activity','')
|
||||||
|
|
||||||
titleStr+='<a href="'+messageId+'">@'+actorNickname+'@'+actorDomain+'</a>'
|
titleStr+='<a href="'+messageId+'">@'+actorNickname+'@'+actorDomain+'</a>'
|
||||||
if postJsonObject['object'].get('inReplyTo'):
|
if isAnnounced and postJsonObject['object'].get('actor'):
|
||||||
|
announceNickname=getNicknameFromActor(postJsonObject['object']['actor'])
|
||||||
|
announceDomain,announcePort=getDomainFromActor(postJsonObject['object']['actor'])
|
||||||
|
if postJsonObject['object'].get('atomUri'):
|
||||||
|
titleStr+=' <i class="replyingto">announced</i> <a href="'+postJsonObject['object']['id']+'">@'+announceNickname+'@'+announceDomain+'</a>'
|
||||||
|
else:
|
||||||
|
if postJsonObject['object'].get('id'):
|
||||||
|
titleStr+=' <i class="replyingto">announced</i> <a href="'+postJsonObject['object']['id']+'">@'+announceNickname+'@'+announceDomain+'</a>'
|
||||||
|
else:
|
||||||
|
titleStr+=' <i class="replyingto">announced</i>'
|
||||||
|
|
||||||
|
if not isAnnounced and postJsonObject['object'].get('inReplyTo'):
|
||||||
containerClassIcons='containericons darker'
|
containerClassIcons='containericons darker'
|
||||||
containerClass='container darker'
|
containerClass='container darker'
|
||||||
avatarPosition=' class="right"'
|
avatarPosition=' class="right"'
|
||||||
#timeClass='time-left'
|
#timeClass='time-left'
|
||||||
if '/statuses/' in postJsonObject['object']['inReplyTo']:
|
|
||||||
replyNickname=getNicknameFromActor(postJsonObject['object']['inReplyTo'])
|
|
||||||
replyDomain,replyPort=getDomainFromActor(postJsonObject['object']['inReplyTo'])
|
|
||||||
if replyNickname and replyDomain:
|
|
||||||
titleStr+=' <i class="replyingto">replying to</i> <a href="'+postJsonObject['object']['inReplyTo']+'">@'+replyNickname+'@'+replyDomain+'</a>'
|
|
||||||
else:
|
else:
|
||||||
postDomain=postJsonObject['object']['inReplyTo'].replace('https://','').replace('http://','').replace('dat://','')
|
if '/statuses/' in postJsonObject['object']['inReplyTo']:
|
||||||
if '/' in postDomain:
|
replyNickname=getNicknameFromActor(postJsonObject['object']['inReplyTo'])
|
||||||
postDomain=postDomain.split('/',1)[0]
|
replyDomain,replyPort=getDomainFromActor(postJsonObject['object']['inReplyTo'])
|
||||||
titleStr+=' <i class="replyingto">replying to</i> <a href="'+postJsonObject['object']['inReplyTo']+'">'+postDomain+'</a>'
|
if replyNickname and replyDomain:
|
||||||
|
titleStr+=' <i class="replyingto">replying to</i> <a href="'+postJsonObject['object']['inReplyTo']+'">@'+replyNickname+'@'+replyDomain+'</a>'
|
||||||
|
else:
|
||||||
|
postDomain=postJsonObject['object']['inReplyTo'].replace('https://','').replace('http://','').replace('dat://','')
|
||||||
|
if '/' in postDomain:
|
||||||
|
postDomain=postDomain.split('/',1)[0]
|
||||||
|
titleStr+=' <i class="replyingto">replying to</i> <a href="'+postJsonObject['object']['inReplyTo']+'">'+postDomain+'</a>'
|
||||||
attachmentStr=''
|
attachmentStr=''
|
||||||
if postJsonObject['object']['attachment']:
|
if postJsonObject['object']['attachment']:
|
||||||
if isinstance(postJsonObject['object']['attachment'], list):
|
if isinstance(postJsonObject['object']['attachment'], list):
|
||||||
|
|
Loading…
Reference in New Issue