Align metadata flow: data.txt-first admin, strict quote_da, teaser support, and modal ordering tweaks
This commit is contained in:
parent
752565a7a4
commit
78212227f3
4 changed files with 135 additions and 60 deletions
25
index.php
25
index.php
|
|
@ -61,9 +61,11 @@ function video_metadata($path){
|
|||
$base = pathinfo($path, PATHINFO_FILENAME);
|
||||
$meta = [
|
||||
'title' => nice_title($base),
|
||||
'teaser' => '',
|
||||
'date' => date('Y-m-d', filemtime($path)),
|
||||
'sort_date' => date('Y-m-d', filemtime($path)),
|
||||
'location' => '',
|
||||
'quote_da' => '',
|
||||
'description' => ''
|
||||
];
|
||||
|
||||
|
|
@ -79,8 +81,9 @@ function video_metadata($path){
|
|||
if (!str_contains($line, ':')) continue;
|
||||
[$k, $v] = array_map('trim', explode(':', $line, 2));
|
||||
$k = strtolower($k);
|
||||
if (in_array($k, ['title','date','location','place','description'], true)) {
|
||||
$meta[$k === 'place' ? 'location' : $k] = $v;
|
||||
if (in_array($k, ['title','teaser','date','location','place','description','quote_da'], true)) {
|
||||
$target = ($k === 'place') ? 'location' : $k;
|
||||
$meta[$target] = $target === 'quote_da' ? trim((string)$v, "\"“”") : $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -94,6 +97,7 @@ function video_metadata($path){
|
|||
foreach ($tags as $k => $v) $lower[strtolower((string)$k)] = $v;
|
||||
|
||||
if (!empty($lower['title'])) $meta['title'] = $lower['title'];
|
||||
if (!empty($lower['teaser'])) $meta['teaser'] = $lower['teaser'];
|
||||
if (!empty($lower['date'])) $meta['date'] = $lower['date'];
|
||||
if (!empty($lower['creation_time'])) {
|
||||
$meta['sort_date'] = substr((string)$lower['creation_time'], 0, 10);
|
||||
|
|
@ -105,6 +109,9 @@ function video_metadata($path){
|
|||
foreach (['description','synopsis'] as $k) {
|
||||
if (!empty($lower[$k])) { $meta['description'] = $lower[$k]; break; }
|
||||
}
|
||||
if (!empty($lower['quote_da'])) {
|
||||
$meta['quote_da'] = trim((string)$lower['quote_da'], "\"“”");
|
||||
}
|
||||
}
|
||||
|
||||
return $meta;
|
||||
|
|
@ -113,7 +120,7 @@ function video_metadata($path){
|
|||
function load_video_cache($videos){
|
||||
$cacheFile = __DIR__ . '/cache/videos.json';
|
||||
$cache = is_file($cacheFile) ? json_decode((string)file_get_contents($cacheFile), true) : [];
|
||||
if (!is_array($cache) || ($cache['version'] ?? 0) !== 2) $cache = [];
|
||||
if (!is_array($cache) || ($cache['version'] ?? 0) !== 4) $cache = [];
|
||||
$items = $cache['items'] ?? [];
|
||||
$newItems = [];
|
||||
$changed = false;
|
||||
|
|
@ -134,7 +141,7 @@ function load_video_cache($videos){
|
|||
|
||||
if ($changed) {
|
||||
file_put_contents($cacheFile, json_encode([
|
||||
'version' => 2,
|
||||
'version' => 4,
|
||||
'generated_at' => date('c'),
|
||||
'items' => $newItems
|
||||
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), LOCK_EX);
|
||||
|
|
@ -193,7 +200,9 @@ $videos = array_values(array_filter($videos, function($v) use ($videoCache, $key
|
|||
$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'] ?? '');
|
||||
|
|
@ -205,7 +214,7 @@ $videos = array_values(array_filter($videos, function($v) use ($videoCache, $key
|
|||
return ci_contains($location, $keywordValue);
|
||||
}
|
||||
|
||||
return ci_contains($title, $keywordValue) || ci_contains($description, $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));
|
||||
|
|
@ -242,6 +251,8 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : [];
|
|||
.video-row-head-mobile{display:none}
|
||||
.video-info .video-row-title{margin:0 0 .35rem}
|
||||
.video-info .meta{margin:0 0 .45rem}
|
||||
.description-teaser{margin:.15rem 0 .45rem;color:#EADFC9}
|
||||
.description-quote{margin:.15rem 0 .45rem;font-style:italic;font-size:.82rem;color:#D6D9DE}
|
||||
#videos .video-wrapper{align-self:start}
|
||||
#videos .video-info{align-self:start}
|
||||
#videos .video-info .description{margin-top:0}
|
||||
|
|
@ -263,7 +274,7 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : [];
|
|||
<section id="videos">
|
||||
<form method="get" class="filter-form">
|
||||
<div class="filter-input-wrap">
|
||||
<input name="q" value="<?=h($rawKeyword)?>" placeholder="Search title/description or use date=... / location=..." aria-label="Search articles">
|
||||
<input name="q" value="<?=h($rawKeyword)?>" placeholder="Search title/teaser/quote_da/description or use date=... / location=..." aria-label="Search articles">
|
||||
<a class="filter-clear-inside <?=$rawKeyword === '' ? 'is-empty' : ''?>" href="index.php" aria-label="Clear filter" title="Clear filter">×</a>
|
||||
</div>
|
||||
<button type="submit" class="filter-submit" aria-label="Filter">
|
||||
|
|
@ -312,7 +323,9 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : [];
|
|||
<span><a href="<?=h($dateFilterUrl)?>"><?=h($m['date'])?></a></span>
|
||||
<?php if(!empty($m['location'])): ?><span><a href="<?=h($locFilterUrl)?>"><?=h($m['location'])?></a></span><?php endif; ?>
|
||||
</p>
|
||||
<?php if(!empty($m['teaser'])): ?><p class="description-teaser"><?=h((string)$m['teaser'])?></p><?php endif; ?>
|
||||
<?php if(!empty($m['description'])): ?><p class="description"><?=nl2br(h($m['description']), false)?></p><?php endif; ?>
|
||||
<?php if(!empty($m['quote_da'])): ?><p class="description-quote">“<?=h(trim((string)$m['quote_da'], "\"“”"))?>”</p><?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue