fix: Magazine card wasn't working.
This commit is contained in:
+113
-31
@@ -156,6 +156,33 @@ function export_take_entries(array $entries, callable $filter, int $limit = 4):
|
|||||||
return $picked;
|
return $picked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function export_programme_label(array $programme): string {
|
||||||
|
if (export_programme_has_category($programme, ['document', 'docu', 'biopic', 'history', 'histoire'])) {
|
||||||
|
return 'Documentaire';
|
||||||
|
}
|
||||||
|
if (export_programme_is_series($programme)) {
|
||||||
|
return 'Serie';
|
||||||
|
}
|
||||||
|
if (export_programme_duration($programme) >= 80) {
|
||||||
|
return 'Film';
|
||||||
|
}
|
||||||
|
return 'Selection';
|
||||||
|
}
|
||||||
|
|
||||||
|
function export_entry_tease(array $entry): string {
|
||||||
|
$programme = $entry['programme'];
|
||||||
|
if (!empty($programme['subtitle'])) {
|
||||||
|
return $programme['subtitle'];
|
||||||
|
}
|
||||||
|
if (!empty($programme['categories'])) {
|
||||||
|
return implode(' · ', array_slice($programme['categories'], 0, 3));
|
||||||
|
}
|
||||||
|
if (!empty($programme['desc'])) {
|
||||||
|
return mb_strimwidth($programme['desc'], 0, 120, '…');
|
||||||
|
}
|
||||||
|
return 'A suivre sur ' . $entry['channel_name'];
|
||||||
|
}
|
||||||
|
|
||||||
function export_build_magazine(array $channels): array {
|
function export_build_magazine(array $channels): array {
|
||||||
$all = [];
|
$all = [];
|
||||||
foreach ($channels as $channel) {
|
foreach ($channels as $channel) {
|
||||||
@@ -180,6 +207,11 @@ function export_build_magazine(array $channels): array {
|
|||||||
$movies = export_take_entries($all, static fn($entry) => !export_programme_is_series($entry['programme']) && export_programme_duration($entry['programme']) >= 80, 4);
|
$movies = export_take_entries($all, static fn($entry) => !export_programme_is_series($entry['programme']) && export_programme_duration($entry['programme']) >= 80, 4);
|
||||||
$late_picks = export_take_entries($all, static fn($entry) => (int) $entry['programme']['start']->format('H') >= 21, 4);
|
$late_picks = export_take_entries($all, static fn($entry) => (int) $entry['programme']['start']->format('H') >= 21, 4);
|
||||||
$docs = export_take_entries($all, static fn($entry) => export_programme_has_category($entry['programme'], ['document', 'biopic', 'history', 'histoire']), 4);
|
$docs = export_take_entries($all, static fn($entry) => export_programme_has_category($entry['programme'], ['document', 'biopic', 'history', 'histoire']), 4);
|
||||||
|
$premieres = export_take_entries(
|
||||||
|
$all,
|
||||||
|
static fn($entry) => export_programme_is_series($entry['programme']) && !empty($entry['programme']['subtitle']),
|
||||||
|
4
|
||||||
|
);
|
||||||
|
|
||||||
$by_channel = [];
|
$by_channel = [];
|
||||||
foreach ($channels as $channel) {
|
foreach ($channels as $channel) {
|
||||||
@@ -190,30 +222,45 @@ function export_build_magazine(array $channels): array {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$cards = [
|
$sections = [
|
||||||
[
|
[
|
||||||
|
'slug' => 'top-picks',
|
||||||
'title' => 'Ce soir a la tele',
|
'title' => 'Ce soir a la tele',
|
||||||
'kicker' => 'Selection de la redaction',
|
'kicker' => 'Selection de la redaction',
|
||||||
|
'intro' => 'Les programmes qui donnent envie de garder la tele allumee ce soir.',
|
||||||
'items' => array_slice($highlights, 0, 4),
|
'items' => array_slice($highlights, 0, 4),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'title' => 'Series en diffusion',
|
'slug' => 'series',
|
||||||
|
'title' => 'Nouvelles series diffusees',
|
||||||
'kicker' => 'Episodes et rendez-vous',
|
'kicker' => 'Episodes et rendez-vous',
|
||||||
'items' => $series ?: array_slice($highlights, 0, 4),
|
'intro' => 'Les feuilletons, rediffusions premium et lancements du moment.',
|
||||||
|
'items' => $premieres ?: ($series ?: array_slice($highlights, 0, 4)),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'slug' => 'movies',
|
||||||
'title' => 'Films de la selection',
|
'title' => 'Films de la selection',
|
||||||
'kicker' => 'Longs formats',
|
'kicker' => 'Longs formats',
|
||||||
|
'intro' => 'Le bloc cinema de la journee, entre classiques, blockbusters et belles surprises.',
|
||||||
'items' => $movies ?: array_slice($highlights, 0, 4),
|
'items' => $movies ?: array_slice($highlights, 0, 4),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
'slug' => 'docs',
|
||||||
'title' => 'Docs et recits de vie',
|
'title' => 'Docs et recits de vie',
|
||||||
'kicker' => 'Documentaires / biopics',
|
'kicker' => 'Documentaires / biopics',
|
||||||
|
'intro' => 'Pour les amateurs de recits, d histoires vraies et de programmes a contexte.',
|
||||||
'items' => $docs ?: $late_picks ?: array_slice($highlights, 0, 4),
|
'items' => $docs ?: $late_picks ?: array_slice($highlights, 0, 4),
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'slug' => 'prime',
|
||||||
|
'title' => 'Prime time',
|
||||||
|
'kicker' => 'A partir de 21h',
|
||||||
|
'intro' => 'Les rendez-vous les plus costauds de la tranche du soir.',
|
||||||
|
'items' => $late_picks ?: array_slice($highlights, 0, 4),
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
return ['highlights' => $highlights, 'channels' => $by_channel, 'cards' => $cards];
|
return ['lead' => $highlights[0] ?? null, 'highlights' => $highlights, 'channels' => $by_channel, 'sections' => $sections];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sources = array_values($config['epg_sources'] ?? []);
|
$sources = array_values($config['epg_sources'] ?? []);
|
||||||
@@ -302,7 +349,7 @@ $magazine = export_build_magazine($visible_channels);
|
|||||||
.mag-title{font-family:'IM Fell English',serif;font-size:38px;line-height:1.02;margin-bottom:10px}
|
.mag-title{font-family:'IM Fell English',serif;font-size:38px;line-height:1.02;margin-bottom:10px}
|
||||||
.mag-meta{font-family:'Share Tech Mono',monospace;font-size:11px;color:var(--ink-soft);letter-spacing:.04em;margin-bottom:10px}
|
.mag-meta{font-family:'Share Tech Mono',monospace;font-size:11px;color:var(--ink-soft);letter-spacing:.04em;margin-bottom:10px}
|
||||||
.mag-desc{font-size:14px;line-height:1.45;color:var(--ink-soft)}
|
.mag-desc{font-size:14px;line-height:1.45;color:var(--ink-soft)}
|
||||||
.mag-side-list,.mag-channels,.mag-cards{display:grid;gap:14px}
|
.mag-side-list,.mag-channels,.mag-sections{display:grid;gap:14px}
|
||||||
.mag-mini-title{font-size:18px;font-weight:700;line-height:1.08}
|
.mag-mini-title{font-size:18px;font-weight:700;line-height:1.08}
|
||||||
.mag-mini{padding-top:12px;border-top:1px dashed var(--line)}
|
.mag-mini{padding-top:12px;border-top:1px dashed var(--line)}
|
||||||
.mag-mini:first-child{padding-top:0;border-top:none}
|
.mag-mini:first-child{padding-top:0;border-top:none}
|
||||||
@@ -315,9 +362,25 @@ $magazine = export_build_magazine($visible_channels);
|
|||||||
.mag-item:first-child{padding-top:0;border-top:none}
|
.mag-item:first-child{padding-top:0;border-top:none}
|
||||||
.mag-time{font-family:'Share Tech Mono',monospace;font-size:11px;color:var(--accent-2)}
|
.mag-time{font-family:'Share Tech Mono',monospace;font-size:11px;color:var(--accent-2)}
|
||||||
.mag-item-title{font-size:15px;font-weight:700;line-height:1.08}
|
.mag-item-title{font-size:15px;font-weight:700;line-height:1.08}
|
||||||
.mag-card{background:rgba(255,255,255,.35);border:1px solid var(--line);padding:14px}
|
.mag-sections{grid-template-columns:repeat(2,minmax(0,1fr))}
|
||||||
.mag-cards{grid-template-columns:repeat(2,minmax(0,1fr))}
|
.mag-section{background:rgba(255,255,255,.48);border:1px solid var(--line);padding:18px;position:relative;overflow:hidden}
|
||||||
.mag-card.featured{background:linear-gradient(180deg,rgba(170,66,49,.12),rgba(255,255,255,.35))}
|
.mag-section::before{content:'';position:absolute;left:0;top:0;bottom:0;width:6px;background:linear-gradient(180deg,var(--accent),rgba(170,66,49,.1))}
|
||||||
|
.mag-section.featured{background:linear-gradient(180deg,rgba(170,66,49,.16),rgba(255,255,255,.48))}
|
||||||
|
.mag-section-head{padding-left:8px;margin-bottom:12px}
|
||||||
|
.mag-section-title{font-family:'IM Fell English',serif;font-size:32px;line-height:1;margin:0 0 8px}
|
||||||
|
.mag-section-intro{font-size:13px;line-height:1.45;color:var(--ink-soft);max-width:44ch}
|
||||||
|
.mag-spotlight{display:grid;grid-template-columns:110px 1fr;gap:14px;padding:14px 0;border-top:1px solid rgba(38,70,83,.15);border-bottom:1px solid rgba(38,70,83,.15);margin-bottom:12px}
|
||||||
|
.mag-spotlight-time{font-family:'Share Tech Mono',monospace;font-size:12px;color:var(--accent-2);letter-spacing:.06em}
|
||||||
|
.mag-badge{display:inline-flex;align-items:center;padding:4px 8px;background:#f1dfc2;color:#5f2e20;font-family:'Share Tech Mono',monospace;font-size:10px;letter-spacing:.08em;text-transform:uppercase;border:1px solid rgba(170,66,49,.22);margin-bottom:8px}
|
||||||
|
.mag-spotlight-title{font-size:24px;font-weight:700;line-height:1.03;margin-bottom:6px}
|
||||||
|
.mag-spotlight-tease{font-size:13px;line-height:1.45;color:var(--ink-soft)}
|
||||||
|
.mag-briefs{display:grid;gap:10px}
|
||||||
|
.mag-brief{display:grid;grid-template-columns:74px 1fr;gap:10px;padding-top:10px;border-top:1px dashed var(--line)}
|
||||||
|
.mag-brief:first-child{padding-top:0;border-top:none}
|
||||||
|
.mag-brief-time{font-family:'Share Tech Mono',monospace;font-size:11px;color:var(--accent-2)}
|
||||||
|
.mag-brief-title{font-size:16px;font-weight:700;line-height:1.08}
|
||||||
|
.mag-brief-tease{font-size:12px;color:var(--ink-soft);line-height:1.35;margin-top:2px}
|
||||||
|
.mag-footer-title{margin-top:8px}
|
||||||
.timeline-wrap{display:grid;gap:14px}
|
.timeline-wrap{display:grid;gap:14px}
|
||||||
.timeline-row{display:grid;grid-template-columns:180px 1fr;gap:14px;align-items:stretch}
|
.timeline-row{display:grid;grid-template-columns:180px 1fr;gap:14px;align-items:stretch}
|
||||||
.timeline-channel{border-top:2px solid var(--accent-2);padding-top:8px}
|
.timeline-channel{border-top:2px solid var(--accent-2);padding-top:8px}
|
||||||
@@ -329,7 +392,7 @@ $magazine = export_build_magazine($visible_channels);
|
|||||||
.mini-title{font-size:13px;font-weight:700;line-height:1.05}
|
.mini-title{font-size:13px;font-weight:700;line-height:1.05}
|
||||||
.mini-meta{font-family:'Share Tech Mono',monospace;font-size:10px;color:var(--ink-soft);margin-top:3px}
|
.mini-meta{font-family:'Share Tech Mono',monospace;font-size:10px;color:var(--ink-soft);margin-top:3px}
|
||||||
@media print{body{background:#fff}.page{padding:0}.toolbar{display:none}.sheet{box-shadow:none;border:none;width:auto;margin:0}.sheet-wrap{overflow:visible}.cards-grid{grid-template-columns:1fr 1fr}}
|
@media print{body{background:#fff}.page{padding:0}.toolbar{display:none}.sheet{box-shadow:none;border:none;width:auto;margin:0}.sheet-wrap{overflow:visible}.cards-grid{grid-template-columns:1fr 1fr}}
|
||||||
@media (max-width:1200px){.sheet{width:100%}.cards-grid,.mag-channels,.mag-hero,.mag-cards,.mag-banner{grid-template-columns:1fr}.timeline-row{grid-template-columns:1fr}.timeline-grid{overflow:auto}}
|
@media (max-width:1200px){.sheet{width:100%}.cards-grid,.mag-channels,.mag-hero,.mag-sections,.mag-banner,.mag-spotlight{grid-template-columns:1fr}.timeline-row{grid-template-columns:1fr}.timeline-grid{overflow:auto}}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -481,7 +544,7 @@ $items = array_values(array_filter($channel['programmes'], static fn($p) => $p['
|
|||||||
<div class="mag-hero">
|
<div class="mag-hero">
|
||||||
<section class="mag-lead">
|
<section class="mag-lead">
|
||||||
<div class="mag-kicker">Cover story</div>
|
<div class="mag-kicker">Cover story</div>
|
||||||
<?php if (!empty($magazine['highlights'][0])): $lead = $magazine['highlights'][0]; $p = $lead['programme']; ?>
|
<?php if (!empty($magazine['lead'])): $lead = $magazine['lead']; $p = $lead['programme']; ?>
|
||||||
<div class="mag-title"><?= htmlspecialchars($p['title']) ?></div>
|
<div class="mag-title"><?= htmlspecialchars($p['title']) ?></div>
|
||||||
<div class="mag-meta"><?= htmlspecialchars($lead['channel_name']) ?> · <?= htmlspecialchars($p['start']->format('H:i') . ' - ' . $p['stop']->format('H:i')) ?><?= $p['rating'] ? ' · ' . htmlspecialchars($p['rating']) : '' ?></div>
|
<div class="mag-meta"><?= htmlspecialchars($lead['channel_name']) ?> · <?= htmlspecialchars($p['start']->format('H:i') . ' - ' . $p['stop']->format('H:i')) ?><?= $p['rating'] ? ' · ' . htmlspecialchars($p['rating']) : '' ?></div>
|
||||||
<?php if ($p['subtitle']): ?><div class="mag-desc" style="font-style:italic;margin-bottom:8px"><?= htmlspecialchars($p['subtitle']) ?></div><?php endif; ?>
|
<?php if ($p['subtitle']): ?><div class="mag-desc" style="font-style:italic;margin-bottom:8px"><?= htmlspecialchars($p['subtitle']) ?></div><?php endif; ?>
|
||||||
@@ -504,7 +567,44 @@ $items = array_values(array_filter($channel['programmes'], static fn($p) => $p['
|
|||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mag-kicker">Channel picks</div>
|
<div class="mag-kicker">Nos cartes editoriales</div>
|
||||||
|
<div class="mag-sections">
|
||||||
|
<?php foreach ($magazine['sections'] as $index => $section): ?>
|
||||||
|
<section class="mag-section<?= $index === 0 ? ' featured' : '' ?>">
|
||||||
|
<div class="mag-section-head">
|
||||||
|
<div class="mag-kicker"><?= htmlspecialchars($section['kicker']) ?></div>
|
||||||
|
<h2 class="mag-section-title"><?= htmlspecialchars($section['title']) ?></h2>
|
||||||
|
<div class="mag-section-intro"><?= htmlspecialchars($section['intro']) ?></div>
|
||||||
|
</div>
|
||||||
|
<?php $spotlight = $section['items'][0] ?? null; ?>
|
||||||
|
<?php if ($spotlight): $p = $spotlight['programme']; ?>
|
||||||
|
<article class="mag-spotlight">
|
||||||
|
<div class="mag-spotlight-time"><?= htmlspecialchars($p['start']->format('H:i')) ?><br><?= htmlspecialchars($p['stop']->format('H:i')) ?></div>
|
||||||
|
<div>
|
||||||
|
<div class="mag-badge"><?= htmlspecialchars(export_programme_label($p)) ?></div>
|
||||||
|
<div class="mag-spotlight-title"><?= htmlspecialchars($p['title']) ?></div>
|
||||||
|
<div class="mag-meta"><?= htmlspecialchars($spotlight['channel_name']) ?><?= $p['rating'] ? ' · ' . htmlspecialchars($p['rating']) : '' ?></div>
|
||||||
|
<div class="mag-spotlight-tease"><?= htmlspecialchars(export_entry_tease($spotlight)) ?></div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="mag-briefs">
|
||||||
|
<?php foreach (array_slice($section['items'], 1) as $entry): $p = $entry['programme']; ?>
|
||||||
|
<article class="mag-brief">
|
||||||
|
<div class="mag-brief-time"><?= htmlspecialchars($p['start']->format('H:i')) ?></div>
|
||||||
|
<div>
|
||||||
|
<div class="mag-brief-title"><?= htmlspecialchars($p['title']) ?></div>
|
||||||
|
<div class="mag-meta"><?= htmlspecialchars($entry['channel_name']) ?></div>
|
||||||
|
<div class="mag-brief-tease"><?= htmlspecialchars(export_entry_tease($entry)) ?></div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mag-kicker mag-footer-title">Les chaines a la loupe</div>
|
||||||
<div class="mag-channels">
|
<div class="mag-channels">
|
||||||
<?php foreach ($magazine['channels'] as $channel): ?>
|
<?php foreach ($magazine['channels'] as $channel): ?>
|
||||||
<section class="mag-channel">
|
<section class="mag-channel">
|
||||||
@@ -513,36 +613,18 @@ $items = array_values(array_filter($channel['programmes'], static fn($p) => $p['
|
|||||||
<div class="mag-channel-name"><?= htmlspecialchars($channel['name']) ?></div>
|
<div class="mag-channel-name"><?= htmlspecialchars($channel['name']) ?></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mag-list">
|
<div class="mag-list">
|
||||||
<?php foreach ($channel['programmes'] as $programme): ?>
|
<?php foreach (array_slice($channel['programmes'], 0, 3) as $programme): ?>
|
||||||
<div class="mag-item">
|
<div class="mag-item">
|
||||||
<div class="mag-time"><?= htmlspecialchars($programme['start']->format('H:i')) ?><br><?= htmlspecialchars($programme['stop']->format('H:i')) ?></div>
|
<div class="mag-time"><?= htmlspecialchars($programme['start']->format('H:i')) ?><br><?= htmlspecialchars($programme['stop']->format('H:i')) ?></div>
|
||||||
<div>
|
<div>
|
||||||
<div class="mag-item-title"><?= htmlspecialchars($programme['title']) ?></div>
|
<div class="mag-item-title"><?= htmlspecialchars($programme['title']) ?></div>
|
||||||
<?php if ($programme['subtitle']): ?><div class="prog-sub"><?= htmlspecialchars($programme['subtitle']) ?></div><?php endif; ?>
|
<?php if ($programme['subtitle']): ?><div class="prog-sub"><?= htmlspecialchars($programme['subtitle']) ?></div><?php endif; ?>
|
||||||
<?php if ($programme['categories']): ?><div class="prog-cats"><?= htmlspecialchars(implode(' · ', $programme['categories'])) ?></div><?php endif; ?>
|
<?php if ($programme['categories']): ?><div class="prog-cats"><?= htmlspecialchars(implode(' · ', array_slice($programme['categories'], 0, 3))) ?></div><?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mag-kicker">Magazine cards</div>
|
|
||||||
<div class="mag-cards">
|
|
||||||
<?php foreach ($magazine['cards'] as $card): ?>
|
|
||||||
<section class="mag-card<?= $card === $magazine['cards'][0] ? ' featured' : '' ?>">
|
|
||||||
<div class="mag-kicker"><?= htmlspecialchars($card['kicker']) ?></div>
|
|
||||||
<div class="mag-mini-title" style="margin-bottom:10px"><?= htmlspecialchars($card['title']) ?></div>
|
|
||||||
<?php foreach ($card['items'] as $entry): $p = $entry['programme']; ?>
|
|
||||||
<div class="mag-mini">
|
|
||||||
<div class="mag-mini-title"><?= htmlspecialchars($p['title']) ?></div>
|
|
||||||
<div class="mag-meta"><?= htmlspecialchars($entry['channel_name']) ?> · <?= htmlspecialchars($p['start']->format('H:i') . ' - ' . $p['stop']->format('H:i')) ?></div>
|
|
||||||
<?php if ($p['subtitle']): ?><div class="prog-sub"><?= htmlspecialchars($p['subtitle']) ?></div><?php endif; ?>
|
|
||||||
<?php if ($p['categories']): ?><div class="prog-cats"><?= htmlspecialchars(implode(' · ', $p['categories'])) ?></div><?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</section>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user