nieuws: toc view option to show headlines in placeholder
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 3 Sep 2018 20:58:19 +0000 (22:58 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 3 Sep 2018 21:24:19 +0000 (23:24 +0200)
Allows overview features to be specified by static templates,
so pages can be dynamically customised.

Track default html with all options enabled as before on melding.

nieuws.php
nieuws/index.html [new file with mode: 0644]
nieuws/index.php

index 7127a545332171b144ebdb457396e5c1e38a5330..2b0151da20f0de37f327e68c1d6af6503dd74ceb 100644 (file)
@@ -2,8 +2,21 @@
 include_once 'nieuws.inc.php';
 $articles = (ltrim($Args, '/') ?: 'nieuws');
 if (strpos($articles, '/') === FALSE) {
+       if (@$Place['view'] === 'toc') {
+               foreach (array_reverse(glob("$articles/2???")) as $page) {
+                       $year = basename($page, '.html');
+                       printf('<h3><a href="/%s">%s</a></h3>'."\n", $page, $year);
+                       printtoc($page);
+               }
+               return;
+       }
        $articles .= '/????';
 }
+
+if (@$Place['view'] === 'toc') {
+       printtoc($articles);
+       return;
+}
 ob_start();
 shownews($articles, @$Place['n'] ?: 5);
 print getoutput();
diff --git a/nieuws/index.html b/nieuws/index.html
new file mode 100644 (file)
index 0000000..513237f
--- /dev/null
@@ -0,0 +1,16 @@
+<div class="nav right"><a href="/nieuws/feed" rel="alternate" title="Atom feed van nieuwsberichten" type="application/atom+xml">Feed</a></div>
+
+<div id="news">
+<h2>Nieuwsarchief</h2>
+[[nieuws view=toc]]
+
+<h3><a href="/nieuws/19">Eerder</a></h3>
+[[nieuws view=toc nieuws/19??]]
+
+<h3>Melding rapporteren</h3>
+[[contact subject=melding]]
+
+<form method="post">
+<p><textarea cols="60" name="body" rows="4"></textarea> <input type="submit" value="Versturen" /></p>
+</form>
+</div>
index 468de280f72cfd6a6cb480269256fa9f59621901..b54d5bd7a38a04e5fa0f7b8891d9a618266c5191 100644 (file)
@@ -40,42 +40,6 @@ if ($year) {
        return 1;
 }
 
-$html = ob_get_clean();
-printf('<div class="nav right"><a href="%s"%s>Feed</a></div>'."\n",
-       "/$Page/feed",
-       ' rel="alternate" title="Atom feed van nieuwsberichten" type="application/atom+xml"'
-);
-print $html;
-
-print '<div id="news">'."\n\n";
-
-foreach (array_reverse(glob("$Page/2???")) as $page) {
-       $year = basename($page, '.html');
-       printf('<h3><a href="/%s">%s</a></h3>'."\n", $page, $year);
-       printtoc($page);
-}
-
-if ($pages = glob("$Page/19??/*.html")) {
-       printf('<h3><a href="/%s">%s</a></h3>'."\n", "$Page/19", 'Eerder');
-       printtoc($pages);
-}
-
-print "</div>\n\n";
-
-if ($replyform) {
-       print "<h3>Melding rapporteren</h3>\n";
-       $_REQUEST['subject'] = 'melding';
-       require 'contact.php';
-?>
-<form method="post">
-<p>
-       <textarea name="body" cols=60 rows=4></textarea>
-       <input type="submit" value="Versturen" />
-</p>
-</form>
-<?php
-}
-
 if (!empty($User['admin'])) {
        print '<script src="/nieuws/edit.js"></script>'."\n";
 }