X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/fa30f71a6ab727c90e0b600582f9944dfaa1ca89..fc74e45e15e3b1f17312f229496c25f7caff7d60:/nieuws.inc.php
diff --git a/nieuws.inc.php b/nieuws.inc.php
index 35ae092..6d84d1a 100644
--- a/nieuws.inc.php
+++ b/nieuws.inc.php
@@ -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
(
]*>)
\s*\z}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
+ if ( preg_match('{\n(
]*>)
}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
$this->img = $img[1][0];
return substr($rest, 0, $img[0][1]);
}
@@ -86,6 +86,13 @@ class ArchiveArticle
return $rest;
}
+ function teaser()
+ {
+ if (preg_match('{(.*?)
}s', $this->body, $bodyp)) {
+ return $bodyp[1];
+ }
+ }
+
function img()
{
$this->body;
@@ -109,34 +116,47 @@ class ArchiveArticle
function shownews($input, $limit = 1000)
{
if (!is_array($input)) $input = glob("$input/*.html");
- print ''."\n\n";
foreach (array_reverse($input) as $filename) {
$article = new ArchiveArticle($filename);
- print '- ';
+ print '';
if ($article->thumb) {
- printf('
', $article->thumb);
+ $img = preg_replace('{(?<= \b src="/) [^"]* }x', $article->thumb, $article->img);
+ $img = preg_replace('{(?= />$)}', ' class="left"', $img);
+ print $img;
}
- print '';
+ print '';
printf(
'
',
$article->link, $article->title, $article->date
);
print $article->body;
- print "\n\n";
+ print '
';
+ print "\n\n";
if (--$limit <= 0) break;
}
- print "
\n\n";
}
-function printtoc($input)
+function printtoc($input, $class = FALSE)
{
if (!is_array($input)) $input = glob("$input/*.html");
- print '';
+ print '';
foreach (array_reverse($input) as $page) {
$article = new ArchiveArticle($page);
- printf('- %s %s
',
- $article->link, $article->safetitle, $article->date);
+ $html = $article->safetitle;
+ $dateparts = $article->dateparts;
+ if ($class) {
+ $dateparts[1] = NULL; # omit year
+ }
+ $html .= sprintf(' %s', showdate($dateparts));
+ if ($class == 'gallery' and $article->img) {
+ $html = "$html
";
+ $html = sprintf('
', $article->thumb(200)) . $html;
+ }
+ $html = sprintf('%s', $article->link, $html);
+ print "- $html
\n";
}
print "
\n";
}