+++ /dev/null
-<?php
-global $monthname;
-$monthname = ['?',
- 'januari', 'februari', 'maart', 'april', 'mei', 'juni',
- 'juli', 'augustus', 'september', 'oktober', 'november', 'december',
-];
-
-function showdate($parts)
-{
- global $monthname;
- return implode(' ', array_filter([
- intval($parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1],
- ]));
-}
-
-function shownewsdate($url)
-{
- if (!preg_match('</(\d{4})/(\d{2})-(\d{2})->', $url, $parts)) return;
- return showdate($parts);
-}
-
-function shownewsimage($url)
-{
- foreach (['jpg', 'png'] as $ext) {
- if (file_exists("$url.$ext")) {
- return "$url.$ext";
- }
- }
-}
-
-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>']),
- $url
- );
-
- if (!$link and $image = shownewsimage($url)) {
- global $Place;
- $Place['image'] = "https://lijtweg.nl/thumb/600x/".$image;
- ob_start();
- print '[[1]]';
- $html .= getoutput([
- 1 => sprintf("\n".'<p><img src="%s" /></p>', "/thumb/640x/".$image),
- ]);
- }
-
- return preg_replace('{<h2>(.*?)</h2>}', $title, $html);
-}
-
-function shownews($input, $limit = 1000)
-{
- if (!is_array($input)) $input = glob("$input/*.html");
- print '<ul class="left">'."\n\n";
- foreach (array_reverse($input) as $filename) {
- $url = preg_replace('/\.html$/', '', $filename);
- print '<li>';
- if ($image = shownewsimage($url)) {
- printf('<img src="%s" class="left" />', "/thumb/300x/".$image);
- }
- print '<article>';
- ob_start();
- include $filename;
- print shownewsarticle($url);
- print "</article></li>\n\n";
-
- if (--$limit <= 0) break;
- }
- print "</ul>\n\n";
-}
-
-function printtoc($input)
-{
- if (!is_array($input)) $input = glob("$input/*.html");
- print '<ul>';
- foreach (array_reverse($input) as $page) {
- $title = fgets(fopen($page, 'r'));
- $title = strip_tags($title);
- $linkurl = preg_replace('/\.html$/', '', $page);
- printf('<li><a href="/%s">%s <small class="date">%s</small></a></li>',
- $linkurl, $title, shownewsdate($linkurl));
- }
- print "</ul>\n";
-}