nieuws: fix block replacement of variable contents
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 1 Jan 2020 07:53:32 +0000 (08:53 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 5 Dec 2020 00:41:19 +0000 (01:41 +0100)
Restored as empty [[]] placeholders since previous commit.

edit/page.js
nieuws/index.php

index 3071844a96e685c64d8ae6328e81af773e940bc2..ac2288a07fceb1ef132958ef22e44fad7f57f409 100644 (file)
@@ -162,7 +162,12 @@ if (pagebody) {
                editlink.onclick = undefined;
                pagebody.setAttribute('contenteditable', true);
                pagebody.querySelectorAll('[data-dyn]').forEach(function (el) {
-                       el.outerHTML = '[[' + el.getAttribute('data-dyn') + ']]';
+                       let blockname = el.getAttribute('data-dyn');
+                       if (!blockname) {
+                               el.remove();
+                               return;
+                       }
+                       el.outerHTML = '[[' + blockname + ']]';
                });
                CKEDITOR.inline(pagebody, { customConfig: '' });
                document.body.className = 'edit';
index f74c632bd762ea06dab685c70ce9c41a6f4733fa..ff433d5d7b80001921a3d360b66a4796f98f4041 100644 (file)
@@ -15,6 +15,9 @@ if ($page and !is_numeric($page)) {
        if ($Article->dateparts) {
                $Place[1] = ' <small class="date">'.$Article->date.'</small>';
        }
+       else {
+               $Place[1] = '';
+       }
        print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Article->raw);
        if ($User->admin("edit $Page$Args")) {
                $taglist = [];