From 7f45193a6f7beaecba2c17324c31588ebf6cd916 Mon Sep 17 00:00:00 2001 From: hbrain Date: Sun, 31 May 2026 15:11:49 +0200 Subject: [PATCH] Simplify index keyword filter UI and unify q-based push target URLs --- index.php | 114 ++++++++++++++++++++++++++-------------------- lib/send_push.php | 3 +- 2 files changed, 65 insertions(+), 52 deletions(-) diff --git a/index.php b/index.php index a23358f..f5282fd 100644 --- a/index.php +++ b/index.php @@ -125,40 +125,52 @@ usort($videos, function($a, $b) use ($videoCache) { return $bd <=> $ad; }); -$filters = [ - 'f_title' => trim((string)($_GET['f_title'] ?? '')), - 'f_date' => trim((string)($_GET['f_date'] ?? '')), - 'f_location' => trim((string)($_GET['f_location'] ?? '')), -]; -$titleExact = !empty($_GET['f_exact']) && (string)$_GET['f_exact'] === '1'; +$rawKeyword = trim((string)($_GET['q'] ?? '')); -// Backward compatibility with old push URL format (?job=...) -$legacyJob = trim((string)($_GET['job'] ?? '')); -if ($filters['f_title'] === '' && $legacyJob !== '') { - $legacy = preg_replace('/^\d{8}[_-]/', '', $legacyJob); - $filters['f_title'] = 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); + } } -$videos = array_values(array_filter($videos, function($v) use ($videoCache, $filters) { +$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'] ?? ''); + $description = (string)($m['description'] ?? ''); $date = (string)($m['date'] ?? ''); $sortDate = (string)($m['sort_date'] ?? ''); $location = (string)($m['location'] ?? ''); - if ($filters['f_title'] !== '') { - if ($titleExact) { - if (lower_text(trim($title)) !== lower_text(trim($filters['f_title']))) return false; - } else { - if (stripos($title, $filters['f_title']) === false) return false; - } + if ($keywordType === 'date') { + return stripos($date, $keywordValue) !== false || stripos($sortDate, $keywordValue) !== false; + } + if ($keywordType === 'location') { + return stripos($location, $keywordValue) !== false; } - if ($filters['f_date'] !== '' && stripos($date, $filters['f_date']) === false && stripos($sortDate, $filters['f_date']) === false) return false; - if ($filters['f_location'] !== '' && stripos($location, $filters['f_location']) === false) return false; - return true; + return stripos($title, $keywordValue) !== false || stripos($description, $keywordValue) !== false; })); $page = max(1, (int)($_GET['page'] ?? 1)); @@ -168,9 +180,8 @@ $pages = max(1, (int)ceil($total / $per)); $page = min($page, $pages); $slice = array_slice($videos, ($page - 1) * $per, $per); -$activeFilterCount = count(keep_non_empty($filters)); -$baseParams = keep_non_empty($filters); -if ($titleExact && ($filters['f_title'] ?? '') !== '') $baseParams['f_exact'] = '1'; +$activeFilterCount = ($keywordValue !== '') ? 1 : 0; +$baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : []; ?> @@ -182,17 +193,21 @@ if ($titleExact && ($filters['f_title'] ?? '') !== '') $baseParams['f_exact'] = @@ -200,17 +215,14 @@ if ($titleExact && ($filters['f_title'] ?? '') !== '') $baseParams['f_exact'] =
- - - - × - +
+ + × +
+

@@ -225,11 +237,18 @@ if ($titleExact && ($filters['f_title'] ?? '') !== '') $baseParams['f_exact'] = $name = basename($v); $url = $config['public_videos'].'/'.rawurlencode($name); $m = $videoCache[$name]['metadata'] ?? video_metadata($v); - $dateFilterUrl = query_url(array_merge($baseParams, ['f_date' => (string)($m['date'] ?? '')])); - $locFilterUrl = query_url(array_merge($baseParams, ['f_location' => (string)($m['location'] ?? '')])); + $dateFilterUrl = query_url(['q' => 'date=' . (string)($m['date'] ?? '')]); + $locFilterUrl = query_url(['q' => 'location=' . (string)($m['location'] ?? '')]); ?>

+
+

+

+ + +

+
-

-

- - -

diff --git a/lib/send_push.php b/lib/send_push.php index cb5f1b3..c06107d 100644 --- a/lib/send_push.php +++ b/lib/send_push.php @@ -151,8 +151,7 @@ function try_send_show_notification($job, $jobdir, $mvlog_root = null, $logfile if ($articleTitle === '') $articleTitle = mvlog_nice_title((string)$job); $filterUrl = 'https://bubulescu.org/mvlog/?' . http_build_query([ - 'f_title' => $articleTitle, - 'f_exact' => '1', + 'q' => $articleTitle, ]); $payload = json_encode([