From 9217f874b4649370c87877129956add247587e7a Mon Sep 17 00:00:00 2001 From: hbrain Date: Tue, 2 Jun 2026 07:44:54 +0200 Subject: [PATCH] implement article permalinks and hide search bar conditionally on index.php --- index.php | 113 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 48 deletions(-) diff --git a/index.php b/index.php index 4f8344b..5b4f3cd 100644 --- a/index.php +++ b/index.php @@ -178,56 +178,67 @@ usort($videos, function($a, $b) use ($videoCache) { return $bd <=> $ad; }); -$rawKeyword = trim((string)($_GET['q'] ?? '')); +$articleId = trim((string)($_GET['id'] ?? '')); -// Backward compatibility with older filter/query formats. -if ($rawKeyword === '') { - $legacyTitle = trim((string)($_GET['f_title'] ?? '')); - $legacyDate = trim((string)($_GET['f_date'] ?? '')); - $legacyLocation = trim((string)($_GET['f_location'] ?? '')); - $legacyJob = trim((string)($_GET['job'] ?? '')); +if ($articleId !== '') { + $videos = array_values(array_filter($videos, function($v) use ($articleId) { + return pathinfo($v, PATHINFO_FILENAME) === $articleId; + })); + $rawKeyword = ''; + $keywordType = 'general'; + $keywordValue = ''; +} else { + $rawKeyword = trim((string)($_GET['q'] ?? '')); - if ($legacyTitle !== '') $rawKeyword = $legacyTitle; - elseif ($legacyDate !== '') $rawKeyword = 'date=' . $legacyDate; - elseif ($legacyLocation !== '') $rawKeyword = 'location=' . $legacyLocation; - elseif ($legacyJob !== '') { - $legacy = preg_replace('/^\d{8}[_-]/', '', $legacyJob); - $rawKeyword = nice_title($legacy ?: $legacyJob); + // Backward compatibility with older filter/query formats. + if ($rawKeyword === '') { + $legacyTitle = trim((string)($_GET['f_title'] ?? '')); + $legacyDate = trim((string)($_GET['f_date'] ?? '')); + $legacyLocation = trim((string)($_GET['f_location'] ?? '')); + $legacyJob = trim((string)($_GET['job'] ?? '')); + + if ($legacyTitle !== '') $rawKeyword = $legacyTitle; + elseif ($legacyDate !== '') $rawKeyword = 'date=' . $legacyDate; + elseif ($legacyLocation !== '') $rawKeyword = 'location=' . $legacyLocation; + elseif ($legacyJob !== '') { + $legacy = preg_replace('/^\d{8}[_-]/', '', $legacyJob); + $rawKeyword = nice_title($legacy ?: $legacyJob); + } } + + $keywordType = 'general'; + $keywordValue = $rawKeyword; + if ($rawKeyword !== '' && preg_match('/^\s*(date|location|place)\s*=\s*(.+)\s*$/i', $rawKeyword, $m)) { + $keywordType = lower_text((string)$m[1]); + if ($keywordType === 'place') $keywordType = 'location'; + $keywordValue = trim((string)$m[2]); + } + + $videos = array_values(array_filter($videos, function($v) use ($videoCache, $keywordType, $keywordValue) { + if ($keywordValue === '') return true; + + $name = basename($v); + $m = $videoCache[$name]['metadata'] ?? video_metadata($v); + + $title = (string)($m['title'] ?? ''); + $teaser = (string)($m['teaser'] ?? ''); + $description = (string)($m['description'] ?? ''); + $quoteDa = (string)($m['quote_da'] ?? ''); + $date = (string)($m['date'] ?? ''); + $sortDate = (string)($m['sort_date'] ?? ''); + $location = (string)($m['location'] ?? ''); + + if ($keywordType === 'date') { + return ci_contains($date, $keywordValue) || ci_contains($sortDate, $keywordValue); + } + if ($keywordType === 'location') { + return ci_contains($location, $keywordValue); + } + + return ci_contains($title, $keywordValue) || ci_contains($teaser, $keywordValue) || ci_contains($quoteDa, $keywordValue) || ci_contains($description, $keywordValue); + })); } -$keywordType = 'general'; -$keywordValue = $rawKeyword; -if ($rawKeyword !== '' && preg_match('/^\s*(date|location|place)\s*=\s*(.+)\s*$/i', $rawKeyword, $m)) { - $keywordType = lower_text((string)$m[1]); - if ($keywordType === 'place') $keywordType = 'location'; - $keywordValue = trim((string)$m[2]); -} - -$videos = array_values(array_filter($videos, function($v) use ($videoCache, $keywordType, $keywordValue) { - if ($keywordValue === '') return true; - - $name = basename($v); - $m = $videoCache[$name]['metadata'] ?? video_metadata($v); - - $title = (string)($m['title'] ?? ''); - $teaser = (string)($m['teaser'] ?? ''); - $description = (string)($m['description'] ?? ''); - $quoteDa = (string)($m['quote_da'] ?? ''); - $date = (string)($m['date'] ?? ''); - $sortDate = (string)($m['sort_date'] ?? ''); - $location = (string)($m['location'] ?? ''); - - if ($keywordType === 'date') { - return ci_contains($date, $keywordValue) || ci_contains($sortDate, $keywordValue); - } - if ($keywordType === 'location') { - return ci_contains($location, $keywordValue); - } - - return ci_contains($title, $keywordValue) || ci_contains($teaser, $keywordValue) || ci_contains($quoteDa, $keywordValue) || ci_contains($description, $keywordValue); -})); - $page = max(1, (int)($_GET['page'] ?? 1)); $per = $config['items_per_page']; $total = count($videos); @@ -321,6 +332,8 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)]; .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0} .filter-summary{color:#A0A4AB;font-size:.9rem;margin:0 0 .8rem} .video-row-title{font-size:1.35rem;line-height:1.2;color:#F3F4F6} +.video-row-title a{color:inherit;text-decoration:none} +.video-row-title a:hover{text-decoration:underline} .video-row-head-mobile{display:none} .video-info .video-row-title{margin:0 0 .35rem} .video-info .meta{margin:0 0 .45rem} @@ -348,6 +361,7 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];
+
@@ -358,6 +372,7 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)]; Filter +

Showing article(s) @@ -369,6 +384,8 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];

$base]); $url = $config['public_videos'].'/'.rawurlencode($name); $m = $videoCache[$name]['metadata'] ?? video_metadata($v); $posterUrl = video_thumb_public_url($config, $name); @@ -377,7 +394,7 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)]; ?>
-

+

@@ -395,7 +412,7 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];

-

+

@@ -420,4 +437,4 @@ $siteHeaderTitle = $headerTitles[array_rand($headerTitles)];

- + \ No newline at end of file