nieuws: hide text after cover image in overviews
[minimedit.git] / nieuws.inc.php
index 35ae0925b87d443ccf1d6e722330599a692abe39..b58def7b7302bdad9ac4e41cc7e93c1155d6cbb2 100644 (file)
@@ -9,7 +9,7 @@ function showdate($parts)
 {
        global $monthname;
        return implode(' ', array_filter([
-               intval($parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1],
+               intval(@$parts[3]), $parts[2] > 0 ? $monthname[intval($parts[2])] : '', $parts[1],
                count($parts) > 6 ? "$parts[4]:$parts[5]" : '',
        ]));
 }
@@ -60,7 +60,7 @@ class ArchiveArticle
 
        function dateparts()
        {
-               preg_match('</(\d{4})[/-](\d{2})-(\d{2})->', $this->page, $ymd);
+               preg_match('< / (\d{4}) [/-] (\d{2}) (?:- (\d{2}) )? - >x', $this->page, $ymd);
                return $ymd;
        }
 
@@ -78,7 +78,7 @@ class ArchiveArticle
        {
                $this->title;
                $rest = fread($this->file, filesize($this->page));
-               if ( preg_match('{\n<p>(<img [^>]*>)</p>\s*\z}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
+               if ( preg_match('{\n<p>(<img [^>]*>)</p>}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
                        $this->img = $img[1][0];
                        return substr($rest, 0, $img[0][1]);
                }
@@ -114,7 +114,9 @@ function shownews($input, $limit = 1000)
                $article = new ArchiveArticle($filename);
                print '<li>';
                if ($article->thumb) {
-                       printf('<img src="/%s" class="left" />', $article->thumb);
+                       $img = preg_replace('{(?<= \b src="/) [^"]* }x', $article->thumb, $article->img);
+                       $img = preg_replace('{(?= />$)}', ' class="left"', $img);
+                       print $img;
                }
                print '<article>';
                printf(