From a7b85ecc11c2c2404f858e7aeecb6e751f6f0b78 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 20 Jun 2019 02:35:04 +0200 Subject: [PATCH 1/5] Create wikiedit royalprint --- royalnet/royalgamesweb.py | 4 +- royalnet/web/royalprints/__init__.py | 3 +- royalnet/web/royalprints/wikiedit/__init__.py | 21 +++ .../wikiedit/templates/wikiedit_page.html | 154 ++++++++++++++++++ .../wikiview/templates/wikiview_page.html | 12 +- royalnet/web/static/ryg.css | 35 ++++ royalnet/web/static/ryg.css.map | 2 +- royalnet/web/static/ryg.less | 42 ++++- royalnet/web/templates/base.html | 1 + 9 files changed, 267 insertions(+), 7 deletions(-) create mode 100644 royalnet/web/royalprints/wikiedit/__init__.py create mode 100644 royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html diff --git a/royalnet/royalgamesweb.py b/royalnet/royalgamesweb.py index ac823de8..7e912ff8 100644 --- a/royalnet/royalgamesweb.py +++ b/royalnet/royalgamesweb.py @@ -1,6 +1,6 @@ import os from .web import create_app -from .web.royalprints import rp_home, rp_wikiview, rp_tglogin, rp_docs +from .web.royalprints import * class TestConfig: @@ -8,7 +8,7 @@ class TestConfig: TG_AK = os.environ["TG_AK"] -app = create_app(TestConfig, [rp_home, rp_wikiview, rp_tglogin, rp_docs]) +app = create_app(TestConfig, [rp_home, rp_wikiview, rp_tglogin, rp_docs, rp_wikiedit]) if __name__ == "__main__": diff --git a/royalnet/web/royalprints/__init__.py b/royalnet/web/royalprints/__init__.py index ba7a5706..5a4c8d0d 100644 --- a/royalnet/web/royalprints/__init__.py +++ b/royalnet/web/royalprints/__init__.py @@ -4,5 +4,6 @@ from .home import rp as rp_home from .wikiview import rp as rp_wikiview from .tglogin import rp as rp_tglogin from .docs import rp as rp_docs +from .wikiedit import rp as rp_wikiedit -__all__ = ["rp_home", "rp_wikiview", "rp_tglogin", "rp_docs"] +__all__ = ["rp_home", "rp_wikiview", "rp_tglogin", "rp_docs", "rp_wikiedit"] diff --git a/royalnet/web/royalprints/wikiedit/__init__.py b/royalnet/web/royalprints/wikiedit/__init__.py new file mode 100644 index 00000000..9bde90c7 --- /dev/null +++ b/royalnet/web/royalprints/wikiedit/__init__.py @@ -0,0 +1,21 @@ +"""A Royal Games Wiki viewer :py:class:`royalnet.web.Royalprint`. Doesn't support any kind of edit.""" +import flask as f +import uuid +import os +from ... import Royalprint +from ....database.tables import Royal, WikiPage, WikiRevision + + +tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') +rp = Royalprint("wikiedit", __name__, url_prefix="/wikiedit", template_folder=tmpl_dir, + required_tables={Royal, WikiPage, WikiRevision}) + + +@rp.route("/", defaults={"title": ""}) +@rp.route("//") +def wikiedit_by_id(page_id: uuid.UUID, title: str): + alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"] + page = alchemy_session.query(alchemy.WikiPage).filter(alchemy.WikiPage.page_id == page_id).one_or_none() + if page is None: + return "No such page", 404 + return f.render_template("wikiedit_page.html", page=page) diff --git a/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html b/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html new file mode 100644 index 00000000..f832e6c7 --- /dev/null +++ b/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html @@ -0,0 +1,154 @@ +{% extends "base.html" %} + +{% block title %} + {{ page.title }} - RYGwikieditor +{% endblock %} + +{% block head %} + <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css"> + <script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script> +{% endblock %} + +{% block content %} + <div class="doublebox"> + <div class="top"> + <span class="left"> + Wiki Editor + </span> + </div> + <div class="bot"> + <form method="POST" class="wikiedit-form"> + <div class="field"> + <label for="wikiedit-title"> + Titolo + <input id="wikiedit-title" type="text" name="title" placeholder="Titolo" value="{{ page.title }}"> + </label> + </div> + <div class="field"> + <label for="wikiedit-format"> + Formato + <input id="wikiedit-format" type="text" name="format" placeholder="Format" disabled value="{{ page.format }}"> + </label> + </div> + <div class="field"> + <label for="wikiedit-content"> + Contenuto + <textarea id="wikiedit-content" name="content">{{ page.content }}</textarea> + </label> + </div> + <div class="field"> + <label for="wikiedit-css"> + Tema + <select id="wikiedit-css" name="css"> + <option value="None" {% if page.css == None %}selected{% endif %}>Royal Games</option> + <option value="tf2.css" {% if page.css == "tf2.css" %}selected{% endif %}>Team Fortress 2</option> + </select> + </label> + </div> + <div class="field"> + Attenzione! Se due persone stanno modificando la stessa pagina, le modifiche di una di loro rischiano di essere annullate! + </div> + <div class="field"> + <input id="wikiedit-submit" type="submit" value="Applica modifica"> + </div> + </form> + </div> + </div> +{% endblock %} + +{% block footscripts %} + <script> + //TODO: maybe enable autosave? + let simplemde = new SimpleMDE({ + element: document.getElementById("wikiedit-content"), + blockStyles: { + italic: "_" + }, + tabSize: 4, + spellChecker: false, + toolbar: [ + { + name: "bold", + action: SimpleMDE.toggleBold, + className: "fas fa-bold no-icon", + title: "Grassetto", + }, + { + name: "italic", + action: SimpleMDE.toggleItalic, + className: "fas fa-italic no-icon", + title: "Corsivo", + }, + { + name: "strikethrough", + action: SimpleMDE.toggleStrikethrough, + className: "fas fa-strikethrough no-icon", + title: "Barrato", + }, + { + name: "link", + action: SimpleMDE.drawLink, + className: "fas fa-link no-icon", + title: "Link", + }, + "|", + { + name: "heading-smaller", + action: SimpleMDE.toggleHeadingSmaller, + className: "fas fa-header no-icon", + title: "(Rimpicciolisci) Titolo", + }, + { + name: "heading", + action: SimpleMDE.toggleHeadingBigger, + className: "fas fa-header fa-lg no-icon", + title: "(Ingrandisci) Titolo", + }, + "|", + { + name: "code", + action: SimpleMDE.toggleCodeBlock, + className: "fas fa-code no-icon", + title: "Codice", + }, + { + name: "quote", + action: SimpleMDE.toggleBlockquote, + className: "fas fa-quote-left no-icon", + title: "Citazione", + }, + { + name: "unordered-list", + action: SimpleMDE.toggleUnorderedList, + className: "fas fa-list-ul no-icon", + title: "Lista puntata", + }, + { + name: "ordered-list", + action: SimpleMDE.toggleOrderedList, + className: "fas fa-list-ol no-icon", + title: "Lista ordinata", + }, + { + name: "horizontal-rule", + action: SimpleMDE.drawHorizontalRule, + className: "fas fa-minus no-icon", + title: "Separatore", + }, + "|", + { + name: "image", + action: SimpleMDE.drawImage, + className: "fas fa-picture-o no-icon", + title: "Immagine", + }, + { + name: "table", + action: SimpleMDE.drawTable, + className: "fas fa-table no-icon", + title: "Tabella", + } + ], + }); + </script> +{% endblock %} \ No newline at end of file diff --git a/royalnet/web/royalprints/wikiview/templates/wikiview_page.html b/royalnet/web/royalprints/wikiview/templates/wikiview_page.html index e6999bec..adcd9933 100644 --- a/royalnet/web/royalprints/wikiview/templates/wikiview_page.html +++ b/royalnet/web/royalprints/wikiview/templates/wikiview_page.html @@ -8,14 +8,22 @@ <div class="doublebox"> <div class="top"> <span class="left"> - {{ page.title }} + Wiki page </span> <span class="right"> + <a class="permalink no-icon" href="{{ url_for("wikiedit.wikiedit_by_id", page_id=page.page_id|string, title=page.title) }}">e</a> <a class="permalink no-icon" href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string, title=page.title) }}">#</a> </span> </div> <div class="bot"> - {{ parsed_content }} + <div class="wikiview-page"> + <h1 class="wikiview-title"> + {{ page.title }} + </h1> + <div class="wikiview-content"> + {{ parsed_content }} + </div> + </div> </div> </div> {% endblock %} diff --git a/royalnet/web/static/ryg.css b/royalnet/web/static/ryg.css index 9ff44fbe..d69ee476 100644 --- a/royalnet/web/static/ryg.css +++ b/royalnet/web/static/ryg.css @@ -406,4 +406,39 @@ nav .nav-login-unavailable { .faded { opacity: 0.3; } +.wikiedit-form .field { + margin-top: 4px; + margin-bottom: 4px; +} +.wikiedit-form .editor-toolbar, +.wikiedit-form .editor-statusbar { + background-color: #2a3d62; + color: #a0ccff !important; + border: 0; + opacity: 1 !important; +} +.wikiedit-form .editor-toolbar a, +.wikiedit-form .editor-statusbar a { + color: #a0ccff !important; + border: 0; +} +.wikiedit-form .editor-toolbar a:hover, +.wikiedit-form .editor-statusbar a:hover { + background-color: rgba(160, 204, 255, 0.2); + color: #ffffff !important; +} +.wikiedit-form .editor-toolbar a.active, +.wikiedit-form .editor-statusbar a.active { + background-color: rgba(160, 204, 255, 0.3); + color: white !important; +} +.wikiedit-form .editor-toolbar a.active:hover, +.wikiedit-form .editor-statusbar a.active:hover { + background-color: rgba(160, 204, 255, 0.2); + color: #ffffff !important; +} +.wikiedit-form .CodeMirror { + font-family: "Consolas", monospace !important; + border: 0; +} /*# sourceMappingURL=ryg.css.map */ \ No newline at end of file diff --git a/royalnet/web/static/ryg.css.map b/royalnet/web/static/ryg.css.map index 763fe430..61207c49 100644 --- a/royalnet/web/static/ryg.css.map +++ b/royalnet/web/static/ryg.css.map @@ -1 +1 @@ -{"version":3,"sources":["ryg.less"],"names":[],"mappings":"AAiBA;EACI,aALS,SAAS,4BAKlB;EACA,yBAAA;EACA,cAAA;EACA,sBAAA;;AAGJ;EACI,cAAA;EACA,qBAAA;;AAEA,CAAC;EACG,cAAA;;AAGJ,CAAC;EACG,YAAA;;AAOA,CAFH,IAAI,UAEA;EACG,aAAa,qBAAb;EACA,iBAAA;EACA,SAAS,OAAT;EACA,iBAAA;;AAIJ,CAVH,IAAI,UAUA,sBAAsB;EACnB,aAAa,uBAAb;EACA,iBAAA;EACA,SAAS,OAAT;EACA,iBAAA;;AAIJ,CAlBH,IAAI,UAkBA,iCAAiC;AAAU,CAlB/C,IAAI,UAkB4C,0BAA0B;EACnE,aAAa,uBAAb;EACA,iBAAA;EACA,SAAS,OAAT;EACA,iBAAA;;AAIJ,CA1BH,IAAI,UA0BA,2BAA2B;AAAU,CA1BzC,IAAI,UA0BsC,kCAAkC;EACrE,aAAa,uBAAb;EACA,iBAAA;EACA,SAAS,OAAT;EACA,iBAAA;;AAIJ,CAlCH,IAAI,UAkCA,4BAA4B;AAAU,CAlC1C,IAAI,UAkCuC,iCAAiC;EACrE,aAAa,uBAAb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EA,cAVR,gBAMI,EAIK;AAAD,cAVS,kBAMb,EAIK;EACG,0CAAA;EACA,cAAA;;AAGJ,cAfR,gBAMI,EASK;AAAD,cAfS,kBAMb,EASK;EACG,0CAAA;EACA,uBAAA;;AAEA,cAnBZ,gBAMI,EASK,OAII;AAAD,cAnBK,kBAMb,EASK,OAII;EACG,0CAAA;EACA,cAAA;;AA5BpB,cAkCI;EACI,aAAa,qBAAb;EACA,SAAA","file":"ryg.css"} \ No newline at end of file diff --git a/royalnet/web/static/ryg.less b/royalnet/web/static/ryg.less index c8ea1749..c871b01a 100644 --- a/royalnet/web/static/ryg.less +++ b/royalnet/web/static/ryg.less @@ -496,4 +496,44 @@ nav { .faded { opacity: 0.3; -} \ No newline at end of file +} + +.wikiedit-form { + + .field { + margin-top: 4px; + margin-bottom: 4px; + } + + .editor-toolbar, .editor-statusbar { + background-color: #2a3d62; + color: @fg !important; + border: 0; + opacity: 1 !important; + + a { + color: @fg !important; + border: 0; + + &:hover { + background-color: fade(@fg, 20%); + color: lighten(@fg, 25%) !important; + } + + &.active { + background-color: fade(@fg, 30%); + color: white !important; + + &:hover { + background-color: fade(@fg, 20%); + color: lighten(@fg, 25%) !important; + } + } + } + } + + .CodeMirror { + font-family: "Consolas", monospace !important; + border: 0; + } +} diff --git a/royalnet/web/templates/base.html b/royalnet/web/templates/base.html index c6776f7f..dc5be072 100644 --- a/royalnet/web/templates/base.html +++ b/royalnet/web/templates/base.html @@ -16,6 +16,7 @@ <link rel="stylesheet" href="{{ url_for("static", filename="ryg.css") }}"> {% endif %} <link rel="icon" href="{{ url_for("static", filename="logo.png") }}" type="image/png"> + {% block head %}{% endblock %} </head> <body> <nav> From 87578155a8e329b1bd67bc1e55a74b6a6155ace8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <ste.pigozzi@gmail.com> Date: Thu, 20 Jun 2019 16:44:05 +0200 Subject: [PATCH 2/5] Wiki progress --- royalnet/web/royalprints/wikiedit/__init__.py | 9 +- .../wikiedit/templates/wikiedit_page.html | 29 ++---- royalnet/web/static/ryg.css | 78 +++++++++++++++- royalnet/web/static/ryg.css.map | 2 +- royalnet/web/static/ryg.less | 90 ++++++++++++++++++- 5 files changed, 178 insertions(+), 30 deletions(-) diff --git a/royalnet/web/royalprints/wikiedit/__init__.py b/royalnet/web/royalprints/wikiedit/__init__.py index 9bde90c7..4e9f2d3b 100644 --- a/royalnet/web/royalprints/wikiedit/__init__.py +++ b/royalnet/web/royalprints/wikiedit/__init__.py @@ -11,11 +11,16 @@ rp = Royalprint("wikiedit", __name__, url_prefix="/wikiedit", template_folder=tm required_tables={Royal, WikiPage, WikiRevision}) -@rp.route("/<uuid:page_id>", defaults={"title": ""}) +@rp.route("/<uuid:page_id>", defaults={"title": ""}, methods=["GET", "POST"]) @rp.route("/<uuid:page_id>/<title>") def wikiedit_by_id(page_id: uuid.UUID, title: str): alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"] page = alchemy_session.query(alchemy.WikiPage).filter(alchemy.WikiPage.page_id == page_id).one_or_none() if page is None: return "No such page", 404 - return f.render_template("wikiedit_page.html", page=page) + + if f.request.method == "GET": + return f.render_template("wikiedit_page.html", page=page) + + elif f.request.method == "POST": + return "Haha doesn't work yet" diff --git a/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html b/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html index f832e6c7..fd77c6a7 100644 --- a/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html +++ b/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html @@ -18,39 +18,26 @@ </div> <div class="bot"> <form method="POST" class="wikiedit-form"> - <div class="field"> <label for="wikiedit-title"> - Titolo + <span class="label-text">Titolo</span> <input id="wikiedit-title" type="text" name="title" placeholder="Titolo" value="{{ page.title }}"> </label> - </div> - <div class="field"> <label for="wikiedit-format"> - Formato + <span class="label-text">Formato</span> <input id="wikiedit-format" type="text" name="format" placeholder="Format" disabled value="{{ page.format }}"> </label> - </div> - <div class="field"> - <label for="wikiedit-content"> - Contenuto - <textarea id="wikiedit-content" name="content">{{ page.content }}</textarea> - </label> - </div> - <div class="field"> + <!--suppress HtmlFormInputWithoutLabel --> + <textarea id="wikiedit-content" name="content">{{ page.content }}</textarea> <label for="wikiedit-css"> - Tema + <span class="label-text">Tema</span> <select id="wikiedit-css" name="css"> <option value="None" {% if page.css == None %}selected{% endif %}>Royal Games</option> <option value="tf2.css" {% if page.css == "tf2.css" %}selected{% endif %}>Team Fortress 2</option> </select> </label> - </div> - <div class="field"> - Attenzione! Se due persone stanno modificando la stessa pagina, le modifiche di una di loro rischiano di essere annullate! - </div> - <div class="field"> - <input id="wikiedit-submit" type="submit" value="Applica modifica"> - </div> + <label for="wikiedit-submit"> + <input id="wikiedit-submit" type="submit" value="Salva"> + </label> </form> </div> </div> diff --git a/royalnet/web/static/ryg.css b/royalnet/web/static/ryg.css index d69ee476..7b50d657 100644 --- a/royalnet/web/static/ryg.css +++ b/royalnet/web/static/ryg.css @@ -176,6 +176,32 @@ input[type="submit"]:active, color: white; border-color: white; } +input[type="text"], +input[type="password"], +input[type="email"] { + background-color: rgba(160, 204, 255, 0.1); + color: #a0ccff; + border: none; + border-bottom: 1px dashed #a0ccff; + padding: 2px; + margin: 1px; + font-size: medium; + font-family: sans-serif; +} +select { + background-color: rgba(160, 204, 255, 0.1); + color: #a0ccff; + border: none; + border-bottom: 1px dotted #a0ccff; + padding: 2px; + margin: 1px; + font-size: medium; + font-family: sans-serif; +} +select option { + background-color: #293c61; + color: #a0ccff; +} pre { margin: 0; } @@ -403,12 +429,28 @@ nav .nav-login-unavailable { .spoiler:hover { color: #a0ccff; } -.faded { +.faded, +input[disabled=""], +button[disabled=""] { opacity: 0.3; } -.wikiedit-form .field { +.wikiedit-form label { margin-top: 4px; margin-bottom: 4px; + display: flex; +} +.wikiedit-form label .label-text { + margin-right: 12px; + min-width: 60px; +} +.wikiedit-form label input { + flex-grow: 1; +} +.wikiedit-form label[for="wikiedit-title"] { + font-size: x-large; +} +.wikiedit-form label[for="wikiedit-title"] * { + font-size: x-large; } .wikiedit-form .editor-toolbar, .wikiedit-form .editor-statusbar { @@ -439,6 +481,36 @@ nav .nav-login-unavailable { } .wikiedit-form .CodeMirror { font-family: "Consolas", monospace !important; - border: 0; + background-color: transparent; + color: #a0ccff; + border-top: 0; + border-bottom: 0; + border-left: 1px solid rgba(160, 204, 255, 0.2); + border-right: 1px solid rgba(160, 204, 255, 0.2); + border-radius: 0; +} +.wikiedit-form .CodeMirror .cm-link { + color: #7dffff !important; +} +.wikiedit-form .CodeMirror .cm-url { + color: #00caca !important; +} +.wikiedit-form .CodeMirror .cm-tag { + color: #ff7dff !important; +} +.wikiedit-form .CodeMirror .cm-strong { + color: #ffff7d !important; +} +.wikiedit-form .CodeMirror .cm-em { + color: #ffbb7d !important; +} +.wikiedit-form .CodeMirror .cm-quote { + color: #7dff7d !important; +} +.wikiedit-form .CodeMirror .cm-comment { + color: #ff7d7d !important; +} +.wikiedit-form .CodeMirror .cm-header { + color: #ffffff !important; } /*# sourceMappingURL=ryg.css.map */ \ No newline at end of file diff --git a/royalnet/web/static/ryg.css.map b/royalnet/web/static/ryg.css.map index 61207c49..a5e2e653 100644 --- a/royalnet/web/static/ryg.css.map +++ b/royalnet/web/static/ryg.css.map @@ -1 +1 @@ -{"version":3,"sources":["ryg.less"],"names":[],"mappings":"AAiBA;EACI,aALS,SAAS,4BAKlB;EACA,yBAAA;EACA,cAAA;EACA,sBAAA;;AAGJ;EACI,cAAA;EACA,qBAAA;;AAEA,CAAC;EACG,cAAA;;AAGJ,CAAC;EACG,YAAA;;AAOA,CAFH,IAAI,UAEA;EACG,aAAa,qBAAb;EACA,iBAAA;EACA,SAAS,OAAT;EACA,iBAAA;;AAIJ,CAVH,IAAI,UAUA,sBAAsB;EACnB,aAAa,uBAAb;EACA,iBAAA;EACA,SAAS,OAAT;EACA,iBAAA;;AAIJ,CAlBH,IAAI,UAkBA,iCAAiC;AAAU,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AAEA,cAVR,gBAMI,EAIK;AAAD,cAVS,kBAMb,EAIK;EACG,0CAAA;EACA,cAAA;;AAGJ,cAfR,gBAMI,EASK;AAAD,cAfS,kBAMb,EASK;EACG,0CAAA;EACA,uBAAA;;AAEA,cAnBZ,gBAMI,EASK,OAII;AAAD,cAnBK,kBAMb,EASK,OAII;EACG,0CAAA;EACA,cAAA;;AA9CpB,cAoDI;EACI,aAAa,qBAAb;EACA,6BAAA;EACA,cAAA;EACA,aAAA;EACA,gBAAA;EACA,+CAAA;EACA,gDAAA;EACA,gBAAA;;AA5DR,cAoDI,YAUI;EACI,cAAA;;AA/DZ,cAoDI,YAcI;EACI,cAAA;;AAnEZ,cAoDI,YAkBI;EACI,cAAA;;AAvEZ,cAoDI,YAsBI;EACI,cAAA;;AA3EZ,cAoDI,YA0BI;EACI,cAAA;;AA/EZ,cAoDI,YA8BI;EACI,cAAA;;AAnFZ,cAoDI,YAkCI;EACI,cAAA;;AAvFZ,cAoDI,YAsCI;EACI,cAAA","file":"ryg.css"} \ No newline at end of file diff --git a/royalnet/web/static/ryg.less b/royalnet/web/static/ryg.less index c871b01a..a46e3a70 100644 --- a/royalnet/web/static/ryg.less +++ b/royalnet/web/static/ryg.less @@ -215,6 +215,33 @@ button, input[type="submit"], .btn { } } +input[type="text"], input[type="password"], input[type="email"] { + background-color: fade(@fg, 10%); + color: @fg; + border: none; + border-bottom: 1px dashed @fg; + padding: 2px; + margin: 1px; + font-size: medium; + font-family: sans-serif; +} + +select { + background-color: fade(@fg, 10%); + color: @fg; + border: none; + border-bottom: 1px dotted @fg; + padding: 2px; + margin: 1px; + font-size: medium; + font-family: sans-serif; + + option { + background-color: #293c61; + color: @fg; + } +} + pre { margin: 0; } @@ -494,15 +521,33 @@ nav { } } -.faded { +.faded, input[disabled=""], button[disabled=""] { opacity: 0.3; } .wikiedit-form { - .field { + label { margin-top: 4px; margin-bottom: 4px; + display: flex; + + .label-text { + margin-right: 12px; + min-width: 60px; + } + + input { + flex-grow: 1; + } + } + + label[for="wikiedit-title"] { + font-size: x-large; + + * { + font-size: x-large; + } } .editor-toolbar, .editor-statusbar { @@ -534,6 +579,45 @@ nav { .CodeMirror { font-family: "Consolas", monospace !important; - border: 0; + background-color: transparent; + color: @fg; + border-top: 0; + border-bottom: 0; + border-left: 1px solid fade(@fg, 20%); + border-right: 1px solid fade(@fg, 20%); + border-radius: 0; + + .cm-link { + color: @pastel-cyan !important; + } + + .cm-url { + color: @li !important; + } + + .cm-tag { + color: @pastel-magenta !important; + } + + .cm-strong { + color: @pastel-yellow !important; + } + + .cm-em { + color: @pastel-orange !important; + } + + .cm-quote { + color: @pastel-lime !important; + } + + .cm-comment { + color: @pastel-red !important; + } + + .cm-header { + color: @ec !important; + } + } } From fb0f3d939572e447146e13abaab31f1c3ea94514 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <ste.pigozzi@gmail.com> Date: Thu, 20 Jun 2019 17:01:13 +0200 Subject: [PATCH 3/5] Progress --- royalnet/web/royalprints/wikiedit/__init__.py | 4 +- .../wikiedit/templates/wikiedit_page.html | 44 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/royalnet/web/royalprints/wikiedit/__init__.py b/royalnet/web/royalprints/wikiedit/__init__.py index 4e9f2d3b..0d918fef 100644 --- a/royalnet/web/royalprints/wikiedit/__init__.py +++ b/royalnet/web/royalprints/wikiedit/__init__.py @@ -12,7 +12,7 @@ rp = Royalprint("wikiedit", __name__, url_prefix="/wikiedit", template_folder=tm @rp.route("/<uuid:page_id>", defaults={"title": ""}, methods=["GET", "POST"]) -@rp.route("/<uuid:page_id>/<title>") +@rp.route("/<uuid:page_id>/<title>", methods=["GET", "POST"]) def wikiedit_by_id(page_id: uuid.UUID, title: str): alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"] page = alchemy_session.query(alchemy.WikiPage).filter(alchemy.WikiPage.page_id == page_id).one_or_none() @@ -23,4 +23,4 @@ def wikiedit_by_id(page_id: uuid.UUID, title: str): return f.render_template("wikiedit_page.html", page=page) elif f.request.method == "POST": - return "Haha doesn't work yet" + return "" \ No newline at end of file diff --git a/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html b/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html index fd77c6a7..6d2a24cb 100644 --- a/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html +++ b/royalnet/web/royalprints/wikiedit/templates/wikiedit_page.html @@ -18,26 +18,30 @@ </div> <div class="bot"> <form method="POST" class="wikiedit-form"> - <label for="wikiedit-title"> - <span class="label-text">Titolo</span> - <input id="wikiedit-title" type="text" name="title" placeholder="Titolo" value="{{ page.title }}"> - </label> - <label for="wikiedit-format"> - <span class="label-text">Formato</span> - <input id="wikiedit-format" type="text" name="format" placeholder="Format" disabled value="{{ page.format }}"> - </label> - <!--suppress HtmlFormInputWithoutLabel --> - <textarea id="wikiedit-content" name="content">{{ page.content }}</textarea> - <label for="wikiedit-css"> - <span class="label-text">Tema</span> - <select id="wikiedit-css" name="css"> - <option value="None" {% if page.css == None %}selected{% endif %}>Royal Games</option> - <option value="tf2.css" {% if page.css == "tf2.css" %}selected{% endif %}>Team Fortress 2</option> - </select> - </label> - <label for="wikiedit-submit"> - <input id="wikiedit-submit" type="submit" value="Salva"> - </label> + <label for="wikiedit-title"> + <span class="label-text">Titolo</span> + <input id="wikiedit-title" type="text" name="title" value="{{ page.title }}"> + </label> + <label for="wikiedit-format"> + <span class="label-text">Formato</span> + <input id="wikiedit-format" type="text" name="format" disabled value="{{ page.format }}"> + </label> + <!--suppress HtmlFormInputWithoutLabel --> + <textarea id="wikiedit-content" name="content">{{ page.content }}</textarea> + <label for="wikiedit-css"> + <span class="label-text">Tema</span> + <select id="wikiedit-css" name="css"> + <option value="None" {% if page.css == None %}selected{% endif %}>Royal Games</option> + <option value="tf2.css" {% if page.css == "tf2.css" %}selected{% endif %}>Team Fortress 2</option> + </select> + </label> + <label for="wikiedit-reason"> + <span class="label-text">Motivo</span> + <input id="wikiedit-reason" type="text" name="reason"> + </label> + <label for="wikiedit-submit"> + <input id="wikiedit-submit" type="submit" value="Salva"> + </label> </form> </div> </div> From d4991576c989e0c993bf23efb36a1f40a9dda10e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <ste.pigozzi@gmail.com> Date: Thu, 20 Jun 2019 19:23:44 +0200 Subject: [PATCH 4/5] Working wiki edits --- royalnet/web/royalprints/wikiedit/__init__.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/royalnet/web/royalprints/wikiedit/__init__.py b/royalnet/web/royalprints/wikiedit/__init__.py index 0d918fef..33487c7c 100644 --- a/royalnet/web/royalprints/wikiedit/__init__.py +++ b/royalnet/web/royalprints/wikiedit/__init__.py @@ -2,6 +2,8 @@ import flask as f import uuid import os +import datetime +import difflib from ... import Royalprint from ....database.tables import Royal, WikiPage, WikiRevision @@ -14,6 +16,9 @@ rp = Royalprint("wikiedit", __name__, url_prefix="/wikiedit", template_folder=tm @rp.route("/<uuid:page_id>", defaults={"title": ""}, methods=["GET", "POST"]) @rp.route("/<uuid:page_id>/<title>", methods=["GET", "POST"]) def wikiedit_by_id(page_id: uuid.UUID, title: str): + if "royal" not in f.session: + return "Please login to edit wiki pages", 403 + alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"] page = alchemy_session.query(alchemy.WikiPage).filter(alchemy.WikiPage.page_id == page_id).one_or_none() if page is None: @@ -23,4 +28,24 @@ def wikiedit_by_id(page_id: uuid.UUID, title: str): return f.render_template("wikiedit_page.html", page=page) elif f.request.method == "POST": - return "" \ No newline at end of file + fd = f.request.form + if "content" not in fd: + return "Missing page content", 400 + # Create new revision + revision = alchemy.WikiRevision(revision_id=uuid.uuid4(), + page_id=page.page_id, + author_id=f.session["royal"]["uid"], + timestamp=datetime.datetime.now(), + reason=fd.get("reason"), + diff="\n".join(difflib.unified_diff(page.content.split("\n"), fd["content"].split("\n")))) + alchemy_session.add(revision) + # Apply changes + page.content = fd["content"] + if "title" in fd: + page.title = fd["title"] + if "format" in fd: + page.format = fd["format"] + if "css" in fd: + page.css = fd["css"] if fd["css"] != "None" else None + alchemy_session.commit() + return f.redirect(f.url_for("wikiview.wikiview_by_id", page_id=page.page_id, title=page.title)) From a72a97736dc0b258f528dde3a541857f1ab6000d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <ste.pigozzi@gmail.com> Date: Thu, 20 Jun 2019 19:57:54 +0200 Subject: [PATCH 5/5] Complete wiki features --- royalnet/web/royalprints/wikiedit/__init__.py | 44 +++++++++++++++---- .../wikiview/templates/wikiview_index.html | 5 +++ .../wikiview/templates/wikiview_page.html | 9 +++- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/royalnet/web/royalprints/wikiedit/__init__.py b/royalnet/web/royalprints/wikiedit/__init__.py index 33487c7c..bf5264cb 100644 --- a/royalnet/web/royalprints/wikiedit/__init__.py +++ b/royalnet/web/royalprints/wikiedit/__init__.py @@ -13,6 +13,36 @@ rp = Royalprint("wikiedit", __name__, url_prefix="/wikiedit", template_folder=tm required_tables={Royal, WikiPage, WikiRevision}) +@rp.route("/newpage", methods=["GET", "POST"]) +def wikiedit_newpage(): + if "royal" not in f.session: + return "Please login to edit wiki pages", 403 + + if f.request.method == "GET": + return f.render_template("wikiedit_page.html", page=None) + + elif f.request.method == "POST": + fd = f.request.form + if not ("title" in fd and "content" in fd and "css" in fd): + return "Missing field", 400 + alchemy, alchemy_session = f.current_app.config["ALCHEMY"], f.current_app.config["ALCHEMY_SESSION"] + page = alchemy.WikiPage(page_id=uuid.uuid4(), + title=fd["title"], + content=fd["content"], + format="markdown", + css=fd["css"] if fd["css"] != "None" else None) + revision = alchemy.WikiRevision(revision_id=uuid.uuid4(), + page=page, + author_id=f.session["royal"]["uid"], + timestamp=datetime.datetime.now(), + reason=fd.get("reason"), + diff="\n".join(difflib.unified_diff([], page.content.split("\n")))) + alchemy_session.add(page) + alchemy_session.add(revision) + alchemy_session.commit() + return f.redirect(f.url_for("wikiview.wikiview_by_id", page_id=page.page_id, title=page.title)) + + @rp.route("/<uuid:page_id>", defaults={"title": ""}, methods=["GET", "POST"]) @rp.route("/<uuid:page_id>/<title>", methods=["GET", "POST"]) def wikiedit_by_id(page_id: uuid.UUID, title: str): @@ -29,11 +59,11 @@ def wikiedit_by_id(page_id: uuid.UUID, title: str): elif f.request.method == "POST": fd = f.request.form - if "content" not in fd: - return "Missing page content", 400 + if not ("title" in fd and "content" in fd and "css" in fd): + return "Missing field", 400 # Create new revision revision = alchemy.WikiRevision(revision_id=uuid.uuid4(), - page_id=page.page_id, + page=page, author_id=f.session["royal"]["uid"], timestamp=datetime.datetime.now(), reason=fd.get("reason"), @@ -41,11 +71,7 @@ def wikiedit_by_id(page_id: uuid.UUID, title: str): alchemy_session.add(revision) # Apply changes page.content = fd["content"] - if "title" in fd: - page.title = fd["title"] - if "format" in fd: - page.format = fd["format"] - if "css" in fd: - page.css = fd["css"] if fd["css"] != "None" else None + page.title = fd["title"] + page.css = fd["css"] if fd["css"] != "None" else None alchemy_session.commit() return f.redirect(f.url_for("wikiview.wikiview_by_id", page_id=page.page_id, title=page.title)) diff --git a/royalnet/web/royalprints/wikiview/templates/wikiview_index.html b/royalnet/web/royalprints/wikiview/templates/wikiview_index.html index 4afb2780..e4d73745 100644 --- a/royalnet/web/royalprints/wikiview/templates/wikiview_index.html +++ b/royalnet/web/royalprints/wikiview/templates/wikiview_index.html @@ -12,6 +12,11 @@ </span> </div> <div class="bot"> + {% if session.royal %} + <a href="{{ url_for("wikiedit.wikiedit_newpage") }}" class="btn no-icon">Crea nuova pagina</a> + {% else %} + <button disabled title="Devi fare il login per creare nuove pagine!">Crea nuova pagina</button> + {% endif %} <ul> {% for page in pages %} <li><a href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string, title=page.title) }}">{{ page.title }}</a></li> diff --git a/royalnet/web/royalprints/wikiview/templates/wikiview_page.html b/royalnet/web/royalprints/wikiview/templates/wikiview_page.html index adcd9933..6f7605e1 100644 --- a/royalnet/web/royalprints/wikiview/templates/wikiview_page.html +++ b/royalnet/web/royalprints/wikiview/templates/wikiview_page.html @@ -11,8 +11,13 @@ Wiki page </span> <span class="right"> - <a class="permalink no-icon" href="{{ url_for("wikiedit.wikiedit_by_id", page_id=page.page_id|string, title=page.title) }}">e</a> - <a class="permalink no-icon" href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string, title=page.title) }}">#</a> + {% if session.royal %} + <a class="edit no-icon" href="{{ url_for("wikiedit.wikiedit_by_id", page_id=page.page_id|string, title=page.title) }}">Modifica</a> + {% else %} + <a class="edit no-icon faded" title="Devi fare il login per creare nuove pagine!">Modifica</a> + {% endif %} + | + <a class="permalink no-icon" href="{{ url_for("wikiview.wikiview_by_id", page_id=page.page_id|string, title=page.title) }}">Permalink</a> </span> </div> <div class="bot">