nieuws: toc option to prepend images
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 26 Nov 2018 18:19:25 +0000 (19:19 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 9 Dec 2018 03:48:12 +0000 (04:48 +0100)
Show yearly archive as gallery.

nieuws.inc.php
nieuws.php

index 1565c63af25994371a3367cb4ad177d52c79f6d4..40313e4b868eaca401db2331b303ae17261015b4 100644 (file)
@@ -130,14 +130,24 @@ function shownews($input, $limit = 1000)
        }
 }
 
-function printtoc($input)
+function printtoc($input, $class = FALSE)
 {
        if (!is_array($input)) $input = glob("$input/*.html");
-       print '<ul>';
+       print '<ul';
+       if ($class) printf(' class="%s"', $class);
+       print '>';
        foreach (array_reverse($input) as $page) {
                $article = new ArchiveArticle($page);
                $html = $article->safetitle;
-               $html .= sprintf(' <small class="date">%s</small>', $article->date);
+               $dateparts = $article->dateparts;
+               if ($class) {
+                       $dateparts[1] = NULL;  # omit year
+               }
+               $html .= sprintf(' <small class="date">%s</small>', showdate($dateparts));
+               if ($class == 'gallery' and $article->img) {
+                       $html = "<div>$html</div>";
+                       $html = sprintf('<img src="%s" />', $article->thumb(200)) . $html;
+               }
                $html = sprintf('<a href="/%s">%s</a>', $article->link, $html);
                print "<li><article>$html</article></li>\n";
        }
index 2b0151da20f0de37f327e68c1d6af6503dd74ceb..338a6b6693d2fdfee42b8303d09552888f10c723 100644 (file)
@@ -6,7 +6,7 @@ if (strpos($articles, '/') === FALSE) {
                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);
+                       printtoc($page, 'gallery');
                }
                return;
        }