Stadionzeitung, Veranstaltungen, News-Artikel, Lightbox und Anzeigen-Verteilung
Stadionzeitung: Live-Seiten (Tabellen, Ergebnisse, Vorschau, Termine, News, Kontakt, Historie, Sportheim, Partner, Momente, Impressum), automatisches Cover, Swipe-Viewer mit Vollbildmodus und die Druckfassung als Falt-Heft. Anzeigen kommen jetzt aus dem Bestand und werden gleichmäßig verteilt, nie mehr als zwei hintereinander (vorher vier Blöcke à fünf). Die Doppelseiten-Regel rechnet das Skript selbst, statt sie von Hand zu prüfen. Veranstaltungen: Bereich /veranstaltungen mit Detailseite pro Fest, Lebenszyklus über das Datum (Ankündigung vor dem Fest, Rückblick danach), Galerie mit Lightbox. veranstaltungen.json ist dritte Termin-Quelle, damit ein Fest nie doppelt gepflegt wird. News-Artikel als dritte dynamische Prefix-Route, gemeinsamer detail-head. Behobene Fehler: - Wappen-Kontexte setzten Zeilen-Layout auf .crest statt auf die Zeile; das Wappen wurde zum Grid, Vereinsname und Tore rutschten darunter zusammen (Ergebnis-Rückblick, Vorschau, Cover). - --header-h (60px) unterschätzt die Kopfleiste um 32px (Logo 72px + 20px Versatz): neues abgeleitetes --header-space, sonst klebten Zurück-Links unter dem Logo. - base_url in der Produktions-Config ohne www, während .htaccess auf www umleitet; preflight prüft das jetzt. - .lightbox brauchte display:none mit (0,2,0), sonst lag das Overlay offen. Neue Werkzeuge: bin/anzeige-add.php (Anzeigen-Bestand), bin/veranstaltung-bilder.php (Plakate und Galerien, Alt-Texte folgen der Quelldatei), bin/qr.php (Druck-QR mit Warnung, wenn base_url nicht auf die echte Domain zeigt). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NzeVVgMCrzCDJAKeLEdKr7
This commit is contained in:
84
app/components/news-artikel.php
Normal file
84
app/components/news-artikel.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Artikelkörper einer News-Detailseite. Props:
|
||||
* $image array (optional) — Aufmacher {base, widths, alt}, above the fold
|
||||
* $blocks array — data/news.json → artikel[], Blöcke mit `typ`:
|
||||
* text {absaetze: string[]} Fließtext
|
||||
* zwischentitel {text} h2 (h1 steht im detail-head)
|
||||
* bild {base, widths, alt, caption?}
|
||||
* zitat {text, quelle?}
|
||||
*
|
||||
* Ein unbekannter `typ` wird stillschweigend übersprungen; gemeldet wird er von
|
||||
* bin/preflight.php, damit ein Tippfehler vor dem Deploy auffällt und nicht erst
|
||||
* durch einen fehlenden Absatz auf der Seite.
|
||||
*
|
||||
* Fließtext läuft durch inline_links_html(): interne Deeplinks [Label](slug)
|
||||
* werden zu <a>, alles andere escaped. Kein rohes HTML in der JSON.
|
||||
*
|
||||
* Bilder sind wie bei den Veranstaltungen ohne JS normale Links auf die größte
|
||||
* Variante; mit JS fängt assets/js/lightbox.js den Klick ab. Das Overlay kommt
|
||||
* nur dazu, wenn der Artikel überhaupt Bilder hat.
|
||||
*/
|
||||
$image = $image ?? null;
|
||||
$blocks = $blocks ?? [];
|
||||
|
||||
$bilder = array_values(array_filter(
|
||||
$blocks,
|
||||
static fn (array $b): bool => ($b['typ'] ?? '') === 'bild' && !empty($b['base']) && !empty($b['widths'])
|
||||
));
|
||||
$bildAnzahl = count($bilder);
|
||||
$bildIndex = 0;
|
||||
?>
|
||||
<article class="section news-article"<?= $bildAnzahl > 0 ? ' data-lightbox-gallery' : '' ?>>
|
||||
<div class="container">
|
||||
<?php if (!empty($image['base'])): ?>
|
||||
<figure class="news-article__lead">
|
||||
<?php component('img', [
|
||||
'image' => $image,
|
||||
'sizes' => '(max-width: 768px) 100vw, 72ch',
|
||||
'class' => 'news-article__lead-img',
|
||||
'eager' => true,
|
||||
]); ?>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<div class="news-article__body prose">
|
||||
<?php foreach ($blocks as $block): ?>
|
||||
<?php $typ = $block['typ'] ?? ''; ?>
|
||||
<?php if ($typ === 'text'): ?>
|
||||
<?php foreach ($block['absaetze'] ?? [] as $absatz): ?>
|
||||
<p><?= inline_links_html((string) $absatz) ?></p>
|
||||
<?php endforeach; ?>
|
||||
<?php elseif ($typ === 'zwischentitel' && !empty($block['text'])): ?>
|
||||
<h2 class="news-article__heading"><?= e($block['text']) ?></h2>
|
||||
<?php elseif ($typ === 'bild' && !empty($block['base']) && !empty($block['widths'])): ?>
|
||||
<figure class="news-article__figure">
|
||||
<a class="news-article__figure-link" href="<?= e(asset($block['base'] . '-' . max($block['widths']) . '.jpg')) ?>" data-lightbox="<?= $bildIndex++ ?>">
|
||||
<?php component('img', [
|
||||
'image' => $block,
|
||||
'sizes' => '(max-width: 768px) 100vw, 72ch',
|
||||
'class' => 'news-article__img',
|
||||
]); ?>
|
||||
<span class="visually-hidden">(größer ansehen)</span>
|
||||
</a>
|
||||
<?php if (!empty($block['caption'])): ?>
|
||||
<figcaption class="news-article__caption"><?= e($block['caption']) ?></figcaption>
|
||||
<?php endif; ?>
|
||||
</figure>
|
||||
<?php elseif ($typ === 'zitat' && !empty($block['text'])): ?>
|
||||
<figure class="news-article__quote">
|
||||
<blockquote><p><?= e($block['text']) ?></p></blockquote>
|
||||
<?php if (!empty($block['quelle'])): ?>
|
||||
<figcaption class="news-article__quote-source"><?= e($block['quelle']) ?></figcaption>
|
||||
<?php endif; ?>
|
||||
</figure>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($bildAnzahl > 0): ?>
|
||||
<?php component('lightbox-overlay', ['label' => 'Bild aus dem Artikel', 'count' => $bildAnzahl]); ?>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
Reference in New Issue
Block a user