From 34b72419c312d21b77185b72a47cb49508ed47e9 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sat, 13 Apr 2019 16:39:47 +0100 Subject: Some more work towards the editor pages --- pydis_site/static/js/wiki/load_editor.js | 51 ++++-- pydis_site/templates/wiki/create_root.html | 7 +- pydis_site/templates/wiki/edit.html | 194 ++++++++++++--------- pydis_site/templates/wiki/includes/editor.html | 7 - .../templates/wiki/includes/editor_sidebar.html | 12 -- pydis_site/templates/wiki/settings.html | 7 +- 6 files changed, 161 insertions(+), 117 deletions(-) (limited to 'pydis_site') diff --git a/pydis_site/static/js/wiki/load_editor.js b/pydis_site/static/js/wiki/load_editor.js index a9f78e65..1837c7fd 100644 --- a/pydis_site/static/js/wiki/load_editor.js +++ b/pydis_site/static/js/wiki/load_editor.js @@ -1,8 +1,44 @@ (function() { window.editors = {}; // So that other scripts can get at 'em + const TOCText = "[TOC]"; + + const headingAction = { + name: "heading", + action: SimpleMDE.toggleHeadingSmaller, + className: "fa fa-heading", + title: "Heading", + }; + + const imageAction = { + name: "image", + action: SimpleMDE.drawImage, + className: "fa fa-image", + title: "Insert image", + }; + + const TOCAction = { + name: "toc", + action: inserTOC, + className: "fa fa-stream", + title: "Insert Table of Contents" + }; + let elements = document.getElementsByClassName("simple-mde"); + function inserTOC(editor) { + let doc = editor.codemirror.getDoc(), + cursor = doc.getCursor(), + line = doc.getLine(cursor.line), + position = {"line": cursor.line}; + + if (line.length === 0) { + doc.replaceRange(TOCText, position); + } else { + doc.replaceRange("\n" + TOCText, position) + } + } + for (let element of elements) { window.editors[element.id] = new SimpleMDE({ "element": element, @@ -28,19 +64,10 @@ tabSize: 4, toolbar: [ - "bold", "italic", "strikethrough", { - name: "heading", - action: SimpleMDE.toggleHeadingSmaller, - className: "fa fa-heading", - title: "Heading", - }, "|", + "bold", "italic", "strikethrough", headingAction, "|", "code", "quote", "unordered-list", "ordered-list", "|", - "link", { - name: "image", - action: SimpleMDE.drawImage, - className: "fa fa-image", - title: "Insert image", - }, "table", "horizontal-rule", "|", + "link", imageAction, "table", "horizontal-rule", "|", + TOCAction, "|", "preview", "side-by-side", "fullscreen", "|", "guide" ], diff --git a/pydis_site/templates/wiki/create_root.html b/pydis_site/templates/wiki/create_root.html index 08ee7f82..376321c6 100644 --- a/pydis_site/templates/wiki/create_root.html +++ b/pydis_site/templates/wiki/create_root.html @@ -39,7 +39,12 @@
- +
diff --git a/pydis_site/templates/wiki/edit.html b/pydis_site/templates/wiki/edit.html index fc5955e9..8d5b61db 100644 --- a/pydis_site/templates/wiki/edit.html +++ b/pydis_site/templates/wiki/edit.html @@ -6,13 +6,83 @@ Edit: {{ article.current_revision.title }} {% endblock %} +{% block head %} + {{ block.super }} + + + + + + +{% endblock %} + {% block wiki_contents_tab %} {% if not user.is_authenticated %} -

- {% trans "Warning: You are not logged in. Your IP address will be logged." %} - {% trans "Click here to log in" %} » -

+

+ {% trans "Warning: You are not logged in. Your IP address will be logged." %} + {% trans "Click here to log in" %} » +

{% endif %}
@@ -23,39 +93,44 @@ {% include "wiki/includes/editor.html" %} {% endwith %} -
-
-
- - - -
- {% if user.is_authenticated and urlpath.path %} - - - {% trans "Move article" %} - - {% endif %} - {% if article|can_delete:user %} - - - {% trans "Delete article" %} - - {% endif %} -
-
-
+ + + +
+ {% if user.is_authenticated and urlpath.path %} + + + + + Move Article + + {% endif %} + {% if article|can_delete:user %} + + + + + Delete Article + + {% endif %}
+
+
+
@@ -88,53 +163,4 @@
- - {% addtoblock "js" %} - - {% endaddtoblock %} {% endblock %} diff --git a/pydis_site/templates/wiki/includes/editor.html b/pydis_site/templates/wiki/includes/editor.html index 6686d8dd..bc1da1a0 100644 --- a/pydis_site/templates/wiki/includes/editor.html +++ b/pydis_site/templates/wiki/includes/editor.html @@ -2,10 +2,3 @@ {% include "wiki/includes/editormedia.html" %} {% wiki_form form %} -{% addtoblock "js" %} - -{% endaddtoblock %} diff --git a/pydis_site/templates/wiki/includes/editor_sidebar.html b/pydis_site/templates/wiki/includes/editor_sidebar.html index 480dc239..87efed4d 100644 --- a/pydis_site/templates/wiki/includes/editor_sidebar.html +++ b/pydis_site/templates/wiki/includes/editor_sidebar.html @@ -1,16 +1,4 @@ {% load i18n sekizai_tags %} -{% addtoblock "js" %} - -{% endaddtoblock %}
diff --git a/pydis_site/templates/wiki/settings.html b/pydis_site/templates/wiki/settings.html index 3e8c8dab..c26e4ccd 100644 --- a/pydis_site/templates/wiki/settings.html +++ b/pydis_site/templates/wiki/settings.html @@ -17,7 +17,12 @@
- +
-- cgit v1.2.3