X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/3da476bb04d8dcb7545a5c7eb328054c7ee20df3..ae841e9139f7eb89f8f5fc2242d4b0d7c121418a:/nieuws.inc.php diff --git a/nieuws.inc.php b/nieuws.inc.php index f9fec6a..524109d 100644 --- a/nieuws.inc.php +++ b/nieuws.inc.php @@ -1,18 +1,34 @@ ', $url, $parts)) return; global $monthname; return implode(' ', array_filter([ - intval($parts[3]), $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]" : '', ])); } +function shownewsdate($url) +{ + if (!preg_match('', $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(); @@ -24,29 +40,48 @@ function shownewsarticle($url, $link = TRUE, $title = NULL) $title = sprintf( $link ? '

%s

' : '

%s

', getoutput([1 => ' '.$date.'']), - preg_replace('/\.html$/', '', $url) + $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".'

', "/thumb/640x/".$image), + ]); + } + return preg_replace('{

(.*?)

}', $title, $html); } -function shownews($root, $limit = 5) +function shownews($input, $limit = 1000) { - if (strpos($root, '/') === FALSE) $root .= '/*'; - foreach (array_reverse(glob("$root/*.html")) as $url) { - print "
"; + if (!is_array($input)) $input = glob("$input/*.html"); + print '
\n\n"; if (--$limit <= 0) break; } + print "\n\n"; } -function printtoc($root) +function printtoc($input) { + if (!is_array($input)) $input = glob("$input/*.html"); print '