Improvment: Getting Magazine export even better.
This commit is contained in:
+68
-3
@@ -128,6 +128,24 @@ function export_programme_weight(array $programme): int {
|
|||||||
return $weight;
|
return $weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function export_programme_duration(array $programme): int {
|
||||||
|
return max(1, (int) round(($programme['stop']->getTimestamp() - $programme['start']->getTimestamp()) / 60));
|
||||||
|
}
|
||||||
|
|
||||||
|
function export_programme_is_series(array $programme): bool {
|
||||||
|
return !empty($programme['subtitle']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function export_take_entries(array $entries, callable $filter, int $limit = 4): array {
|
||||||
|
$picked = [];
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
if (!$filter($entry)) continue;
|
||||||
|
$picked[] = $entry;
|
||||||
|
if (count($picked) >= $limit) break;
|
||||||
|
}
|
||||||
|
return $picked;
|
||||||
|
}
|
||||||
|
|
||||||
function export_build_magazine(array $channels): array {
|
function export_build_magazine(array $channels): array {
|
||||||
$all = [];
|
$all = [];
|
||||||
foreach ($channels as $channel) {
|
foreach ($channels as $channel) {
|
||||||
@@ -148,6 +166,10 @@ function export_build_magazine(array $channels): array {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$highlights = array_slice($all, 0, 5);
|
$highlights = array_slice($all, 0, 5);
|
||||||
|
$series = export_take_entries($all, static fn($entry) => export_programme_is_series($entry['programme']), 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);
|
||||||
|
|
||||||
$by_channel = [];
|
$by_channel = [];
|
||||||
foreach ($channels as $channel) {
|
foreach ($channels as $channel) {
|
||||||
$by_channel[] = [
|
$by_channel[] = [
|
||||||
@@ -157,7 +179,30 @@ function export_build_magazine(array $channels): array {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['highlights' => $highlights, 'channels' => $by_channel];
|
$cards = [
|
||||||
|
[
|
||||||
|
'title' => 'A ne pas manquer',
|
||||||
|
'kicker' => 'Selection de la redaction',
|
||||||
|
'items' => array_slice($highlights, 0, 4),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'title' => 'Series en diffusion',
|
||||||
|
'kicker' => 'Nouvelle serie diffusee',
|
||||||
|
'items' => $series ?: array_slice($highlights, 0, 4),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'title' => 'Grands formats',
|
||||||
|
'kicker' => 'Films et longs formats',
|
||||||
|
'items' => $movies ?: array_slice($highlights, 0, 4),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'title' => 'Nouveautes du soir',
|
||||||
|
'kicker' => 'Prime time',
|
||||||
|
'items' => $late_picks ?: array_slice($highlights, 0, 4),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
return ['highlights' => $highlights, 'channels' => $by_channel, 'cards' => $cards];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sources = array_values($config['epg_sources'] ?? []);
|
$sources = array_values($config['epg_sources'] ?? []);
|
||||||
@@ -241,7 +286,7 @@ $magazine = export_build_magazine($visible_channels);
|
|||||||
.mag-title{font-family:'IM Fell English',serif;font-size:34px;line-height:1.02;margin-bottom:10px}
|
.mag-title{font-family:'IM Fell English',serif;font-size:34px;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{display:grid;gap:14px}
|
.mag-side-list,.mag-channels,.mag-cards{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}
|
||||||
@@ -254,6 +299,8 @@ $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-cards{grid-template-columns:repeat(2,minmax(0,1fr))}
|
||||||
.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}
|
||||||
@@ -265,7 +312,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{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-cards{grid-template-columns:1fr}.timeline-row{grid-template-columns:1fr}.timeline-grid{overflow:auto}}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -448,6 +495,24 @@ $items = array_values(array_filter($channel['programmes'], static fn($p) => $p['
|
|||||||
<?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">
|
||||||
|
<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