blob: 9f3c741e1e9144aca72ad70cc8344c84a549525d [file] [log] [blame]
Matthias Andreas Benkardae402342020-01-25 10:09:57 +01001{@eu.mulk.mulkcms2.benki.wiki.WikiPageRevision page}
Matthias Andreas Benkardd8f16442020-01-25 05:37:43 +01002
Matthias Andreas Benkardae402342020-01-25 10:09:57 +01003{#include base.html}
Matthias Andreas Benkardffb428e2020-01-25 10:47:36 +01004
Matthias Andreas Benkardae402342020-01-25 10:09:57 +01005{#title}{page.title} — Benki Wiki{/title}
Matthias Andreas Benkardffb428e2020-01-25 10:47:36 +01006
7{#head}
8<link rel="stylesheet" type="text/css" href="/web_modules/ContentTools/build/content-tools.min.css" />
9<script type="module">
Matthias Andreas Benkard578c8652020-02-01 23:53:37 +010010 import ContentTools from "/web_modules/ContentTools.js";
Matthias Andreas Benkard2f537452020-01-27 21:23:00 +010011
Matthias Andreas Benkardffb428e2020-01-25 10:47:36 +010012 window.addEventListener('DOMContentLoaded', function() {
13 let editor = ContentTools.EditorApp.get();
14 editor.init('*[data-editable]', 'data-name');
Matthias Andreas Benkard2f537452020-01-27 21:23:00 +010015
Matthias Andreas Benkardd50bbb72020-01-27 05:53:07 +010016 editor.addEventListener('saved', async function (ev) {
17 let regions = ev.detail().regions;
18 if (Object.getOwnPropertyNames(regions).length === 0) {
19 // Nothing changed.
20 return;
21 }
22
23 this.busy(true);
24
25 let requestParams = new URLSearchParams();
26 for (let name of Object.getOwnPropertyNames(regions)) {
27 requestParams.append(name, regions[name]);
28 }
29
Matthias Andreas Benkard97130f92020-01-27 21:03:39 +010030 let response = await fetch("/wiki/{page.title}", {
Matthias Andreas Benkardd50bbb72020-01-27 05:53:07 +010031 method: 'POST',
32 body: requestParams
33 });
Matthias Andreas Benkard97130f92020-01-27 21:03:39 +010034
Matthias Andreas Benkard2f537452020-01-27 21:23:00 +010035 let status = await response.json();
36 if (status.status === "ok") {
37 if (status.hasOwnProperty("content")) {
38 document.getElementById("wiki-content").innerHTML = status.content;
39 }
40 } else {
41 alert("Failed to save page: " + JSON.stringify(status));
42 }
43
Matthias Andreas Benkardd50bbb72020-01-27 05:53:07 +010044 this.busy(false);
45 });
Matthias Andreas Benkardffb428e2020-01-25 10:47:36 +010046 });
47</script>
48{/head}
49
Matthias Andreas Benkardae402342020-01-25 10:09:57 +010050{#body}
51<article id="wiki-page">
52 <header>
Matthias Andreas Benkardd50bbb72020-01-27 05:53:07 +010053 <div data-editable data-name="wiki-title">
54 <h1>{page.title}</h1>
55 </div>
Matthias Andreas Benkardae402342020-01-25 10:09:57 +010056 </header>
Matthias Andreas Benkardd8f16442020-01-25 05:37:43 +010057
Matthias Andreas Benkardae402342020-01-25 10:09:57 +010058 <main>
Matthias Andreas Benkard2f537452020-01-27 21:23:00 +010059 <div data-editable data-name="wiki-content" id="wiki-content">
Matthias Andreas Benkard97130f92020-01-27 21:03:39 +010060 {#with page}{enrichedContent.raw}{/}
Matthias Andreas Benkardffb428e2020-01-25 10:47:36 +010061 </div>
Matthias Andreas Benkardae402342020-01-25 10:09:57 +010062 </main>
Matthias Andreas Benkardd8f16442020-01-25 05:37:43 +010063
Matthias Andreas Benkardae402342020-01-25 10:09:57 +010064 <hr>
Matthias Andreas Benkard9222efa2020-01-24 19:11:24 +010065
Matthias Andreas Benkardae402342020-01-25 10:09:57 +010066 <footer>
67 <a href="/wiki/{page.title}/revisions">Page revisions</a>
68 </footer>
69</article>
70{/body}
Matthias Andreas Benkardffb428e2020-01-25 10:47:36 +010071
Matthias Andreas Benkardae402342020-01-25 10:09:57 +010072{/include}