X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/b95195ed4540a07ac0f31c363101698ada841d67..2ac61542b2b7be587b9b5d0bc6b84a385b38914a:/nieuws.inc.php
diff --git a/nieuws.inc.php b/nieuws.inc.php
index 8af5694..524109d 100644
--- a/nieuws.inc.php
+++ b/nieuws.inc.php
@@ -5,15 +5,30 @@ $monthname = ['?',
'juli', 'augustus', 'september', 'oktober', 'november', 'december',
];
-function shownewsdate($url)
+function showdate($parts)
{
- if (!preg_match('(\d{4})/(\d{2})-(\d{2})->', $url, $parts)) return;
global $monthname;
return implode(' ', array_filter([
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('(\d{4})/(\d{2})-(\d{2})->', $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();
@@ -25,23 +40,41 @@ function shownewsarticle($url, $link = TRUE, $title = NULL)
$title = sprintf(
$link ? '
' : '%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".'![](%s)
', "/thumb/640x/".$image),
+ ]);
+ }
+
return preg_replace('{(.*?)
}', $title, $html);
}
function shownews($input, $limit = 1000)
{
if (!is_array($input)) $input = glob("$input/*.html");
- foreach (array_reverse($input) as $url) {
- print "";
+ print ''."\n\n";
+ foreach (array_reverse($input) as $filename) {
+ $url = preg_replace('/\.html$/', '', $filename);
+ print '- ';
+ if ($image = shownewsimage($url)) {
+ printf('
', "/thumb/300x/".$image);
+ }
+ print '';
ob_start();
- include $url;
+ include $filename;
print shownewsarticle($url);
- print "\n\n";
+ print "
\n\n";
if (--$limit <= 0) break;
}
+ print "\n\n";
}
function printtoc($input)