Add index filters and title-targeted push links; polish clear icon control

This commit is contained in:
hbrain 2026-05-31 14:38:51 +02:00
parent de1c753a42
commit d407c40d75
2 changed files with 213 additions and 36 deletions

View file

@ -68,6 +68,11 @@ function mvlog_write_temp_push_json(array $cfg): ?string
return $tmp;
}
function mvlog_nice_title(string $s): string
{
return trim(ucwords(str_replace(['_', '-'], ' ', $s)));
}
function try_send_show_notification($job, $jobdir, $mvlog_root = null, $logfile = null)
{
if ($mvlog_root === null) $mvlog_root = dirname(__DIR__);
@ -122,25 +127,38 @@ function try_send_show_notification($job, $jobdir, $mvlog_root = null, $logfile
return false;
}
// Determine a title/url for the notification. Prefer existing output filename if present.
$title = preg_replace('/_+/', ' ', $job);
$title = ucwords($title);
// Determine article title (used both in notification text and filtered URL).
$articleTitle = mvlog_nice_title((string)$job);
if (preg_match('/^\d{8}[_-](.+)$/', (string)$job, $m)) {
$articleTitle = mvlog_nice_title((string)$m[1]);
}
$state_file = $jobdir . '/.movmaker-state.json';
if (is_file($state_file)) {
$state = json_decode(@file_get_contents($state_file), true) ?: [];
if (!empty($state['output']) && is_string($state['output'])) {
$out = pathinfo($state['output'], PATHINFO_FILENAME);
if ($out) {
$title = preg_replace('/_+/', ' ', $out);
$title = ucwords($title);
if (preg_match('/^\d{8}[_-](.+)$/', (string)$out, $m)) {
$articleTitle = mvlog_nice_title((string)$m[1]);
} else {
$articleTitle = mvlog_nice_title((string)$out);
}
}
}
}
if ($articleTitle === '') $articleTitle = mvlog_nice_title((string)$job);
$filterUrl = 'https://bubulescu.org/mvlog/?' . http_build_query([
'f_title' => $articleTitle,
'f_exact' => '1',
]);
$payload = json_encode([
'title' => 'Show enabled',
'body' => $title,
'url' => "https://bubulescu.org/mvlog/?job={$job}",
'title' => $articleTitle,
'body' => 'New MVLog article is now visible',
'url' => $filterUrl,
'tag' => "mvlog-show-{$job}",
], JSON_UNESCAPED_UNICODE);