Indicate whether replies exist

main
Bob Mottram 2020-11-28 19:39:37 +00:00
parent 22bf539b4a
commit 4dc41efe21
2 changed files with 23 additions and 0 deletions

View File

@ -2912,6 +2912,13 @@ def addPostToTimeline(filePath: str, boxname: str,
"""
with open(filePath, 'r') as postFile:
postStr = postFile.read()
if filePath.endswith('.json'):
repliesFilename = filePath.replace('.json', '.replies')
if os.path.isfile(repliesFilename):
# append a replies identifier, which will later be removed
postStr += '<hasReplies>'
return addPostStringToTimeline(postStr, boxname, postsInBox, boxActor)
return False
@ -3109,12 +3116,24 @@ def createBoxIndexed(recentPostsCache: {},
return boxHeader
for postStr in postsInBox:
# Check if the post has replies
hasReplies = False
if postStr.endswith('<hasReplies>'):
hasReplies = True
# remove the replies identifier
postStr = postStr.replace('<hasReplies>', '')
p = None
try:
p = json.loads(postStr)
except BaseException:
continue
# Does this post have replies?
# This will be used to indicate that replies exist within the html
# created by individualPostAsHtml
p['hasReplies'] = hasReplies
# Don't show likes, replies or shares (announces) to
# unauthorized viewers
if not authorized:

View File

@ -1026,6 +1026,10 @@ def individualPostAsHtml(allowDownloads: bool,
publishedStr = datetimeObject.strftime("%a %b %d, %H:%M")
else:
publishedStr = datetimeObject.strftime("%a %b %d")
# if the post has replies then append a symbol to indicate this
if postJsonObject.get('hasReplies'):
if postJsonObject['hasReplies'] is True:
publishedStr += ''
# benchmark 15
if not allowDownloads: