Add additional citation checks to editor

This commit is contained in:
Tim Van Baak 2018-11-13 13:03:55 -08:00
parent 9a8ad419a0
commit aeb195e595
2 changed files with 9 additions and 2 deletions

View File

@ -427,8 +427,11 @@ def build_all(path_prefix, lexicon_name):
writtenArticles = "" writtenArticles = ""
phantomArticles = "" phantomArticles = ""
for article in articles: for article in articles:
citedby = {'"' + citer.player + '"' for citer in article.citedby}
if article.player is None: 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: else:
writtenArticles += "{{title: \"{0}\", author: \"{1.player}\"}},".format( writtenArticles += "{{title: \"{0}\", author: \"{1.player}\"}},".format(
article.title.replace("\"", "\\\""), article) article.title.replace("\"", "\\\""), article)

View File

@ -20,9 +20,13 @@
] ]
function updatePreview() { function updatePreview() {
var articlePlayer = document.getElementById("article-player").value;
var articleTitle = document.getElementById("article-title").value; var articleTitle = document.getElementById("article-title").value;
var articleBody = document.getElementById("article-body").value; var articleBody = document.getElementById("article-body").value;
var previewHtml = "<h1>" + articleTitle + "</h1>\n"; var previewHtml = "<h1>" + articleTitle + "</h1>\n";
if (phantomArticles.some(e => (e.title === articleTitle && e.citedby.some(p => (p === articlePlayer))))) {
previewHtml += "<p><span style=\"color:#dd0000\">You've cited this article!</span></p>"
}
previewHtml += parseLexipythonMarkdown(articleBody); previewHtml += parseLexipythonMarkdown(articleBody);
document.getElementById("preview").innerHTML = previewHtml; document.getElementById("preview").innerHTML = previewHtml;
} }
@ -164,7 +168,7 @@
<div class="column"> <div class="column">
<table style="width:100%"> <table style="width:100%">
<tr><td># Player:</td> <tr><td># Player:</td>
<td><input id="article-player" style="width:100%;" value="PN"/></td> <td><input id="article-player" style="width:100%;" value="PN" oninput="updatePreview()"/></td>
</tr> </tr>
<tr><td># Turn:</td> <tr><td># Turn:</td>
<td><input id="article-turn" style="width:100%" value="TURNNUMBER"/></td> <td><input id="article-turn" style="width:100%" value="TURNNUMBER"/></td>