nieuws: first paragraph teaser as page description
[minimedit.git] / nieuws.inc.php
index 1565c63af25994371a3367cb4ad177d52c79f6d4..6d84d1ac54b5930a19f2f26af75dcc13a96d6c14 100644 (file)
@@ -86,6 +86,13 @@ class ArchiveArticle
                return $rest;
        }
 
+       function teaser()
+       {
+               if (preg_match('{<p>(.*?)</p>}s', $this->body, $bodyp)) {
+                       return $bodyp[1];
+               }
+       }
+
        function img()
        {
                $this->body;
@@ -130,14 +137,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";
        }