Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 1 | {@eu.mulk.mulkcms2.benki.wiki.WikiPageRevision page} |
Matthias Andreas Benkard | d8f1644 | 2020-01-25 05:37:43 +0100 | [diff] [blame] | 2 | |
Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 3 | {#include base.html} |
Matthias Andreas Benkard | ffb428e | 2020-01-25 10:47:36 +0100 | [diff] [blame] | 4 | |
Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 5 | {#title}{page.title} — Benki Wiki{/title} |
Matthias Andreas Benkard | c275812 | 2020-02-09 06:46:33 +0100 | [diff] [blame] | 6 | {#siteSection}Wiki{/siteSection} |
Matthias Andreas Benkard | 310e71f | 2020-02-09 10:39:45 +0100 | [diff] [blame] | 7 | {#wikiClass}this-page{/wikiClass} |
Matthias Andreas Benkard | c275812 | 2020-02-09 06:46:33 +0100 | [diff] [blame] | 8 | |
Matthias Andreas Benkard | 371164a | 2020-03-23 06:21:25 +0100 | [diff] [blame] | 9 | {#nav}{#navbar siteSection="Wiki" /}{/nav} |
| 10 | |
Matthias Andreas Benkard | ffb428e | 2020-01-25 10:47:36 +0100 | [diff] [blame] | 11 | {#head} |
| 12 | <link rel="stylesheet" type="text/css" href="/web_modules/ContentTools/build/content-tools.min.css" /> |
Matthias Andreas Benkard | 4bb21a5 | 2020-02-08 10:14:40 +0100 | [diff] [blame] | 13 | <script type="module" src="/web_modules/elix/define/ExpandablePanel.js" defer></script> |
Matthias Andreas Benkard | 93da53a | 2020-02-02 20:30:36 +0100 | [diff] [blame] | 14 | |
| 15 | <style type="text/css"> |
| 16 | #warning-panel { |
| 17 | background-color: lightcoral; |
| 18 | font-style: italic; |
| 19 | } |
| 20 | </style> |
| 21 | |
Matthias Andreas Benkard | 4bb21a5 | 2020-02-08 10:14:40 +0100 | [diff] [blame] | 22 | <script type="module" defer> |
Matthias Andreas Benkard | 578c865 | 2020-02-01 23:53:37 +0100 | [diff] [blame] | 23 | import ContentTools from "/web_modules/ContentTools.js"; |
Matthias Andreas Benkard | 2f53745 | 2020-01-27 21:23:00 +0100 | [diff] [blame] | 24 | |
Matthias Andreas Benkard | ffb428e | 2020-01-25 10:47:36 +0100 | [diff] [blame] | 25 | window.addEventListener('DOMContentLoaded', function() { |
| 26 | let editor = ContentTools.EditorApp.get(); |
| 27 | editor.init('*[data-editable]', 'data-name'); |
Matthias Andreas Benkard | 2f53745 | 2020-01-27 21:23:00 +0100 | [diff] [blame] | 28 | |
Matthias Andreas Benkard | d50bbb7 | 2020-01-27 05:53:07 +0100 | [diff] [blame] | 29 | editor.addEventListener('saved', async function (ev) { |
Matthias Andreas Benkard | 93da53a | 2020-02-02 20:30:36 +0100 | [diff] [blame] | 30 | document.getElementById("warning-panel").close(); |
| 31 | |
Matthias Andreas Benkard | d50bbb7 | 2020-01-27 05:53:07 +0100 | [diff] [blame] | 32 | let regions = ev.detail().regions; |
| 33 | if (Object.getOwnPropertyNames(regions).length === 0) { |
| 34 | // Nothing changed. |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | this.busy(true); |
| 39 | |
| 40 | let requestParams = new URLSearchParams(); |
| 41 | for (let name of Object.getOwnPropertyNames(regions)) { |
| 42 | requestParams.append(name, regions[name]); |
| 43 | } |
| 44 | |
Matthias Andreas Benkard | 97130f9 | 2020-01-27 21:03:39 +0100 | [diff] [blame] | 45 | let response = await fetch("/wiki/{page.title}", { |
Matthias Andreas Benkard | d50bbb7 | 2020-01-27 05:53:07 +0100 | [diff] [blame] | 46 | method: 'POST', |
| 47 | body: requestParams |
| 48 | }); |
Matthias Andreas Benkard | 97130f9 | 2020-01-27 21:03:39 +0100 | [diff] [blame] | 49 | |
Matthias Andreas Benkard | 93da53a | 2020-02-02 20:30:36 +0100 | [diff] [blame] | 50 | if (!response.ok) { |
| 51 | document.getElementById("warning-panel").open(); |
| 52 | document.getElementById("warning-text").innerText = "Failed to save page: " + response.statusText; |
| 53 | this.busy(false); |
| 54 | return; |
| 55 | } |
| 56 | |
Matthias Andreas Benkard | 2f53745 | 2020-01-27 21:23:00 +0100 | [diff] [blame] | 57 | let status = await response.json(); |
Matthias Andreas Benkard | 93da53a | 2020-02-02 20:30:36 +0100 | [diff] [blame] | 58 | if (status.status !== "ok") { |
| 59 | document.getElementById("warning-panel").open(); |
| 60 | document.getElementById("warning-text").innerText = "Failed to save page: " + JSON.stringify(status); |
| 61 | this.busy(false); |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | if (status.hasOwnProperty("content")) { |
| 66 | document.getElementById("wiki-content").innerHTML = status.content; |
Matthias Andreas Benkard | 2f53745 | 2020-01-27 21:23:00 +0100 | [diff] [blame] | 67 | } |
| 68 | |
Matthias Andreas Benkard | d50bbb7 | 2020-01-27 05:53:07 +0100 | [diff] [blame] | 69 | this.busy(false); |
| 70 | }); |
Matthias Andreas Benkard | ffb428e | 2020-01-25 10:47:36 +0100 | [diff] [blame] | 71 | }); |
| 72 | </script> |
| 73 | {/head} |
| 74 | |
Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 75 | {#body} |
| 76 | <article id="wiki-page"> |
| 77 | <header> |
Matthias Andreas Benkard | d50bbb7 | 2020-01-27 05:53:07 +0100 | [diff] [blame] | 78 | <div data-editable data-name="wiki-title"> |
| 79 | <h1>{page.title}</h1> |
| 80 | </div> |
Matthias Andreas Benkard | 93da53a | 2020-02-02 20:30:36 +0100 | [diff] [blame] | 81 | |
Matthias Andreas Benkard | c275812 | 2020-02-09 06:46:33 +0100 | [diff] [blame] | 82 | <elix-expandable-panel id="warning-panel" role="alert"><div id="warning-text"></div></elix-expandable-panel> |
Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 83 | </header> |
Matthias Andreas Benkard | d8f1644 | 2020-01-25 05:37:43 +0100 | [diff] [blame] | 84 | |
Matthias Andreas Benkard | c275812 | 2020-02-09 06:46:33 +0100 | [diff] [blame] | 85 | <section id="wiki-page-content"> |
Matthias Andreas Benkard | 2f53745 | 2020-01-27 21:23:00 +0100 | [diff] [blame] | 86 | <div data-editable data-name="wiki-content" id="wiki-content"> |
Matthias Andreas Benkard | 97130f9 | 2020-01-27 21:03:39 +0100 | [diff] [blame] | 87 | {#with page}{enrichedContent.raw}{/} |
Matthias Andreas Benkard | ffb428e | 2020-01-25 10:47:36 +0100 | [diff] [blame] | 88 | </div> |
Matthias Andreas Benkard | c275812 | 2020-02-09 06:46:33 +0100 | [diff] [blame] | 89 | </section> |
Matthias Andreas Benkard | d8f1644 | 2020-01-25 05:37:43 +0100 | [diff] [blame] | 90 | |
Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 91 | <hr> |
Matthias Andreas Benkard | 9222efa | 2020-01-24 19:11:24 +0100 | [diff] [blame] | 92 | |
Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 93 | <footer> |
| 94 | <a href="/wiki/{page.title}/revisions">Page revisions</a> |
| 95 | </footer> |
| 96 | </article> |
| 97 | {/body} |
Matthias Andreas Benkard | ffb428e | 2020-01-25 10:47:36 +0100 | [diff] [blame] | 98 | |
Matthias Andreas Benkard | ae40234 | 2020-01-25 10:09:57 +0100 | [diff] [blame] | 99 | {/include} |