Add additional citation checks to editor
This commit is contained in:
parent
9a8ad419a0
commit
aeb195e595
@ -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)
|
||||
|
@ -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 = "<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);
|
||||
document.getElementById("preview").innerHTML = previewHtml;
|
||||
}
|
||||
@ -164,7 +168,7 @@
|
||||
<div class="column">
|
||||
<table style="width:100%">
|
||||
<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><td># Turn:</td>
|
||||
<td><input id="article-turn" style="width:100%" value="TURNNUMBER"/></td>
|
||||
|
Loading…
Reference in New Issue
Block a user