+<?php
+$monthname = ['?',
+ 'januari', 'februari', 'maart', 'april', 'mei', 'juni',
+ 'juli', 'augustus', 'september', 'oktober', 'november', 'december',
+];
+
+function shownewsdate($url)
+{
+ $parts = pathinfo($url);
+ $year = pathinfo($parts['dirname'], PATHINFO_FILENAME);
+ @list ($month, $day) = explode('-', $parts['filename'], 3);
+ global $monthname;
+ return sprintf('<small class="date">%s %s %s</small>',
+ intval($day), $monthname[intval($month)], $year);
+}
+
+function shownewsarticle($url, $link = TRUE, $title = NULL)
+{
+ $html = ob_get_clean();
+ $date = shownewsdate($url);
+ ob_start();
+ print $title ?: '\1';
+ print '[[1]]';
+
+ $title = sprintf(
+ $link ? '<h3><a href="/%2$s">%s</a></h3>' : '<h2>%s</h2>',
+ getoutput([1 => ' <small class="date">'.$date.'</small>']),
+ preg_replace('/\.html$/', '', $url)
+ );
+ return preg_replace('{<h2>(.*?)</h2>}', $title, $html);
+}
+
+function shownews($root, $limit = 5)
+{
+ foreach (array_reverse(glob("$root/*/*.html")) as $url) {
+ print "<article>";
+ ob_start();
+ include $url;
+ print shownewsarticle($url);
+ print "</article>\n\n";
+
+ if (--$limit <= 0) break;
+ }
+}