From 3c6a35b280b03271618b55810bf02a20d854bb81 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 6 Nov 2020 11:53:59 +0000 Subject: [PATCH] Show citations on new blog post --- posts.py | 2 +- webinterface.py | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/posts.py b/posts.py index 56a89020d..ec59bc6db 100644 --- a/posts.py +++ b/posts.py @@ -1243,7 +1243,7 @@ def createBlogPost(baseDir: str, sections = line.strip().split(citationsSeparator) if len(sections) != 3: continue - dateStr = sections[0] + # dateStr = sections[0] title = sections[1] link = sections[2] tagJson = { diff --git a/webinterface.py b/webinterface.py index 19dbe51d8..03a84788f 100644 --- a/webinterface.py +++ b/webinterface.py @@ -2748,6 +2748,30 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, extraFields += '\n' extraFields += '\n' + citationsStr = '' + if endpoint == 'newblog': + citationsFilename = \ + baseDir + '/accounts/' + \ + nickname + '@' + domain + '/.citations.txt' + if os.path.isfile(citationsFilename): + citationsStr = '
\n' + citationsStr += '

\n' + citationsSeparator = '#####' + with open(citationsFilename, "r") as f: + citations = f.readlines() + for line in citations: + if citationsSeparator not in line: + continue + sections = line.strip().split(citationsSeparator) + if len(sections) != 3: + continue + title = sections[1] + link = sections[2] + citationsStr += \ + '' + title + '
' + citationsStr += '
\n' + dateAndLocation = '' if endpoint != 'newshare' and \ endpoint != 'newreport' and \ @@ -3050,7 +3074,7 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {}, newPostForm += \ ' \n' - newPostForm += extraFields+dateAndLocation + newPostForm += extraFields + citationsStr + dateAndLocation if not mediaInstance or replyStr: newPostForm += newPostImageSection newPostForm += ' \n'