From 8260b014f34b37bdba1c46e114d93a501f41dd76 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sat, 3 Nov 2018 14:54:13 -0700 Subject: [PATCH] Add custom editor --- src/build.py | 18 ++++ src/resources/editor.html | 183 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 src/resources/editor.html diff --git a/src/build.py b/src/build.py index ac5ccf5..c7198a0 100644 --- a/src/build.py +++ b/src/build.py @@ -398,6 +398,24 @@ def build_all(path_prefix, lexicon_name): f.write(build_compiled_page(articles, config)) print(" Wrote compiled page to " + config["PRINTABLE_FILE"]) + with open(pathto("editor.html"), "w", encoding="utf-8") as f: + editor = utils.load_resource("editor.html") + writtenArticles = "" + phantomArticles = "" + for article in articles: + if article.player is None: + phantomArticles += "{{title: \"{0}\"}},".format(article.title.replace("\"", "\\\"")) + else: + writtenArticles += "{{title: \"{0}\", author: \"{1.player}\"}},".format( + article.title.replace("\"", "\\\""), article) + nextTurn = 0 + if articles: + nextTurn = max([article.turn for article in articles if article.player is not None]) + 1 + editor = editor.replace("//writtenArticles", writtenArticles) + editor = editor.replace("//phantomArticles", phantomArticles) + editor = editor.replace("TURNNUMBER", str(nextTurn)) + f.write(editor) + # Check that authors aren't citing themselves print("Running citation checks...") for parent in articles: diff --git a/src/resources/editor.html b/src/resources/editor.html new file mode 100644 index 0000000..cdaaa55 --- /dev/null +++ b/src/resources/editor.html @@ -0,0 +1,183 @@ + + +Lexicon Editor + + + + +
+

Lexicon Editor

+
+ +
+
+ + + + + + + + + + +
# Player:
# Turn:
# Title:
+ +
+
+
+
+
+
+ +