From aeb195e59581c8c2facf00dcfa126cdb6431b280 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 13 Nov 2018 13:03:55 -0800 Subject: [PATCH] Add additional citation checks to editor --- src/build.py | 5 ++++- src/resources/editor.html | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/build.py b/src/build.py index c2f1e22..8408c21 100644 --- a/src/build.py +++ b/src/build.py @@ -427,8 +427,11 @@ def build_all(path_prefix, lexicon_name): writtenArticles = "" phantomArticles = "" for article in articles: + citedby = {'"' + citer.player + '"' for citer in article.citedby} if article.player is None: - phantomArticles += "{{title: \"{0}\"}},".format(article.title.replace("\"", "\\\"")) + phantomArticles += "{{title: \"{0}\", citedby: [{1}]}},".format( + article.title.replace("\"", "\\\""), + ",".join(sorted(citedby))) else: writtenArticles += "{{title: \"{0}\", author: \"{1.player}\"}},".format( article.title.replace("\"", "\\\""), article) diff --git a/src/resources/editor.html b/src/resources/editor.html index 3a13bd5..a5a62da 100644 --- a/src/resources/editor.html +++ b/src/resources/editor.html @@ -20,9 +20,13 @@ ] function updatePreview() { + var articlePlayer = document.getElementById("article-player").value; var articleTitle = document.getElementById("article-title").value; var articleBody = document.getElementById("article-body").value; var previewHtml = "

" + articleTitle + "

\n"; + if (phantomArticles.some(e => (e.title === articleTitle && e.citedby.some(p => (p === articlePlayer))))) { + previewHtml += "

You've cited this article!

" + } previewHtml += parseLexipythonMarkdown(articleBody); document.getElementById("preview").innerHTML = previewHtml; } @@ -164,7 +168,7 @@
- +
# Player:
# Turn: