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: with open(filePath, 'r') as postFile:
postStr = postFile.read() 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 addPostStringToTimeline(postStr, boxname, postsInBox, boxActor)
return False return False
@ -3109,12 +3116,24 @@ def createBoxIndexed(recentPostsCache: {},
return boxHeader return boxHeader
for postStr in postsInBox: 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 p = None
try: try:
p = json.loads(postStr) p = json.loads(postStr)
except BaseException: except BaseException:
continue 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 # Don't show likes, replies or shares (announces) to
# unauthorized viewers # unauthorized viewers
if not authorized: if not authorized:

View File

@ -1026,6 +1026,10 @@ def individualPostAsHtml(allowDownloads: bool,
publishedStr = datetimeObject.strftime("%a %b %d, %H:%M") publishedStr = datetimeObject.strftime("%a %b %d, %H:%M")
else: else:
publishedStr = datetimeObject.strftime("%a %b %d") 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 # benchmark 15
if not allowDownloads: if not allowDownloads: