From 3f53b0651772b1d604bb039b0fcdb3e6d9ae4a95 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 6 Nov 2020 11:21:41 +0000 Subject: [PATCH] Attaching citations to a blog as tags --- posts.py | 21 +++++++++++++++++++++ webinterface.py | 8 +++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/posts.py b/posts.py index ed93f04e9..4071911a4 100644 --- a/posts.py +++ b/posts.py @@ -1228,6 +1228,27 @@ def createBlogPost(baseDir: str, schedulePost, eventDate, eventTime, location) blog['object']['type'] = 'Article' + + # append citations tags, stored in a file + citationsFilename = \ + baseDir + '/accounts/' + \ + nickname + '@' + domain + '/.citations.txt' + if os.path.isfile(citationsFilename): + citationsSeparator = '#####' + with open(citationsFilename, "r") as f: + citations = f.readlines() + for line in citations: + sections = line.split(citationsSeparator) + dateStr = sections[0] + title = sections[1] + link = sections[2] + tagJson = { + "type": "Article", + "name": title + "url": link + } + blog['object']['tag'].append(tagJson) + return blog diff --git a/webinterface.py b/webinterface.py index 5844e92be..19dbe51d8 100644 --- a/webinterface.py +++ b/webinterface.py @@ -5912,6 +5912,8 @@ def htmlCitations(baseDir: str, nickname: str, domain: str, translate['Submit'] + '">\n' htmlStr += ' \n' + citationsSeparator = '#####' + # list of newswire items if newswire: ctr = 0 @@ -5923,9 +5925,13 @@ def htmlCitations(baseDir: str, nickname: str, domain: str, title = removeLongWords(item[0], 16, []).replace('\n', '
') link = item[1] + citationValue = \ + dateStr + citationsSeparator + \ + title + citationsSeparator + \ + link htmlStr += \ '' + \ + '" value="' + citationValue + '"/>' + \ '' + title + ' ' htmlStr += '' + \ dateShown + '
\n'