Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2467b87f5 | ||
|
|
4fed048843 | ||
|
|
f466df2c5c | ||
|
|
25da870601 | ||
|
|
fb24d171ae | ||
|
|
5a9d7735d4 |
No files matched your search
@@ -3,7 +3,7 @@
|
|||||||
"title": "Sendewerk",
|
"title": "Sendewerk",
|
||||||
"description": "Redaktionelle Planung und Durchführung von heinzlive-Sendungen.",
|
"description": "Redaktionelle Planung und Durchführung von heinzlive-Sendungen.",
|
||||||
"tagline": "Vom Fundstück bis zur Livesendung",
|
"tagline": "Vom Fundstück bis zur Livesendung",
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"healthCheckPath": "/healthz",
|
"healthCheckPath": "/healthz",
|
||||||
"httpPort": 3000,
|
"httpPort": 3000,
|
||||||
"addons": {
|
"addons": {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
Sendewerk ist die redaktionelle Webanwendung für den Weg vom vorbereiteten
|
Sendewerk ist die redaktionelle Webanwendung für den Weg vom vorbereiteten
|
||||||
Inhalt bis zur moderierten und archivierten Sendung. Der aktuelle Stand umfasst
|
Inhalt bis zur moderierten und archivierten Sendung. Der aktuelle Stand umfasst
|
||||||
Etappe 1 bis 4: technisches Grundgerüst, Anmeldung und Rollen, einen
|
Etappe 1 bis 5: technisches Grundgerüst, Anmeldung und Rollen, einen
|
||||||
persistenten Fundus sowie den vollständigen Sendungsbaukasten. Live-Steuerung
|
persistenten Fundus, den Sendungsbaukasten sowie Live-Steuerung und eine
|
||||||
und Präsentationsausgabe folgen in späteren Etappen.
|
abgesicherte Präsentationsausgabe. Abschluss und Archivierung folgen in Etappe 6.
|
||||||
|
|
||||||
## Voraussetzungen
|
## Voraussetzungen
|
||||||
|
|
||||||
@@ -77,12 +77,27 @@ automatisch; ein sichtbarer Status meldet Erfolg, Fehler oder eine parallele
|
|||||||
Änderung. In diesem Fall muss die Seite neu geladen werden, bevor erneut
|
Änderung. In diesem Fall muss die Seite neu geladen werden, bevor erneut
|
||||||
gespeichert wird.
|
gespeichert wird.
|
||||||
|
|
||||||
|
Bereits gesendete Pieces und Pieces mit einer Einplanung in einer noch nicht
|
||||||
|
abgeschlossenen Sendung sind standardmäßig ausgeblendet. Als gesendet gilt nur
|
||||||
|
eine erledigte Verwendung in einer abgeschlossenen Sendung; übersprungene oder
|
||||||
|
reservierte Inhalte gelten nicht als gesendet. Über **Auch verwendete Inhalte
|
||||||
|
zeigen** und **Auch eingeplante Inhalte zeigen** lassen sich beide Gruppen
|
||||||
|
unabhängig einblenden. Dann erscheinen auch Datum, Sendung und die aufklappbare
|
||||||
|
Verwendungshistorie.
|
||||||
|
|
||||||
Markdown ist in Einleitung, Recherche, Moderation, Überleitung und Präsentation
|
Markdown ist in Einleitung, Recherche, Moderation, Überleitung und Präsentation
|
||||||
möglich. Die Ausgabe wird serverseitig auf eine begrenzte Auswahl sicherer
|
möglich. Die Ausgabe wird serverseitig auf eine begrenzte Auswahl sicherer
|
||||||
Elemente und Links reduziert. Bilder dürfen höchstens 5 MB groß sein und müssen
|
Elemente und Links reduziert. Bilder dürfen höchstens 5 MB groß sein und müssen
|
||||||
als JPEG, PNG, WebP oder GIF erkannt werden. Sie liegen im konfigurierten
|
als JPEG, PNG, WebP oder GIF erkannt werden. Sie liegen im konfigurierten
|
||||||
Uploadverzeichnis und sind nur über eine angemeldete Route erreichbar.
|
Uploadverzeichnis und sind nur über eine angemeldete Route erreichbar.
|
||||||
|
|
||||||
|
Für die Präsentation kann ein Piece alternativ genau eine seiner vorhandenen
|
||||||
|
Quellen als Linkkarte oder Video verwenden. Linktitel, Anreißer und Bildadresse
|
||||||
|
lassen sich manuell korrigieren. **Vorschau laden** ruft Metadaten ausdrücklich
|
||||||
|
neu ab; manuell geänderte Felder werden dabei nicht überschrieben. Die
|
||||||
|
**Präsentation testen**-Ansicht öffnet den aktuellen Piece-Inhalt isoliert und
|
||||||
|
verändert weder eine Sendung noch deren laufende Ausgabe.
|
||||||
|
|
||||||
## Sendungen planen
|
## Sendungen planen
|
||||||
|
|
||||||
Unter **Sendungen** lässt sich ein neuer Stream leer, mit dem Standardablauf
|
Unter **Sendungen** lässt sich ein neuer Stream leer, mit dem Standardablauf
|
||||||
@@ -92,11 +107,49 @@ eingeplanten Pieces. Die Reservebank zählt nie zur Planzeit.
|
|||||||
|
|
||||||
Der sendefertige Fundus steht neben dem Ablauf. Pieces können mehrfach
|
Der sendefertige Fundus steht neben dem Ablauf. Pieces können mehrfach
|
||||||
eingeplant und je Verwendung mit eigenem Titel, eigener Dauer und eigenen
|
eingeplant und je Verwendung mit eigenem Titel, eigener Dauer und eigenen
|
||||||
Redaktionstexten bearbeitet werden, ohne das Original zu verändern. Abschnitte
|
Redaktionstexten bearbeitet werden, ohne das Original zu verändern. Das
|
||||||
und Verwendungen lassen sich per Drag-and-drop sowie gleichwertig mit sichtbaren
|
Stift-Symbol öffnet dafür einen auch mobil scrollbaren Editor-Dialog. **Aus
|
||||||
Schaltflächen und Auswahlfeldern verschieben. Twitch-Titel und Ankündigung sind
|
Fundus aktualisieren** übernimmt auf Wunsch Titel, Dauer und Redaktionstexte des
|
||||||
kopierbar. Gleichzeitige Änderungen werden über die Revision der gesamten
|
aktuellen Originals; eigene Notizen, Live-Status und gemessene Zeiten bleiben
|
||||||
Sendung erkannt und nicht still überschrieben.
|
erhalten. Abschnitte und Verwendungen lassen sich per Drag-and-drop sowie
|
||||||
|
gleichwertig mit sichtbaren Schaltflächen und Auswahlfeldern verschieben.
|
||||||
|
Twitch-Titel und Ankündigung sind kopierbar. Gleichzeitige Änderungen werden
|
||||||
|
über die Revision der gesamten Sendung erkannt und nicht still überschrieben.
|
||||||
|
|
||||||
|
Die Quellspalte blendet gesendete und bereits in derselben Sendung eingeplante
|
||||||
|
Originale zunächst aus; beide Gruppen lassen sich unabhängig wieder anzeigen.
|
||||||
|
Eine konkrete Einplanung kann direkt hinter sich dupliziert werden. Dabei
|
||||||
|
bleiben ihre angepassten Texte und ihre Dauer erhalten, während Live-Status und
|
||||||
|
gemessene Zeiten neu beginnen. **Piece duplizieren** im Fundus erzeugt dagegen
|
||||||
|
weiterhin einen eigenständigen Fundusinhalt.
|
||||||
|
|
||||||
|
## Live moderieren und präsentieren
|
||||||
|
|
||||||
|
Die Live-Steuerung öffnet sich aus einer geplanten Sendung. Sie zeigt
|
||||||
|
Einleitung, Moderationsstichpunkte und Überleitung in einstellbarer
|
||||||
|
Prompter-Schrift; die private Recherche bleibt standardmäßig geschlossen.
|
||||||
|
Zeiten und Ablaufleiste können ausgeblendet werden. Schriftgröße, Sichtbarkeit
|
||||||
|
und Leseposition bleiben im Browser erhalten.
|
||||||
|
|
||||||
|
Start, Erledigen, Überspringen und Zurück werden persistent mit tatsächlichen
|
||||||
|
Zeitintervallen gespeichert. Wiederholte Befehle erzeugen keine doppelte
|
||||||
|
Zeitbuchung. Offene Pieces und die Reserve lassen sich während der Sendung
|
||||||
|
sortieren beziehungsweise als nächster Beitrag einfügen.
|
||||||
|
|
||||||
|
Das separate Präsentationsfenster unter `/heinzlive/...` verwendet einen langen,
|
||||||
|
widerrufbaren Zufallstoken. Es ändert sich ausschließlich durch die Aktion
|
||||||
|
**Präsentieren** und erhält nur den bei der Einplanung gespeicherten Text-, Link-
|
||||||
|
oder Video-Snapshot. YouTube- und TikTok-Adressen werden auf validierte IDs
|
||||||
|
reduziert und ohne Autoplay in offiziellen Player-Iframes dargestellt. Andere
|
||||||
|
oder unvollständige Videoquellen erscheinen als Linkkarte. Recherche,
|
||||||
|
Moderationsnotizen, eigene Notizen, Kontodaten und interne Dateipfade werden
|
||||||
|
weder im HTML noch im JSON-Zustand ausgeliefert. Der Token ist ein
|
||||||
|
Zugangsgeheimnis und darf nicht weitergegeben oder protokolliert werden.
|
||||||
|
|
||||||
|
Metadaten und externe Vorschaubilder werden ausschließlich serverseitig mit
|
||||||
|
DNS-, Redirect-, Zeit- und Größenlimits abgerufen. Private und lokale
|
||||||
|
Netzwerkziele sind gesperrt. Eingebettetes HTML oder Skripte einer Quellseite
|
||||||
|
werden nicht übernommen.
|
||||||
|
|
||||||
## Befehle
|
## Befehle
|
||||||
|
|
||||||
@@ -173,6 +226,7 @@ Medien und redaktionellen Inhalten werden dadurch nicht verändert.
|
|||||||
|
|
||||||
Die direkten Laufzeit- und Werkzeugabhängigkeiten verwenden MIT- oder
|
Die direkten Laufzeit- und Werkzeugabhängigkeiten verwenden MIT- oder
|
||||||
Apache-2.0-Lizenzen: Svelte/SvelteKit, Vite, Vitest, ESLint und
|
Apache-2.0-Lizenzen: Svelte/SvelteKit, Vite, Vitest, ESLint und
|
||||||
`better-sqlite3`, `@node-rs/argon2`, Marked, sanitize-html und file-type sind
|
`better-sqlite3`, `@node-rs/argon2`, Marked, sanitize-html, file-type und
|
||||||
MIT-lizenziert; Nodemailer verwendet MIT-0, TypeScript und Playwright stehen
|
Metascraper sind MIT-lizenziert; Nodemailer verwendet MIT-0, TypeScript und
|
||||||
unter Apache-2.0. Die Lockdatei fixiert den tatsächlich installierten Baum.
|
Playwright stehen unter Apache-2.0. Die Lockdatei fixiert den tatsächlich
|
||||||
|
installierten Baum.
|
||||||
@@ -120,3 +120,140 @@
|
|||||||
ungewollten horizontalen Überlauf
|
ungewollten horizontalen Überlauf
|
||||||
- Mobile Aufnahme des vollständigen Sendungsbaukastens visuell kontrolliert
|
- Mobile Aufnahme des vollständigen Sendungsbaukastens visuell kontrolliert
|
||||||
- `bash -n start.sh` und `git diff --check`: erfolgreich
|
- `bash -n start.sh` und `git diff --check`: erfolgreich
|
||||||
|
|
||||||
|
## Etappe 5
|
||||||
|
|
||||||
|
| Kriterium | Nachweis | Stand |
|
||||||
|
| ------------------------------------- | ----------------------------------------------------------------------------------------------- | --------------------- |
|
||||||
|
| Lesbare Moderation | Prompter-Schrift, Einleitung und Überleitung im Browser; Recherche initial geschlossen | erfüllt am 22.10.2026 |
|
||||||
|
| Wiederherstellung | Live-Stand, Laufintervalle, Schriftgröße und Leseposition nach Neuladen geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Keine doppelte Zeiterfassung | Verhaltenstest wiederholt dieselbe Befehls-ID und findet genau ein Zeitintervall | erfüllt am 22.10.2026 |
|
||||||
|
| Explizite Präsentation | Zweitfenster bleibt nach Start leer und ändert sich erst durch „Präsentieren“ | erfüllt am 22.10.2026 |
|
||||||
|
| Getrennte sichere Ausgabe | anonymer Browserkontext prüft Text, Bild, HTML, JSON und fremde Medien ohne private Daten | erfüllt am 22.10.2026 |
|
||||||
|
| Reserve und Reihenfolge | Reserve als nächstes Piece eingefügt; offene Reihenfolge und serverseitige Live-Grenze geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Popup- und Verbindungsfehler sichtbar | blockiertes Popup sowie unterbrochenes und wiederhergestelltes State-Polling im Browser geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Persistente Linkvorschau | Quellwahl, manuelle Felder, Reload, fehlendes Bild und isolierte Testansicht im Browser geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Sichere Metadatenabrufe | Tests sperren private IPv4-/IPv6-Ziele; Redirect-, Größen- und Zeitlimits sind implementiert | erfüllt am 22.10.2026 |
|
||||||
|
| Validierte Videoplayer | YouTube-URL-Varianten, TikTok-ID, Zeitmarke und Playerwechsel automatisiert geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Präsentationssnapshot | Einplanung, Duplikation und explizite Aktualisierung aus dem Original im Servicetest geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Reale OBS-Browserquelle | lokale tokenisierte Browserausgabe vorhanden; kein OBS auf der Prüfmaschine | offen |
|
||||||
|
| Reale Anbieterwiedergabe | automatisierte Tests fangen YouTube-/TikTok-Requests lokal ab | offen |
|
||||||
|
|
||||||
|
## Ausgeführte Prüfungen Etappe 5
|
||||||
|
|
||||||
|
- `npm run lint`: erfolgreich
|
||||||
|
- `npm run check`: 0 Fehler und 0 Warnungen
|
||||||
|
- `npm test`: 29 Tests in 6 Dateien erfolgreich
|
||||||
|
- `npm run build`: erfolgreich mit `@sveltejs/adapter-node`
|
||||||
|
- `npm run test:e2e`: 14 von 14 Browsertests erfolgreich
|
||||||
|
- Anonymer zweiter Chromium-Kontext mit Präsentationstext, Quelle, geschütztem
|
||||||
|
Bild und gefiltertem JSON geprüft
|
||||||
|
- Mobile Aufnahme der Live-Steuerung bei 390 × 844 Pixeln und Desktopaufnahme
|
||||||
|
der heinzlive-Ausgabe visuell kontrolliert
|
||||||
|
- Popup-Blockade sowie Verbindungsabbruch und automatische Wiederverbindung im
|
||||||
|
Browser geprüft
|
||||||
|
- YouTube-/TikTok-Iframes, Playerwechsel, mobile Hochformatausgabe,
|
||||||
|
Linkkartenvorschau ohne Bild, isolierte Testansicht und private Datenfilterung
|
||||||
|
mit lokal abgefangenen Anbieterrequests geprüft
|
||||||
|
- SSRF-Blockade einer privaten Zieladresse über die sichtbare Editorfehlermeldung
|
||||||
|
geprüft
|
||||||
|
- `bash -n start.sh` und `git diff --check`: erfolgreich
|
||||||
|
|
||||||
|
## Gezielte Fundus- und Einplanungsanpassung
|
||||||
|
|
||||||
|
| Kriterium | Nachweis | Stand |
|
||||||
|
| ------------------------------------------- | ------------------------------------------------------------------------------------------ | --------------------- |
|
||||||
|
| Gesendet korrekt abgeleitet | Servicetest schließt offene, übersprungene, Reserve- und nicht abgeschlossene Nutzung aus | erfüllt am 22.10.2026 |
|
||||||
|
| Historie und Fundusfilter | Browser prüft letztes Datum, Sendungslink, weitere Verwendungen und Sofortfilter | erfüllt am 22.10.2026 |
|
||||||
|
| Unabhängige Quellfilter | Browser kombiniert verwendet/eingeplant getrennt und erhält sie über Suchfilter | erfüllt am 22.10.2026 |
|
||||||
|
| Reserve und Mehrfacheinplanung | Reserve zählt als eingeplant; bewusstes Wiedereinblenden erlaubt weitere Einplanung | erfüllt am 22.10.2026 |
|
||||||
|
| Rückkehr nach Entfernen | Browser entfernt die letzte Reserveeinplanung und bietet das Original sofort wieder an | erfüllt am 22.10.2026 |
|
||||||
|
| Angepasste Einplanung dupliziert | Service und Browser prüfen Position, Texte, Notizen, Dauer und Reload | erfüllt am 22.10.2026 |
|
||||||
|
| Live-Zustand des Duplikats zurückgesetzt | Servicetest prüft `open`, neue ID und fehlende Zeitintervalle | erfüllt am 22.10.2026 |
|
||||||
|
| Original unverändert | Piece-Anzahl und Original-ID vor und nach Einplanungsduplikation verglichen | erfüllt am 22.10.2026 |
|
||||||
|
| Speicherfehler nicht als Erfolg dargestellt | veraltete Revision rollt Duplikation vollständig zurück | erfüllt am 22.10.2026 |
|
||||||
|
| Globale aktive Einplanung ausgeblendet | Browser prüft den unabhängigen Filter über mehrere nicht abgeschlossene Sendungen | erfüllt am 22.10.2026 |
|
||||||
|
| Snapshot ausdrücklich aktualisiert | Service prüft neue Originaltexte und erhaltene Notizen/Intervalle; Browser löst Aktion aus | erfüllt am 22.10.2026 |
|
||||||
|
| Fehlendes Original atomar behandelt | Servicetest prüft Fehler und unveränderte Sendungsrevision | erfüllt am 22.10.2026 |
|
||||||
|
| Verwendungsdialog responsiv | Browser prüft Desktop/Mobil, Reserve, erreichbare Aktionen und sichtbare Konfliktfehler | erfüllt am 22.10.2026 |
|
||||||
|
|
||||||
|
## Ausgeführte Prüfungen Fundus und Einplanung
|
||||||
|
|
||||||
|
- `npm test`: 22 Tests in 5 Dateien erfolgreich
|
||||||
|
- `npm run lint`: erfolgreich
|
||||||
|
- `npm run check`: 0 Fehler und 0 Warnungen
|
||||||
|
- gezielter Playwright-Lauf: 4 von 4 Browsertests erfolgreich
|
||||||
|
- `npm run test:e2e`: 12 von 12 Browsertests erfolgreich
|
||||||
|
- Desktopansichten von Fundushistorie, kombinierten Sendungsfiltern und
|
||||||
|
Verwendungsdialog sowie mobile Quellspalte und mobiler Dialog bei 390 × 844
|
||||||
|
Pixeln visuell kontrolliert
|
||||||
|
- `npm run build`: erfolgreich mit `@sveltejs/adapter-node`
|
||||||
|
- `bash -n start.sh` und `git diff --check`: erfolgreich
|
||||||
|
|
||||||
|
## Redaktionelles Piece-Arbeitsblatt
|
||||||
|
|
||||||
|
| Kriterium | Nachweis | Stand |
|
||||||
|
| ---------------------------------------- | ------------------------------------------------------------------------------------------------- | --------------------- |
|
||||||
|
| Schreiben steht im Mittelpunkt | Desktop- und Mobilprüfung zeigt Fundstück, Recherche und drei Sendungstexte im primären Lesefluss | erfüllt am 22.10.2026 |
|
||||||
|
| Kontext bleibt vollständig erreichbar | Quellen, Einordnung, Präsentation und Bilder auf Desktop sowie als vier mobile Werkzeuge geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Textfelder unabhängig bearbeitbar | Recherche und Moderationsstichpunkte im Browser gleichzeitig geöffnet und gespeichert | erfüllt am 22.10.2026 |
|
||||||
|
| Bestehender Formvertrag bleibt erhalten | Autosave, Reload, Taxonomie, Quelle, Markdown, Upload, Archiv und Duplikat im Browser durchlaufen | erfüllt am 22.10.2026 |
|
||||||
|
| Konflikte und Speicherfehler sichtbar | parallele Revision sowie Offline-Autosave mit erfolgreicher manueller Wiederholung geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Schneller Video-Einstieg ohne Einordnung | Link im Eingang aufgenommen, direkt geöffnet, beschrieben und isoliert als Video getestet | erfüllt am 22.10.2026 |
|
||||||
|
| Responsive Darstellung und beide Themes | 1440 × 1000 und 390 × 844 in Light/Dark ohne horizontalen Überlauf visuell kontrolliert | erfüllt am 22.10.2026 |
|
||||||
|
|
||||||
|
## Ausgeführte Prüfungen Piece-Arbeitsblatt
|
||||||
|
|
||||||
|
- `npm run lint`: erfolgreich
|
||||||
|
- `npm run check`: 0 Fehler und 0 Warnungen
|
||||||
|
- `npm test`: 29 Tests in 6 Dateien erfolgreich
|
||||||
|
- `npm run build`: erfolgreich mit `@sveltejs/adapter-node`
|
||||||
|
- gezielter Playwright-Lauf für Autosave, Offline-Fehler, Konflikt und Upload:
|
||||||
|
1 von 1 Browsertest erfolgreich
|
||||||
|
- `npm run test:e2e`: 15 von 15 Browsertests erfolgreich
|
||||||
|
- Desktop Light/Dark sowie Smartphone Light/Dark und mobiles
|
||||||
|
Präsentationswerkzeug visuell kontrolliert; langer Titel bricht vollständig um,
|
||||||
|
Werkzeugfläche ist opak und die Speicherleiste überdeckt mobil keine Eingaben
|
||||||
|
- `bash -n start.sh` und `git diff --check`: erfolgreich
|
||||||
|
|
||||||
|
## Oberflächenrelease 0.5.4
|
||||||
|
|
||||||
|
| Kriterium | Nachweis | Stand |
|
||||||
|
| ------------------------------------------ | ---------------------------------------------------------------------------------------------- | --------------------- |
|
||||||
|
| Klare Hierarchie in beiden Themes | Eingang, Fundus, Editor, Sendungsplan und Live-Steuerung in Light/Dark visuell kontrolliert | erfüllt am 22.10.2026 |
|
||||||
|
| Exakte heinzlive-Darkmode-Farben | berechnete Theme-Tokens und Screenshots der dunklen Arbeitsansichten geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Responsive Darstellung ohne Seitenüberlauf | Chromium-Messung bei 1440 × 1000 und 390 × 844 Pixeln auf allen gezielt geprüften Ansichten | erfüllt am 22.10.2026 |
|
||||||
|
| Sendungsplan-Aktionen bleiben erreichbar | drei sichtbare Aktionen einer Planzeile liegen waagerecht auf gleicher Höhe; Mobilbild geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Fokus und reduzierte Bewegung | sichtbarer Cyan-Fokusring und bestehende `prefers-reduced-motion`-Regeln im Stylesheet geprüft | erfüllt am 22.10.2026 |
|
||||||
|
|
||||||
|
## Ausgeführte Prüfungen Oberflächenrelease 0.5.4
|
||||||
|
|
||||||
|
- `npm run check`: 0 Fehler und 0 Warnungen
|
||||||
|
- `npm run build`: erfolgreich mit `@sveltejs/adapter-node`
|
||||||
|
- gezielter Chromium-Lauf für Eingang, Fundus, Piece-Editor, Sendungsplan und
|
||||||
|
Live-Steuerung bei 1440 × 1000 und 390 × 844 Pixeln in Light/Dark ohne
|
||||||
|
Konsolenfehler oder horizontalen Seitenüberlauf
|
||||||
|
- Desktop- und Mobilaufnahmen aller genannten Ansichten visuell kontrolliert
|
||||||
|
- vollständige Unit- und E2E-Matrix nicht erneut ausgeführt, weil dieser Release
|
||||||
|
ausschließlich Darstellung und redaktionelle Kurztexte verändert
|
||||||
|
- `git diff --check`: erfolgreich
|
||||||
|
|
||||||
|
## Oberflächenkorrektur 0.5.5
|
||||||
|
|
||||||
|
| Kriterium | Nachweis | Stand |
|
||||||
|
| ------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------- |
|
||||||
|
| Nachtblau und Glaswirkung erkennbar | berechnete Transparenz/Unschärfe und Desktop-/Mobilaufnahmen in Darkmode geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Schreibfelder im Ruhezustand sichtbar | deckende Feldfarbe, feine Kontur, Innenabstand und Textcursor im Piece-Editor geprüft | erfüllt am 22.10.2026 |
|
||||||
|
| Goldener Tastaturfokus | berechnete Fokusfarbe und Fokus-Schatten am Titelfeld geprüft; Cyanrahmen nicht mehr aktiv | erfüllt am 22.10.2026 |
|
||||||
|
| Inhaltsgerechte Feldhöhen | kurze Einleitung ist niedriger als ausführliche Moderationsfläche; beide bleiben skalierbar | erfüllt am 22.10.2026 |
|
||||||
|
| Lightmode und Smartphone erhalten | fünf Arbeitsansichten bei 1440 × 1000 und 390 × 844 Pixeln ohne Seitenüberlauf geprüft | erfüllt am 22.10.2026 |
|
||||||
|
|
||||||
|
## Ausgeführte Prüfungen Oberflächenkorrektur 0.5.5
|
||||||
|
|
||||||
|
- `npm run check`: 0 Fehler und 0 Warnungen
|
||||||
|
- `npm run build`: erfolgreich mit `@sveltejs/adapter-node`
|
||||||
|
- gezielter Chromium-Lauf in Light/Dark und Desktop/Mobil ohne Konsolenfehler
|
||||||
|
oder horizontalen Seitenüberlauf; Glas-, Feld- und Fokuswerte zusätzlich
|
||||||
|
programmatisch geprüft
|
||||||
|
- vollständige Unit- und E2E-Matrix gemäß Auftrag nicht erneut ausgeführt
|
||||||
|
- `git diff --check`: erfolgreich
|
||||||
+105
-19
@@ -33,8 +33,9 @@ spätere API dieselben Regeln verwenden.
|
|||||||
|
|
||||||
## Gesamtdatenmodell
|
## Gesamtdatenmodell
|
||||||
|
|
||||||
Die ersten vier Etappen materialisieren Identität, Inhaltsverwaltung und
|
Die ersten fünf Etappen materialisieren Identität, Inhaltsverwaltung,
|
||||||
Sendungsplanung. Folgende Grenzen gelten für umgesetzte und spätere Bereiche.
|
Sendungsplanung und Live-Durchführung. Folgende Grenzen gelten für umgesetzte
|
||||||
|
und spätere Bereiche.
|
||||||
|
|
||||||
| Bereich | Geplante Entitäten und Beziehungen |
|
| Bereich | Geplante Entitäten und Beziehungen |
|
||||||
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
@@ -96,6 +97,10 @@ erhalten ausschließlich kompakte Piece-Daten; private Recherche und vollständi
|
|||||||
Redaktionstexte werden nur an den angemeldeten Editor ausgeliefert. Themen und
|
Redaktionstexte werden nur an den angemeldeten Editor ausgeliefert. Themen und
|
||||||
Abschnittskategorien sind Mehrfachzuordnungen, das Format bleibt eine einzelne
|
Abschnittskategorien sind Mehrfachzuordnungen, das Format bleibt eine einzelne
|
||||||
unabhängige Zuordnung. Quellen werden gemeinsam mit einem Piece atomar ersetzt.
|
unabhängige Zuordnung. Quellen werden gemeinsam mit einem Piece atomar ersetzt.
|
||||||
|
Ein Piece kann für die Präsentation Text oder genau eine vorhandene Quelle als
|
||||||
|
Linkkarte beziehungsweise Video auswählen. Abgerufene Metadaten und Kennzeichen
|
||||||
|
für manuell korrigierte Felder liegen am Piece; ein erneuter Abruf überschreibt
|
||||||
|
diese Felder nicht.
|
||||||
|
|
||||||
Jedes Piece besitzt eine ganzzahlige Revision. Speichern, Archivieren und
|
Jedes Piece besitzt eine ganzzahlige Revision. Speichern, Archivieren und
|
||||||
Medienänderungen verwenden ein bedingtes Update auf die erwartete Revision.
|
Medienänderungen verwenden ein bedingtes Update auf die erwartete Revision.
|
||||||
@@ -123,9 +128,28 @@ erhöht sie atomar. Abgeschlossene Sendungen sind bereits an dieser Grenze gegen
|
|||||||
weitere Bearbeitung geschützt.
|
weitere Bearbeitung geschützt.
|
||||||
|
|
||||||
Beim Einplanen werden Titel, Dauer, Einleitung, Recherche, Moderation,
|
Beim Einplanen werden Titel, Dauer, Einleitung, Recherche, Moderation,
|
||||||
Überleitung und Präsentation aus dem sendefertigen Piece kopiert. Eigene Notizen
|
Überleitung und der vollständige Präsentationszustand aus dem sendefertigen
|
||||||
liegen ausschließlich an der Verwendung. Die Referenz zum Original bleibt für
|
Piece kopiert. Dazu gehören Modus, ausgewählte Quelladresse samt Zeitmarke,
|
||||||
Historie und Nachvollziehbarkeit erhalten, wird aber nicht live gespiegelt.
|
Metadaten und validierte Anbieter-ID. Eigene Notizen liegen ausschließlich an
|
||||||
|
der Verwendung. Die Referenz zum Original bleibt für Historie und
|
||||||
|
Nachvollziehbarkeit erhalten, wird aber nicht live gespiegelt. Eine explizite
|
||||||
|
Aktualisierung aus dem Fundus ersetzt Titel, Dauer, alle fünf Redaktionstexte
|
||||||
|
und den Präsentationszustand atomar aus dem referenzierten Original. Eigene
|
||||||
|
Notizen, Status und vorhandene Live-Intervalle werden dabei nicht verändert;
|
||||||
|
fehlt das Original oder ist die Sendungsrevision veraltet, wird die gesamte
|
||||||
|
Mutation verworfen.
|
||||||
|
Eine Einplanung zu duplizieren kopiert genau diesen Snapshot mit derselben
|
||||||
|
Original-ID direkt hinter das Ausgangselement. Die neue Verwendung erhält den
|
||||||
|
Status `open`, eine neue ID und damit weder Live-Referenzen noch Zeitintervalle.
|
||||||
|
|
||||||
|
Die Verwendungshistorie wird nicht separat gepflegt. Sie wird über die
|
||||||
|
Original-ID aus Verwendungen mit Status `done` in abgeschlossenen Sendungen
|
||||||
|
abgeleitet; Reservebank und alle anderen Verwendungs- oder Sendungsstatus sind
|
||||||
|
ausgeschlossen. Über dieselbe Original-ID wird unabhängig davon ermittelt, ob
|
||||||
|
mindestens eine Verwendung in einer noch nicht abgeschlossenen Sendung liegt.
|
||||||
|
Der allgemeine Fundus blendet diesen globalen Kontext standardmäßig aus. Die
|
||||||
|
Quellspalte einer Sendung betrachtet für ihren separaten Einplanungsfilter nur
|
||||||
|
die aktuelle Sendung einschließlich Reservebank.
|
||||||
|
|
||||||
Jede Sendung besitzt intern genau einen ausgeblendeten Reserveabschnitt. Dadurch
|
Jede Sendung besitzt intern genau einen ausgeblendeten Reserveabschnitt. Dadurch
|
||||||
verwenden Plan und Reserve dieselbe geprüfte Verwendungslogik, während die
|
verwenden Plan und Reserve dieselbe geprüfte Verwendungslogik, während die
|
||||||
@@ -138,17 +162,70 @@ die Abschnitte mit neuen IDs kopiert; spätere Änderungen an der Sendung könne
|
|||||||
die Vorlage deshalb nicht verändern.
|
die Vorlage deshalb nicht verändern.
|
||||||
|
|
||||||
Die Editorformulare bleiben progressive SvelteKit-Form-Actions, werden im
|
Die Editorformulare bleiben progressive SvelteKit-Form-Actions, werden im
|
||||||
Browser aber mit `use:enhance` gesendet. Dadurch bleibt das Dokument bei
|
Browser aber mit `use:enhance` gesendet. Der Verwendungseditor liegt in einem
|
||||||
Planungsmutationen bestehen; nur die serverseitigen Seitendaten werden
|
nativen Dialog, den ein beschrifteter Icon-Button öffnet. Dadurch bleibt das
|
||||||
aktualisiert. Ladeanzeige und FLIP-Animation liegen am betroffenen Abschnitt
|
Dokument bei Planungsmutationen bestehen; nur die serverseitigen Seitendaten
|
||||||
oder an der betroffenen Verwendung. Eindeutige Drag-Griffe übertragen entweder
|
werden aktualisiert. Ladeanzeige und FLIP-Animation liegen am betroffenen
|
||||||
eine Quellenkopie, einen Abschnitt oder eine Verwendung auf dieselben
|
Abschnitt oder an der betroffenen Verwendung. Eindeutige Drag-Griffe übertragen
|
||||||
|
entweder eine Quellenkopie, einen Abschnitt oder eine Verwendung auf dieselben
|
||||||
serverseitig geprüften Actions wie die alternativen Schaltflächen. Während des
|
serverseitig geprüften Actions wie die alternativen Schaltflächen. Während des
|
||||||
Ziehens bleibt das Original transparent an seinem Ausgangsort; eine flüchtige
|
Ziehens bleibt das Original transparent an seinem Ausgangsort; eine flüchtige
|
||||||
Vorschau in der Liste belegt bereits die anhand der Zeigerposition berechnete
|
Vorschau in der Liste belegt bereits die anhand der Zeigerposition berechnete
|
||||||
Zielhöhe und verdrängt dadurch die benachbarten Elemente. Persistiert wird erst
|
Zielhöhe und verdrängt dadurch die benachbarten Elemente. Persistiert wird erst
|
||||||
beim Loslassen.
|
beim Loslassen.
|
||||||
|
|
||||||
|
Die Ausschlussfilter für gesendete und bereits eingeplante Pieces arbeiten
|
||||||
|
clientseitig auf der serverseitig berechneten Kontextmenge. Ihr Zustand wird
|
||||||
|
ohne Navigation in die URL übernommen und bei nachfolgenden Suchfiltern
|
||||||
|
mitgesendet. Planmutationen invalidieren anschließend die Seitendaten, sodass
|
||||||
|
das Entfernen der letzten Einplanung ein Original unmittelbar wieder anbietet.
|
||||||
|
|
||||||
|
## Live-Modus und Präsentationsgrenze
|
||||||
|
|
||||||
|
`src/lib/server/live.ts` ist die Transaktionsgrenze der Live-Durchführung. Der
|
||||||
|
Live-Stand besitzt eine eigene Revision. Jeder steuernde Befehl trägt zusätzlich
|
||||||
|
eine vom Browser erzeugte Befehls-ID; `(show_id, command_id)` ist eindeutig und
|
||||||
|
liefert bei Wiederholung das bereits gespeicherte Ergebnis. Tatsächliche Zeiten
|
||||||
|
liegen als mehrere Start-/Endintervalle je Verwendung vor. Damit bleiben
|
||||||
|
Zurückgehen, Wiederaufnahme und bereits abgeschlossene Laufzeit getrennt von der
|
||||||
|
geplanten Dauer nachvollziehbar.
|
||||||
|
|
||||||
|
Die interne Route `/live` benötigt weiterhin eine aktive Sitzung und darf
|
||||||
|
Recherche, Moderation und eigene Arbeitsdaten lesen. Die separate Ausgabe
|
||||||
|
`/heinzlive/[token]` liegt dagegen in einem reduzierten Layout ohne Navigation
|
||||||
|
oder Nutzerdaten. In SQLite liegt nur der SHA-256-Hash des 256-Bit-Tokens; ein
|
||||||
|
neu erzeugter Ausgabezugang widerruft den vorherigen. Page, Polling-JSON und
|
||||||
|
Medienroute leiten ihre Daten aus einer eigenen Positivliste ab. Bilder werden
|
||||||
|
nur ausgeliefert, wenn sie zum aktuell ausdrücklich präsentierten Piece gehören.
|
||||||
|
Normale Auswahl, Fortschaltung oder Wiederaufnahme verändern den
|
||||||
|
Präsentationsstand nicht. Die öffentliche Projektion liest ausschließlich den
|
||||||
|
gespeicherten Verwendungssnapshot; spätere Änderungen am Original erscheinen
|
||||||
|
erst nach einer ausdrücklichen Snapshot-Aktualisierung.
|
||||||
|
|
||||||
|
Linkmetadaten werden nur auf ausdrückliche Aktion durch
|
||||||
|
`src/lib/server/presentation.ts` geladen. Jeder HTTP(S)-Abruf löst den Zielhost
|
||||||
|
serverseitig auf, sperrt lokale und private IPv4-/IPv6-Ziele und bindet den
|
||||||
|
Request an die geprüfte Adresse. Dieselbe Prüfung gilt nach höchstens drei
|
||||||
|
Redirects. Zeit- und Größenlimits begrenzen HTML, Anbieter-Metadaten und Bilder.
|
||||||
|
Externe Vorschaubilder gelangen nur über token- beziehungsweise
|
||||||
|
sitzungsgebundene Proxyrouten in die Ausgabe; fremdes HTML und fremde Skripte
|
||||||
|
werden nie übernommen.
|
||||||
|
|
||||||
|
Videoquellen werden aus der gespeicherten URL erneut auf eine streng validierte
|
||||||
|
YouTube- oder TikTok-ID reduziert. Der Browser erhält nur daraus erzeugte
|
||||||
|
offizielle Embed-URLs, startet sie nicht automatisch und ersetzt das Iframe bei
|
||||||
|
jedem Inhaltswechsel. YouTube erhält die Startsekunde als Embed-Parameter;
|
||||||
|
TikTok wird nach dessen Bereitschaft über die offizielle Player-`postMessage`-
|
||||||
|
Schnittstelle positioniert. Nicht unterstützte oder unvollständige Videoquellen
|
||||||
|
fallen auf eine normale Linkkarte zurück. Eine authentifizierte Testansicht
|
||||||
|
verwendet denselben Renderer, schreibt aber keinen Live-Zustand.
|
||||||
|
|
||||||
|
Die Ausgabe synchronisiert ihren kleinen öffentlichen Zustand per
|
||||||
|
`no-store`-Polling. Der letzte gültige Inhalt bleibt bei einem Verbindungsfehler
|
||||||
|
sichtbar; die Oberfläche kennzeichnet den Abbruch und versucht die Verbindung
|
||||||
|
mit verlangsamtem Intervall erneut. Private Live-Daten werden nicht Teil dieses
|
||||||
|
Zustandsobjekts.
|
||||||
|
|
||||||
## Oberflächenstruktur
|
## Oberflächenstruktur
|
||||||
|
|
||||||
Die Hauptnavigation umfasst Eingang, Fundus, Sendungen, Archiv und Verwaltung.
|
Die Hauptnavigation umfasst Eingang, Fundus, Sendungen, Archiv und Verwaltung.
|
||||||
@@ -158,17 +235,26 @@ die untere Hauptnavigation die Seitenleiste vollständig. Auf breiten Ansichten
|
|||||||
stehen Fundus und Ablauf nebeneinander. Bis einschließlich `72rem` werden sie
|
stehen Fundus und Ablauf nebeneinander. Bis einschließlich `72rem` werden sie
|
||||||
über eine gut erreichbare Umschaltung einzeln gezeigt, damit auch schmale
|
über eine gut erreichbare Umschaltung einzeln gezeigt, damit auch schmale
|
||||||
Desktopfenster ohne horizontalen Überlauf bedienbar bleiben.
|
Desktopfenster ohne horizontalen Überlauf bedienbar bleiben.
|
||||||
Der Live-Modus ist eine eigene, fokussierte Ansicht; die spätere
|
Der Live-Modus ist eine eigene, fokussierte Arbeitsansicht. Die
|
||||||
Präsentationsausgabe erhält eine separate, strikt reduzierte Datenansicht.
|
Präsentationsausgabe verwendet eine separate, strikt reduzierte Datenansicht
|
||||||
|
ohne interne Anwendungsnavigation.
|
||||||
|
|
||||||
Fundus und Sendungsbau sind produktive Arbeitsansichten. Der Live-Modus bleibt
|
Der eigenständige Piece-Editor ordnet denselben Formvertrag als redaktionelles
|
||||||
bis Etappe 5 eine sichtbare Gestaltungsvorschau, kann aber bereits gezielt die
|
Arbeitsblatt an. Titel, Fundstück, private Recherche sowie Einleitung,
|
||||||
gewählte Sendung und deren kopierte Texte lesen.
|
Moderationsstichpunkte und Überleitung bilden die primäre Schreibfläche.
|
||||||
|
Quellen, Einordnung, Präsentation und eine Bildzusammenfassung liegen auf breiten
|
||||||
|
Ansichten in einer kontextuellen Seitenleiste; auf kleinen Ansichten öffnen
|
||||||
|
dieselben DOM-Formfelder als fokussierbare Werkzeugflächen und werden dabei nicht
|
||||||
|
neu erzeugt oder ausgehängt. `EditorialMarkdownField` hält Lese- und
|
||||||
|
Bearbeitungszustand je Textfeld lokal, während alle Werte weiterhin gemeinsam
|
||||||
|
über die bestehende `save`-Action und Piece-Revision gespeichert werden. Die
|
||||||
|
separate Bild-Action und alle Präsentationsactions bleiben eigene serverseitige
|
||||||
|
Mutationen.
|
||||||
|
|
||||||
## Sicherheitsgrenzen ab den Folgeetappen
|
## Sicherheitsgrenzen
|
||||||
|
|
||||||
Authentifizierung und Autorisierung werden seit Etappe 2 serverseitig an jeder
|
Authentifizierung und Autorisierung werden seit Etappe 2 serverseitig an jeder
|
||||||
betroffenen Route und Action geprüft. Markdown und fremdes HTML werden vor
|
betroffenen Route und Action geprüft. Markdown und fremdes HTML werden vor
|
||||||
Ausgabe bereinigt. Uploadzugriff folgt denselben Rechten. Spätere
|
Ausgabe bereinigt. Uploadzugriff folgt denselben Rechten. Netzwerkabrufe für
|
||||||
Netzwerkabrufe erhalten Schutz gegen interne Ziele, Größen-/Zeitlimits und
|
Präsentationsmetadaten und Vorschaubilder schützen interne Ziele auch nach
|
||||||
kontrollierte Redirects.
|
DNS-Auflösung und Redirects und besitzen Größen-, Zeit- und Redirectlimits.
|
||||||
+75
-1
@@ -1,6 +1,6 @@
|
|||||||
# Entscheidungen
|
# Entscheidungen
|
||||||
|
|
||||||
Stand der Quellenprüfung: 21. Oktober 2026. Verwendet wurden offizielle
|
Stand der Quellenprüfung: 22. Oktober 2026. Verwendet wurden offizielle
|
||||||
Dokumentationen und die npm-Registry für konkrete Paket-Metadaten.
|
Dokumentationen und die npm-Registry für konkrete Paket-Metadaten.
|
||||||
|
|
||||||
## D-001: SvelteKit 3 und Node-Unterstützung
|
## D-001: SvelteKit 3 und Node-Unterstützung
|
||||||
@@ -202,3 +202,77 @@ Quellen:
|
|||||||
|
|
||||||
- <https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements>
|
- <https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements>
|
||||||
- <https://svelte.dev/docs/kit/form-actions>
|
- <https://svelte.dev/docs/kit/form-actions>
|
||||||
|
|
||||||
|
## D-016: Live-Befehle idempotent, tatsächliche Zeiten als Intervalle
|
||||||
|
|
||||||
|
Die Live-Steuerung verwendet eine eigene Revision und zusätzlich eine pro
|
||||||
|
Bedienaktion erzeugte Befehls-ID. Die Datenbank akzeptiert jede Kombination aus
|
||||||
|
Sendung und Befehls-ID nur einmal. Ein nach Verbindungsabbruch wiederholter
|
||||||
|
Befehl liefert dieselbe Ergebnisrevision und erzeugt weder einen zweiten
|
||||||
|
Statuswechsel noch ein zweites Zeitintervall. Laufzeit wird nicht als einzelner
|
||||||
|
überschreibbarer Wert, sondern als Summe abgeschlossener und höchstens eines
|
||||||
|
aktiven Intervalls ermittelt. Dadurch bleiben Zurückgehen und Wiederaufnahme
|
||||||
|
korrekt.
|
||||||
|
|
||||||
|
## D-017: Präsentationsausgabe als Positivliste mit gehashtem Zugang
|
||||||
|
|
||||||
|
Die heinzlive-Ausgabe ist kein eingeschränkter Aufruf der internen Live-Ansicht,
|
||||||
|
sondern eine eigene Datenprojektion. Zulässig sind ausschließlich ausdrücklich
|
||||||
|
präsentierter Titel und Präsentationstext, öffentliche Quellen sowie zugehörige
|
||||||
|
Bilder und Alternativtexte. Recherche, Einleitung, Moderation, eigene Notizen,
|
||||||
|
Ablauf, Nutzer und interne Dateinamen werden nicht in HTML oder JSON übernommen.
|
||||||
|
Ein zufälliger 256-Bit-Token steht in der URL, während SQLite nur seinen
|
||||||
|
SHA-256-Hash speichert. Medienzugriff prüft Token, aktuelle Präsentation und
|
||||||
|
Bildzuordnung gemeinsam. Synchronisierung erfolgt über kleines `no-store`-
|
||||||
|
Polling statt über eine dauerhaft offene Serververbindung.
|
||||||
|
|
||||||
|
## D-018: Verwendung aus bestehenden Sendungsdaten ableiten
|
||||||
|
|
||||||
|
„Gesendet“ ist kein Zustand am Fundus-Piece. Die Anzeige wird ausschließlich
|
||||||
|
aus der vorhandenen Original-ID, einer erledigten Verwendung außerhalb der
|
||||||
|
Reservebank und dem Status `completed` ihrer Sendung abgeleitet. Dadurch können
|
||||||
|
Einplanung, Reserve und Überspringen ein Original nicht versehentlich als
|
||||||
|
gesendet markieren, und mehrere tatsächliche Verwendungen bleiben als Historie
|
||||||
|
sichtbar.
|
||||||
|
|
||||||
|
Eine Duplikation im Sendungsablauf kopiert den konkreten Verwendungssnapshot und
|
||||||
|
nicht das Original-Piece. Die neue ID, der Status `open` und fehlende
|
||||||
|
Live-Intervalle trennen sie von der bisherigen Durchführung. Der allgemeine
|
||||||
|
Verwendungseditor darf den Live-Status nicht mehr aus Formulardaten schreiben;
|
||||||
|
Statuswechsel bleiben der Live-Geschäftslogik vorbehalten.
|
||||||
|
|
||||||
|
Eine bestehende Einplanung wird nicht automatisch mit späteren Änderungen am
|
||||||
|
Original synchronisiert. Die ausdrücklich ausgelöste Aktion **Aus Fundus
|
||||||
|
aktualisieren** überschreibt nur Titel, Dauer und Redaktionstexte. Eigene
|
||||||
|
Notizen, Status und Messintervalle bleiben erhalten. Alle Zuordnungen und Filter
|
||||||
|
verwenden ausschließlich `original_piece_id`, niemals veränderliche Titel. Im
|
||||||
|
allgemeinen Fundus gilt „eingeplant“ global für jede nicht abgeschlossene
|
||||||
|
Sendung; im Sendungsbau gilt es lokal für die aktuelle Sendung samt Reserve.
|
||||||
|
|
||||||
|
## D-019: Lokale Linkmetadaten und streng abgeleitete Video-Embeds
|
||||||
|
|
||||||
|
Sendewerk verwendet Metascraper ausschließlich serverseitig, um Titel,
|
||||||
|
Beschreibung, Bild und Herausgeber einer ausdrücklich gewählten vorhandenen
|
||||||
|
Quelle zu ermitteln. Die Ergebnisse werden gespeichert und nicht bei jedem
|
||||||
|
Seitenaufruf neu geladen. Manuell korrigierte Felder haben Vorrang. Ein eigener
|
||||||
|
HTTP(S)-Client prüft Protokoll, Port, DNS-Ergebnisse und jedes Redirectziel,
|
||||||
|
bindet den Request an die geprüfte öffentliche Adresse und begrenzt Redirects,
|
||||||
|
Laufzeit und Antwortgröße. Damit ist weder ein externer Vorschaudienst noch die
|
||||||
|
Übernahme fremden HTMLs erforderlich.
|
||||||
|
|
||||||
|
Player werden nur für streng erkannte YouTube- und TikTok-URLs erzeugt. Aus der
|
||||||
|
validierten Anbieter-ID baut Sendewerk die offiziellen Embed-Adressen selbst;
|
||||||
|
gespeichertes oder fremd geliefertes Embed-HTML wird nicht verwendet. YouTube
|
||||||
|
nutzt die datenschutzreduzierte `youtube-nocookie.com`-Adresse und den
|
||||||
|
`start`-Parameter. TikTok erhält eine Startposition nach `onPlayerReady` über
|
||||||
|
die dokumentierte Player-`postMessage`-API. Autoplay bleibt ausgeschaltet, und
|
||||||
|
ein Inhaltswechsel ersetzt das Iframe vollständig.
|
||||||
|
|
||||||
|
Quellen:
|
||||||
|
|
||||||
|
- <https://github.com/microlinkhq/metascraper>
|
||||||
|
- <https://developers.google.com/youtube/player_parameters>
|
||||||
|
- <https://developers.google.com/youtube/terms/required-minimum-functionality>
|
||||||
|
- <https://developers.tiktok.com/doc/embed-player>
|
||||||
|
- <https://developers.tiktok.com/doc/embed-videos>
|
||||||
|
- <https://owasp.org/www-community/attacks/Server_Side_Request_Forgery>
|
||||||
+118
-6
@@ -2,9 +2,52 @@
|
|||||||
|
|
||||||
## Aktueller Umfang
|
## Aktueller Umfang
|
||||||
|
|
||||||
Etappe 1 bis Etappe 4 sind abgeschlossen. Architektur, Gesamtdatenmodell,
|
Etappe 1 bis Etappe 5 sind abgeschlossen. Architektur, Gesamtdatenmodell,
|
||||||
Anmeldung, Rollen, persistente Inhaltsbearbeitung, Sendungsplanung und lokaler
|
Anmeldung, Rollen, persistente Inhaltsbearbeitung, Sendungsplanung,
|
||||||
Betriebsweg sind dokumentiert. Etappe 5 wurde nicht begonnen.
|
Live-Steuerung, Präsentationsausgabe und lokaler Betriebsweg sind dokumentiert.
|
||||||
|
Etappe 6 wurde nicht begonnen.
|
||||||
|
|
||||||
|
## Oberflächenkorrektur 0.5.5
|
||||||
|
|
||||||
|
- dunkle Grundfläche mit sehr zurückhaltenden Gold-/Cyan-Lichtfeldern innerhalb
|
||||||
|
der Anwendung statt gleichmäßig deckender Blauflächen
|
||||||
|
- Navigation, große Arbeitsflächen und Piece-Dialog als dunkles beziehungsweise
|
||||||
|
helles Glas mit feiner Lichtkante, Unschärfe und ruhigem Schatten
|
||||||
|
- Gold für Dialogkontur, Fokus, aktive Zustände und Hauptaktionen; Cyan nur noch
|
||||||
|
für ergänzende redaktionelle Hinweise und Links
|
||||||
|
- klar abgegrenzte, weitgehend deckende Schreibfelder mit Goldfokus, Platzhaltern
|
||||||
|
und nach Textrolle abgestuften Höhen
|
||||||
|
- bestehende nachträgliche CSS-Override-Schicht entfernt und die Gestaltung in
|
||||||
|
gemeinsame Tokens und ursprüngliche Komponentenregeln zurückgeführt
|
||||||
|
|
||||||
|
Geprüft wurden Typen, Produktionsbuild sowie gezielte Chromium-Ansichten von
|
||||||
|
Eingang, Fundus, Piece-Editor, Sendungsplanung und Live-Steuerung bei 1440 × 1000
|
||||||
|
und 390 × 844 Pixeln in beiden Themes. Die vollständige Unit- und E2E-Matrix
|
||||||
|
bleibt wie beauftragt Schritt 3 vorbehalten.
|
||||||
|
|
||||||
|
## Oberflächenrelease 0.5.4
|
||||||
|
|
||||||
|
- gemeinsame Light-/Dark-Tokens für ruhige Arbeitsflächen, Cyan als
|
||||||
|
Interaktionsfarbe und Gold für die jeweilige Hauptaktion
|
||||||
|
- Darkmode im heinzlive-Farbraum mit Hintergrund `#0B1220`, Flächen `#152238`,
|
||||||
|
Text `#FFF7E8`, Sekundärtext `#A9B6C8`, Gold `#E7B957`, Cyan `#67DDE8` und
|
||||||
|
Grenzen `#30435C`
|
||||||
|
- vereinheitlichte Navigation, Formulare, Meldungen, Listen, Sendungsplan,
|
||||||
|
Live-Steuerung und Piece-Dialoge ohne Änderung der Bedienlogik
|
||||||
|
- kompaktere Planzeilen mit sichtbarem Drag-Griff und waagerechter Aktionsgruppe;
|
||||||
|
Klick-, Touch- und Tastaturalternativen bleiben erhalten
|
||||||
|
- verständliche Kontextnamen „Fundusfassung“ und „Sendungsfassung“ sowie weniger
|
||||||
|
technische Erläuterungen im redaktionellen Arbeitsfluss
|
||||||
|
- dezente Speicheraktion im gespeicherten Zustand und hervorgehobene Aktion bei
|
||||||
|
ungespeicherten Änderungen, Fehlern oder Konflikten
|
||||||
|
|
||||||
|
Für diesen Design-Release wurden `npm run check`, `npm run build` und gezielte
|
||||||
|
Chromium-Sichtkontrollen auf Eingang, Fundus, Piece-Editor, Sendungsplan und
|
||||||
|
Live-Steuerung bei 1440 × 1000 sowie 390 × 844 Pixeln in Light/Dark ausgeführt.
|
||||||
|
Konsolenfehler und horizontaler Seitenüberlauf traten dabei nicht auf. Die
|
||||||
|
vollständige Unit- und E2E-Matrix wurde für die rein visuelle Änderung bewusst
|
||||||
|
nicht erneut ausgeführt; die fachlichen Nachweise der Etappen 1 bis 5 bleiben
|
||||||
|
unverändert.
|
||||||
|
|
||||||
## Umgesetzter Stand Etappe 1
|
## Umgesetzter Stand Etappe 1
|
||||||
|
|
||||||
@@ -37,9 +80,8 @@ umgebrochen.
|
|||||||
|
|
||||||
## Noch nicht umgesetzt
|
## Noch nicht umgesetzt
|
||||||
|
|
||||||
Echte Live-Steuerung, Präsentationsfenster, Archivabschluss, Freigaben, RSS und
|
Archivabschluss, Freigaben, RSS und API. Diese späteren Bereiche dürfen nicht
|
||||||
API. Die verbleibenden Vorschauen dürfen nicht als
|
als bereits implementiert verstanden werden.
|
||||||
Implementierung dieser späteren Funktionen verstanden werden.
|
|
||||||
|
|
||||||
## Umgesetzter Stand Etappe 2
|
## Umgesetzter Stand Etappe 2
|
||||||
|
|
||||||
@@ -67,6 +109,32 @@ Implementierung dieser späteren Funktionen verstanden werden.
|
|||||||
- Archivieren und Wiederherstellen in den vorherigen Arbeitsstatus
|
- Archivieren und Wiederherstellen in den vorherigen Arbeitsstatus
|
||||||
- private Rasterbilder mit Größen-/Signaturprüfung und geschützter Auslieferung
|
- private Rasterbilder mit Größen-/Signaturprüfung und geschützter Auslieferung
|
||||||
- erweiterter Seed mit Eingangs-, Archiv-, Markdown- und Recherchebeispielen
|
- erweiterter Seed mit Eingangs-, Archiv-, Markdown- und Recherchebeispielen
|
||||||
|
- standardmäßig ausgeblendete gesendete Pieces mit verlinkter, aufklappbarer
|
||||||
|
Verwendungshistorie; gesendet bedeutet erledigt in abgeschlossener Sendung
|
||||||
|
- standardmäßig ausgeblendete Pieces, die in mindestens einer noch nicht
|
||||||
|
abgeschlossenen Sendung eingeplant sind, mit unabhängigem Sofortfilter
|
||||||
|
- Fundus-Originale und sendungsspezifische Verwendungen nutzen denselben
|
||||||
|
großzügigen Dialograhmen mit den Bereichen „Sendungstext“, „Recherche &
|
||||||
|
Quellen“ und „Präsentation“; der jeweilige Speicherkontext ist sichtbar und
|
||||||
|
Original sowie Verwendung bleiben getrennte Revisionsgrenzen
|
||||||
|
- Titel, Einleitung, Moderationsstichpunkte und Überleitung sind ohne
|
||||||
|
vorgeschaltete Lese-/Bearbeitungsschalter direkt beschreibbar; eine kleine
|
||||||
|
Markdown-Leiste ergänzt Formatierung ohne Änderung des Speicherformats
|
||||||
|
- Recherche, Quellen, verwendungseigene Notizen und Material sind in einem
|
||||||
|
Bereich gebündelt; öffentliche Texte, Darstellungswahl und tatsächliche
|
||||||
|
Vorschau stehen gemeinsam im Präsentationsbereich
|
||||||
|
- der Dialog bleibt innerhalb der Desktop-Fensterhöhe, hält Kopf,
|
||||||
|
Bereichsnavigation und Aktionen sichtbar und nutzt mobil die volle
|
||||||
|
Bildschirmfläche; Bereichswechsel hängen Eingaben nicht aus und merken die
|
||||||
|
jeweilige Scrollposition
|
||||||
|
- die Schnellaufnahme akzeptiert Gedanke oder URL, bleibt nach dem Ablegen im
|
||||||
|
Eingang und öffnet die Ausarbeitung erst über eine bewusste Aktion
|
||||||
|
|
||||||
|
Für diese gezielte Überarbeitung wurden `npm run check` sowie kurze
|
||||||
|
Chromium-Sichtkontrollen des Original- und Verwendungseditors bei 1440 × 1000
|
||||||
|
und 390 × 844 Pixeln ausgeführt. Dabei waren Dialoggrenzen, feste Bedienbereiche,
|
||||||
|
alle drei Arbeitsbereiche und horizontaler Überlauf unauffällig. Die vollständige
|
||||||
|
Unit-, E2E- und Build-Matrix ist gemäß Auftrag noch offen.
|
||||||
|
|
||||||
## Umgesetzter Stand Etappe 4
|
## Umgesetzter Stand Etappe 4
|
||||||
|
|
||||||
@@ -78,6 +146,12 @@ Implementierung dieser späteren Funktionen verstanden werden.
|
|||||||
- showweite Reservebank, die nicht in Abschnitts- oder Gesamtdauer einfließt
|
- showweite Reservebank, die nicht in Abschnitts- oder Gesamtdauer einfließt
|
||||||
- explizite Abschnittsdauer ersetzt die Piece-Summe statt sie zu addieren
|
- explizite Abschnittsdauer ersetzt die Piece-Summe statt sie zu addieren
|
||||||
- Bearbeiten, Entfernen sowie Verschieben innerhalb und zwischen Abschnitten
|
- Bearbeiten, Entfernen sowie Verschieben innerhalb und zwischen Abschnitten
|
||||||
|
- zugänglicher Stift-Dialog für alle sendungsspezifischen Felder und Aktionen,
|
||||||
|
auf Desktop zweispaltig und auf kleinen Bildschirmen einspaltig scrollbar
|
||||||
|
- explizites Aktualisieren eines Verwendungssnapshots aus dem Original für
|
||||||
|
Titel, Dauer und Redaktionstexte bei erhaltenen Notizen und Live-Daten
|
||||||
|
- Duplizieren einer konkreten Einplanung direkt hinter dem Ausgangselement mit
|
||||||
|
erhaltenen Anpassungen, aber zurückgesetztem Live-Zustand
|
||||||
- Piece-Dauern werden im Editor in Minuten eingegeben und intern weiterhin als
|
- Piece-Dauern werden im Editor in Minuten eingegeben und intern weiterhin als
|
||||||
ganze Sekunden gespeichert
|
ganze Sekunden gespeichert
|
||||||
- Drag-and-drop über eindeutige Griffe, auch direkt aus gefilterten Quellen,
|
- Drag-and-drop über eindeutige Griffe, auch direkt aus gefilterten Quellen,
|
||||||
@@ -85,11 +159,40 @@ Implementierung dieser späteren Funktionen verstanden werden.
|
|||||||
gleichwertigen Klick-, Touch- und Tastaturaktionen
|
gleichwertigen Klick-, Touch- und Tastaturaktionen
|
||||||
- Planungsmutationen ohne Dokumentreload mit lokalem Speicherzustand und
|
- Planungsmutationen ohne Dokumentreload mit lokalem Speicherzustand und
|
||||||
animierter Neusortierung der betroffenen Elemente
|
animierter Neusortierung der betroffenen Elemente
|
||||||
|
- unabhängige Sofortfilter für verwendete sowie in der aktuellen Sendung schon
|
||||||
|
eingeplante Originale einschließlich Reservebank
|
||||||
- kopierbare Twitch-Titel und Ankündigungstexte
|
- kopierbare Twitch-Titel und Ankündigungstexte
|
||||||
- showweite optimistische Revision schützt Metadaten, Reihenfolge und Inhalte
|
- showweite optimistische Revision schützt Metadaten, Reihenfolge und Inhalte
|
||||||
vor unbemerktem parallelem Überschreiben
|
vor unbemerktem parallelem Überschreiben
|
||||||
- realistischer Seed mit Standardablauf und eigenständigem Spieleabend
|
- realistischer Seed mit Standardablauf und eigenständigem Spieleabend
|
||||||
|
|
||||||
|
## Umgesetzter Stand Etappe 5
|
||||||
|
|
||||||
|
- fokussierte Moderationsansicht mit Prompter-Schrift, Einleitung, Moderation,
|
||||||
|
Überleitung und standardmäßig geschlossener privater Recherche
|
||||||
|
- ausblendbare Zeit- und Ablaufanzeige sowie persistente lokale Leseposition
|
||||||
|
- aktuelles und nächstes Piece samt Abschnitt und geplantem Zeitbedarf
|
||||||
|
- persistenter Live-Stand mit tatsächlichen Laufintervallen, Erledigen,
|
||||||
|
Überspringen, Zurück und Wiederaufnahme
|
||||||
|
- idempotente Live-Befehle verhindern doppelte Wirkung bei Wiederholung
|
||||||
|
- serverseitig geschützte Umsortierung offener Pieces und Reserveeinfügung
|
||||||
|
- explizite Präsentationsaktion; normale Live-Navigation verändert die Ausgabe
|
||||||
|
nicht
|
||||||
|
- getrennte, tokenisierte heinzlive-Ausgabe mit Polling, Verbindungsanzeige,
|
||||||
|
Präsentationstext, Quellen und erlaubten Bildern
|
||||||
|
- wählbare Text-, Linkkarten- und Videodarstellung aus genau einer vorhandenen
|
||||||
|
Piece-Quelle mit manuell korrigierbaren, persistenten Metadaten
|
||||||
|
- ausdrückliches serverseitiges Neuladen von Linkmetadaten über Metascraper mit
|
||||||
|
DNS-, Redirect-, Zeit-, Größen- und Privatnetzschutz
|
||||||
|
- validierte YouTube- und TikTok-IDs, offizielle Player-Iframes ohne Autoplay
|
||||||
|
sowie Linkkarten-Fallback für nicht unterstützte Videoquellen
|
||||||
|
- unveränderliche Präsentationssnapshots je Einplanung und explizite
|
||||||
|
Aktualisierung aus dem Fundus
|
||||||
|
- isolierte Präsentationstestansicht ohne Änderung des Live-Stands sowie
|
||||||
|
tokengebundene, serverseitig geschützte Proxys für externe Vorschaubilder
|
||||||
|
- Ausgabe-HTML, JSON und Medienzugriff enthalten keine Recherche,
|
||||||
|
Moderationsnotizen, eigenen Notizen, Kontodaten oder internen Dateipfade
|
||||||
|
|
||||||
## Bekannte offene Betriebsprüfung
|
## Bekannte offene Betriebsprüfung
|
||||||
|
|
||||||
Eine echte Cloudron-Installation samt Backup/Restore, Reverse-Proxy-Verhalten
|
Eine echte Cloudron-Installation samt Backup/Restore, Reverse-Proxy-Verhalten
|
||||||
@@ -98,6 +201,15 @@ durchgeführt werden. Auch der lokale Container-Smoke-Test blieb offen, weil
|
|||||||
auf der Prüfmaschine kein Docker-Daemon lief. Manifestkernfelder und
|
auf der Prüfmaschine kein Docker-Daemon lief. Manifestkernfelder und
|
||||||
Startskript-Syntax wurden lokal geprüft.
|
Startskript-Syntax wurden lokal geprüft.
|
||||||
|
|
||||||
|
Eine reale OBS-Browserquelle stand nicht zur Verfügung. Die tokenisierte
|
||||||
|
Präsentationsausgabe wurde stattdessen in einem anonymen zweiten Chromium-
|
||||||
|
Browserkontext einschließlich Bild, JSON-Filterung, Polling und sichtbarem
|
||||||
|
Verbindungsabbruch geprüft.
|
||||||
|
|
||||||
|
Die automatisierten Playerprüfungen fingen YouTube- und TikTok-Requests lokal
|
||||||
|
ab. URL-Erkennung, Iframe-Wechsel, Zeitmarkenübergabe und mobile Ausgabe sind
|
||||||
|
damit geprüft, nicht jedoch die reale Wiedergabe oder Verfügbarkeit der Anbieter.
|
||||||
|
|
||||||
## Verifizierte Umgebung
|
## Verifizierte Umgebung
|
||||||
|
|
||||||
- Node.js 22.23.1, npm 10.9.8
|
- Node.js 22.23.1, npm 10.9.8
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
CREATE TABLE show_live_states (
|
||||||
|
show_id TEXT PRIMARY KEY REFERENCES shows(id) ON DELETE CASCADE,
|
||||||
|
revision INTEGER NOT NULL DEFAULT 0 CHECK (revision >= 0),
|
||||||
|
current_usage_id TEXT REFERENCES piece_usages(id) ON DELETE SET NULL,
|
||||||
|
started_at_utc TEXT,
|
||||||
|
ended_at_utc TEXT,
|
||||||
|
presentation_usage_id TEXT REFERENCES piece_usages(id) ON DELETE SET NULL,
|
||||||
|
presentation_revision INTEGER NOT NULL DEFAULT 0 CHECK (presentation_revision >= 0),
|
||||||
|
updated_at_utc TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE live_usage_runs (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
show_id TEXT NOT NULL REFERENCES shows(id) ON DELETE CASCADE,
|
||||||
|
usage_id TEXT NOT NULL REFERENCES piece_usages(id) ON DELETE CASCADE,
|
||||||
|
started_at_utc TEXT NOT NULL,
|
||||||
|
ended_at_utc TEXT,
|
||||||
|
CHECK (ended_at_utc IS NULL OR ended_at_utc >= started_at_utc)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX idx_one_active_live_run_per_show
|
||||||
|
ON live_usage_runs(show_id) WHERE ended_at_utc IS NULL;
|
||||||
|
CREATE INDEX idx_live_runs_usage ON live_usage_runs(usage_id, started_at_utc);
|
||||||
|
|
||||||
|
CREATE TABLE live_commands (
|
||||||
|
show_id TEXT NOT NULL REFERENCES shows(id) ON DELETE CASCADE,
|
||||||
|
command_id TEXT NOT NULL,
|
||||||
|
action TEXT NOT NULL,
|
||||||
|
result_revision INTEGER NOT NULL CHECK (result_revision >= 0),
|
||||||
|
created_at_utc TEXT NOT NULL,
|
||||||
|
PRIMARY KEY (show_id, command_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE presentation_access_tokens (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
show_id TEXT NOT NULL REFERENCES shows(id) ON DELETE CASCADE,
|
||||||
|
token_hash TEXT NOT NULL UNIQUE,
|
||||||
|
created_at_utc TEXT NOT NULL,
|
||||||
|
revoked_at_utc TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_presentation_tokens_show
|
||||||
|
ON presentation_access_tokens(show_id, revoked_at_utc);
|
||||||
|
|
||||||
|
UPDATE piece_usages SET status = 'open' WHERE status = 'current';
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
ALTER TABLE pieces ADD COLUMN presentation_mode TEXT NOT NULL DEFAULT 'text'
|
||||||
|
CHECK (presentation_mode IN ('text', 'link', 'video'));
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_source_position INTEGER;
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_title TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_description TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_image_url TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_site_name TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_provider TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_provider_id TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_title_manual INTEGER NOT NULL DEFAULT 0
|
||||||
|
CHECK (presentation_title_manual IN (0, 1));
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_description_manual INTEGER NOT NULL DEFAULT 0
|
||||||
|
CHECK (presentation_description_manual IN (0, 1));
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_image_manual INTEGER NOT NULL DEFAULT 0
|
||||||
|
CHECK (presentation_image_manual IN (0, 1));
|
||||||
|
ALTER TABLE pieces ADD COLUMN presentation_metadata_fetched_at_utc TEXT;
|
||||||
|
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_mode_snapshot TEXT NOT NULL DEFAULT 'text'
|
||||||
|
CHECK (presentation_mode_snapshot IN ('text', 'link', 'video'));
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_source_label_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_source_url_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_source_timecode_snapshot INTEGER;
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_title_meta_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_description_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_image_url_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_site_name_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_provider_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE piece_usages ADD COLUMN presentation_provider_id_snapshot TEXT NOT NULL DEFAULT '';
|
||||||
Generated
+1591
-7
File diff suppressed because it is too large.
Load diff
+6
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "sendewerk",
|
"name": "sendewerk",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.4.0",
|
"version": "0.5.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=22.17 <25"
|
"node": ">=22.17 <25"
|
||||||
@@ -28,6 +28,11 @@
|
|||||||
"better-sqlite3": "^13.0.3",
|
"better-sqlite3": "^13.0.3",
|
||||||
"file-type": "^22.2.0",
|
"file-type": "^22.2.0",
|
||||||
"marked": "^18.1.1",
|
"marked": "^18.1.1",
|
||||||
|
"metascraper": "^5.58.5",
|
||||||
|
"metascraper-description": "^5.58.4",
|
||||||
|
"metascraper-image": "^5.58.4",
|
||||||
|
"metascraper-publisher": "^5.58.4",
|
||||||
|
"metascraper-title": "^5.58.4",
|
||||||
"nodemailer": "^10.1.7",
|
"nodemailer": "^10.1.7",
|
||||||
"sanitize-html": "^2.18.1"
|
"sanitize-html": "^2.18.1"
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -348,7 +348,7 @@ export function seed(databasePath = getPaths().database) {
|
|||||||
'section-stories',
|
'section-stories',
|
||||||
'piece-console',
|
'piece-console',
|
||||||
0,
|
0,
|
||||||
'current',
|
'open',
|
||||||
480,
|
480,
|
||||||
'Die kleine Konsole mit dem großen Dreh',
|
'Die kleine Konsole mit dem großen Dreh',
|
||||||
'Eine Kurbel, ein gelber Knopf und sehr viel Charme: Was macht kleine Hardware spannend?',
|
'Eine Kurbel, ein gelber Knopf und sehr viel Charme: Was macht kleine Hardware spannend?',
|
||||||
|
|||||||
+2139
-106
File diff suppressed because it is too large.
Load diff
Vendored
+1
@@ -7,6 +7,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
interface PageData {
|
interface PageData {
|
||||||
user?: AuthUser | null;
|
user?: AuthUser | null;
|
||||||
|
presentationMode?: boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -13,11 +13,13 @@ const publicPaths = new Set([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export const handle: Handle = async ({ event, resolve }) => {
|
export const handle: Handle = async ({ event, resolve }) => {
|
||||||
|
const presentationPath = event.url.pathname.startsWith('/heinzlive/');
|
||||||
|
const presentationTestPath = /^\/fundus\/[^/]+\/praesentation(?:\/|$)/.test(event.url.pathname);
|
||||||
const token = event.cookies.get(SESSION_COOKIE);
|
const token = event.cookies.get(SESSION_COOKIE);
|
||||||
event.locals.user = getSessionUser(token);
|
event.locals.user = getSessionUser(token);
|
||||||
if (token && !event.locals.user) deleteSession(event.cookies);
|
if (token && !event.locals.user) deleteSession(event.cookies);
|
||||||
|
|
||||||
if (!publicPaths.has(event.url.pathname) && !event.locals.user) {
|
if (!presentationPath && !publicPaths.has(event.url.pathname) && !event.locals.user) {
|
||||||
redirect(303, hasUsers() ? '/login' : '/setup');
|
redirect(303, hasUsers() ? '/login' : '/setup');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +27,14 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|||||||
response.headers.set('Referrer-Policy', 'same-origin');
|
response.headers.set('Referrer-Policy', 'same-origin');
|
||||||
response.headers.set('X-Content-Type-Options', 'nosniff');
|
response.headers.set('X-Content-Type-Options', 'nosniff');
|
||||||
response.headers.set('X-Frame-Options', 'DENY');
|
response.headers.set('X-Frame-Options', 'DENY');
|
||||||
|
if (presentationPath || presentationTestPath) {
|
||||||
|
response.headers.set('Cache-Control', 'no-store');
|
||||||
|
response.headers.set('Referrer-Policy', 'strict-origin-when-cross-origin');
|
||||||
|
response.headers.set(
|
||||||
|
'Content-Security-Policy',
|
||||||
|
"frame-src https://www.youtube-nocookie.com https://www.youtube.com https://www.tiktok.com; frame-ancestors 'none'"
|
||||||
|
);
|
||||||
|
}
|
||||||
if (event.url.pathname === '/einladung' || event.url.pathname === '/passwort-zuruecksetzen') {
|
if (event.url.pathname === '/einladung' || event.url.pathname === '/passwort-zuruecksetzen') {
|
||||||
response.headers.set('Cache-Control', 'no-store');
|
response.headers.set('Cache-Control', 'no-store');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { tick } from 'svelte';
|
||||||
|
|
||||||
|
let {
|
||||||
|
name,
|
||||||
|
label,
|
||||||
|
value = $bindable(),
|
||||||
|
rows = 4,
|
||||||
|
placeholder = '',
|
||||||
|
privateField = false,
|
||||||
|
form
|
||||||
|
}: {
|
||||||
|
name: string;
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
rows?: number;
|
||||||
|
placeholder?: string;
|
||||||
|
privateField?: boolean;
|
||||||
|
form?: string;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let textarea: HTMLTextAreaElement;
|
||||||
|
|
||||||
|
async function replaceSelection(before: string, after = before, fallback = 'Text') {
|
||||||
|
const start = textarea.selectionStart;
|
||||||
|
const end = textarea.selectionEnd;
|
||||||
|
const selected = value.slice(start, end) || fallback;
|
||||||
|
value = `${value.slice(0, start)}${before}${selected}${after}${value.slice(end)}`;
|
||||||
|
await tick();
|
||||||
|
textarea.focus();
|
||||||
|
textarea.setSelectionRange(start + before.length, start + before.length + selected.length);
|
||||||
|
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addList() {
|
||||||
|
const start = textarea.selectionStart;
|
||||||
|
const end = textarea.selectionEnd;
|
||||||
|
const selected = value.slice(start, end) || 'Stichpunkt';
|
||||||
|
const replacement = selected
|
||||||
|
.split('\n')
|
||||||
|
.map((line) => `- ${line}`)
|
||||||
|
.join('\n');
|
||||||
|
value = `${value.slice(0, start)}${replacement}${value.slice(end)}`;
|
||||||
|
await tick();
|
||||||
|
textarea.focus();
|
||||||
|
textarea.setSelectionRange(start + 2, start + replacement.length);
|
||||||
|
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class:private-field={privateField} class="markdown-editor-field">
|
||||||
|
<div class="markdown-editor-heading">
|
||||||
|
<span
|
||||||
|
>{label}{#if privateField}<small>Nur intern</small>{/if}</span
|
||||||
|
>
|
||||||
|
<span class="markdown-toolbar" role="toolbar" aria-label={`${label} formatieren`}>
|
||||||
|
<button type="button" aria-label="Fett" title="Fett" onclick={() => replaceSelection('**')}
|
||||||
|
><strong>B</strong></button
|
||||||
|
>
|
||||||
|
<button type="button" aria-label="Kursiv" title="Kursiv" onclick={() => replaceSelection('_')}
|
||||||
|
><em>I</em></button
|
||||||
|
>
|
||||||
|
<button type="button" aria-label="Liste" title="Liste" onclick={addList}>• Liste</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label="Link"
|
||||||
|
title="Link"
|
||||||
|
onclick={() => replaceSelection('[', '](https://)', 'Linktext')}>↗ Link</button
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<textarea
|
||||||
|
bind:this={textarea}
|
||||||
|
aria-label={label}
|
||||||
|
{name}
|
||||||
|
{rows}
|
||||||
|
{placeholder}
|
||||||
|
{form}
|
||||||
|
maxlength="50000"
|
||||||
|
bind:value></textarea>
|
||||||
|
</div>
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
<path
|
<path
|
||||||
d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M18.4 5.6 17 7M7 17l-1.4 1.4"
|
d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M18.4 5.6 17 7M7 17l-1.4 1.4"
|
||||||
/>
|
/>
|
||||||
|
{:else if name === 'edit'}
|
||||||
|
<path d="M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4" />
|
||||||
{/if}
|
{/if}
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { tick, type Snippet } from 'svelte';
|
||||||
|
|
||||||
|
let {
|
||||||
|
labelledby,
|
||||||
|
activeSection = $bindable(),
|
||||||
|
onrequestclose,
|
||||||
|
header,
|
||||||
|
children,
|
||||||
|
footer
|
||||||
|
}: {
|
||||||
|
labelledby: string;
|
||||||
|
activeSection: 'script' | 'research' | 'presentation';
|
||||||
|
onrequestclose: () => void;
|
||||||
|
header: Snippet;
|
||||||
|
children: Snippet;
|
||||||
|
footer: Snippet;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let dialog: HTMLDialogElement;
|
||||||
|
let workspace: HTMLDivElement;
|
||||||
|
const scrollPositions = { script: 0, research: 0, presentation: 0 };
|
||||||
|
|
||||||
|
async function selectSection(section: typeof activeSection) {
|
||||||
|
scrollPositions[activeSection] = workspace.scrollTop;
|
||||||
|
activeSection = section;
|
||||||
|
await tick();
|
||||||
|
workspace.scrollTop = scrollPositions[section];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function showModal() {
|
||||||
|
if (!dialog.open) dialog.showModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function close() {
|
||||||
|
dialog.close();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<dialog
|
||||||
|
bind:this={dialog}
|
||||||
|
class="piece-editor-dialog"
|
||||||
|
aria-labelledby={labelledby}
|
||||||
|
oncancel={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
onrequestclose();
|
||||||
|
}}
|
||||||
|
onclick={(event) => event.target === dialog && onrequestclose()}
|
||||||
|
>
|
||||||
|
<header class="piece-dialog-header">
|
||||||
|
<div class="piece-dialog-heading">{@render header()}</div>
|
||||||
|
<button
|
||||||
|
class="dialog-close"
|
||||||
|
type="button"
|
||||||
|
aria-label="Editor schließen"
|
||||||
|
onclick={onrequestclose}>×</button
|
||||||
|
>
|
||||||
|
</header>
|
||||||
|
<nav class="piece-dialog-tabs" aria-label="Editorbereiche">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class:active={activeSection === 'script'}
|
||||||
|
aria-current={activeSection === 'script' ? 'page' : undefined}
|
||||||
|
onclick={() => selectSection('script')}>Sendungstext</button
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class:active={activeSection === 'research'}
|
||||||
|
aria-current={activeSection === 'research' ? 'page' : undefined}
|
||||||
|
onclick={() => selectSection('research')}>Recherche & Quellen</button
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class:active={activeSection === 'presentation'}
|
||||||
|
aria-current={activeSection === 'presentation' ? 'page' : undefined}
|
||||||
|
onclick={() => selectSection('presentation')}>Präsentation</button
|
||||||
|
>
|
||||||
|
</nav>
|
||||||
|
<div bind:this={workspace} class="piece-dialog-workspace">{@render children()}</div>
|
||||||
|
<footer class="piece-dialog-footer">{@render footer()}</footer>
|
||||||
|
</dialog>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
|
import type { SentPieceUsage } from '#lib/server/shows.js';
|
||||||
|
|
||||||
|
let { history }: { history: SentPieceUsage[] } = $props();
|
||||||
|
|
||||||
|
function berlinDate(value: string) {
|
||||||
|
return new Intl.DateTimeFormat('de-DE', {
|
||||||
|
timeZone: 'Europe/Berlin',
|
||||||
|
dateStyle: 'medium'
|
||||||
|
}).format(new Date(value));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if history.length}
|
||||||
|
<div class="piece-usage-history">
|
||||||
|
<p>
|
||||||
|
<strong>Gesendet am {berlinDate(history[0].usedAtUtc)}</strong>
|
||||||
|
in <a href={resolve('/sendungen/[id]', { id: history[0].showId })}>{history[0].showTitle}</a>
|
||||||
|
{#if history.length > 1}<span>+ {history.length - 1} weitere</span>{/if}
|
||||||
|
</p>
|
||||||
|
{#if history.length > 1}
|
||||||
|
<details>
|
||||||
|
<summary>Vollständige Verwendungshistorie</summary>
|
||||||
|
<ul>
|
||||||
|
{#each history as usage (usage.usageId)}
|
||||||
|
<li>
|
||||||
|
<time datetime={usage.usedAtUtc}>{berlinDate(usage.usedAtUtc)}</time>
|
||||||
|
<a href={resolve('/sendungen/[id]', { id: usage.showId })}>{usage.showTitle}</a>
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import type { PresentationContent } from '#lib/server/presentation.js';
|
||||||
|
|
||||||
|
let {
|
||||||
|
content,
|
||||||
|
imageSrc = ''
|
||||||
|
}: {
|
||||||
|
content: PresentationContent & {
|
||||||
|
sources?: { label: string; url: string }[];
|
||||||
|
images?: { id: string; altText: string }[];
|
||||||
|
};
|
||||||
|
imageSrc?: string;
|
||||||
|
} = $props();
|
||||||
|
let frame = $state<HTMLIFrameElement>();
|
||||||
|
let playerUnavailable = $state(false);
|
||||||
|
let imageUnavailable = $state(false);
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const receive = (event: MessageEvent) => {
|
||||||
|
if (content.provider !== 'tiktok' || event.origin !== 'https://www.tiktok.com') return;
|
||||||
|
if (event.source !== frame?.contentWindow || typeof event.data !== 'object' || !event.data)
|
||||||
|
return;
|
||||||
|
const message = event.data as { type?: string; value?: unknown };
|
||||||
|
if (message.type === 'onPlayerReady' && content.source?.timecodeSeconds) {
|
||||||
|
frame.contentWindow?.postMessage(
|
||||||
|
{
|
||||||
|
type: 'seekTo',
|
||||||
|
value: content.source.timecodeSeconds,
|
||||||
|
'x-tiktok-player': true
|
||||||
|
},
|
||||||
|
'https://www.tiktok.com'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (message.type === 'onPlayerError') playerUnavailable = true;
|
||||||
|
};
|
||||||
|
addEventListener('message', receive);
|
||||||
|
return () => removeEventListener('message', receive);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if content.mode === 'text'}
|
||||||
|
<article class="output-content output-text">
|
||||||
|
<p class="output-kicker">heinzlive</p>
|
||||||
|
<h1>{content.title}</h1>
|
||||||
|
<!-- HTML is produced exclusively by the server-side allowlist sanitizer. -->
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
|
<div class="output-copy">{@html content.html}</div>
|
||||||
|
{#if content.images?.length}<div class="output-images">
|
||||||
|
{#each content.images as image (image.id)}
|
||||||
|
<img src={`${imageSrc}/${image.id}`} alt={image.altText} />
|
||||||
|
{/each}
|
||||||
|
</div>{/if}
|
||||||
|
{#if content.sources?.length}<footer class="output-sources">
|
||||||
|
<span>Quellen</span>
|
||||||
|
{#each content.sources as source, index (`${index}-${source.url}`)}
|
||||||
|
<!-- The URL is a server-validated external HTTP(S) source. -->
|
||||||
|
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
||||||
|
<a href={source.url} target="_blank" rel="noopener noreferrer">{source.label}</a>
|
||||||
|
{/each}
|
||||||
|
</footer>{/if}
|
||||||
|
</article>
|
||||||
|
{:else if content.mode === 'link'}
|
||||||
|
<article class="output-content output-link-card">
|
||||||
|
{#if imageSrc && !imageUnavailable}<div class="output-link-image">
|
||||||
|
<img src={imageSrc} alt="" onerror={() => (imageUnavailable = true)} />
|
||||||
|
</div>{/if}
|
||||||
|
<div class="output-link-copy">
|
||||||
|
<p class="output-kicker">{content.siteName || content.source?.label || 'Webseite'}</p>
|
||||||
|
<h1>{content.previewTitle || content.title}</h1>
|
||||||
|
{#if content.description}<p>{content.description}</p>{/if}
|
||||||
|
<!-- The URL is a server-validated external HTTP(S) source. -->
|
||||||
|
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
||||||
|
{#if content.source}<a href={content.source.url} target="_blank" rel="noopener noreferrer"
|
||||||
|
>Original öffnen</a
|
||||||
|
>{/if}
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
{:else}
|
||||||
|
<article class:portrait={content.provider === 'tiktok'} class="output-content output-video">
|
||||||
|
<header>
|
||||||
|
<p class="output-kicker">{content.siteName || content.source?.label || 'Video'}</p>
|
||||||
|
<h1>{content.previewTitle || content.title}</h1>
|
||||||
|
</header>
|
||||||
|
{#if content.embedUrl && !playerUnavailable}
|
||||||
|
<div class="output-player">
|
||||||
|
<iframe
|
||||||
|
bind:this={frame}
|
||||||
|
title={content.previewTitle || content.title}
|
||||||
|
src={content.embedUrl}
|
||||||
|
allow="encrypted-media; fullscreen; picture-in-picture"
|
||||||
|
allowfullscreen
|
||||||
|
onerror={() => (playerUnavailable = true)}
|
||||||
|
></iframe>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<section class="output-fallback">
|
||||||
|
<strong>Video kann nicht eingebettet werden</strong>
|
||||||
|
<p>Der Anbieter oder diese URL ist für die eingebettete Wiedergabe nicht verfügbar.</p>
|
||||||
|
<!-- The URL is a server-validated external HTTP(S) source. -->
|
||||||
|
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
||||||
|
{#if content.source}<a href={content.source.url} target="_blank" rel="noopener noreferrer"
|
||||||
|
>Original öffnen</a
|
||||||
|
>{/if}
|
||||||
|
</section>
|
||||||
|
{/if}
|
||||||
|
{#if content.source}<footer class="output-video-source">
|
||||||
|
<!-- The URL is a server-validated external HTTP(S) source. -->
|
||||||
|
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
||||||
|
<a href={content.source.url} target="_blank" rel="noopener noreferrer">Original öffnen</a>
|
||||||
|
</footer>{/if}
|
||||||
|
</article>
|
||||||
|
{/if}
|
||||||
@@ -0,0 +1,336 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { enhance, type SubmitFunction } from '$app/forms';
|
||||||
|
import { untrack } from 'svelte';
|
||||||
|
import MarkdownEditorField from './MarkdownEditorField.svelte';
|
||||||
|
import NavIcon from './NavIcon.svelte';
|
||||||
|
import PieceEditorDialog from './PieceEditorDialog.svelte';
|
||||||
|
import type { PieceUsage } from '#lib/server/shows.js';
|
||||||
|
|
||||||
|
let {
|
||||||
|
usage,
|
||||||
|
revision,
|
||||||
|
sectionId,
|
||||||
|
sections,
|
||||||
|
error,
|
||||||
|
enhanceCommand
|
||||||
|
}: {
|
||||||
|
usage: PieceUsage;
|
||||||
|
revision: number;
|
||||||
|
sectionId: string;
|
||||||
|
sections: { id: string; name: string }[];
|
||||||
|
error?: string;
|
||||||
|
enhanceCommand: SubmitFunction;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let formId = $derived(`usage-editor-form-${usage.id}`);
|
||||||
|
let editor: { showModal: () => void; close: () => void };
|
||||||
|
let activeSection = $state<'script' | 'research' | 'presentation'>('script');
|
||||||
|
let draft = $state(untrack(() => ({ ...usage })));
|
||||||
|
let dirty = $state(false);
|
||||||
|
|
||||||
|
function durationInMinutes(seconds: number) {
|
||||||
|
return Number((seconds / 60).toFixed(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestClose() {
|
||||||
|
if (dirty && !confirm('Ungespeicherte Änderungen verwerfen und Editor schließen?')) return;
|
||||||
|
dirty = false;
|
||||||
|
editor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
const enhanceEditor: SubmitFunction = async (input) => {
|
||||||
|
const finish = await enhanceCommand(input);
|
||||||
|
return async (result) => {
|
||||||
|
if (finish) await finish(result);
|
||||||
|
if (result.result.type === 'success') dirty = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="usage-edit-button"
|
||||||
|
type="button"
|
||||||
|
aria-label={`${usage.title} bearbeiten und verschieben`}
|
||||||
|
title="Bearbeiten und verschieben"
|
||||||
|
onclick={() => editor.showModal()}
|
||||||
|
>
|
||||||
|
<NavIcon name="edit" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<PieceEditorDialog
|
||||||
|
bind:this={editor}
|
||||||
|
bind:activeSection
|
||||||
|
labelledby={`usage-editor-title-${usage.id}`}
|
||||||
|
onrequestclose={requestClose}
|
||||||
|
>
|
||||||
|
{#snippet header()}
|
||||||
|
<p class="eyebrow">Sendungsfassung</p>
|
||||||
|
<label class="piece-dialog-title">
|
||||||
|
<span class="sr-only">Titel</span>
|
||||||
|
<textarea
|
||||||
|
form={formId}
|
||||||
|
name="title"
|
||||||
|
required
|
||||||
|
rows="1"
|
||||||
|
maxlength="200"
|
||||||
|
aria-label="Titel"
|
||||||
|
bind:value={draft.title}
|
||||||
|
oninput={() => (dirty = true)}></textarea>
|
||||||
|
</label>
|
||||||
|
<h2 class="sr-only" id={`usage-editor-title-${usage.id}`}>{draft.title}</h2>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
<form
|
||||||
|
id={formId}
|
||||||
|
use:enhance={enhanceEditor}
|
||||||
|
method="POST"
|
||||||
|
action="?/updateUsage"
|
||||||
|
class="piece-dialog-form"
|
||||||
|
oninput={() => (dirty = true)}
|
||||||
|
onchange={() => (dirty = true)}
|
||||||
|
>
|
||||||
|
<input type="hidden" name="revision" value={revision} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
|
||||||
|
<section class="piece-editor-panel" hidden={activeSection !== 'script'}>
|
||||||
|
<div class="piece-panel-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Für die Moderation</p>
|
||||||
|
<h3>Sendungstext</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="piece-writing-stack">
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="intro"
|
||||||
|
label="Einleitung"
|
||||||
|
placeholder="Wie beginnt dieses Thema in der Sendung?"
|
||||||
|
bind:value={draft.intro}
|
||||||
|
/>
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="moderation"
|
||||||
|
label="Moderationsstichpunkte"
|
||||||
|
placeholder="Argumente, Fragen und Ablaufpunkte"
|
||||||
|
rows={10}
|
||||||
|
bind:value={draft.moderation}
|
||||||
|
/>
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="transition"
|
||||||
|
label="Überleitung"
|
||||||
|
placeholder="Wie geht es zum nächsten Thema weiter?"
|
||||||
|
bind:value={draft.transition}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<details class="piece-meta-details">
|
||||||
|
<summary>Dauer und Einplanung</summary>
|
||||||
|
<div class="piece-meta-grid">
|
||||||
|
<label
|
||||||
|
>Dauer in Minuten<input
|
||||||
|
name="durationMinutes"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
max="1440"
|
||||||
|
step="any"
|
||||||
|
value={durationInMinutes(usage.durationSeconds)}
|
||||||
|
/></label
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="piece-editor-panel" hidden={activeSection !== 'research'}>
|
||||||
|
<div class="piece-panel-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Nicht öffentlich</p>
|
||||||
|
<h3>Recherche & Quellen</h3>
|
||||||
|
</div>
|
||||||
|
<small>Diese Inhalte bleiben innerhalb der Redaktion.</small>
|
||||||
|
</div>
|
||||||
|
<div class="piece-writing-stack">
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="research"
|
||||||
|
label="Private Recherche"
|
||||||
|
placeholder="Hintergrund, Prüfung und offene Fragen"
|
||||||
|
rows={10}
|
||||||
|
privateField
|
||||||
|
bind:value={draft.research}
|
||||||
|
/>
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="ownNotes"
|
||||||
|
label="Interne Notizen zu dieser Verwendung"
|
||||||
|
placeholder="Absprachen und Hinweise nur für diese Sendung"
|
||||||
|
privateField
|
||||||
|
bind:value={draft.ownNotes}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<section class="piece-source-summary">
|
||||||
|
<p class="eyebrow">Snapshot-Quelle</p>
|
||||||
|
{#if draft.presentationSourceUrl}
|
||||||
|
<strong>{draft.presentationSourceLabel || draft.presentationSourceUrl}</strong>
|
||||||
|
<small>{draft.presentationSourceUrl}</small>
|
||||||
|
{:else}
|
||||||
|
<p>Für diese Verwendung wurde keine Präsentationsquelle kopiert.</p>
|
||||||
|
{/if}
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="piece-editor-panel" hidden={activeSection !== 'presentation'}>
|
||||||
|
<div class="piece-panel-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Öffentliche Ausgabe</p>
|
||||||
|
<h3>Präsentation</h3>
|
||||||
|
</div>
|
||||||
|
<small>Private Recherche und Notizen werden nicht ausgegeben.</small>
|
||||||
|
</div>
|
||||||
|
<div class="piece-presentation-layout">
|
||||||
|
<div class="piece-presentation-controls">
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="presentation"
|
||||||
|
label="Öffentlicher Text"
|
||||||
|
placeholder="Text für die Publikumsausgabe"
|
||||||
|
bind:value={draft.presentation}
|
||||||
|
/>
|
||||||
|
<div class="presentation-mode-picker" role="group" aria-label="Darstellung">
|
||||||
|
{#each [['text', 'Text'], ['link', 'Linkvorschau'], ['video', 'Video']] as mode (mode[0])}
|
||||||
|
<label
|
||||||
|
><input
|
||||||
|
type="radio"
|
||||||
|
name="presentationMode"
|
||||||
|
value={mode[0]}
|
||||||
|
bind:group={draft.presentationMode}
|
||||||
|
/>{mode[1]}</label
|
||||||
|
>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="presentationSourceLabel"
|
||||||
|
value={draft.presentationSourceLabel}
|
||||||
|
/>
|
||||||
|
<input type="hidden" name="presentationSourceUrl" value={draft.presentationSourceUrl} />
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="presentationSourceTimecodeSeconds"
|
||||||
|
value={draft.presentationSourceTimecodeSeconds ?? ''}
|
||||||
|
/>
|
||||||
|
<input type="hidden" name="presentationSiteName" value={draft.presentationSiteName} />
|
||||||
|
{#if draft.presentationMode !== 'text'}
|
||||||
|
<div class="presentation-settings">
|
||||||
|
<div class="presentation-source-summary wide-field">
|
||||||
|
<span>Ausgewählte Quelle</span>
|
||||||
|
<strong
|
||||||
|
>{draft.presentationSourceLabel ||
|
||||||
|
draft.presentationSourceUrl ||
|
||||||
|
'Keine Quelle'}</strong
|
||||||
|
>
|
||||||
|
{#if draft.presentationSourceUrl}<small>{draft.presentationSourceUrl}</small>{/if}
|
||||||
|
</div>
|
||||||
|
<label
|
||||||
|
>Titel<input
|
||||||
|
name="presentationTitle"
|
||||||
|
maxlength="300"
|
||||||
|
placeholder="Optionaler Anzeigetitel"
|
||||||
|
bind:value={draft.presentationTitle}
|
||||||
|
/></label
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
>Bild-URL<input
|
||||||
|
name="presentationImageUrl"
|
||||||
|
type="url"
|
||||||
|
maxlength="2000"
|
||||||
|
placeholder="https://…"
|
||||||
|
bind:value={draft.presentationImageUrl}
|
||||||
|
/></label
|
||||||
|
>
|
||||||
|
<label class="wide-field"
|
||||||
|
>Anreißer<textarea
|
||||||
|
name="presentationDescription"
|
||||||
|
rows="3"
|
||||||
|
maxlength="1000"
|
||||||
|
placeholder="Kurzer Text zur Vorschau"
|
||||||
|
bind:value={draft.presentationDescription}></textarea></label
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<input type="hidden" name="presentationTitle" value={draft.presentationTitle} />
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="presentationDescription"
|
||||||
|
value={draft.presentationDescription}
|
||||||
|
/>
|
||||||
|
<input type="hidden" name="presentationImageUrl" value={draft.presentationImageUrl} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<aside class="piece-presentation-preview" aria-label="Präsentationsvorschau">
|
||||||
|
<p class="output-kicker">Vorschau · {draft.presentationMode}</p>
|
||||||
|
<h4>{draft.presentationTitle || draft.title}</h4>
|
||||||
|
{#if draft.presentationMode === 'text'}
|
||||||
|
<p class="preview-markdown-source">
|
||||||
|
{draft.presentation || 'Noch kein öffentlicher Text.'}
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
{#if draft.presentationImageUrl}<img src={draft.presentationImageUrl} alt="" />{/if}
|
||||||
|
<p>
|
||||||
|
{draft.presentationDescription ||
|
||||||
|
draft.presentationSourceUrl ||
|
||||||
|
'Noch keine Vorschauangaben.'}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{#snippet footer()}
|
||||||
|
<div class="piece-dialog-secondary-actions">
|
||||||
|
<form use:enhance={enhanceCommand} method="POST" action="?/refreshUsage">
|
||||||
|
<input type="hidden" name="revision" value={revision} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
<button class="text-button" type="submit" disabled={!usage.originalPieceId || dirty}
|
||||||
|
>Aus Fundus aktualisieren</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<form use:enhance={enhanceCommand} method="POST" action="?/duplicateUsage">
|
||||||
|
<input type="hidden" name="revision" value={revision} /><input
|
||||||
|
type="hidden"
|
||||||
|
name="usageId"
|
||||||
|
value={usage.id}
|
||||||
|
/>
|
||||||
|
<button class="text-button" type="submit" disabled={dirty}>Duplizieren</button>
|
||||||
|
</form>
|
||||||
|
<form use:enhance={enhanceCommand} method="POST" action="?/moveUsage">
|
||||||
|
<input type="hidden" name="revision" value={revision} /><input
|
||||||
|
type="hidden"
|
||||||
|
name="usageId"
|
||||||
|
value={usage.id}
|
||||||
|
/><input type="hidden" name="position" value="9999" />
|
||||||
|
<label
|
||||||
|
><span class="sr-only">Ziel</span><select name="sectionId"
|
||||||
|
><option value="">Reservebank</option>{#each sections as target (target.id)}<option
|
||||||
|
value={target.id}
|
||||||
|
selected={target.id === sectionId}>{target.name}</option
|
||||||
|
>{/each}</select
|
||||||
|
></label
|
||||||
|
>
|
||||||
|
<button class="text-button" type="submit" disabled={dirty}>Verschieben</button>
|
||||||
|
</form>
|
||||||
|
<form
|
||||||
|
use:enhance={enhanceCommand}
|
||||||
|
method="POST"
|
||||||
|
action="?/removeUsage"
|
||||||
|
onsubmit={(event) =>
|
||||||
|
!confirm('Verwendung aus der Sendung entfernen?') && event.preventDefault()}
|
||||||
|
>
|
||||||
|
<input type="hidden" name="revision" value={revision} /><input
|
||||||
|
type="hidden"
|
||||||
|
name="usageId"
|
||||||
|
value={usage.id}
|
||||||
|
/>
|
||||||
|
<button class="text-button danger-text" type="submit" disabled={dirty}>Entfernen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="piece-dialog-primary-action">
|
||||||
|
{#if error}<span class="problem" role="alert">{error}</span>{/if}
|
||||||
|
<button class="primary-button" type="submit" form={formId}>Verwendung speichern</button>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</PieceEditorDialog>
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
getPiece,
|
getPiece,
|
||||||
getTaxonomy,
|
getTaxonomy,
|
||||||
listPieces,
|
listPieces,
|
||||||
|
loadPiecePresentationMetadata,
|
||||||
savePiece,
|
savePiece,
|
||||||
setPieceArchived,
|
setPieceArchived,
|
||||||
uploadPieceImage,
|
uploadPieceImage,
|
||||||
@@ -50,6 +51,18 @@ function completeInput(overrides: Partial<PieceInput> = {}): PieceInput {
|
|||||||
moderationNotes: '- Punkt eins',
|
moderationNotes: '- Punkt eins',
|
||||||
transitionText: 'Weiter geht es.',
|
transitionText: 'Weiter geht es.',
|
||||||
presentationText: '## Sichtbare Aussage',
|
presentationText: '## Sichtbare Aussage',
|
||||||
|
presentationMode: 'text',
|
||||||
|
presentationSourcePosition: null,
|
||||||
|
presentationTitle: '',
|
||||||
|
presentationDescription: '',
|
||||||
|
presentationImageUrl: '',
|
||||||
|
presentationSiteName: '',
|
||||||
|
presentationProvider: '',
|
||||||
|
presentationProviderId: '',
|
||||||
|
presentationTitleManual: false,
|
||||||
|
presentationDescriptionManual: false,
|
||||||
|
presentationImageManual: false,
|
||||||
|
presentationMetadataFetchedAtUtc: null,
|
||||||
topicIds: ['topic-gaming', 'topic-internet'],
|
topicIds: ['topic-gaming', 'topic-internet'],
|
||||||
categoryIds: ['cat-jc', 'cat-reaction'],
|
categoryIds: ['cat-jc', 'cat-reaction'],
|
||||||
sources: [
|
sources: [
|
||||||
@@ -86,6 +99,49 @@ describe('content management', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('stores fetched preview metadata and preserves manual corrections on reload', async () => {
|
||||||
|
const id = createPiece('find');
|
||||||
|
const initial = getPiece(id)!;
|
||||||
|
const saved = savePiece(
|
||||||
|
id,
|
||||||
|
initial.revision,
|
||||||
|
completeInput({
|
||||||
|
presentationMode: 'link',
|
||||||
|
presentationSourcePosition: 0,
|
||||||
|
presentationTitle: 'Manueller Titel',
|
||||||
|
presentationTitleManual: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
const loaded = await loadPiecePresentationMetadata(id, saved.revision, async () => ({
|
||||||
|
title: 'Automatischer Titel',
|
||||||
|
description: 'Geladener Anreißer',
|
||||||
|
imageUrl: 'https://example.com/vorschau.jpg',
|
||||||
|
siteName: 'Example',
|
||||||
|
provider: '',
|
||||||
|
providerId: ''
|
||||||
|
}));
|
||||||
|
expect(getPiece(id)).toMatchObject({
|
||||||
|
revision: loaded.revision,
|
||||||
|
presentationTitle: 'Manueller Titel',
|
||||||
|
presentationDescription: 'Geladener Anreißer',
|
||||||
|
presentationImageUrl: 'https://example.com/vorschau.jpg',
|
||||||
|
presentationSiteName: 'Example'
|
||||||
|
});
|
||||||
|
|
||||||
|
await loadPiecePresentationMetadata(id, loaded.revision, async () => ({
|
||||||
|
title: 'Anderer automatischer Titel',
|
||||||
|
description: 'Aktualisierter Anreißer',
|
||||||
|
imageUrl: '',
|
||||||
|
siteName: 'Example',
|
||||||
|
provider: '',
|
||||||
|
providerId: ''
|
||||||
|
}));
|
||||||
|
expect(getPiece(id)).toMatchObject({
|
||||||
|
presentationTitle: 'Manueller Titel',
|
||||||
|
presentationDescription: 'Aktualisierter Anreißer'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('searches independent taxonomies and archives, restores and duplicates pieces', async () => {
|
it('searches independent taxonomies and archives, restores and duplicates pieces', async () => {
|
||||||
createTaxonomy('topic', 'Technikgeschichte');
|
createTaxonomy('topic', 'Technikgeschichte');
|
||||||
const topic = getTaxonomy().topics.find((entry) => entry.name === 'Technikgeschichte')!;
|
const topic = getTaxonomy().topics.find((entry) => entry.name === 'Technikgeschichte')!;
|
||||||
|
|||||||
+193
-5
@@ -4,6 +4,11 @@ import path from 'node:path';
|
|||||||
import { fileTypeFromBuffer } from 'file-type';
|
import { fileTypeFromBuffer } from 'file-type';
|
||||||
import { getDatabase } from './database.js';
|
import { getDatabase } from './database.js';
|
||||||
import { getServerPaths } from './config.js';
|
import { getServerPaths } from './config.js';
|
||||||
|
import {
|
||||||
|
detectVideoProvider,
|
||||||
|
fetchPresentationMetadata,
|
||||||
|
type PresentationMode
|
||||||
|
} from './presentation.js';
|
||||||
|
|
||||||
export const PIECE_STATUSES = ['inbox', 'preparing', 'ready', 'archived'] as const;
|
export const PIECE_STATUSES = ['inbox', 'preparing', 'ready', 'archived'] as const;
|
||||||
export type PieceStatus = (typeof PIECE_STATUSES)[number];
|
export type PieceStatus = (typeof PIECE_STATUSES)[number];
|
||||||
@@ -27,6 +32,18 @@ export type PieceInput = {
|
|||||||
moderationNotes: string;
|
moderationNotes: string;
|
||||||
transitionText: string;
|
transitionText: string;
|
||||||
presentationText: string;
|
presentationText: string;
|
||||||
|
presentationMode: PresentationMode;
|
||||||
|
presentationSourcePosition: number | null;
|
||||||
|
presentationTitle: string;
|
||||||
|
presentationDescription: string;
|
||||||
|
presentationImageUrl: string;
|
||||||
|
presentationSiteName: string;
|
||||||
|
presentationProvider: string;
|
||||||
|
presentationProviderId: string;
|
||||||
|
presentationTitleManual: boolean;
|
||||||
|
presentationDescriptionManual: boolean;
|
||||||
|
presentationImageManual: boolean;
|
||||||
|
presentationMetadataFetchedAtUtc: string | null;
|
||||||
topicIds: string[];
|
topicIds: string[];
|
||||||
categoryIds: string[];
|
categoryIds: string[];
|
||||||
sources: PieceSourceInput[];
|
sources: PieceSourceInput[];
|
||||||
@@ -164,6 +181,25 @@ function validatePieceInput(input: PieceInput): PieceInput {
|
|||||||
}
|
}
|
||||||
return { label, url, timecodeSeconds: source.timecodeSeconds };
|
return { label, url, timecodeSeconds: source.timecodeSeconds };
|
||||||
});
|
});
|
||||||
|
if (!['text', 'link', 'video'].includes(input.presentationMode)) {
|
||||||
|
throw new Error('INVALID_PRESENTATION');
|
||||||
|
}
|
||||||
|
const sourcePosition = input.presentationSourcePosition;
|
||||||
|
if (
|
||||||
|
sourcePosition !== null &&
|
||||||
|
(!Number.isInteger(sourcePosition) || sourcePosition < 0 || sourcePosition >= sources.length)
|
||||||
|
) {
|
||||||
|
throw new Error('INVALID_PRESENTATION');
|
||||||
|
}
|
||||||
|
if (input.presentationMode !== 'text' && sourcePosition === null) {
|
||||||
|
throw new Error('INVALID_PRESENTATION');
|
||||||
|
}
|
||||||
|
const presentationImageUrl = cleanText(input.presentationImageUrl, 2_000, 'presentation_image');
|
||||||
|
if (presentationImageUrl && !validUrl(presentationImageUrl)) {
|
||||||
|
throw new Error('INVALID_PRESENTATION');
|
||||||
|
}
|
||||||
|
const detected =
|
||||||
|
sourcePosition === null ? null : detectVideoProvider(sources[sourcePosition].url);
|
||||||
return {
|
return {
|
||||||
title,
|
title,
|
||||||
summary: cleanText(input.summary, 2_000, 'summary'),
|
summary: cleanText(input.summary, 2_000, 'summary'),
|
||||||
@@ -175,6 +211,22 @@ function validatePieceInput(input: PieceInput): PieceInput {
|
|||||||
moderationNotes: cleanText(input.moderationNotes, 50_000, 'moderation'),
|
moderationNotes: cleanText(input.moderationNotes, 50_000, 'moderation'),
|
||||||
transitionText: cleanText(input.transitionText, 50_000, 'transition'),
|
transitionText: cleanText(input.transitionText, 50_000, 'transition'),
|
||||||
presentationText: cleanText(input.presentationText, 50_000, 'presentation'),
|
presentationText: cleanText(input.presentationText, 50_000, 'presentation'),
|
||||||
|
presentationMode: input.presentationMode,
|
||||||
|
presentationSourcePosition: sourcePosition,
|
||||||
|
presentationTitle: cleanText(input.presentationTitle, 300, 'presentation_title'),
|
||||||
|
presentationDescription: cleanText(
|
||||||
|
input.presentationDescription,
|
||||||
|
1_000,
|
||||||
|
'presentation_description'
|
||||||
|
),
|
||||||
|
presentationImageUrl,
|
||||||
|
presentationSiteName: cleanText(input.presentationSiteName, 200, 'presentation_site'),
|
||||||
|
presentationProvider: detected?.provider ?? '',
|
||||||
|
presentationProviderId: detected?.id ?? '',
|
||||||
|
presentationTitleManual: Boolean(input.presentationTitleManual),
|
||||||
|
presentationDescriptionManual: Boolean(input.presentationDescriptionManual),
|
||||||
|
presentationImageManual: Boolean(input.presentationImageManual),
|
||||||
|
presentationMetadataFetchedAtUtc: input.presentationMetadataFetchedAtUtc || null,
|
||||||
topicIds,
|
topicIds,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
sources
|
sources
|
||||||
@@ -298,6 +350,18 @@ type PieceRow = {
|
|||||||
moderation_notes: string;
|
moderation_notes: string;
|
||||||
transition_text: string;
|
transition_text: string;
|
||||||
presentation_text: string;
|
presentation_text: string;
|
||||||
|
presentation_mode: PresentationMode;
|
||||||
|
presentation_source_position: number | null;
|
||||||
|
presentation_title: string;
|
||||||
|
presentation_description: string;
|
||||||
|
presentation_image_url: string;
|
||||||
|
presentation_site_name: string;
|
||||||
|
presentation_provider: string;
|
||||||
|
presentation_provider_id: string;
|
||||||
|
presentation_title_manual: number;
|
||||||
|
presentation_description_manual: number;
|
||||||
|
presentation_image_manual: number;
|
||||||
|
presentation_metadata_fetched_at_utc: string | null;
|
||||||
revision: number;
|
revision: number;
|
||||||
created_at_utc: string;
|
created_at_utc: string;
|
||||||
updated_at_utc: string;
|
updated_at_utc: string;
|
||||||
@@ -308,7 +372,12 @@ export function getPiece(id: string): PieceEditor | null {
|
|||||||
const row = database
|
const row = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT id, title, summary, format_id, status, duration_seconds, intro, research_text,
|
`SELECT id, title, summary, format_id, status, duration_seconds, intro, research_text,
|
||||||
moderation_notes, transition_text, presentation_text, revision, created_at_utc, updated_at_utc
|
moderation_notes, transition_text, presentation_text, presentation_mode,
|
||||||
|
presentation_source_position, presentation_title, presentation_description,
|
||||||
|
presentation_image_url, presentation_site_name, presentation_provider,
|
||||||
|
presentation_provider_id, presentation_title_manual, presentation_description_manual,
|
||||||
|
presentation_image_manual, presentation_metadata_fetched_at_utc,
|
||||||
|
revision, created_at_utc, updated_at_utc
|
||||||
FROM pieces WHERE id = ?`
|
FROM pieces WHERE id = ?`
|
||||||
)
|
)
|
||||||
.get(id) as PieceRow | undefined;
|
.get(id) as PieceRow | undefined;
|
||||||
@@ -325,6 +394,18 @@ export function getPiece(id: string): PieceEditor | null {
|
|||||||
moderationNotes: row.moderation_notes,
|
moderationNotes: row.moderation_notes,
|
||||||
transitionText: row.transition_text,
|
transitionText: row.transition_text,
|
||||||
presentationText: row.presentation_text,
|
presentationText: row.presentation_text,
|
||||||
|
presentationMode: row.presentation_mode,
|
||||||
|
presentationSourcePosition: row.presentation_source_position,
|
||||||
|
presentationTitle: row.presentation_title,
|
||||||
|
presentationDescription: row.presentation_description,
|
||||||
|
presentationImageUrl: row.presentation_image_url,
|
||||||
|
presentationSiteName: row.presentation_site_name,
|
||||||
|
presentationProvider: row.presentation_provider,
|
||||||
|
presentationProviderId: row.presentation_provider_id,
|
||||||
|
presentationTitleManual: row.presentation_title_manual === 1,
|
||||||
|
presentationDescriptionManual: row.presentation_description_manual === 1,
|
||||||
|
presentationImageManual: row.presentation_image_manual === 1,
|
||||||
|
presentationMetadataFetchedAtUtc: row.presentation_metadata_fetched_at_utc,
|
||||||
revision: row.revision,
|
revision: row.revision,
|
||||||
createdAtUtc: row.created_at_utc,
|
createdAtUtc: row.created_at_utc,
|
||||||
updatedAtUtc: row.updated_at_utc,
|
updatedAtUtc: row.updated_at_utc,
|
||||||
@@ -405,6 +486,11 @@ export function savePiece(id: string, expectedRevision: number, rawInput: PieceI
|
|||||||
.prepare(
|
.prepare(
|
||||||
`UPDATE pieces SET title = ?, summary = ?, format_id = ?, status = ?, duration_seconds = ?,
|
`UPDATE pieces SET title = ?, summary = ?, format_id = ?, status = ?, duration_seconds = ?,
|
||||||
intro = ?, research_text = ?, moderation_notes = ?, transition_text = ?, presentation_text = ?,
|
intro = ?, research_text = ?, moderation_notes = ?, transition_text = ?, presentation_text = ?,
|
||||||
|
presentation_mode = ?, presentation_source_position = ?, presentation_title = ?,
|
||||||
|
presentation_description = ?, presentation_image_url = ?, presentation_site_name = ?,
|
||||||
|
presentation_provider = ?, presentation_provider_id = ?, presentation_title_manual = ?,
|
||||||
|
presentation_description_manual = ?, presentation_image_manual = ?,
|
||||||
|
presentation_metadata_fetched_at_utc = ?,
|
||||||
updated_at_utc = ?, revision = revision + 1, archived_from_status = NULL
|
updated_at_utc = ?, revision = revision + 1, archived_from_status = NULL
|
||||||
WHERE id = ? AND revision = ? AND status != 'archived'`
|
WHERE id = ? AND revision = ? AND status != 'archived'`
|
||||||
)
|
)
|
||||||
@@ -419,6 +505,18 @@ export function savePiece(id: string, expectedRevision: number, rawInput: PieceI
|
|||||||
input.moderationNotes,
|
input.moderationNotes,
|
||||||
input.transitionText,
|
input.transitionText,
|
||||||
input.presentationText,
|
input.presentationText,
|
||||||
|
input.presentationMode,
|
||||||
|
input.presentationSourcePosition,
|
||||||
|
input.presentationTitle,
|
||||||
|
input.presentationDescription,
|
||||||
|
input.presentationImageUrl,
|
||||||
|
input.presentationSiteName,
|
||||||
|
input.presentationProvider,
|
||||||
|
input.presentationProviderId,
|
||||||
|
input.presentationTitleManual ? 1 : 0,
|
||||||
|
input.presentationDescriptionManual ? 1 : 0,
|
||||||
|
input.presentationImageManual ? 1 : 0,
|
||||||
|
input.presentationMetadataFetchedAtUtc,
|
||||||
updatedAtUtc,
|
updatedAtUtc,
|
||||||
id,
|
id,
|
||||||
expectedRevision
|
expectedRevision
|
||||||
@@ -477,6 +575,18 @@ export function createPiece(template: PieceTemplateId = 'blank'): string {
|
|||||||
moderationNotes: defaults.moderationNotes ?? '',
|
moderationNotes: defaults.moderationNotes ?? '',
|
||||||
transitionText: '',
|
transitionText: '',
|
||||||
presentationText: defaults.presentationText ?? '',
|
presentationText: defaults.presentationText ?? '',
|
||||||
|
presentationMode: 'text',
|
||||||
|
presentationSourcePosition: null,
|
||||||
|
presentationTitle: '',
|
||||||
|
presentationDescription: '',
|
||||||
|
presentationImageUrl: '',
|
||||||
|
presentationSiteName: '',
|
||||||
|
presentationProvider: '',
|
||||||
|
presentationProviderId: '',
|
||||||
|
presentationTitleManual: false,
|
||||||
|
presentationDescriptionManual: false,
|
||||||
|
presentationImageManual: false,
|
||||||
|
presentationMetadataFetchedAtUtc: null,
|
||||||
topicIds: [],
|
topicIds: [],
|
||||||
categoryIds: defaults.categoryIds ?? [],
|
categoryIds: defaults.categoryIds ?? [],
|
||||||
sources: []
|
sources: []
|
||||||
@@ -510,10 +620,11 @@ export function createPiece(template: PieceTemplateId = 'blank'): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function captureInbox(titleValue: string, urlValue: string): string {
|
export function captureInbox(titleValue: string, urlValue: string): string {
|
||||||
const title = cleanText(titleValue, 200, 'title');
|
let title = cleanText(titleValue, 200, 'title');
|
||||||
if (!title) throw new Error('INVALID_TITLE');
|
|
||||||
const url = cleanText(urlValue, 2_000, 'source');
|
const url = cleanText(urlValue, 2_000, 'source');
|
||||||
if (url && !validUrl(url)) throw new Error('INVALID_SOURCES');
|
if (url && !validUrl(url)) throw new Error('INVALID_SOURCES');
|
||||||
|
if (!title && !url) throw new Error('INVALID_TITLE');
|
||||||
|
if (!title) title = new URL(url).hostname;
|
||||||
const id = createPiece('blank');
|
const id = createPiece('blank');
|
||||||
const piece = getPiece(id)!;
|
const piece = getPiece(id)!;
|
||||||
savePiece(id, piece.revision, {
|
savePiece(id, piece.revision, {
|
||||||
@@ -582,8 +693,13 @@ export async function duplicatePiece(sourceId: string): Promise<string> {
|
|||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`INSERT INTO pieces (id, title, summary, format_id, status, duration_seconds, intro,
|
`INSERT INTO pieces (id, title, summary, format_id, status, duration_seconds, intro,
|
||||||
research_text, moderation_notes, transition_text, presentation_text, created_at_utc,
|
research_text, moderation_notes, transition_text, presentation_text, presentation_mode,
|
||||||
updated_at_utc, revision) VALUES (?, ?, ?, ?, 'preparing', ?, ?, ?, ?, ?, ?, ?, ?, 1)`
|
presentation_source_position, presentation_title, presentation_description,
|
||||||
|
presentation_image_url, presentation_site_name, presentation_provider,
|
||||||
|
presentation_provider_id, presentation_title_manual,
|
||||||
|
presentation_description_manual, presentation_image_manual,
|
||||||
|
presentation_metadata_fetched_at_utc, created_at_utc, updated_at_utc, revision)
|
||||||
|
VALUES (?, ?, ?, ?, 'preparing', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
id,
|
id,
|
||||||
@@ -596,6 +712,18 @@ export async function duplicatePiece(sourceId: string): Promise<string> {
|
|||||||
source.moderationNotes,
|
source.moderationNotes,
|
||||||
source.transitionText,
|
source.transitionText,
|
||||||
source.presentationText,
|
source.presentationText,
|
||||||
|
source.presentationMode,
|
||||||
|
source.presentationSourcePosition,
|
||||||
|
source.presentationTitle,
|
||||||
|
source.presentationDescription,
|
||||||
|
source.presentationImageUrl,
|
||||||
|
source.presentationSiteName,
|
||||||
|
source.presentationProvider,
|
||||||
|
source.presentationProviderId,
|
||||||
|
source.presentationTitleManual ? 1 : 0,
|
||||||
|
source.presentationDescriptionManual ? 1 : 0,
|
||||||
|
source.presentationImageManual ? 1 : 0,
|
||||||
|
source.presentationMetadataFetchedAtUtc,
|
||||||
now,
|
now,
|
||||||
now
|
now
|
||||||
);
|
);
|
||||||
@@ -627,6 +755,66 @@ export async function duplicatePiece(sourceId: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function loadPiecePresentationMetadata(
|
||||||
|
id: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
metadataLoader = fetchPresentationMetadata
|
||||||
|
) {
|
||||||
|
if (!Number.isInteger(expectedRevision) || expectedRevision < 1) {
|
||||||
|
throw new Error('INVALID_REVISION');
|
||||||
|
}
|
||||||
|
const database = getDatabase();
|
||||||
|
const piece = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT p.revision, p.presentation_mode, p.presentation_source_position,
|
||||||
|
p.presentation_title_manual, p.presentation_description_manual,
|
||||||
|
p.presentation_image_manual, s.url
|
||||||
|
FROM pieces p LEFT JOIN piece_sources s ON s.piece_id = p.id
|
||||||
|
AND s.position = p.presentation_source_position
|
||||||
|
WHERE p.id = ? AND p.status != 'archived'`
|
||||||
|
)
|
||||||
|
.get(id) as
|
||||||
|
| {
|
||||||
|
revision: number;
|
||||||
|
presentation_mode: PresentationMode;
|
||||||
|
presentation_source_position: number | null;
|
||||||
|
presentation_title_manual: number;
|
||||||
|
presentation_description_manual: number;
|
||||||
|
presentation_image_manual: number;
|
||||||
|
url: string | null;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
if (!piece) throw new Error('NOT_FOUND');
|
||||||
|
if (piece.revision !== expectedRevision) throw new Error('CONFLICT');
|
||||||
|
if (piece.presentation_mode === 'text' || !piece.url) throw new Error('INVALID_PRESENTATION');
|
||||||
|
const metadata = await metadataLoader(piece.url);
|
||||||
|
const now = new Date().toISOString();
|
||||||
|
const result = database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE pieces SET
|
||||||
|
presentation_title = CASE WHEN presentation_title_manual = 1 THEN presentation_title ELSE ? END,
|
||||||
|
presentation_description = CASE WHEN presentation_description_manual = 1 THEN presentation_description ELSE ? END,
|
||||||
|
presentation_image_url = CASE WHEN presentation_image_manual = 1 THEN presentation_image_url ELSE ? END,
|
||||||
|
presentation_site_name = ?, presentation_provider = ?, presentation_provider_id = ?,
|
||||||
|
presentation_metadata_fetched_at_utc = ?, updated_at_utc = ?, revision = revision + 1
|
||||||
|
WHERE id = ? AND revision = ? AND status != 'archived'`
|
||||||
|
)
|
||||||
|
.run(
|
||||||
|
metadata.title,
|
||||||
|
metadata.description,
|
||||||
|
metadata.imageUrl,
|
||||||
|
metadata.siteName,
|
||||||
|
metadata.provider,
|
||||||
|
metadata.providerId,
|
||||||
|
now,
|
||||||
|
now,
|
||||||
|
id,
|
||||||
|
expectedRevision
|
||||||
|
);
|
||||||
|
if (result.changes !== 1) throw new Error('CONFLICT');
|
||||||
|
return { revision: expectedRevision + 1, updatedAtUtc: now };
|
||||||
|
}
|
||||||
|
|
||||||
export async function uploadPieceImage(
|
export async function uploadPieceImage(
|
||||||
pieceId: string,
|
pieceId: string,
|
||||||
expectedRevision: number,
|
expectedRevision: number,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ describe('database setup', () => {
|
|||||||
database.close();
|
database.close();
|
||||||
|
|
||||||
expect(counts).toEqual({
|
expect(counts).toEqual({
|
||||||
migrations: 4,
|
migrations: 6,
|
||||||
pieces: 6,
|
pieces: 6,
|
||||||
shows: 2,
|
shows: 2,
|
||||||
usages: 5,
|
usages: 5,
|
||||||
|
|||||||
@@ -0,0 +1,185 @@
|
|||||||
|
import { execFileSync } from 'node:child_process';
|
||||||
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||||
|
import { closeDatabase, getDatabase } from './database.js';
|
||||||
|
import {
|
||||||
|
completeCurrent,
|
||||||
|
getLiveView,
|
||||||
|
getPresentationMedia,
|
||||||
|
getPresentationView,
|
||||||
|
goBack,
|
||||||
|
issuePresentationAccess,
|
||||||
|
moveOpenUsage,
|
||||||
|
presentUsage,
|
||||||
|
skipCurrent,
|
||||||
|
startOrResumeLive
|
||||||
|
} from './live.js';
|
||||||
|
|
||||||
|
let directory: string;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
directory = mkdtempSync(path.join(tmpdir(), 'sendewerk-live-test-'));
|
||||||
|
process.env.SENDEWERK_DB_PATH = path.join(directory, 'test.sqlite');
|
||||||
|
process.env.SENDEWERK_UPLOAD_DIR = path.join(directory, 'uploads');
|
||||||
|
execFileSync(process.execPath, ['scripts/migrate.mjs'], { cwd: process.cwd(), env: process.env });
|
||||||
|
execFileSync(process.execPath, ['scripts/seed.mjs'], { cwd: process.cwd(), env: process.env });
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
closeDatabase();
|
||||||
|
delete process.env.SENDEWERK_DB_PATH;
|
||||||
|
delete process.env.SENDEWERK_UPLOAD_DIR;
|
||||||
|
rmSync(directory, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('live mode', () => {
|
||||||
|
it('restores live state, records actual intervals and applies commands only once', () => {
|
||||||
|
const started = new Date('2026-10-22T18:00:00.000Z');
|
||||||
|
const initial = getLiveView('show-october', started);
|
||||||
|
expect(initial.current).toBeNull();
|
||||||
|
|
||||||
|
expect(startOrResumeLive('show-october', 'start-command', 0, started)).toEqual({
|
||||||
|
revision: 1,
|
||||||
|
duplicate: false
|
||||||
|
});
|
||||||
|
expect(startOrResumeLive('show-october', 'start-command', 0, started)).toEqual({
|
||||||
|
revision: 1,
|
||||||
|
duplicate: true
|
||||||
|
});
|
||||||
|
let live = getLiveView('show-october', new Date('2026-10-22T18:05:00.000Z'));
|
||||||
|
expect(live.current?.id).toBe('usage-console');
|
||||||
|
expect(live.current?.actualDurationSeconds).toBe(300);
|
||||||
|
expect(() =>
|
||||||
|
moveOpenUsage('show-october', 'usage-effects', live.show.revision, {
|
||||||
|
sectionId: 'section-stories',
|
||||||
|
position: 0
|
||||||
|
})
|
||||||
|
).toThrow('LIVE_ORDER_LOCKED');
|
||||||
|
|
||||||
|
completeCurrent('show-october', 'complete-console', 1, new Date('2026-10-22T18:05:00.000Z'));
|
||||||
|
completeCurrent('show-october', 'complete-console', 1, new Date('2026-10-22T18:05:00.000Z'));
|
||||||
|
live = getLiveView('show-october', new Date('2026-10-22T18:06:00.000Z'));
|
||||||
|
expect(live.current?.id).toBe('usage-effects');
|
||||||
|
expect(
|
||||||
|
live.sections
|
||||||
|
.flatMap((section) => section.usages)
|
||||||
|
.find((usage) => usage.id === 'usage-console')
|
||||||
|
).toMatchObject({ status: 'done', actualDurationSeconds: 300 });
|
||||||
|
expect(
|
||||||
|
getDatabase()
|
||||||
|
.prepare('SELECT count(*) AS count FROM live_usage_runs WHERE usage_id = ?')
|
||||||
|
.get('usage-console')
|
||||||
|
).toEqual({ count: 1 });
|
||||||
|
|
||||||
|
expect(() => skipCurrent('show-october', 'stale-command', 1)).toThrow('CONFLICT');
|
||||||
|
skipCurrent('show-october', 'skip-effects', 2, new Date('2026-10-22T18:06:00.000Z'));
|
||||||
|
live = getLiveView('show-october', new Date('2026-10-22T18:07:00.000Z'));
|
||||||
|
expect(live.current).toBeNull();
|
||||||
|
expect(live.completedCount).toBe(2);
|
||||||
|
|
||||||
|
goBack('show-october', 'back-effects', 3, new Date('2026-10-22T18:07:00.000Z'));
|
||||||
|
live = getLiveView('show-october', new Date('2026-10-22T18:08:00.000Z'));
|
||||||
|
expect(live.current).toMatchObject({ id: 'usage-effects', status: 'current' });
|
||||||
|
expect(live.current?.actualDurationSeconds).toBe(120);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('changes presentation only explicitly and exposes no private fields', async () => {
|
||||||
|
const uploads = process.env.SENDEWERK_UPLOAD_DIR!;
|
||||||
|
mkdirSync(uploads, { recursive: true });
|
||||||
|
writeFileSync(path.join(uploads, 'presentation.png'), Buffer.from('test-image'));
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO piece_media (id, piece_id, storage_name, original_name, mime_type,
|
||||||
|
byte_size, alt_text, position, created_at_utc) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(
|
||||||
|
'presentation-image',
|
||||||
|
'piece-console',
|
||||||
|
'presentation.png',
|
||||||
|
'private-original-name.png',
|
||||||
|
'image/png',
|
||||||
|
10,
|
||||||
|
'Konsole auf dem Tisch',
|
||||||
|
0,
|
||||||
|
'2026-10-22T18:00:00.000Z'
|
||||||
|
);
|
||||||
|
|
||||||
|
const token = issuePresentationAccess('show-october');
|
||||||
|
expect(getPresentationView(token)).toEqual({ revision: 0, content: null });
|
||||||
|
startOrResumeLive('show-october', 'start-output', 0);
|
||||||
|
expect(getPresentationView(token)).toEqual({ revision: 0, content: null });
|
||||||
|
|
||||||
|
presentUsage('show-october', 'usage-console', 'present-console', 1);
|
||||||
|
const output = getPresentationView(token)!;
|
||||||
|
expect(output.content).toMatchObject({
|
||||||
|
title: 'Die kleine Konsole mit dem großen Dreh',
|
||||||
|
images: [{ id: 'presentation-image', altText: 'Konsole auf dem Tisch' }]
|
||||||
|
});
|
||||||
|
const serialized = JSON.stringify(output);
|
||||||
|
expect(serialized).toContain('Weniger Leistung, mehr Idee.');
|
||||||
|
expect(serialized).not.toContain('Herstellerangaben');
|
||||||
|
expect(serialized).not.toContain('Moderationsstichpunkte');
|
||||||
|
expect(serialized).not.toContain('private-original-name');
|
||||||
|
expect(serialized).not.toContain('presentation.png');
|
||||||
|
|
||||||
|
const media = await getPresentationMedia(token, 'presentation-image');
|
||||||
|
expect(media?.data.toString()).toBe('test-image');
|
||||||
|
expect(await getPresentationMedia(token, 'unknown-image')).toBeNull();
|
||||||
|
|
||||||
|
const replacementToken = issuePresentationAccess('show-october');
|
||||||
|
expect(getPresentationView(token)).toBeNull();
|
||||||
|
expect(getPresentationView(replacementToken)?.content?.title).toBe(
|
||||||
|
'Die kleine Konsole mit dem großen Dreh'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('projects only snapshotted link and video data and changes players explicitly', () => {
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`UPDATE piece_usages SET presentation_mode_snapshot = 'video',
|
||||||
|
presentation_source_label_snapshot = 'YouTube',
|
||||||
|
presentation_source_url_snapshot = 'https://youtu.be/dQw4w9WgXcQ',
|
||||||
|
presentation_source_timecode_snapshot = 75,
|
||||||
|
presentation_title_meta_snapshot = 'Videotitel',
|
||||||
|
presentation_site_name_snapshot = 'YouTube',
|
||||||
|
presentation_provider_snapshot = 'youtube',
|
||||||
|
presentation_provider_id_snapshot = 'dQw4w9WgXcQ'
|
||||||
|
WHERE id = 'usage-console'`
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`UPDATE piece_usages SET presentation_mode_snapshot = 'link',
|
||||||
|
presentation_source_label_snapshot = 'Artikel',
|
||||||
|
presentation_source_url_snapshot = 'https://example.com/artikel',
|
||||||
|
presentation_title_meta_snapshot = 'Linktitel',
|
||||||
|
presentation_description_snapshot = 'Öffentlicher Anreißer',
|
||||||
|
presentation_site_name_snapshot = 'Example'
|
||||||
|
WHERE id = 'usage-effects'`
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
const token = issuePresentationAccess('show-october');
|
||||||
|
presentUsage('show-october', 'usage-console', 'present-video', 0);
|
||||||
|
expect(getPresentationView(token)?.content).toMatchObject({
|
||||||
|
mode: 'video',
|
||||||
|
previewTitle: 'Videotitel',
|
||||||
|
embedUrl: 'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=75',
|
||||||
|
source: { url: 'https://youtu.be/dQw4w9WgXcQ', timecodeSeconds: 75 }
|
||||||
|
});
|
||||||
|
|
||||||
|
presentUsage('show-october', 'usage-effects', 'present-link', 1);
|
||||||
|
const link = getPresentationView(token)!;
|
||||||
|
expect(link.content).toMatchObject({
|
||||||
|
mode: 'link',
|
||||||
|
previewTitle: 'Linktitel',
|
||||||
|
description: 'Öffentlicher Anreißer',
|
||||||
|
embedUrl: '',
|
||||||
|
source: { label: 'Artikel', url: 'https://example.com/artikel' }
|
||||||
|
});
|
||||||
|
const serialized = JSON.stringify(link);
|
||||||
|
expect(serialized).not.toContain('Herstellerangaben');
|
||||||
|
expect(serialized).not.toContain('Moderationsstichpunkte');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,623 @@
|
|||||||
|
import { createHash, randomBytes, randomUUID } from 'node:crypto';
|
||||||
|
import type Database from 'better-sqlite3';
|
||||||
|
import { getMediaFile } from './content.js';
|
||||||
|
import { getDatabase } from './database.js';
|
||||||
|
import { renderMarkdown } from './markdown.js';
|
||||||
|
import { buildEmbedUrl, fetchPresentationImage, type PresentationContent } from './presentation.js';
|
||||||
|
import {
|
||||||
|
getShow,
|
||||||
|
movePieceUsage,
|
||||||
|
type MovePieceUsageInput,
|
||||||
|
type PieceUsage,
|
||||||
|
type ShowSection
|
||||||
|
} from './shows.js';
|
||||||
|
|
||||||
|
type LiveStateRow = {
|
||||||
|
show_id: string;
|
||||||
|
revision: number;
|
||||||
|
current_usage_id: string | null;
|
||||||
|
started_at_utc: string | null;
|
||||||
|
ended_at_utc: string | null;
|
||||||
|
presentation_usage_id: string | null;
|
||||||
|
presentation_revision: number;
|
||||||
|
updated_at_utc: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type OrderedUsageRow = {
|
||||||
|
id: string;
|
||||||
|
section_id: string;
|
||||||
|
section_name: string;
|
||||||
|
section_position: number;
|
||||||
|
position: number;
|
||||||
|
status: PieceUsage['status'];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LiveUsage = PieceUsage & {
|
||||||
|
sectionId: string;
|
||||||
|
sectionName: string;
|
||||||
|
actualDurationSeconds: number;
|
||||||
|
introHtml: string;
|
||||||
|
researchHtml: string;
|
||||||
|
moderationHtml: string;
|
||||||
|
transitionHtml: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LiveSection = Omit<ShowSection, 'usages'> & { usages: LiveUsage[] };
|
||||||
|
|
||||||
|
export type LiveView = {
|
||||||
|
show: {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
status: string;
|
||||||
|
revision: number;
|
||||||
|
totalDurationSeconds: number;
|
||||||
|
};
|
||||||
|
liveRevision: number;
|
||||||
|
startedAtUtc: string | null;
|
||||||
|
updatedAtUtc: string;
|
||||||
|
presentationUsageId: string | null;
|
||||||
|
presentationRevision: number;
|
||||||
|
sections: LiveSection[];
|
||||||
|
reserve: LiveUsage[];
|
||||||
|
current: LiveUsage | null;
|
||||||
|
next: LiveUsage | null;
|
||||||
|
completedCount: number;
|
||||||
|
totalCount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PresentationView = {
|
||||||
|
revision: number;
|
||||||
|
content: null | {
|
||||||
|
mode: PresentationContent['mode'];
|
||||||
|
title: string;
|
||||||
|
html: string;
|
||||||
|
source: PresentationContent['source'];
|
||||||
|
previewTitle: string;
|
||||||
|
description: string;
|
||||||
|
imageUrl: string;
|
||||||
|
siteName: string;
|
||||||
|
provider: PresentationContent['provider'];
|
||||||
|
providerId: string;
|
||||||
|
embedUrl: string;
|
||||||
|
sources: { label: string; url: string; timecodeSeconds: number | null }[];
|
||||||
|
images: { id: string; altText: string }[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function hashToken(token: string) {
|
||||||
|
return createHash('sha256').update(token).digest('hex');
|
||||||
|
}
|
||||||
|
|
||||||
|
function nowIso(now?: Date) {
|
||||||
|
return (now ?? new Date()).toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function requireCommandId(commandId: string) {
|
||||||
|
if (!commandId || commandId.length > 200) throw new Error('INVALID_COMMAND');
|
||||||
|
}
|
||||||
|
|
||||||
|
function ensureLiveState(database: Database.Database, showId: string, now: string): LiveStateRow {
|
||||||
|
const show = database.prepare('SELECT 1 FROM shows WHERE id = ?').get(showId);
|
||||||
|
if (!show) throw new Error('NOT_FOUND');
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`INSERT OR IGNORE INTO show_live_states (show_id, updated_at_utc)
|
||||||
|
VALUES (?, ?)`
|
||||||
|
)
|
||||||
|
.run(showId, now);
|
||||||
|
return database
|
||||||
|
.prepare('SELECT * FROM show_live_states WHERE show_id = ?')
|
||||||
|
.get(showId) as LiveStateRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
function orderedUsages(database: Database.Database, showId: string): OrderedUsageRow[] {
|
||||||
|
return database
|
||||||
|
.prepare(
|
||||||
|
`SELECT u.id, s.id AS section_id, s.name AS section_name,
|
||||||
|
s.position AS section_position, u.position, u.status
|
||||||
|
FROM piece_usages u JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
WHERE s.show_id = ? AND s.is_reserve_bank = 0
|
||||||
|
ORDER BY s.position, u.position`
|
||||||
|
)
|
||||||
|
.all(showId) as OrderedUsageRow[];
|
||||||
|
}
|
||||||
|
|
||||||
|
function usageBelongsToShow(database: Database.Database, showId: string, usageId: string) {
|
||||||
|
const row = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT s.is_reserve_bank FROM piece_usages u
|
||||||
|
JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
WHERE u.id = ? AND s.show_id = ?`
|
||||||
|
)
|
||||||
|
.get(usageId, showId) as { is_reserve_bank: number } | undefined;
|
||||||
|
if (!row || row.is_reserve_bank) throw new Error('NOT_FOUND');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeActiveRun(database: Database.Database, showId: string, now: string) {
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE live_usage_runs SET ended_at_utc = ?
|
||||||
|
WHERE show_id = ? AND ended_at_utc IS NULL`
|
||||||
|
)
|
||||||
|
.run(now, showId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function activateUsage(database: Database.Database, showId: string, usageId: string, now: string) {
|
||||||
|
usageBelongsToShow(database, showId, usageId);
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE piece_usages SET status = 'open'
|
||||||
|
WHERE status = 'current' AND id != ? AND id IN (
|
||||||
|
SELECT u.id FROM piece_usages u JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
WHERE s.show_id = ?
|
||||||
|
)`
|
||||||
|
)
|
||||||
|
.run(usageId, showId);
|
||||||
|
database.prepare(`UPDATE piece_usages SET status = 'current' WHERE id = ?`).run(usageId);
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO live_usage_runs (id, show_id, usage_id, started_at_utc)
|
||||||
|
VALUES (?, ?, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(randomUUID(), showId, usageId, now);
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
'UPDATE show_live_states SET current_usage_id = ?, ended_at_utc = NULL WHERE show_id = ?'
|
||||||
|
)
|
||||||
|
.run(usageId, showId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeCommand(
|
||||||
|
showId: string,
|
||||||
|
commandId: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
action: string,
|
||||||
|
operation: (database: Database.Database, state: LiveStateRow, now: string) => void,
|
||||||
|
nowValue?: Date
|
||||||
|
) {
|
||||||
|
requireCommandId(commandId);
|
||||||
|
const database = getDatabase();
|
||||||
|
return database.transaction(() => {
|
||||||
|
const duplicate = database
|
||||||
|
.prepare('SELECT result_revision FROM live_commands WHERE show_id = ? AND command_id = ?')
|
||||||
|
.get(showId, commandId) as { result_revision: number } | undefined;
|
||||||
|
if (duplicate) return { revision: duplicate.result_revision, duplicate: true };
|
||||||
|
const now = nowIso(nowValue);
|
||||||
|
const state = ensureLiveState(database, showId, now);
|
||||||
|
const show = database.prepare('SELECT status FROM shows WHERE id = ?').get(showId) as {
|
||||||
|
status: string;
|
||||||
|
};
|
||||||
|
if (show.status === 'completed') throw new Error('SHOW_COMPLETED');
|
||||||
|
if (state.revision !== expectedRevision) throw new Error('CONFLICT');
|
||||||
|
operation(database, state, now);
|
||||||
|
const updated = database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE show_live_states SET revision = revision + 1, updated_at_utc = ?
|
||||||
|
WHERE show_id = ? AND revision = ?`
|
||||||
|
)
|
||||||
|
.run(now, showId, expectedRevision);
|
||||||
|
if (updated.changes !== 1) throw new Error('CONFLICT');
|
||||||
|
const revision = expectedRevision + 1;
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO live_commands (show_id, command_id, action, result_revision, created_at_utc)
|
||||||
|
VALUES (?, ?, ?, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(showId, commandId, action, revision, now);
|
||||||
|
return { revision, duplicate: false };
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
function actualDurations(database: Database.Database, showId: string, now: string) {
|
||||||
|
const rows = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT usage_id, started_at_utc, ended_at_utc
|
||||||
|
FROM live_usage_runs WHERE show_id = ?`
|
||||||
|
)
|
||||||
|
.all(showId) as { usage_id: string; started_at_utc: string; ended_at_utc: string | null }[];
|
||||||
|
const durations = new Map<string, number>();
|
||||||
|
for (const row of rows) {
|
||||||
|
const seconds = Math.max(
|
||||||
|
0,
|
||||||
|
Math.floor(
|
||||||
|
(new Date(row.ended_at_utc ?? now).getTime() - new Date(row.started_at_utc).getTime()) /
|
||||||
|
1000
|
||||||
|
)
|
||||||
|
);
|
||||||
|
durations.set(row.usage_id, (durations.get(row.usage_id) ?? 0) + seconds);
|
||||||
|
}
|
||||||
|
return durations;
|
||||||
|
}
|
||||||
|
|
||||||
|
function liveUsage(
|
||||||
|
usage: PieceUsage,
|
||||||
|
sectionId: string,
|
||||||
|
sectionName: string,
|
||||||
|
actualSeconds: number
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
...usage,
|
||||||
|
sectionId,
|
||||||
|
sectionName,
|
||||||
|
actualDurationSeconds: actualSeconds,
|
||||||
|
introHtml: renderMarkdown(usage.intro),
|
||||||
|
researchHtml: renderMarkdown(usage.research),
|
||||||
|
moderationHtml: renderMarkdown(usage.moderation),
|
||||||
|
transitionHtml: renderMarkdown(usage.transition)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLiveView(showId: string, nowValue?: Date): LiveView {
|
||||||
|
const database = getDatabase();
|
||||||
|
const now = nowIso(nowValue);
|
||||||
|
const state = ensureLiveState(database, showId, now);
|
||||||
|
const show = getShow(showId);
|
||||||
|
if (!show) throw new Error('NOT_FOUND');
|
||||||
|
const durations = actualDurations(database, showId, now);
|
||||||
|
const sections = show.sections.map((section) => ({
|
||||||
|
...section,
|
||||||
|
usages: section.usages.map((usage) =>
|
||||||
|
liveUsage(usage, section.id, section.name, durations.get(usage.id) ?? 0)
|
||||||
|
)
|
||||||
|
}));
|
||||||
|
const reserve = show.reserve.map((usage) =>
|
||||||
|
liveUsage(usage, '', 'Reservebank', durations.get(usage.id) ?? 0)
|
||||||
|
);
|
||||||
|
const usages = sections.flatMap((section) => section.usages);
|
||||||
|
const current = usages.find((usage) => usage.id === state.current_usage_id) ?? null;
|
||||||
|
const currentIndex = current ? usages.findIndex((usage) => usage.id === current.id) : -1;
|
||||||
|
const next =
|
||||||
|
usages.slice(currentIndex + 1).find((usage) => usage.status === 'open') ??
|
||||||
|
(current ? null : (usages.find((usage) => usage.status === 'open') ?? null));
|
||||||
|
return {
|
||||||
|
show: {
|
||||||
|
id: show.id,
|
||||||
|
title: show.title,
|
||||||
|
status: show.status,
|
||||||
|
revision: show.revision,
|
||||||
|
totalDurationSeconds: show.totalDurationSeconds
|
||||||
|
},
|
||||||
|
liveRevision: state.revision,
|
||||||
|
startedAtUtc: state.started_at_utc,
|
||||||
|
updatedAtUtc: state.updated_at_utc,
|
||||||
|
presentationUsageId: state.presentation_usage_id,
|
||||||
|
presentationRevision: state.presentation_revision,
|
||||||
|
sections,
|
||||||
|
reserve,
|
||||||
|
current,
|
||||||
|
next,
|
||||||
|
completedCount: usages.filter((usage) => usage.status === 'done' || usage.status === 'skipped')
|
||||||
|
.length,
|
||||||
|
totalCount: usages.length
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function startOrResumeLive(
|
||||||
|
showId: string,
|
||||||
|
commandId: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
nowValue?: Date
|
||||||
|
) {
|
||||||
|
return executeCommand(
|
||||||
|
showId,
|
||||||
|
commandId,
|
||||||
|
expectedRevision,
|
||||||
|
'start',
|
||||||
|
(database, state, now) => {
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE shows SET status = 'live', updated_at_utc = ?
|
||||||
|
WHERE id = ? AND status != 'completed'`
|
||||||
|
)
|
||||||
|
.run(now, showId);
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE show_live_states SET started_at_utc = COALESCE(started_at_utc, ?), ended_at_utc = NULL
|
||||||
|
WHERE show_id = ?`
|
||||||
|
)
|
||||||
|
.run(now, showId);
|
||||||
|
const activeRun = database
|
||||||
|
.prepare('SELECT 1 FROM live_usage_runs WHERE show_id = ? AND ended_at_utc IS NULL')
|
||||||
|
.get(showId);
|
||||||
|
if (state.current_usage_id && activeRun) return;
|
||||||
|
const current = state.current_usage_id
|
||||||
|
? orderedUsages(database, showId).find((usage) => usage.id === state.current_usage_id)
|
||||||
|
: undefined;
|
||||||
|
const target =
|
||||||
|
current ?? orderedUsages(database, showId).find((usage) => usage.status === 'open');
|
||||||
|
if (target) activateUsage(database, showId, target.id, now);
|
||||||
|
},
|
||||||
|
nowValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function advanceCurrent(
|
||||||
|
showId: string,
|
||||||
|
commandId: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
status: 'done' | 'skipped',
|
||||||
|
nowValue?: Date
|
||||||
|
) {
|
||||||
|
return executeCommand(
|
||||||
|
showId,
|
||||||
|
commandId,
|
||||||
|
expectedRevision,
|
||||||
|
status,
|
||||||
|
(database, state, now) => {
|
||||||
|
if (!state.current_usage_id) throw new Error('NO_CURRENT');
|
||||||
|
const ordered = orderedUsages(database, showId);
|
||||||
|
const currentIndex = ordered.findIndex((usage) => usage.id === state.current_usage_id);
|
||||||
|
if (currentIndex < 0) throw new Error('NOT_FOUND');
|
||||||
|
closeActiveRun(database, showId, now);
|
||||||
|
database
|
||||||
|
.prepare('UPDATE piece_usages SET status = ? WHERE id = ?')
|
||||||
|
.run(status, state.current_usage_id);
|
||||||
|
const next = ordered.slice(currentIndex + 1).find((usage) => usage.status === 'open');
|
||||||
|
if (next) activateUsage(database, showId, next.id, now);
|
||||||
|
else
|
||||||
|
database
|
||||||
|
.prepare('UPDATE show_live_states SET current_usage_id = NULL WHERE show_id = ?')
|
||||||
|
.run(showId);
|
||||||
|
},
|
||||||
|
nowValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function completeCurrent(
|
||||||
|
showId: string,
|
||||||
|
commandId: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
nowValue?: Date
|
||||||
|
) {
|
||||||
|
return advanceCurrent(showId, commandId, expectedRevision, 'done', nowValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function skipCurrent(
|
||||||
|
showId: string,
|
||||||
|
commandId: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
nowValue?: Date
|
||||||
|
) {
|
||||||
|
return advanceCurrent(showId, commandId, expectedRevision, 'skipped', nowValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function goBack(
|
||||||
|
showId: string,
|
||||||
|
commandId: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
nowValue?: Date
|
||||||
|
) {
|
||||||
|
return executeCommand(
|
||||||
|
showId,
|
||||||
|
commandId,
|
||||||
|
expectedRevision,
|
||||||
|
'back',
|
||||||
|
(database, state, now) => {
|
||||||
|
const ordered = orderedUsages(database, showId);
|
||||||
|
const currentIndex = state.current_usage_id
|
||||||
|
? ordered.findIndex((usage) => usage.id === state.current_usage_id)
|
||||||
|
: ordered.length;
|
||||||
|
const previous = ordered
|
||||||
|
.slice(0, Math.max(0, currentIndex))
|
||||||
|
.reverse()
|
||||||
|
.find((usage) => usage.status === 'done' || usage.status === 'skipped');
|
||||||
|
if (!previous) throw new Error('NO_PREVIOUS');
|
||||||
|
if (state.current_usage_id) {
|
||||||
|
closeActiveRun(database, showId, now);
|
||||||
|
database
|
||||||
|
.prepare(`UPDATE piece_usages SET status = 'open' WHERE id = ?`)
|
||||||
|
.run(state.current_usage_id);
|
||||||
|
}
|
||||||
|
activateUsage(database, showId, previous.id, now);
|
||||||
|
},
|
||||||
|
nowValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function presentUsage(
|
||||||
|
showId: string,
|
||||||
|
usageId: string | null,
|
||||||
|
commandId: string,
|
||||||
|
expectedRevision: number,
|
||||||
|
nowValue?: Date
|
||||||
|
) {
|
||||||
|
return executeCommand(
|
||||||
|
showId,
|
||||||
|
commandId,
|
||||||
|
expectedRevision,
|
||||||
|
usageId ? 'present' : 'clear-presentation',
|
||||||
|
(database, _state, now) => {
|
||||||
|
if (usageId) usageBelongsToShow(database, showId, usageId);
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE show_live_states SET presentation_usage_id = ?,
|
||||||
|
presentation_revision = presentation_revision + 1, updated_at_utc = ?
|
||||||
|
WHERE show_id = ?`
|
||||||
|
)
|
||||||
|
.run(usageId, now, showId);
|
||||||
|
},
|
||||||
|
nowValue
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function moveOpenUsage(
|
||||||
|
showId: string,
|
||||||
|
usageId: string,
|
||||||
|
expectedShowRevision: number,
|
||||||
|
input: MovePieceUsageInput
|
||||||
|
) {
|
||||||
|
const database = getDatabase();
|
||||||
|
const usage = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT u.status FROM piece_usages u JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
WHERE u.id = ? AND s.show_id = ?`
|
||||||
|
)
|
||||||
|
.get(usageId, showId) as { status: PieceUsage['status'] } | undefined;
|
||||||
|
if (!usage) throw new Error('NOT_FOUND');
|
||||||
|
if (usage.status !== 'open') throw new Error('LIVE_ORDER_LOCKED');
|
||||||
|
if (input.sectionId) {
|
||||||
|
const target = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT u.id, u.status FROM piece_usages u JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
WHERE s.id = ? AND s.show_id = ? AND s.is_reserve_bank = 0 ORDER BY u.position`
|
||||||
|
)
|
||||||
|
.all(input.sectionId, showId) as { id: string; status: PieceUsage['status'] }[];
|
||||||
|
if (!target.length) {
|
||||||
|
const section = database
|
||||||
|
.prepare('SELECT 1 FROM show_sections WHERE id = ? AND show_id = ? AND is_reserve_bank = 0')
|
||||||
|
.get(input.sectionId, showId);
|
||||||
|
if (!section) throw new Error('NOT_FOUND');
|
||||||
|
}
|
||||||
|
const withoutMoved = target.filter((item) => item.id !== usageId);
|
||||||
|
const firstOpenPosition = withoutMoved.findIndex((item) => item.status === 'open');
|
||||||
|
const minimum = firstOpenPosition < 0 ? withoutMoved.length : firstOpenPosition;
|
||||||
|
if (input.position < minimum) throw new Error('LIVE_ORDER_LOCKED');
|
||||||
|
}
|
||||||
|
return movePieceUsage(showId, usageId, expectedShowRevision, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function issuePresentationAccess(showId: string) {
|
||||||
|
const database = getDatabase();
|
||||||
|
const now = nowIso();
|
||||||
|
ensureLiveState(database, showId, now);
|
||||||
|
const token = randomBytes(32).toString('base64url');
|
||||||
|
database.transaction(() => {
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
'UPDATE presentation_access_tokens SET revoked_at_utc = ? WHERE show_id = ? AND revoked_at_utc IS NULL'
|
||||||
|
)
|
||||||
|
.run(now, showId);
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO presentation_access_tokens (id, show_id, token_hash, created_at_utc)
|
||||||
|
VALUES (?, ?, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(randomUUID(), showId, hashToken(token), now);
|
||||||
|
})();
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
function presentationShowId(database: Database.Database, token: string) {
|
||||||
|
if (!token || token.length > 200) return null;
|
||||||
|
const row = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT show_id FROM presentation_access_tokens
|
||||||
|
WHERE token_hash = ? AND revoked_at_utc IS NULL`
|
||||||
|
)
|
||||||
|
.get(hashToken(token)) as { show_id: string } | undefined;
|
||||||
|
return row?.show_id ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPresentationView(token: string): PresentationView | null {
|
||||||
|
const database = getDatabase();
|
||||||
|
const showId = presentationShowId(database, token);
|
||||||
|
if (!showId) return null;
|
||||||
|
const state = ensureLiveState(database, showId, nowIso());
|
||||||
|
if (!state.presentation_usage_id) return { revision: state.presentation_revision, content: null };
|
||||||
|
const usage = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT u.title_snapshot, u.presentation_snapshot, u.original_piece_id,
|
||||||
|
u.presentation_mode_snapshot, u.presentation_source_label_snapshot,
|
||||||
|
u.presentation_source_url_snapshot, u.presentation_source_timecode_snapshot,
|
||||||
|
u.presentation_title_meta_snapshot, u.presentation_description_snapshot,
|
||||||
|
u.presentation_image_url_snapshot, u.presentation_site_name_snapshot,
|
||||||
|
u.presentation_provider_snapshot, u.presentation_provider_id_snapshot
|
||||||
|
FROM piece_usages u JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
WHERE u.id = ? AND s.show_id = ? AND s.is_reserve_bank = 0`
|
||||||
|
)
|
||||||
|
.get(state.presentation_usage_id, showId) as
|
||||||
|
| {
|
||||||
|
title_snapshot: string;
|
||||||
|
presentation_snapshot: string;
|
||||||
|
original_piece_id: string | null;
|
||||||
|
presentation_mode_snapshot: PresentationContent['mode'];
|
||||||
|
presentation_source_label_snapshot: string;
|
||||||
|
presentation_source_url_snapshot: string;
|
||||||
|
presentation_source_timecode_snapshot: number | null;
|
||||||
|
presentation_title_meta_snapshot: string;
|
||||||
|
presentation_description_snapshot: string;
|
||||||
|
presentation_image_url_snapshot: string;
|
||||||
|
presentation_site_name_snapshot: string;
|
||||||
|
presentation_provider_snapshot: PresentationContent['provider'];
|
||||||
|
presentation_provider_id_snapshot: string;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
if (!usage) return { revision: state.presentation_revision, content: null };
|
||||||
|
const sources =
|
||||||
|
usage.presentation_mode_snapshot === 'text' && usage.original_piece_id
|
||||||
|
? (database
|
||||||
|
.prepare(
|
||||||
|
`SELECT label, url, timecode_seconds AS timecodeSeconds
|
||||||
|
FROM piece_sources WHERE piece_id = ? ORDER BY position`
|
||||||
|
)
|
||||||
|
.all(usage.original_piece_id) as {
|
||||||
|
label: string;
|
||||||
|
url: string;
|
||||||
|
timecodeSeconds: number | null;
|
||||||
|
}[])
|
||||||
|
: [];
|
||||||
|
const images =
|
||||||
|
usage.presentation_mode_snapshot === 'text' && usage.original_piece_id
|
||||||
|
? (database
|
||||||
|
.prepare(
|
||||||
|
`SELECT id, alt_text AS altText FROM piece_media
|
||||||
|
WHERE piece_id = ? ORDER BY position`
|
||||||
|
)
|
||||||
|
.all(usage.original_piece_id) as { id: string; altText: string }[])
|
||||||
|
: [];
|
||||||
|
return {
|
||||||
|
revision: state.presentation_revision,
|
||||||
|
content: {
|
||||||
|
mode: usage.presentation_mode_snapshot,
|
||||||
|
title: usage.title_snapshot,
|
||||||
|
html: renderMarkdown(usage.presentation_snapshot),
|
||||||
|
source: usage.presentation_source_url_snapshot
|
||||||
|
? {
|
||||||
|
label: usage.presentation_source_label_snapshot,
|
||||||
|
url: usage.presentation_source_url_snapshot,
|
||||||
|
timecodeSeconds: usage.presentation_source_timecode_snapshot
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
previewTitle: usage.presentation_title_meta_snapshot,
|
||||||
|
description: usage.presentation_description_snapshot,
|
||||||
|
imageUrl: usage.presentation_image_url_snapshot,
|
||||||
|
siteName: usage.presentation_site_name_snapshot,
|
||||||
|
provider: usage.presentation_provider_snapshot,
|
||||||
|
providerId: usage.presentation_provider_id_snapshot,
|
||||||
|
embedUrl: buildEmbedUrl(
|
||||||
|
usage.presentation_provider_snapshot,
|
||||||
|
usage.presentation_provider_id_snapshot,
|
||||||
|
usage.presentation_source_timecode_snapshot
|
||||||
|
),
|
||||||
|
sources,
|
||||||
|
images
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPresentationPreviewImage(token: string) {
|
||||||
|
const view = getPresentationView(token);
|
||||||
|
if (!view?.content?.imageUrl || view.content.mode === 'text') return null;
|
||||||
|
try {
|
||||||
|
return await fetchPresentationImage(view.content.imageUrl);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPresentationMedia(token: string, mediaId: string) {
|
||||||
|
const database = getDatabase();
|
||||||
|
const showId = presentationShowId(database, token);
|
||||||
|
if (!showId) return null;
|
||||||
|
const allowed = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT 1 FROM show_live_states l
|
||||||
|
JOIN piece_usages u ON u.id = l.presentation_usage_id
|
||||||
|
JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
JOIN piece_media m ON m.piece_id = u.original_piece_id
|
||||||
|
WHERE l.show_id = ? AND s.show_id = ? AND m.id = ?`
|
||||||
|
)
|
||||||
|
.get(showId, showId, mediaId);
|
||||||
|
if (!allowed) return null;
|
||||||
|
return getMediaFile(mediaId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import {
|
||||||
|
buildEmbedUrl,
|
||||||
|
detectVideoProvider,
|
||||||
|
extractMetadataFromHtml,
|
||||||
|
fetchPresentationMetadata
|
||||||
|
} from './presentation.js';
|
||||||
|
|
||||||
|
describe('presentation metadata and providers', () => {
|
||||||
|
it('recognizes supported YouTube URL forms and creates privacy-enhanced embeds with start time', () => {
|
||||||
|
for (const url of [
|
||||||
|
'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
||||||
|
'https://youtu.be/dQw4w9WgXcQ',
|
||||||
|
'https://www.youtube.com/shorts/dQw4w9WgXcQ',
|
||||||
|
'https://youtube.com/live/dQw4w9WgXcQ'
|
||||||
|
]) {
|
||||||
|
expect(detectVideoProvider(url)).toEqual({ provider: 'youtube', id: 'dQw4w9WgXcQ' });
|
||||||
|
}
|
||||||
|
expect(buildEmbedUrl('youtube', 'dQw4w9WgXcQ', 75)).toBe(
|
||||||
|
'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=75'
|
||||||
|
);
|
||||||
|
expect(detectVideoProvider('https://evil.example/watch?v=dQw4w9WgXcQ')).toBeNull();
|
||||||
|
expect(detectVideoProvider('https://youtube.com/watch?v=invalid')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('recognizes canonical TikTok videos without inventing a start parameter', () => {
|
||||||
|
expect(
|
||||||
|
detectVideoProvider('https://www.tiktok.com/@scout2015/video/6718335390845095173')
|
||||||
|
).toEqual({ provider: 'tiktok', id: '6718335390845095173' });
|
||||||
|
expect(buildEmbedUrl('tiktok', '6718335390845095173', 90)).toBe(
|
||||||
|
'https://www.tiktok.com/player/v1/6718335390845095173?autoplay=0&controls=1'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('extracts generic metadata from local HTML and tolerates a missing image', async () => {
|
||||||
|
const metadata = await extractMetadataFromHtml(
|
||||||
|
`<!doctype html><html><head>
|
||||||
|
<meta property="og:title" content="Lokale Vorschau">
|
||||||
|
<meta property="og:description" content="Ein kurzer Anreißer">
|
||||||
|
<meta property="og:site_name" content="Testseite">
|
||||||
|
</head></html>`,
|
||||||
|
'https://example.com/artikel'
|
||||||
|
);
|
||||||
|
expect(metadata).toMatchObject({
|
||||||
|
title: 'Lokale Vorschau',
|
||||||
|
description: 'Ein kurzer Anreißer',
|
||||||
|
imageUrl: '',
|
||||||
|
siteName: 'Testseite'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects malformed and private metadata targets before a network request', async () => {
|
||||||
|
await expect(fetchPresentationMetadata('keine-url')).rejects.toThrow('FETCH_INVALID_URL');
|
||||||
|
await expect(fetchPresentationMetadata('http://127.0.0.1/private')).rejects.toThrow(
|
||||||
|
'FETCH_BLOCKED'
|
||||||
|
);
|
||||||
|
await expect(fetchPresentationMetadata('http://[::1]/private')).rejects.toThrow(
|
||||||
|
'FETCH_BLOCKED'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,274 @@
|
|||||||
|
import { lookup } from 'node:dns/promises';
|
||||||
|
import { isIP } from 'node:net';
|
||||||
|
import http from 'node:http';
|
||||||
|
import https from 'node:https';
|
||||||
|
import metascraper from 'metascraper';
|
||||||
|
import description from 'metascraper-description';
|
||||||
|
import image from 'metascraper-image';
|
||||||
|
import publisher from 'metascraper-publisher';
|
||||||
|
import title from 'metascraper-title';
|
||||||
|
|
||||||
|
export type PresentationMode = 'text' | 'link' | 'video';
|
||||||
|
export type VideoProvider = 'youtube' | 'tiktok';
|
||||||
|
|
||||||
|
export type PresentationMetadata = {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
imageUrl: string;
|
||||||
|
siteName: string;
|
||||||
|
provider: VideoProvider | '';
|
||||||
|
providerId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PresentationSource = {
|
||||||
|
label: string;
|
||||||
|
url: string;
|
||||||
|
timecodeSeconds: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PresentationContent = {
|
||||||
|
mode: PresentationMode;
|
||||||
|
title: string;
|
||||||
|
html: string;
|
||||||
|
source: PresentationSource | null;
|
||||||
|
previewTitle: string;
|
||||||
|
description: string;
|
||||||
|
imageUrl: string;
|
||||||
|
siteName: string;
|
||||||
|
provider: VideoProvider | '';
|
||||||
|
providerId: string;
|
||||||
|
embedUrl: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const scrape = metascraper([title(), description({ truncateLength: 500 }), image(), publisher()]);
|
||||||
|
const MAX_HTML_BYTES = 1024 * 1024;
|
||||||
|
const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
||||||
|
const REQUEST_TIMEOUT_MS = 5_000;
|
||||||
|
const MAX_REDIRECTS = 3;
|
||||||
|
|
||||||
|
function isPrivateIpv4(address: string) {
|
||||||
|
const parts = address.split('.').map(Number);
|
||||||
|
return (
|
||||||
|
parts[0] === 0 ||
|
||||||
|
parts[0] === 10 ||
|
||||||
|
parts[0] === 127 ||
|
||||||
|
(parts[0] === 169 && parts[1] === 254) ||
|
||||||
|
(parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) ||
|
||||||
|
(parts[0] === 192 && parts[1] === 168) ||
|
||||||
|
(parts[0] === 100 && parts[1] >= 64 && parts[1] <= 127) ||
|
||||||
|
parts[0] >= 224
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPrivateAddress(address: string) {
|
||||||
|
if (isIP(address) === 4) return isPrivateIpv4(address);
|
||||||
|
const normalized = address.toLowerCase().split('%')[0];
|
||||||
|
if (normalized === '::' || normalized === '::1') return true;
|
||||||
|
if (normalized.startsWith('fc') || normalized.startsWith('fd') || normalized.startsWith('fe8')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
normalized.startsWith('fe9') ||
|
||||||
|
normalized.startsWith('fea') ||
|
||||||
|
normalized.startsWith('feb')
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const mapped = normalized.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/)?.[1];
|
||||||
|
return mapped ? isPrivateIpv4(mapped) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function publicAddress(url: URL) {
|
||||||
|
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) {
|
||||||
|
throw new Error('FETCH_BLOCKED');
|
||||||
|
}
|
||||||
|
if (url.port && url.port !== (url.protocol === 'https:' ? '443' : '80')) {
|
||||||
|
throw new Error('FETCH_BLOCKED');
|
||||||
|
}
|
||||||
|
const hostname = url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname;
|
||||||
|
if (hostname === 'localhost' || hostname.endsWith('.localhost')) {
|
||||||
|
throw new Error('FETCH_BLOCKED');
|
||||||
|
}
|
||||||
|
const addresses = isIP(hostname)
|
||||||
|
? [{ address: hostname, family: isIP(hostname) }]
|
||||||
|
: await lookup(hostname, { all: true, verbatim: true }).catch(() => {
|
||||||
|
throw new Error('FETCH_UNAVAILABLE');
|
||||||
|
});
|
||||||
|
if (!addresses.length || addresses.some((entry) => isPrivateAddress(entry.address))) {
|
||||||
|
throw new Error('FETCH_BLOCKED');
|
||||||
|
}
|
||||||
|
return addresses[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestPublic(
|
||||||
|
input: string,
|
||||||
|
accept: string,
|
||||||
|
maximumBytes: number,
|
||||||
|
redirects = 0
|
||||||
|
): Promise<{ url: string; contentType: string; data: Buffer }> {
|
||||||
|
let url: URL;
|
||||||
|
try {
|
||||||
|
url = new URL(input);
|
||||||
|
} catch {
|
||||||
|
throw new Error('FETCH_INVALID_URL');
|
||||||
|
}
|
||||||
|
const target = await publicAddress(url);
|
||||||
|
const client = url.protocol === 'https:' ? https : http;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const request = client.get(
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Accept: accept,
|
||||||
|
'User-Agent': 'Sendewerk/0.5.1 (+https://git.hnz.io/hnzio/sendewerk)'
|
||||||
|
},
|
||||||
|
lookup: (_hostname, _options, callback) =>
|
||||||
|
callback(null, target.address, target.family as 4 | 6)
|
||||||
|
},
|
||||||
|
(response) => {
|
||||||
|
const status = response.statusCode ?? 0;
|
||||||
|
if (status >= 300 && status < 400 && response.headers.location) {
|
||||||
|
response.resume();
|
||||||
|
if (redirects >= MAX_REDIRECTS) return reject(new Error('FETCH_REDIRECTS'));
|
||||||
|
const next = new URL(response.headers.location, url).href;
|
||||||
|
requestPublic(next, accept, maximumBytes, redirects + 1).then(resolve, reject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (status < 200 || status >= 300) {
|
||||||
|
response.resume();
|
||||||
|
return reject(new Error('FETCH_UNAVAILABLE'));
|
||||||
|
}
|
||||||
|
const chunks: Buffer[] = [];
|
||||||
|
let size = 0;
|
||||||
|
response.on('data', (chunk: Buffer) => {
|
||||||
|
size += chunk.length;
|
||||||
|
if (size > maximumBytes) {
|
||||||
|
request.destroy(new Error('FETCH_TOO_LARGE'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chunks.push(chunk);
|
||||||
|
});
|
||||||
|
response.on('end', () =>
|
||||||
|
resolve({
|
||||||
|
url: url.href,
|
||||||
|
contentType: String(response.headers['content-type'] ?? ''),
|
||||||
|
data: Buffer.concat(chunks)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
request.setTimeout(REQUEST_TIMEOUT_MS, () => request.destroy(new Error('FETCH_TIMEOUT')));
|
||||||
|
request.on('error', reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function detectVideoProvider(input: string): {
|
||||||
|
provider: VideoProvider;
|
||||||
|
id: string;
|
||||||
|
} | null {
|
||||||
|
let url: URL;
|
||||||
|
try {
|
||||||
|
url = new URL(input);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (url.protocol !== 'https:' || url.username || url.password || url.port) return null;
|
||||||
|
const host = url.hostname.toLowerCase();
|
||||||
|
let youtubeId = '';
|
||||||
|
if (host === 'youtu.be') youtubeId = url.pathname.split('/').filter(Boolean)[0] ?? '';
|
||||||
|
if (host === 'youtube.com' || host === 'www.youtube.com' || host === 'm.youtube.com') {
|
||||||
|
if (url.pathname === '/watch') youtubeId = url.searchParams.get('v') ?? '';
|
||||||
|
else if (/^\/(shorts|embed|live)\//.test(url.pathname)) {
|
||||||
|
youtubeId = url.pathname.split('/').filter(Boolean)[1] ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (/^[A-Za-z0-9_-]{11}$/.test(youtubeId)) {
|
||||||
|
return { provider: 'youtube', id: youtubeId };
|
||||||
|
}
|
||||||
|
if (host === 'tiktok.com' || host === 'www.tiktok.com' || host === 'm.tiktok.com') {
|
||||||
|
const id = url.pathname.match(/\/video\/(\d+)/)?.[1] ?? '';
|
||||||
|
if (/^\d+$/.test(id)) return { provider: 'tiktok', id };
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildEmbedUrl(
|
||||||
|
provider: VideoProvider | '',
|
||||||
|
providerId: string,
|
||||||
|
timecodeSeconds: number | null
|
||||||
|
) {
|
||||||
|
if (provider === 'youtube' && /^[A-Za-z0-9_-]{11}$/.test(providerId)) {
|
||||||
|
const url = new URL(`https://www.youtube-nocookie.com/embed/${providerId}`);
|
||||||
|
if (timecodeSeconds && timecodeSeconds > 0)
|
||||||
|
url.searchParams.set('start', String(timecodeSeconds));
|
||||||
|
return url.href;
|
||||||
|
}
|
||||||
|
if (provider === 'tiktok' && /^\d+$/.test(providerId)) {
|
||||||
|
const url = new URL(`https://www.tiktok.com/player/v1/${providerId}`);
|
||||||
|
url.searchParams.set('autoplay', '0');
|
||||||
|
url.searchParams.set('controls', '1');
|
||||||
|
return url.href;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function extractMetadataFromHtml(
|
||||||
|
html: string,
|
||||||
|
url: string
|
||||||
|
): Promise<PresentationMetadata> {
|
||||||
|
const metadata = await scrape({ html, url });
|
||||||
|
return {
|
||||||
|
title: String(metadata.title ?? '').slice(0, 300),
|
||||||
|
description: String(metadata.description ?? '').slice(0, 1_000),
|
||||||
|
imageUrl: String(metadata.image ?? '').slice(0, 2_000),
|
||||||
|
siteName: String(metadata.publisher ?? new URL(url).hostname).slice(0, 200),
|
||||||
|
provider: '',
|
||||||
|
providerId: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function providerMetadata(url: string, provider: VideoProvider) {
|
||||||
|
const endpoint =
|
||||||
|
provider === 'youtube'
|
||||||
|
? `https://www.youtube.com/oembed?format=json&url=${encodeURIComponent(url)}`
|
||||||
|
: `https://www.tiktok.com/oembed?url=${encodeURIComponent(url)}`;
|
||||||
|
const response = await requestPublic(endpoint, 'application/json', 256 * 1024);
|
||||||
|
if (!response.contentType.toLowerCase().includes('json')) throw new Error('FETCH_INVALID_TYPE');
|
||||||
|
const value = JSON.parse(response.data.toString('utf8')) as Record<string, unknown>;
|
||||||
|
return {
|
||||||
|
title: String(value.title ?? '').slice(0, 300),
|
||||||
|
description: '',
|
||||||
|
imageUrl: String(value.thumbnail_url ?? '').slice(0, 2_000),
|
||||||
|
siteName: String(value.provider_name ?? (provider === 'youtube' ? 'YouTube' : 'TikTok')).slice(
|
||||||
|
0,
|
||||||
|
200
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchPresentationMetadata(url: string): Promise<PresentationMetadata> {
|
||||||
|
const video = detectVideoProvider(url);
|
||||||
|
if (video) {
|
||||||
|
const metadata = await providerMetadata(url, video.provider);
|
||||||
|
return { ...metadata, provider: video.provider, providerId: video.id };
|
||||||
|
}
|
||||||
|
const response = await requestPublic(url, 'text/html,application/xhtml+xml', MAX_HTML_BYTES);
|
||||||
|
const contentType = response.contentType.toLowerCase();
|
||||||
|
if (!contentType.includes('text/html') && !contentType.includes('application/xhtml+xml')) {
|
||||||
|
throw new Error('FETCH_INVALID_TYPE');
|
||||||
|
}
|
||||||
|
return extractMetadataFromHtml(response.data.toString('utf8'), response.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchPresentationImage(url: string) {
|
||||||
|
const response = await requestPublic(
|
||||||
|
url,
|
||||||
|
'image/jpeg,image/png,image/webp,image/gif',
|
||||||
|
MAX_IMAGE_BYTES
|
||||||
|
);
|
||||||
|
const mimeType = response.contentType.split(';')[0].trim().toLowerCase();
|
||||||
|
if (!['image/jpeg', 'image/png', 'image/webp', 'image/gif'].includes(mimeType)) {
|
||||||
|
throw new Error('FETCH_INVALID_TYPE');
|
||||||
|
}
|
||||||
|
return { data: response.data, mimeType };
|
||||||
|
}
|
||||||
@@ -9,10 +9,13 @@ import {
|
|||||||
addPieceUsage,
|
addPieceUsage,
|
||||||
addShowSection,
|
addShowSection,
|
||||||
createShow,
|
createShow,
|
||||||
|
duplicatePieceUsage,
|
||||||
|
getPieceUsageContexts,
|
||||||
getShow,
|
getShow,
|
||||||
listShowTemplates,
|
listShowTemplates,
|
||||||
movePieceUsage,
|
movePieceUsage,
|
||||||
moveShowSection,
|
moveShowSection,
|
||||||
|
refreshPieceUsageFromOriginal,
|
||||||
removePieceUsage,
|
removePieceUsage,
|
||||||
removeShowSection,
|
removeShowSection,
|
||||||
updatePieceUsage,
|
updatePieceUsage,
|
||||||
@@ -46,9 +49,16 @@ function editedUsage(usage: PieceUsage, overrides: Partial<PieceUsage> = {}) {
|
|||||||
moderation: edited.moderation,
|
moderation: edited.moderation,
|
||||||
transition: edited.transition,
|
transition: edited.transition,
|
||||||
presentation: edited.presentation,
|
presentation: edited.presentation,
|
||||||
|
presentationMode: edited.presentationMode,
|
||||||
|
presentationSourceLabel: edited.presentationSourceLabel,
|
||||||
|
presentationSourceUrl: edited.presentationSourceUrl,
|
||||||
|
presentationSourceTimecodeSeconds: edited.presentationSourceTimecodeSeconds,
|
||||||
|
presentationTitle: edited.presentationTitle,
|
||||||
|
presentationDescription: edited.presentationDescription,
|
||||||
|
presentationImageUrl: edited.presentationImageUrl,
|
||||||
|
presentationSiteName: edited.presentationSiteName,
|
||||||
ownNotes: edited.ownNotes,
|
ownNotes: edited.ownNotes,
|
||||||
durationSeconds: edited.durationSeconds,
|
durationSeconds: edited.durationSeconds
|
||||||
status: edited.status
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +163,245 @@ describe('show builder data layer', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('derives sent history and current planning only from qualifying usages by original id', () => {
|
||||||
|
const completed = createShow({
|
||||||
|
title: 'Abgeschlossene Sendung',
|
||||||
|
startsAtUtc: '2027-01-10T19:00:00Z',
|
||||||
|
templateId: null
|
||||||
|
});
|
||||||
|
const completedSection = addShowSection(completed.id, completed.revision, {
|
||||||
|
name: 'Ablauf',
|
||||||
|
categoryId: null,
|
||||||
|
explicitDurationSeconds: null
|
||||||
|
});
|
||||||
|
const done = addPieceUsage(completed.id, completedSection.revision, {
|
||||||
|
pieceId: 'piece-console',
|
||||||
|
sectionId: completedSection.id
|
||||||
|
});
|
||||||
|
const skipped = addPieceUsage(completed.id, done.revision, {
|
||||||
|
pieceId: 'piece-effects',
|
||||||
|
sectionId: completedSection.id
|
||||||
|
});
|
||||||
|
const reserve = addPieceUsage(completed.id, skipped.revision, {
|
||||||
|
pieceId: 'piece-pixels',
|
||||||
|
sectionId: null
|
||||||
|
});
|
||||||
|
getDatabase()
|
||||||
|
.prepare("UPDATE piece_usages SET status = 'done' WHERE id IN (?, ?)")
|
||||||
|
.run(done.id, reserve.id);
|
||||||
|
getDatabase()
|
||||||
|
.prepare("UPDATE piece_usages SET status = 'skipped' WHERE id = ?")
|
||||||
|
.run(skipped.id);
|
||||||
|
getDatabase().prepare("UPDATE shows SET status = 'completed' WHERE id = ?").run(completed.id);
|
||||||
|
|
||||||
|
const active = createShow({ title: 'Aktuelle Planung', startsAtUtc: null, templateId: null });
|
||||||
|
const activeSection = addShowSection(active.id, active.revision, {
|
||||||
|
name: 'Plan',
|
||||||
|
categoryId: null,
|
||||||
|
explicitDurationSeconds: null
|
||||||
|
});
|
||||||
|
const planned = addPieceUsage(active.id, activeSection.revision, {
|
||||||
|
pieceId: 'piece-console',
|
||||||
|
sectionId: activeSection.id
|
||||||
|
});
|
||||||
|
const plannedReserve = addPieceUsage(active.id, planned.revision, {
|
||||||
|
pieceId: 'piece-effects',
|
||||||
|
sectionId: null
|
||||||
|
});
|
||||||
|
getDatabase().prepare("UPDATE piece_usages SET status = 'done' WHERE id = ?").run(planned.id);
|
||||||
|
|
||||||
|
let contexts = getPieceUsageContexts(
|
||||||
|
['piece-console', 'piece-effects', 'piece-pixels'],
|
||||||
|
active.id
|
||||||
|
);
|
||||||
|
expect(contexts['piece-console']).toMatchObject({
|
||||||
|
isPlannedInCurrentShow: true,
|
||||||
|
sentHistory: [
|
||||||
|
{
|
||||||
|
usageId: done.id,
|
||||||
|
showId: completed.id,
|
||||||
|
showTitle: 'Abgeschlossene Sendung',
|
||||||
|
usedAtUtc: '2027-01-10T19:00:00.000Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
expect(contexts['piece-effects']).toEqual({
|
||||||
|
isPlannedInActiveShow: true,
|
||||||
|
isPlannedInCurrentShow: true,
|
||||||
|
sentHistory: []
|
||||||
|
});
|
||||||
|
expect(contexts['piece-pixels']).toEqual({
|
||||||
|
isPlannedInActiveShow: true,
|
||||||
|
isPlannedInCurrentShow: false,
|
||||||
|
sentHistory: []
|
||||||
|
});
|
||||||
|
|
||||||
|
removePieceUsage(active.id, plannedReserve.id, plannedReserve.revision);
|
||||||
|
contexts = getPieceUsageContexts(['piece-effects'], active.id);
|
||||||
|
expect(contexts['piece-effects'].isPlannedInCurrentShow).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('duplicates an adjusted usage directly after its source without live measurements', () => {
|
||||||
|
const created = createShow({
|
||||||
|
title: 'Einplanungsduplikat',
|
||||||
|
startsAtUtc: null,
|
||||||
|
templateId: null
|
||||||
|
});
|
||||||
|
const section = addShowSection(created.id, created.revision, {
|
||||||
|
name: 'Ablauf',
|
||||||
|
categoryId: null,
|
||||||
|
explicitDurationSeconds: null
|
||||||
|
});
|
||||||
|
const usage = addPieceUsage(created.id, section.revision, {
|
||||||
|
pieceId: 'piece-console',
|
||||||
|
sectionId: section.id
|
||||||
|
});
|
||||||
|
const source = getShow(created.id)!.sections[0].usages[0];
|
||||||
|
const adjusted = updatePieceUsage(
|
||||||
|
created.id,
|
||||||
|
usage.id,
|
||||||
|
usage.revision,
|
||||||
|
editedUsage(source, {
|
||||||
|
title: 'Angepasste Einplanung',
|
||||||
|
durationSeconds: 777,
|
||||||
|
intro: 'Eigene Einleitung',
|
||||||
|
research: 'Eigene Recherche',
|
||||||
|
moderation: 'Eigene Moderation',
|
||||||
|
transition: 'Eigene Überleitung',
|
||||||
|
presentation: 'Eigene Präsentation',
|
||||||
|
ownNotes: 'Eigene Notizen'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
getDatabase().prepare("UPDATE piece_usages SET status = 'done' WHERE id = ?").run(usage.id);
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO live_usage_runs (id, show_id, usage_id, started_at_utc, ended_at_utc)
|
||||||
|
VALUES ('source-run', ?, ?, '2027-01-01T10:00:00.000Z', '2027-01-01T10:10:00.000Z')`
|
||||||
|
)
|
||||||
|
.run(created.id, usage.id);
|
||||||
|
const pieceCountBefore = (
|
||||||
|
getDatabase().prepare('SELECT count(*) AS count FROM pieces').get() as { count: number }
|
||||||
|
).count;
|
||||||
|
|
||||||
|
const duplicate = duplicatePieceUsage(created.id, usage.id, adjusted.revision);
|
||||||
|
const usages = getShow(created.id)!.sections[0].usages;
|
||||||
|
expect(usages.map((item) => item.id)).toEqual([usage.id, duplicate.id]);
|
||||||
|
expect(usages[1]).toMatchObject({
|
||||||
|
originalPieceId: 'piece-console',
|
||||||
|
status: 'open',
|
||||||
|
durationSeconds: 777,
|
||||||
|
title: 'Angepasste Einplanung',
|
||||||
|
intro: 'Eigene Einleitung',
|
||||||
|
research: 'Eigene Recherche',
|
||||||
|
moderation: 'Eigene Moderation',
|
||||||
|
transition: 'Eigene Überleitung',
|
||||||
|
presentation: 'Eigene Präsentation',
|
||||||
|
ownNotes: 'Eigene Notizen'
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
getDatabase()
|
||||||
|
.prepare('SELECT count(*) AS count FROM live_usage_runs WHERE usage_id = ?')
|
||||||
|
.get(duplicate.id)
|
||||||
|
).toEqual({ count: 0 });
|
||||||
|
expect(
|
||||||
|
(getDatabase().prepare('SELECT count(*) AS count FROM pieces').get() as { count: number })
|
||||||
|
.count
|
||||||
|
).toBe(pieceCountBefore);
|
||||||
|
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`UPDATE pieces SET title = 'Aktuelles Original', duration_seconds = 420,
|
||||||
|
intro = 'Neue Einleitung', research_text = 'Neue Recherche',
|
||||||
|
moderation_notes = 'Neue Moderation', transition_text = 'Neue Überleitung',
|
||||||
|
presentation_text = 'Neue Präsentation' WHERE id = 'piece-console'`
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
const refreshed = refreshPieceUsageFromOriginal(created.id, usage.id, duplicate.revision);
|
||||||
|
const refreshedUsages = getShow(created.id)!.sections[0].usages;
|
||||||
|
expect(refreshedUsages[0]).toMatchObject({
|
||||||
|
title: 'Aktuelles Original',
|
||||||
|
durationSeconds: 420,
|
||||||
|
intro: 'Neue Einleitung',
|
||||||
|
research: 'Neue Recherche',
|
||||||
|
moderation: 'Neue Moderation',
|
||||||
|
transition: 'Neue Überleitung',
|
||||||
|
presentation: 'Neue Präsentation',
|
||||||
|
ownNotes: 'Eigene Notizen',
|
||||||
|
status: 'done'
|
||||||
|
});
|
||||||
|
expect(refreshedUsages[1]).toMatchObject({
|
||||||
|
title: 'Angepasste Einplanung',
|
||||||
|
durationSeconds: 777,
|
||||||
|
status: 'open'
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
getDatabase()
|
||||||
|
.prepare('SELECT count(*) AS count FROM live_usage_runs WHERE usage_id = ?')
|
||||||
|
.get(usage.id)
|
||||||
|
).toEqual({ count: 1 });
|
||||||
|
expect(() => duplicatePieceUsage(created.id, usage.id, adjusted.revision)).toThrow('CONFLICT');
|
||||||
|
expect(getShow(created.id)?.revision).toBe(refreshed.revision);
|
||||||
|
getDatabase()
|
||||||
|
.prepare('UPDATE piece_usages SET original_piece_id = NULL WHERE id = ?')
|
||||||
|
.run(duplicate.id);
|
||||||
|
expect(() =>
|
||||||
|
refreshPieceUsageFromOriginal(created.id, duplicate.id, refreshed.revision)
|
||||||
|
).toThrow('ORIGINAL_NOT_FOUND');
|
||||||
|
expect(getShow(created.id)?.revision).toBe(refreshed.revision);
|
||||||
|
expect(getShow(created.id)!.sections[0].usages).toHaveLength(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('snapshots presentation settings until an explicit refresh and copies them on duplication', () => {
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`UPDATE piece_sources SET label = 'YouTube', url = ?, timecode_seconds = 75
|
||||||
|
WHERE piece_id = 'piece-console' AND position = 0`
|
||||||
|
)
|
||||||
|
.run('https://youtu.be/dQw4w9WgXcQ');
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`UPDATE pieces SET presentation_mode = 'video', presentation_source_position = 0,
|
||||||
|
presentation_title = 'Gespeicherte Vorschau', presentation_description = 'Erster Stand',
|
||||||
|
presentation_site_name = 'YouTube', presentation_provider = 'youtube',
|
||||||
|
presentation_provider_id = 'dQw4w9WgXcQ' WHERE id = 'piece-console'`
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
const show = createShow({ title: 'Snapshot-Test', startsAtUtc: null, templateId: null });
|
||||||
|
const section = addShowSection(show.id, show.revision, {
|
||||||
|
name: 'Videos',
|
||||||
|
categoryId: null,
|
||||||
|
explicitDurationSeconds: null
|
||||||
|
});
|
||||||
|
const added = addPieceUsage(show.id, section.revision, {
|
||||||
|
pieceId: 'piece-console',
|
||||||
|
sectionId: section.id
|
||||||
|
});
|
||||||
|
let usage = getShow(show.id)!.sections[0].usages[0];
|
||||||
|
expect(usage).toMatchObject({
|
||||||
|
presentationMode: 'video',
|
||||||
|
presentationSourceUrl: 'https://youtu.be/dQw4w9WgXcQ',
|
||||||
|
presentationSourceTimecodeSeconds: 75,
|
||||||
|
presentationTitle: 'Gespeicherte Vorschau'
|
||||||
|
});
|
||||||
|
|
||||||
|
getDatabase()
|
||||||
|
.prepare(
|
||||||
|
`UPDATE pieces SET presentation_title = 'Neuer Originaltitel' WHERE id = 'piece-console'`
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
expect(getShow(show.id)!.sections[0].usages[0].presentationTitle).toBe('Gespeicherte Vorschau');
|
||||||
|
const refreshed = refreshPieceUsageFromOriginal(show.id, usage.id, added.revision);
|
||||||
|
usage = getShow(show.id)!.sections[0].usages[0];
|
||||||
|
expect(usage.presentationTitle).toBe('Neuer Originaltitel');
|
||||||
|
duplicatePieceUsage(show.id, usage.id, refreshed.revision);
|
||||||
|
expect(getShow(show.id)!.sections[0].usages[1]).toMatchObject({
|
||||||
|
presentationMode: 'video',
|
||||||
|
presentationSourceUrl: 'https://youtu.be/dQw4w9WgXcQ',
|
||||||
|
presentationTitle: 'Neuer Originaltitel',
|
||||||
|
status: 'open'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('persists normalized section and usage reordering, moving and removal', () => {
|
it('persists normalized section and usage reordering, moving and removal', () => {
|
||||||
const created = createShow({ title: 'Sortierung', startsAtUtc: null, templateId: null });
|
const created = createShow({ title: 'Sortierung', startsAtUtc: null, templateId: null });
|
||||||
const firstSection = addShowSection(created.id, created.revision, {
|
const firstSection = addShowSection(created.id, created.revision, {
|
||||||
|
|||||||
+392
-9
@@ -1,6 +1,7 @@
|
|||||||
import { randomUUID } from 'node:crypto';
|
import { randomUUID } from 'node:crypto';
|
||||||
import type Database from 'better-sqlite3';
|
import type Database from 'better-sqlite3';
|
||||||
import { getDatabase } from './database.js';
|
import { getDatabase } from './database.js';
|
||||||
|
import { detectVideoProvider, type PresentationMode } from './presentation.js';
|
||||||
|
|
||||||
export const SHOW_STATUSES = ['draft', 'ready', 'live', 'completed'] as const;
|
export const SHOW_STATUSES = ['draft', 'ready', 'live', 'completed'] as const;
|
||||||
export const USAGE_STATUSES = ['open', 'current', 'done', 'skipped'] as const;
|
export const USAGE_STATUSES = ['open', 'current', 'done', 'skipped'] as const;
|
||||||
@@ -46,9 +47,32 @@ export type PieceUsage = {
|
|||||||
moderation: string;
|
moderation: string;
|
||||||
transition: string;
|
transition: string;
|
||||||
presentation: string;
|
presentation: string;
|
||||||
|
presentationMode: PresentationMode;
|
||||||
|
presentationSourceLabel: string;
|
||||||
|
presentationSourceUrl: string;
|
||||||
|
presentationSourceTimecodeSeconds: number | null;
|
||||||
|
presentationTitle: string;
|
||||||
|
presentationDescription: string;
|
||||||
|
presentationImageUrl: string;
|
||||||
|
presentationSiteName: string;
|
||||||
|
presentationProvider: string;
|
||||||
|
presentationProviderId: string;
|
||||||
ownNotes: string;
|
ownNotes: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type SentPieceUsage = {
|
||||||
|
usageId: string;
|
||||||
|
showId: string;
|
||||||
|
showTitle: string;
|
||||||
|
usedAtUtc: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PieceUsageContext = {
|
||||||
|
sentHistory: SentPieceUsage[];
|
||||||
|
isPlannedInActiveShow: boolean;
|
||||||
|
isPlannedInCurrentShow: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type ShowSection = {
|
export type ShowSection = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -110,9 +134,16 @@ export type PieceUsageUpdate = {
|
|||||||
moderation: string;
|
moderation: string;
|
||||||
transition: string;
|
transition: string;
|
||||||
presentation: string;
|
presentation: string;
|
||||||
|
presentationMode: PresentationMode;
|
||||||
|
presentationSourceLabel: string;
|
||||||
|
presentationSourceUrl: string;
|
||||||
|
presentationSourceTimecodeSeconds: number | null;
|
||||||
|
presentationTitle: string;
|
||||||
|
presentationDescription: string;
|
||||||
|
presentationImageUrl: string;
|
||||||
|
presentationSiteName: string;
|
||||||
ownNotes: string;
|
ownNotes: string;
|
||||||
durationSeconds: number;
|
durationSeconds: number;
|
||||||
status: UsageStatus;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MovePieceUsageInput = {
|
export type MovePieceUsageInput = {
|
||||||
@@ -159,6 +190,16 @@ type UsageRow = {
|
|||||||
moderation_snapshot: string;
|
moderation_snapshot: string;
|
||||||
transition_snapshot: string;
|
transition_snapshot: string;
|
||||||
presentation_snapshot: string;
|
presentation_snapshot: string;
|
||||||
|
presentation_mode_snapshot: PresentationMode;
|
||||||
|
presentation_source_label_snapshot: string;
|
||||||
|
presentation_source_url_snapshot: string;
|
||||||
|
presentation_source_timecode_snapshot: number | null;
|
||||||
|
presentation_title_meta_snapshot: string;
|
||||||
|
presentation_description_snapshot: string;
|
||||||
|
presentation_image_url_snapshot: string;
|
||||||
|
presentation_site_name_snapshot: string;
|
||||||
|
presentation_provider_snapshot: string;
|
||||||
|
presentation_provider_id_snapshot: string;
|
||||||
own_notes: string;
|
own_notes: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -191,6 +232,50 @@ function validTimestamp(value: string | null): string | null {
|
|||||||
return date.toISOString();
|
return date.toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validPresentation(
|
||||||
|
mode: PresentationMode,
|
||||||
|
sourceLabel: string,
|
||||||
|
sourceUrl: string,
|
||||||
|
timecodeSeconds: number | null,
|
||||||
|
title: string,
|
||||||
|
description: string,
|
||||||
|
imageUrl: string,
|
||||||
|
siteName: string
|
||||||
|
) {
|
||||||
|
if (!['text', 'link', 'video'].includes(mode)) throw new Error('INVALID_PRESENTATION');
|
||||||
|
const cleanUrl = cleanText(sourceUrl, 2_000, 'presentation_source');
|
||||||
|
const cleanImageUrl = cleanText(imageUrl, 2_000, 'presentation_image');
|
||||||
|
for (const value of [cleanUrl, cleanImageUrl]) {
|
||||||
|
if (!value) continue;
|
||||||
|
try {
|
||||||
|
const url = new URL(value);
|
||||||
|
if (!['http:', 'https:'].includes(url.protocol)) throw new Error();
|
||||||
|
} catch {
|
||||||
|
throw new Error('INVALID_PRESENTATION');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mode !== 'text' && !cleanUrl) throw new Error('INVALID_PRESENTATION');
|
||||||
|
if (
|
||||||
|
timecodeSeconds !== null &&
|
||||||
|
(!Number.isInteger(timecodeSeconds) || timecodeSeconds < 0 || timecodeSeconds > 86_400)
|
||||||
|
) {
|
||||||
|
throw new Error('INVALID_PRESENTATION');
|
||||||
|
}
|
||||||
|
const detected = detectVideoProvider(cleanUrl);
|
||||||
|
return {
|
||||||
|
mode,
|
||||||
|
sourceLabel: cleanText(sourceLabel, 200, 'presentation_source'),
|
||||||
|
sourceUrl: cleanUrl,
|
||||||
|
timecodeSeconds,
|
||||||
|
title: cleanText(title, 300, 'presentation_title'),
|
||||||
|
description: cleanText(description, 1_000, 'presentation_description'),
|
||||||
|
imageUrl: cleanImageUrl,
|
||||||
|
siteName: cleanText(siteName, 200, 'presentation_site'),
|
||||||
|
provider: detected?.provider ?? '',
|
||||||
|
providerId: detected?.id ?? ''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function requireRevision(expectedRevision: number): void {
|
function requireRevision(expectedRevision: number): void {
|
||||||
if (!Number.isInteger(expectedRevision) || expectedRevision < 1) {
|
if (!Number.isInteger(expectedRevision) || expectedRevision < 1) {
|
||||||
throw new Error('INVALID_REVISION');
|
throw new Error('INVALID_REVISION');
|
||||||
@@ -296,6 +381,16 @@ function usageFromRow(row: UsageRow): PieceUsage {
|
|||||||
moderation: row.moderation_snapshot,
|
moderation: row.moderation_snapshot,
|
||||||
transition: row.transition_snapshot,
|
transition: row.transition_snapshot,
|
||||||
presentation: row.presentation_snapshot,
|
presentation: row.presentation_snapshot,
|
||||||
|
presentationMode: row.presentation_mode_snapshot,
|
||||||
|
presentationSourceLabel: row.presentation_source_label_snapshot,
|
||||||
|
presentationSourceUrl: row.presentation_source_url_snapshot,
|
||||||
|
presentationSourceTimecodeSeconds: row.presentation_source_timecode_snapshot,
|
||||||
|
presentationTitle: row.presentation_title_meta_snapshot,
|
||||||
|
presentationDescription: row.presentation_description_snapshot,
|
||||||
|
presentationImageUrl: row.presentation_image_url_snapshot,
|
||||||
|
presentationSiteName: row.presentation_site_name_snapshot,
|
||||||
|
presentationProvider: row.presentation_provider_snapshot,
|
||||||
|
presentationProviderId: row.presentation_provider_id_snapshot,
|
||||||
ownNotes: row.own_notes
|
ownNotes: row.own_notes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -384,7 +479,12 @@ export function getShow(id: string): Show | null {
|
|||||||
.prepare(
|
.prepare(
|
||||||
`SELECT u.id, u.show_section_id, u.original_piece_id, u.position, u.status,
|
`SELECT u.id, u.show_section_id, u.original_piece_id, u.position, u.status,
|
||||||
u.duration_seconds, u.title_snapshot, u.intro_snapshot, u.research_snapshot,
|
u.duration_seconds, u.title_snapshot, u.intro_snapshot, u.research_snapshot,
|
||||||
u.moderation_snapshot, u.transition_snapshot, u.presentation_snapshot, u.own_notes
|
u.moderation_snapshot, u.transition_snapshot, u.presentation_snapshot,
|
||||||
|
u.presentation_mode_snapshot, u.presentation_source_label_snapshot,
|
||||||
|
u.presentation_source_url_snapshot, u.presentation_source_timecode_snapshot,
|
||||||
|
u.presentation_title_meta_snapshot, u.presentation_description_snapshot,
|
||||||
|
u.presentation_image_url_snapshot, u.presentation_site_name_snapshot,
|
||||||
|
u.presentation_provider_snapshot, u.presentation_provider_id_snapshot, u.own_notes
|
||||||
FROM piece_usages u JOIN show_sections s ON s.id = u.show_section_id
|
FROM piece_usages u JOIN show_sections s ON s.id = u.show_section_id
|
||||||
WHERE s.show_id = ? ORDER BY s.position, u.position`
|
WHERE s.show_id = ? ORDER BY s.position, u.position`
|
||||||
)
|
)
|
||||||
@@ -430,6 +530,80 @@ export function getShow(id: string): Show | null {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPieceUsageContexts(
|
||||||
|
pieceIds: string[],
|
||||||
|
currentShowId?: string
|
||||||
|
): Record<string, PieceUsageContext> {
|
||||||
|
const uniquePieceIds = [...new Set(pieceIds.filter(Boolean))];
|
||||||
|
const contexts = Object.fromEntries(
|
||||||
|
uniquePieceIds.map((pieceId) => [
|
||||||
|
pieceId,
|
||||||
|
{
|
||||||
|
sentHistory: [],
|
||||||
|
isPlannedInActiveShow: false,
|
||||||
|
isPlannedInCurrentShow: false
|
||||||
|
} satisfies PieceUsageContext
|
||||||
|
])
|
||||||
|
) as Record<string, PieceUsageContext>;
|
||||||
|
if (!uniquePieceIds.length) return contexts;
|
||||||
|
|
||||||
|
const database = getDatabase();
|
||||||
|
const history = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT u.id AS usage_id, u.original_piece_id, sh.id AS show_id,
|
||||||
|
sh.title AS show_title, COALESCE(sh.starts_at_utc, sh.updated_at_utc) AS used_at_utc
|
||||||
|
FROM piece_usages u
|
||||||
|
JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
JOIN shows sh ON sh.id = s.show_id
|
||||||
|
WHERE u.original_piece_id IS NOT NULL AND u.status = 'done'
|
||||||
|
AND sh.status = 'completed' AND s.is_reserve_bank = 0
|
||||||
|
ORDER BY used_at_utc DESC, u.id DESC`
|
||||||
|
)
|
||||||
|
.all() as {
|
||||||
|
usage_id: string;
|
||||||
|
original_piece_id: string;
|
||||||
|
show_id: string;
|
||||||
|
show_title: string;
|
||||||
|
used_at_utc: string;
|
||||||
|
}[];
|
||||||
|
for (const usage of history) {
|
||||||
|
contexts[usage.original_piece_id]?.sentHistory.push({
|
||||||
|
usageId: usage.usage_id,
|
||||||
|
showId: usage.show_id,
|
||||||
|
showTitle: usage.show_title,
|
||||||
|
usedAtUtc: usage.used_at_utc
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const plannedInActiveShows = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT DISTINCT u.original_piece_id FROM piece_usages u
|
||||||
|
JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
JOIN shows sh ON sh.id = s.show_id
|
||||||
|
WHERE sh.status != 'completed' AND u.original_piece_id IS NOT NULL`
|
||||||
|
)
|
||||||
|
.all() as { original_piece_id: string }[];
|
||||||
|
for (const usage of plannedInActiveShows) {
|
||||||
|
const context = contexts[usage.original_piece_id];
|
||||||
|
if (context) context.isPlannedInActiveShow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentShowId) {
|
||||||
|
const planned = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT DISTINCT u.original_piece_id FROM piece_usages u
|
||||||
|
JOIN show_sections s ON s.id = u.show_section_id
|
||||||
|
WHERE s.show_id = ? AND u.original_piece_id IS NOT NULL`
|
||||||
|
)
|
||||||
|
.all(currentShowId) as { original_piece_id: string }[];
|
||||||
|
for (const usage of planned) {
|
||||||
|
const context = contexts[usage.original_piece_id];
|
||||||
|
if (context) context.isPlannedInCurrentShow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return contexts;
|
||||||
|
}
|
||||||
|
|
||||||
export function createShow(input: CreateShowInput): CreatedMutationResult {
|
export function createShow(input: CreateShowInput): CreatedMutationResult {
|
||||||
const database = getDatabase();
|
const database = getDatabase();
|
||||||
const id = randomUUID();
|
const id = randomUUID();
|
||||||
@@ -631,8 +805,15 @@ export function addPieceUsage(
|
|||||||
sectionBelongsToShow(database, showId, sectionId, input.sectionId === null);
|
sectionBelongsToShow(database, showId, sectionId, input.sectionId === null);
|
||||||
const piece = database
|
const piece = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT title, duration_seconds, intro, research_text, moderation_notes,
|
`SELECT p.title, p.duration_seconds, p.intro, p.research_text, p.moderation_notes,
|
||||||
transition_text, presentation_text, status FROM pieces WHERE id = ?`
|
p.transition_text, p.presentation_text, p.status, p.presentation_mode,
|
||||||
|
COALESCE(ps.label, '') AS presentation_source_label,
|
||||||
|
COALESCE(ps.url, '') AS presentation_source_url,
|
||||||
|
ps.timecode_seconds AS presentation_source_timecode,
|
||||||
|
p.presentation_title, p.presentation_description, p.presentation_image_url,
|
||||||
|
p.presentation_site_name, p.presentation_provider, p.presentation_provider_id
|
||||||
|
FROM pieces p LEFT JOIN piece_sources ps ON ps.piece_id = p.id
|
||||||
|
AND ps.position = p.presentation_source_position WHERE p.id = ?`
|
||||||
)
|
)
|
||||||
.get(input.pieceId) as
|
.get(input.pieceId) as
|
||||||
| {
|
| {
|
||||||
@@ -643,6 +824,16 @@ export function addPieceUsage(
|
|||||||
moderation_notes: string;
|
moderation_notes: string;
|
||||||
transition_text: string;
|
transition_text: string;
|
||||||
presentation_text: string;
|
presentation_text: string;
|
||||||
|
presentation_mode: PresentationMode;
|
||||||
|
presentation_source_label: string;
|
||||||
|
presentation_source_url: string;
|
||||||
|
presentation_source_timecode: number | null;
|
||||||
|
presentation_title: string;
|
||||||
|
presentation_description: string;
|
||||||
|
presentation_image_url: string;
|
||||||
|
presentation_site_name: string;
|
||||||
|
presentation_provider: string;
|
||||||
|
presentation_provider_id: string;
|
||||||
status: string;
|
status: string;
|
||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
@@ -659,8 +850,13 @@ export function addPieceUsage(
|
|||||||
.prepare(
|
.prepare(
|
||||||
`INSERT INTO piece_usages (id, show_section_id, original_piece_id, position, status,
|
`INSERT INTO piece_usages (id, show_section_id, original_piece_id, position, status,
|
||||||
duration_seconds, title_snapshot, intro_snapshot, research_snapshot,
|
duration_seconds, title_snapshot, intro_snapshot, research_snapshot,
|
||||||
moderation_snapshot, transition_snapshot, presentation_snapshot, own_notes, is_reserve)
|
moderation_snapshot, transition_snapshot, presentation_snapshot,
|
||||||
VALUES (?, ?, ?, ?, 'open', ?, ?, ?, ?, ?, ?, ?, '', ?)`
|
presentation_mode_snapshot, presentation_source_label_snapshot,
|
||||||
|
presentation_source_url_snapshot, presentation_source_timecode_snapshot,
|
||||||
|
presentation_title_meta_snapshot, presentation_description_snapshot,
|
||||||
|
presentation_image_url_snapshot, presentation_site_name_snapshot,
|
||||||
|
presentation_provider_snapshot, presentation_provider_id_snapshot, own_notes, is_reserve)
|
||||||
|
VALUES (?, ?, ?, ?, 'open', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '', ?)`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
id,
|
id,
|
||||||
@@ -674,6 +870,16 @@ export function addPieceUsage(
|
|||||||
piece.moderation_notes,
|
piece.moderation_notes,
|
||||||
piece.transition_text,
|
piece.transition_text,
|
||||||
piece.presentation_text,
|
piece.presentation_text,
|
||||||
|
piece.presentation_mode,
|
||||||
|
piece.presentation_source_label,
|
||||||
|
piece.presentation_source_url,
|
||||||
|
piece.presentation_source_timecode,
|
||||||
|
piece.presentation_title,
|
||||||
|
piece.presentation_description,
|
||||||
|
piece.presentation_image_url,
|
||||||
|
piece.presentation_site_name,
|
||||||
|
piece.presentation_provider,
|
||||||
|
piece.presentation_provider_id,
|
||||||
input.sectionId === null ? 1 : 0
|
input.sectionId === null ? 1 : 0
|
||||||
);
|
);
|
||||||
ids.splice(position, 0, id);
|
ids.splice(position, 0, id);
|
||||||
@@ -682,6 +888,160 @@ export function addPieceUsage(
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function duplicatePieceUsage(
|
||||||
|
showId: string,
|
||||||
|
usageId: string,
|
||||||
|
expectedRevision: number
|
||||||
|
): CreatedMutationResult {
|
||||||
|
const database = getDatabase();
|
||||||
|
return database.transaction(() => {
|
||||||
|
const result = bumpShow(database, showId, expectedRevision);
|
||||||
|
const sourceSection = usageSection(database, showId, usageId);
|
||||||
|
const source = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT original_piece_id, status, duration_seconds, title_snapshot, intro_snapshot,
|
||||||
|
research_snapshot, moderation_snapshot, transition_snapshot, presentation_snapshot,
|
||||||
|
presentation_mode_snapshot, presentation_source_label_snapshot,
|
||||||
|
presentation_source_url_snapshot, presentation_source_timecode_snapshot,
|
||||||
|
presentation_title_meta_snapshot, presentation_description_snapshot,
|
||||||
|
presentation_image_url_snapshot, presentation_site_name_snapshot,
|
||||||
|
presentation_provider_snapshot, presentation_provider_id_snapshot,
|
||||||
|
own_notes, is_reserve FROM piece_usages WHERE id = ?`
|
||||||
|
)
|
||||||
|
.get(usageId) as Omit<UsageRow, 'id' | 'show_section_id' | 'position'> & {
|
||||||
|
is_reserve: number;
|
||||||
|
};
|
||||||
|
const ids = (
|
||||||
|
database
|
||||||
|
.prepare('SELECT id FROM piece_usages WHERE show_section_id = ? ORDER BY position')
|
||||||
|
.all(sourceSection.sectionId) as { id: string }[]
|
||||||
|
).map((row) => row.id);
|
||||||
|
const sourcePosition = ids.indexOf(usageId);
|
||||||
|
if (sourcePosition < 0) throw new Error('NOT_FOUND');
|
||||||
|
const id = randomUUID();
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO piece_usages (id, show_section_id, original_piece_id, position, status,
|
||||||
|
duration_seconds, title_snapshot, intro_snapshot, research_snapshot,
|
||||||
|
moderation_snapshot, transition_snapshot, presentation_snapshot,
|
||||||
|
presentation_mode_snapshot, presentation_source_label_snapshot,
|
||||||
|
presentation_source_url_snapshot, presentation_source_timecode_snapshot,
|
||||||
|
presentation_title_meta_snapshot, presentation_description_snapshot,
|
||||||
|
presentation_image_url_snapshot, presentation_site_name_snapshot,
|
||||||
|
presentation_provider_snapshot, presentation_provider_id_snapshot, own_notes, is_reserve)
|
||||||
|
VALUES (?, ?, ?, ?, 'open', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(
|
||||||
|
id,
|
||||||
|
sourceSection.sectionId,
|
||||||
|
source.original_piece_id,
|
||||||
|
ids.length,
|
||||||
|
source.duration_seconds,
|
||||||
|
source.title_snapshot,
|
||||||
|
source.intro_snapshot,
|
||||||
|
source.research_snapshot,
|
||||||
|
source.moderation_snapshot,
|
||||||
|
source.transition_snapshot,
|
||||||
|
source.presentation_snapshot,
|
||||||
|
source.presentation_mode_snapshot,
|
||||||
|
source.presentation_source_label_snapshot,
|
||||||
|
source.presentation_source_url_snapshot,
|
||||||
|
source.presentation_source_timecode_snapshot,
|
||||||
|
source.presentation_title_meta_snapshot,
|
||||||
|
source.presentation_description_snapshot,
|
||||||
|
source.presentation_image_url_snapshot,
|
||||||
|
source.presentation_site_name_snapshot,
|
||||||
|
source.presentation_provider_snapshot,
|
||||||
|
source.presentation_provider_id_snapshot,
|
||||||
|
source.own_notes,
|
||||||
|
source.is_reserve
|
||||||
|
);
|
||||||
|
ids.splice(sourcePosition + 1, 0, id);
|
||||||
|
normalizePositions(database, 'piece_usages', ids);
|
||||||
|
return { ...result, id };
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function refreshPieceUsageFromOriginal(
|
||||||
|
showId: string,
|
||||||
|
usageId: string,
|
||||||
|
expectedRevision: number
|
||||||
|
): MutationResult {
|
||||||
|
const database = getDatabase();
|
||||||
|
return database.transaction(() => {
|
||||||
|
const result = bumpShow(database, showId, expectedRevision);
|
||||||
|
usageSection(database, showId, usageId);
|
||||||
|
const source = database
|
||||||
|
.prepare(
|
||||||
|
`SELECT p.title, p.duration_seconds, p.intro, p.research_text,
|
||||||
|
p.moderation_notes, p.transition_text, p.presentation_text, p.presentation_mode,
|
||||||
|
COALESCE(ps.label, '') AS presentation_source_label,
|
||||||
|
COALESCE(ps.url, '') AS presentation_source_url,
|
||||||
|
ps.timecode_seconds AS presentation_source_timecode,
|
||||||
|
p.presentation_title, p.presentation_description, p.presentation_image_url,
|
||||||
|
p.presentation_site_name, p.presentation_provider, p.presentation_provider_id
|
||||||
|
FROM piece_usages u JOIN pieces p ON p.id = u.original_piece_id
|
||||||
|
LEFT JOIN piece_sources ps ON ps.piece_id = p.id
|
||||||
|
AND ps.position = p.presentation_source_position
|
||||||
|
WHERE u.id = ?`
|
||||||
|
)
|
||||||
|
.get(usageId) as
|
||||||
|
| {
|
||||||
|
title: string;
|
||||||
|
duration_seconds: number;
|
||||||
|
intro: string;
|
||||||
|
research_text: string;
|
||||||
|
moderation_notes: string;
|
||||||
|
transition_text: string;
|
||||||
|
presentation_text: string;
|
||||||
|
presentation_mode: PresentationMode;
|
||||||
|
presentation_source_label: string;
|
||||||
|
presentation_source_url: string;
|
||||||
|
presentation_source_timecode: number | null;
|
||||||
|
presentation_title: string;
|
||||||
|
presentation_description: string;
|
||||||
|
presentation_image_url: string;
|
||||||
|
presentation_site_name: string;
|
||||||
|
presentation_provider: string;
|
||||||
|
presentation_provider_id: string;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
if (!source) throw new Error('ORIGINAL_NOT_FOUND');
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`UPDATE piece_usages SET title_snapshot = ?, duration_seconds = ?, intro_snapshot = ?,
|
||||||
|
research_snapshot = ?, moderation_snapshot = ?, transition_snapshot = ?,
|
||||||
|
presentation_snapshot = ?, presentation_mode_snapshot = ?,
|
||||||
|
presentation_source_label_snapshot = ?, presentation_source_url_snapshot = ?,
|
||||||
|
presentation_source_timecode_snapshot = ?, presentation_title_meta_snapshot = ?,
|
||||||
|
presentation_description_snapshot = ?, presentation_image_url_snapshot = ?,
|
||||||
|
presentation_site_name_snapshot = ?, presentation_provider_snapshot = ?,
|
||||||
|
presentation_provider_id_snapshot = ? WHERE id = ?`
|
||||||
|
)
|
||||||
|
.run(
|
||||||
|
source.title,
|
||||||
|
source.duration_seconds,
|
||||||
|
source.intro,
|
||||||
|
source.research_text,
|
||||||
|
source.moderation_notes,
|
||||||
|
source.transition_text,
|
||||||
|
source.presentation_text,
|
||||||
|
source.presentation_mode,
|
||||||
|
source.presentation_source_label,
|
||||||
|
source.presentation_source_url,
|
||||||
|
source.presentation_source_timecode,
|
||||||
|
source.presentation_title,
|
||||||
|
source.presentation_description,
|
||||||
|
source.presentation_image_url,
|
||||||
|
source.presentation_site_name,
|
||||||
|
source.presentation_provider,
|
||||||
|
source.presentation_provider_id,
|
||||||
|
usageId
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
export function updatePieceUsage(
|
export function updatePieceUsage(
|
||||||
showId: string,
|
showId: string,
|
||||||
usageId: string,
|
usageId: string,
|
||||||
@@ -690,7 +1050,6 @@ export function updatePieceUsage(
|
|||||||
): MutationResult {
|
): MutationResult {
|
||||||
const title = cleanText(input.title, 200, 'title', true);
|
const title = cleanText(input.title, 200, 'title', true);
|
||||||
const duration = validDuration(input.durationSeconds)!;
|
const duration = validDuration(input.durationSeconds)!;
|
||||||
if (!USAGE_STATUSES.includes(input.status)) throw new Error('INVALID_STATUS');
|
|
||||||
const values = {
|
const values = {
|
||||||
intro: cleanText(input.intro, 50_000, 'intro'),
|
intro: cleanText(input.intro, 50_000, 'intro'),
|
||||||
research: cleanText(input.research, 50_000, 'research'),
|
research: cleanText(input.research, 50_000, 'research'),
|
||||||
@@ -699,6 +1058,16 @@ export function updatePieceUsage(
|
|||||||
presentation: cleanText(input.presentation, 50_000, 'presentation'),
|
presentation: cleanText(input.presentation, 50_000, 'presentation'),
|
||||||
ownNotes: cleanText(input.ownNotes, 50_000, 'notes')
|
ownNotes: cleanText(input.ownNotes, 50_000, 'notes')
|
||||||
};
|
};
|
||||||
|
const presentation = validPresentation(
|
||||||
|
input.presentationMode,
|
||||||
|
input.presentationSourceLabel,
|
||||||
|
input.presentationSourceUrl,
|
||||||
|
input.presentationSourceTimecodeSeconds,
|
||||||
|
input.presentationTitle,
|
||||||
|
input.presentationDescription,
|
||||||
|
input.presentationImageUrl,
|
||||||
|
input.presentationSiteName
|
||||||
|
);
|
||||||
const database = getDatabase();
|
const database = getDatabase();
|
||||||
return database.transaction(() => {
|
return database.transaction(() => {
|
||||||
const result = bumpShow(database, showId, expectedRevision);
|
const result = bumpShow(database, showId, expectedRevision);
|
||||||
@@ -707,7 +1076,12 @@ export function updatePieceUsage(
|
|||||||
.prepare(
|
.prepare(
|
||||||
`UPDATE piece_usages SET title_snapshot = ?, intro_snapshot = ?, research_snapshot = ?,
|
`UPDATE piece_usages SET title_snapshot = ?, intro_snapshot = ?, research_snapshot = ?,
|
||||||
moderation_snapshot = ?, transition_snapshot = ?, presentation_snapshot = ?,
|
moderation_snapshot = ?, transition_snapshot = ?, presentation_snapshot = ?,
|
||||||
own_notes = ?, duration_seconds = ?, status = ? WHERE id = ?`
|
presentation_mode_snapshot = ?, presentation_source_label_snapshot = ?,
|
||||||
|
presentation_source_url_snapshot = ?, presentation_source_timecode_snapshot = ?,
|
||||||
|
presentation_title_meta_snapshot = ?, presentation_description_snapshot = ?,
|
||||||
|
presentation_image_url_snapshot = ?, presentation_site_name_snapshot = ?,
|
||||||
|
presentation_provider_snapshot = ?, presentation_provider_id_snapshot = ?,
|
||||||
|
own_notes = ?, duration_seconds = ? WHERE id = ?`
|
||||||
)
|
)
|
||||||
.run(
|
.run(
|
||||||
title,
|
title,
|
||||||
@@ -716,9 +1090,18 @@ export function updatePieceUsage(
|
|||||||
values.moderation,
|
values.moderation,
|
||||||
values.transition,
|
values.transition,
|
||||||
values.presentation,
|
values.presentation,
|
||||||
|
presentation.mode,
|
||||||
|
presentation.sourceLabel,
|
||||||
|
presentation.sourceUrl,
|
||||||
|
presentation.timecodeSeconds,
|
||||||
|
presentation.title,
|
||||||
|
presentation.description,
|
||||||
|
presentation.imageUrl,
|
||||||
|
presentation.siteName,
|
||||||
|
presentation.provider,
|
||||||
|
presentation.providerId,
|
||||||
values.ownNotes,
|
values.ownNotes,
|
||||||
duration,
|
duration,
|
||||||
input.status,
|
|
||||||
usageId
|
usageId
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
import type { LayoutServerLoad } from './$types';
|
import type { LayoutServerLoad } from './$types';
|
||||||
|
|
||||||
export const load: LayoutServerLoad = ({ locals }) => ({ user: locals.user });
|
export const load: LayoutServerLoad = ({ locals, url }) => ({
|
||||||
|
user: url.pathname.startsWith('/heinzlive/') ? null : locals.user,
|
||||||
|
presentationMode: url.pathname.startsWith('/heinzlive/')
|
||||||
|
});
|
||||||
@@ -31,7 +31,9 @@
|
|||||||
/>
|
/>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#if data.user}
|
{#if data.presentationMode}
|
||||||
|
{@render children()}
|
||||||
|
{:else if data.user}
|
||||||
<div class="app-shell">
|
<div class="app-shell">
|
||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<a class="brand" href={resolve('/fundus')} aria-label="Sendewerk Startseite">
|
<a class="brand" href={resolve('/fundus')} aria-label="Sendewerk Startseite">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { fail, redirect } from '@sveltejs/kit';
|
import { fail } from '@sveltejs/kit';
|
||||||
import type { Actions, PageServerLoad } from './$types';
|
import type { Actions, PageServerLoad } from './$types';
|
||||||
import { requireUser } from '#lib/server/auth.js';
|
import { requireUser } from '#lib/server/auth.js';
|
||||||
import { captureInbox, listPieces } from '#lib/server/content.js';
|
import { captureInbox, listPieces } from '#lib/server/content.js';
|
||||||
@@ -14,7 +14,7 @@ export const actions = {
|
|||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
try {
|
try {
|
||||||
const id = captureInbox(String(data.get('title') || ''), String(data.get('url') || ''));
|
const id = captureInbox(String(data.get('title') || ''), String(data.get('url') || ''));
|
||||||
redirect(303, `/fundus/${id}`);
|
return { captured: true, capturedId: id };
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
const code = cause instanceof Error ? cause.message : '';
|
const code = cause instanceof Error ? cause.message : '';
|
||||||
return fail(400, {
|
return fail(400, {
|
||||||
|
|||||||
@@ -17,11 +17,14 @@
|
|||||||
<h2>Was soll nicht verloren gehen?</h2>
|
<h2>Was soll nicht verloren gehen?</h2>
|
||||||
</div>
|
</div>
|
||||||
{#if form?.error}<div class="form-message error" role="alert">{form.error}</div>{/if}
|
{#if form?.error}<div class="form-message error" role="alert">{form.error}</div>{/if}
|
||||||
|
{#if form?.captured}<div class="form-message success" role="status">
|
||||||
|
Im Eingang gespeichert.
|
||||||
|
<a href={resolve('/fundus/[id]', { id: form.capturedId })}>Jetzt ausarbeiten</a>
|
||||||
|
</div>{/if}
|
||||||
<form method="POST" action="?/capture" class="capture-form">
|
<form method="POST" action="?/capture" class="capture-form">
|
||||||
<label
|
<label
|
||||||
>Titel oder Gedanke<input
|
>Gedanke <span>optional bei URL</span><input
|
||||||
name="title"
|
name="title"
|
||||||
required
|
|
||||||
maxlength="200"
|
maxlength="200"
|
||||||
value={form?.title ?? ''}
|
value={form?.title ?? ''}
|
||||||
placeholder="Kurze Idee festhalten"
|
placeholder="Kurze Idee festhalten"
|
||||||
@@ -36,7 +39,7 @@
|
|||||||
placeholder="https://…"
|
placeholder="https://…"
|
||||||
/></label
|
/></label
|
||||||
>
|
>
|
||||||
<button class="primary-button" type="submit">Aufnehmen und öffnen</button>
|
<button class="primary-button" type="submit">Im Eingang ablegen</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
{#if data.pieces.length}
|
{#if data.pieces.length}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
setPieceArchived,
|
setPieceArchived,
|
||||||
type PieceTemplateId
|
type PieceTemplateId
|
||||||
} from '#lib/server/content.js';
|
} from '#lib/server/content.js';
|
||||||
|
import { getPieceUsageContexts } from '#lib/server/shows.js';
|
||||||
|
|
||||||
export const load: PageServerLoad = ({ locals, url }) => {
|
export const load: PageServerLoad = ({ locals, url }) => {
|
||||||
requireUser(locals.user);
|
requireUser(locals.user);
|
||||||
@@ -18,21 +19,25 @@ export const load: PageServerLoad = ({ locals, url }) => {
|
|||||||
formatId: url.searchParams.get('format') ?? '',
|
formatId: url.searchParams.get('format') ?? '',
|
||||||
topicId: url.searchParams.get('topic') ?? '',
|
topicId: url.searchParams.get('topic') ?? '',
|
||||||
categoryId: url.searchParams.get('category') ?? '',
|
categoryId: url.searchParams.get('category') ?? '',
|
||||||
status: url.searchParams.get('status') ?? ''
|
status: url.searchParams.get('status') ?? '',
|
||||||
|
includeUsed: url.searchParams.get('includeUsed') === '1',
|
||||||
|
includePlanned: url.searchParams.get('includePlanned') === '1'
|
||||||
};
|
};
|
||||||
|
const pieces = listPieces({
|
||||||
|
statuses:
|
||||||
|
filters.status === 'ready'
|
||||||
|
? ['ready']
|
||||||
|
: filters.status === 'preparing'
|
||||||
|
? ['preparing']
|
||||||
|
: ['preparing', 'ready'],
|
||||||
|
query: filters.query,
|
||||||
|
formatId: filters.formatId,
|
||||||
|
topicId: filters.topicId,
|
||||||
|
categoryId: filters.categoryId
|
||||||
|
});
|
||||||
|
const usageContexts = getPieceUsageContexts(pieces.map((piece) => piece.id));
|
||||||
return {
|
return {
|
||||||
pieces: listPieces({
|
pieces: pieces.map((piece) => ({ ...piece, ...usageContexts[piece.id] })),
|
||||||
statuses:
|
|
||||||
filters.status === 'ready'
|
|
||||||
? ['ready']
|
|
||||||
: filters.status === 'preparing'
|
|
||||||
? ['preparing']
|
|
||||||
: ['preparing', 'ready'],
|
|
||||||
query: filters.query,
|
|
||||||
formatId: filters.formatId,
|
|
||||||
topicId: filters.topicId,
|
|
||||||
categoryId: filters.categoryId
|
|
||||||
}),
|
|
||||||
taxonomy: getTaxonomy(),
|
taxonomy: getTaxonomy(),
|
||||||
templates: pieceTemplates,
|
templates: pieceTemplates,
|
||||||
filters
|
filters
|
||||||
|
|||||||
@@ -1,9 +1,48 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto, replaceState } from '$app/navigation';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
|
import { page } from '$app/state';
|
||||||
|
import { onMount, untrack } from 'svelte';
|
||||||
|
import PieceUsageHistory from '#lib/components/PieceUsageHistory.svelte';
|
||||||
import { formatClock } from '#lib/format.js';
|
import { formatClock } from '#lib/format.js';
|
||||||
import type { PageProps } from './$types';
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
let { data, form }: PageProps = $props();
|
let { data, form }: PageProps = $props();
|
||||||
|
let showUsedPieces = $state(untrack(() => data.filters.includeUsed));
|
||||||
|
let showPlannedPieces = $state(untrack(() => data.filters.includePlanned));
|
||||||
|
let visiblePieces = $derived(
|
||||||
|
data.pieces.filter(
|
||||||
|
(piece) =>
|
||||||
|
(showUsedPieces || piece.sentHistory.length === 0) &&
|
||||||
|
(showPlannedPieces || !piece.isPlannedInActiveShow)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
onMount(() => {
|
||||||
|
const syncFiltersFromHistory = () => {
|
||||||
|
const search = new URL(window.location.href).searchParams;
|
||||||
|
showUsedPieces = search.get('includeUsed') === '1';
|
||||||
|
showPlannedPieces = search.get('includePlanned') === '1';
|
||||||
|
};
|
||||||
|
window.addEventListener('popstate', syncFiltersFromHistory);
|
||||||
|
return () => window.removeEventListener('popstate', syncFiltersFromHistory);
|
||||||
|
});
|
||||||
|
|
||||||
|
function setSourceFilter(name: 'includeUsed' | 'includePlanned', checked: boolean) {
|
||||||
|
if (name === 'includeUsed') showUsedPieces = checked;
|
||||||
|
else showPlannedPieces = checked;
|
||||||
|
const url = new URL(page.url.href);
|
||||||
|
if (checked) url.searchParams.set(name, '1');
|
||||||
|
else url.searchParams.delete(name);
|
||||||
|
// This URL is cloned from the current page; only same-route filter parameters change.
|
||||||
|
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
||||||
|
replaceState(url, page.state);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resetFilters() {
|
||||||
|
await goto(resolve('/fundus'), { invalidateAll: true });
|
||||||
|
showUsedPieces = false;
|
||||||
|
showPlannedPieces = false;
|
||||||
|
}
|
||||||
const statusLabel = {
|
const statusLabel = {
|
||||||
ready: 'Sendefertig',
|
ready: 'Sendefertig',
|
||||||
preparing: 'In Vorbereitung',
|
preparing: 'In Vorbereitung',
|
||||||
@@ -20,8 +59,8 @@
|
|||||||
<h1>Fundus</h1>
|
<h1>Fundus</h1>
|
||||||
<p class="page-intro">Vorbereitete Inhalte für kommende Sendungen.</p>
|
<p class="page-intro">Vorbereitete Inhalte für kommende Sendungen.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="heading-stat" aria-label={`${data.pieces.length} gefundene Inhalte`}>
|
<div class="heading-stat" aria-label={`${visiblePieces.length} gefundene Inhalte`}>
|
||||||
<strong>{data.pieces.length}</strong><span>Inhalte</span>
|
<strong>{visiblePieces.length}</strong><span>Inhalte</span>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
{#if form?.error}<div class="form-message error" role="alert">{form.error}</div>{/if}
|
{#if form?.error}<div class="form-message error" role="alert">{form.error}</div>{/if}
|
||||||
@@ -41,7 +80,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<form class="library-filters" method="GET" aria-label="Fundus durchsuchen und filtern">
|
<form
|
||||||
|
id="library-filters"
|
||||||
|
class="library-filters"
|
||||||
|
method="GET"
|
||||||
|
aria-label="Fundus durchsuchen und filtern"
|
||||||
|
>
|
||||||
<label class="search-field"
|
<label class="search-field"
|
||||||
><span aria-hidden="true">⌕</span><span class="sr-only">Fundus durchsuchen</span><input
|
><span aria-hidden="true">⌕</span><span class="sr-only">Fundus durchsuchen</span><input
|
||||||
name="q"
|
name="q"
|
||||||
@@ -84,12 +128,36 @@
|
|||||||
></label
|
></label
|
||||||
>
|
>
|
||||||
<button class="secondary-button" type="submit">Anwenden</button>
|
<button class="secondary-button" type="submit">Anwenden</button>
|
||||||
<a class="text-link" href={resolve('/fundus')}>Zurücksetzen</a>
|
<button class="text-button" type="button" onclick={resetFilters}>Zurücksetzen</button>
|
||||||
</form>
|
</form>
|
||||||
|
<div class="library-filter-options" aria-label="Fundusauswahl erweitern">
|
||||||
|
<label class="filter-checkbox">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="includeUsed"
|
||||||
|
value="1"
|
||||||
|
form="library-filters"
|
||||||
|
checked={showUsedPieces}
|
||||||
|
onchange={(event) => setSourceFilter('includeUsed', event.currentTarget.checked)}
|
||||||
|
/>
|
||||||
|
<span>Auch verwendete Inhalte zeigen</span>
|
||||||
|
</label>
|
||||||
|
<label class="filter-checkbox">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="includePlanned"
|
||||||
|
value="1"
|
||||||
|
form="library-filters"
|
||||||
|
checked={showPlannedPieces}
|
||||||
|
onchange={(event) => setSourceFilter('includePlanned', event.currentTarget.checked)}
|
||||||
|
/>
|
||||||
|
<span>Auch eingeplante Inhalte zeigen</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if data.pieces.length}
|
{#if visiblePieces.length}
|
||||||
<div class="piece-grid">
|
<div class="piece-grid">
|
||||||
{#each data.pieces as piece (piece.id)}
|
{#each visiblePieces as piece (piece.id)}
|
||||||
<article
|
<article
|
||||||
class="piece-card"
|
class="piece-card"
|
||||||
style={`--category: ${piece.categories[0]?.color ?? '#8b8f98'}`}
|
style={`--category: ${piece.categories[0]?.color ?? '#8b8f98'}`}
|
||||||
@@ -104,6 +172,7 @@
|
|||||||
<div class="piece-primary">
|
<div class="piece-primary">
|
||||||
<h2><a href={resolve('/fundus/[id]', { id: piece.id })}>{piece.title}</a></h2>
|
<h2><a href={resolve('/fundus/[id]', { id: piece.id })}>{piece.title}</a></h2>
|
||||||
<p>{piece.summary || 'Noch keine Kurzbeschreibung.'}</p>
|
<p>{piece.summary || 'Noch keine Kurzbeschreibung.'}</p>
|
||||||
|
<PieceUsageHistory history={piece.sentHistory} />
|
||||||
</div>
|
</div>
|
||||||
<div class="piece-classification">
|
<div class="piece-classification">
|
||||||
<span class="category-label"
|
<span class="category-label"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
duplicatePiece,
|
duplicatePiece,
|
||||||
getPiece,
|
getPiece,
|
||||||
getTaxonomy,
|
getTaxonomy,
|
||||||
|
loadPiecePresentationMetadata,
|
||||||
savePiece,
|
savePiece,
|
||||||
setPieceArchived,
|
setPieceArchived,
|
||||||
uploadPieceImage,
|
uploadPieceImage,
|
||||||
@@ -65,6 +66,20 @@ function pieceInput(data: FormData): PieceInput {
|
|||||||
moderationNotes: text(data, 'moderationNotes'),
|
moderationNotes: text(data, 'moderationNotes'),
|
||||||
transitionText: text(data, 'transitionText'),
|
transitionText: text(data, 'transitionText'),
|
||||||
presentationText: text(data, 'presentationText'),
|
presentationText: text(data, 'presentationText'),
|
||||||
|
presentationMode: text(data, 'presentationMode') as PieceInput['presentationMode'],
|
||||||
|
presentationSourcePosition: text(data, 'presentationSourcePosition')
|
||||||
|
? Number(data.get('presentationSourcePosition'))
|
||||||
|
: null,
|
||||||
|
presentationTitle: text(data, 'presentationTitle'),
|
||||||
|
presentationDescription: text(data, 'presentationDescription'),
|
||||||
|
presentationImageUrl: text(data, 'presentationImageUrl'),
|
||||||
|
presentationSiteName: text(data, 'presentationSiteName'),
|
||||||
|
presentationProvider: text(data, 'presentationProvider'),
|
||||||
|
presentationProviderId: text(data, 'presentationProviderId'),
|
||||||
|
presentationTitleManual: text(data, 'presentationTitleManual') === '1',
|
||||||
|
presentationDescriptionManual: text(data, 'presentationDescriptionManual') === '1',
|
||||||
|
presentationImageManual: text(data, 'presentationImageManual') === '1',
|
||||||
|
presentationMetadataFetchedAtUtc: text(data, 'presentationMetadataFetchedAtUtc') || null,
|
||||||
topicIds: data.getAll('topicIds').map(String),
|
topicIds: data.getAll('topicIds').map(String),
|
||||||
categoryIds: data.getAll('categoryIds').map(String),
|
categoryIds: data.getAll('categoryIds').map(String),
|
||||||
sources
|
sources
|
||||||
@@ -87,6 +102,11 @@ function saveError(cause: unknown) {
|
|||||||
status: 400,
|
status: 400,
|
||||||
error: 'Quellen benötigen einen Namen und eine vollständige HTTP- oder HTTPS-Adresse.'
|
error: 'Quellen benötigen einen Namen und eine vollständige HTTP- oder HTTPS-Adresse.'
|
||||||
};
|
};
|
||||||
|
if (code === 'INVALID_PRESENTATION')
|
||||||
|
return {
|
||||||
|
status: 400,
|
||||||
|
error: 'Für Linkvorschau und Video muss eine vorhandene gültige Quelle ausgewählt sein.'
|
||||||
|
};
|
||||||
if (code.startsWith('INVALID_'))
|
if (code.startsWith('INVALID_'))
|
||||||
return { status: 400, error: 'Mindestens ein Feld ist ungültig oder zu lang.' };
|
return { status: 400, error: 'Mindestens ein Feld ist ungültig oder zu lang.' };
|
||||||
return {
|
return {
|
||||||
@@ -116,6 +136,31 @@ export const actions = {
|
|||||||
return fail(problem.status, { intent: 'save', ...problem });
|
return fail(problem.status, { intent: 'save', ...problem });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
loadPreview: async ({ locals, params, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
try {
|
||||||
|
await loadPiecePresentationMetadata(params.id, Number(data.get('revision')));
|
||||||
|
} catch (cause) {
|
||||||
|
const code = cause instanceof Error ? cause.message : '';
|
||||||
|
if (code === 'FETCH_BLOCKED') {
|
||||||
|
return fail(400, {
|
||||||
|
intent: 'loadPreview',
|
||||||
|
error: 'Interne oder private Netzwerkziele dürfen nicht abgerufen werden.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (code.startsWith('FETCH_')) {
|
||||||
|
return fail(400, {
|
||||||
|
intent: 'loadPreview',
|
||||||
|
error:
|
||||||
|
'Die Vorschau konnte nicht sicher geladen werden. Die manuellen Angaben bleiben erhalten.'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const problem = saveError(cause);
|
||||||
|
return fail(problem.status, { intent: 'loadPreview', ...problem });
|
||||||
|
}
|
||||||
|
redirect(303, `/fundus/${params.id}`);
|
||||||
|
},
|
||||||
upload: async ({ locals, params, request }) => {
|
upload: async ({ locals, params, request }) => {
|
||||||
requireUser(locals.user);
|
requireUser(locals.user);
|
||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
|
|||||||
+494
-243
@@ -2,8 +2,11 @@
|
|||||||
import { enhance, type SubmitFunction } from '$app/forms';
|
import { enhance, type SubmitFunction } from '$app/forms';
|
||||||
import { beforeNavigate, goto } from '$app/navigation';
|
import { beforeNavigate, goto } from '$app/navigation';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import { onDestroy, untrack } from 'svelte';
|
import { onDestroy, onMount, untrack } from 'svelte';
|
||||||
import MarkdownPreview from '#lib/components/MarkdownPreview.svelte';
|
import MarkdownEditorField from '#lib/components/MarkdownEditorField.svelte';
|
||||||
|
import PieceEditorDialog from '#lib/components/PieceEditorDialog.svelte';
|
||||||
|
import PresentationDisplay from '#lib/components/PresentationDisplay.svelte';
|
||||||
|
import type { PresentationContent } from '#lib/server/presentation.js';
|
||||||
import type { PageProps } from './$types';
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
let { data, form }: PageProps = $props();
|
let { data, form }: PageProps = $props();
|
||||||
@@ -12,9 +15,13 @@
|
|||||||
let revision = $state(untrack(() => data.piece.revision));
|
let revision = $state(untrack(() => data.piece.revision));
|
||||||
let sources = $state(untrack(() => data.piece.sources.map((source) => ({ ...source }))));
|
let sources = $state(untrack(() => data.piece.sources.map((source) => ({ ...source }))));
|
||||||
let rendered = $state(untrack(() => ({ ...data.rendered })));
|
let rendered = $state(untrack(() => ({ ...data.rendered })));
|
||||||
|
let activeSection = $state<'script' | 'research' | 'presentation'>('script');
|
||||||
let saveState = $state<'idle' | 'dirty' | 'saving' | 'saved' | 'error' | 'conflict'>('idle');
|
let saveState = $state<'idle' | 'dirty' | 'saving' | 'saved' | 'error' | 'conflict'>('idle');
|
||||||
let saveMessage = $state('Alle Änderungen gespeichert');
|
let saveMessage = $state('Alle Änderungen gespeichert');
|
||||||
|
let sourceImageUnavailable = $state(false);
|
||||||
|
let editorDialog: { showModal: () => void; close: () => void };
|
||||||
let editorForm: HTMLFormElement;
|
let editorForm: HTMLFormElement;
|
||||||
|
let previewForm: HTMLFormElement;
|
||||||
let saveButton: HTMLButtonElement;
|
let saveButton: HTMLButtonElement;
|
||||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||||
let generation = 0;
|
let generation = 0;
|
||||||
@@ -25,9 +32,50 @@
|
|||||||
saveState === 'error' ||
|
saveState === 'error' ||
|
||||||
saveState === 'conflict'
|
saveState === 'conflict'
|
||||||
);
|
);
|
||||||
|
let featuredSource = $derived(
|
||||||
|
draft.presentationSourcePosition === null
|
||||||
|
? (sources[0] ?? null)
|
||||||
|
: (sources[draft.presentationSourcePosition] ?? sources[0] ?? null)
|
||||||
|
);
|
||||||
|
let sourcePreviewImage = $derived(
|
||||||
|
draft.presentationImageUrl
|
||||||
|
? resolve('/fundus/[id]/praesentation/preview-image', { id: data.piece.id })
|
||||||
|
: ''
|
||||||
|
);
|
||||||
|
let previewContent = $derived<PresentationContent>({
|
||||||
|
mode: draft.presentationMode,
|
||||||
|
title: draft.title,
|
||||||
|
html: rendered.presentation,
|
||||||
|
source: featuredSource
|
||||||
|
? {
|
||||||
|
label: featuredSource.label || featuredSource.url,
|
||||||
|
url: featuredSource.url,
|
||||||
|
timecodeSeconds: featuredSource.timecodeSeconds
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
previewTitle: draft.presentationTitle,
|
||||||
|
description: draft.presentationDescription,
|
||||||
|
imageUrl: draft.presentationImageUrl,
|
||||||
|
siteName: draft.presentationSiteName,
|
||||||
|
provider: draft.presentationProvider as PresentationContent['provider'],
|
||||||
|
providerId: draft.presentationProviderId,
|
||||||
|
embedUrl:
|
||||||
|
draft.presentationProvider === 'youtube' && draft.presentationProviderId
|
||||||
|
? `https://www.youtube-nocookie.com/embed/${draft.presentationProviderId}${featuredSource?.timecodeSeconds ? `?start=${featuredSource.timecodeSeconds}` : ''}`
|
||||||
|
: draft.presentationProvider === 'tiktok' && draft.presentationProviderId
|
||||||
|
? `https://www.tiktok.com/player/v1/${draft.presentationProviderId}`
|
||||||
|
: ''
|
||||||
|
});
|
||||||
let pendingHref: string | null = null;
|
let pendingHref: string | null = null;
|
||||||
let allowNavigation = false;
|
let allowNavigation = false;
|
||||||
|
|
||||||
|
const statusLabels = {
|
||||||
|
inbox: 'Eingang',
|
||||||
|
preparing: 'In Vorbereitung',
|
||||||
|
ready: 'Sendefertig'
|
||||||
|
};
|
||||||
|
|
||||||
|
onMount(() => editorDialog.showModal());
|
||||||
onDestroy(() => clearTimeout(timer));
|
onDestroy(() => clearTimeout(timer));
|
||||||
beforeNavigate((navigation) => {
|
beforeNavigate((navigation) => {
|
||||||
if (allowNavigation) return;
|
if (allowNavigation) return;
|
||||||
@@ -42,7 +90,17 @@
|
|||||||
if (!saving) submitSave();
|
if (!saving) submitSave();
|
||||||
});
|
});
|
||||||
|
|
||||||
function scheduleSave() {
|
function scheduleSave(event?: Event) {
|
||||||
|
const control = event?.target;
|
||||||
|
if (event?.type === 'change' && !(control instanceof HTMLSelectElement)) return;
|
||||||
|
if (
|
||||||
|
control instanceof HTMLInputElement &&
|
||||||
|
control.name === 'presentationMode' &&
|
||||||
|
control.value !== 'text' &&
|
||||||
|
draft.presentationSourcePosition === null
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
generation += 1;
|
generation += 1;
|
||||||
saveState = 'dirty';
|
saveState = 'dirty';
|
||||||
saveMessage = 'Ungespeicherte Änderungen';
|
saveMessage = 'Ungespeicherte Änderungen';
|
||||||
@@ -55,6 +113,23 @@
|
|||||||
editorForm.requestSubmit(saveButton);
|
editorForm.requestSubmit(saveButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function requestClose() {
|
||||||
|
const target = resolve('/fundus');
|
||||||
|
if (saveState === 'error' || saveState === 'conflict') {
|
||||||
|
if (!confirm('Ungespeicherte Änderungen verwerfen und Editor schließen?')) return;
|
||||||
|
allowNavigation = true;
|
||||||
|
void goto(target);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (saveState === 'dirty' || saveState === 'saving') {
|
||||||
|
pendingHref = new URL(target, window.location.href).href;
|
||||||
|
if (!saving) submitSave();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
allowNavigation = true;
|
||||||
|
void goto(target);
|
||||||
|
}
|
||||||
|
|
||||||
function addSource() {
|
function addSource() {
|
||||||
sources.push({ label: '', url: '', timecodeSeconds: null });
|
sources.push({ label: '', url: '', timecodeSeconds: null });
|
||||||
scheduleSave();
|
scheduleSave();
|
||||||
@@ -62,9 +137,26 @@
|
|||||||
|
|
||||||
function removeSource(index: number) {
|
function removeSource(index: number) {
|
||||||
sources.splice(index, 1);
|
sources.splice(index, 1);
|
||||||
|
if (draft.presentationSourcePosition === index) draft.presentationSourcePosition = null;
|
||||||
|
else if (
|
||||||
|
draft.presentationSourcePosition !== null &&
|
||||||
|
draft.presentationSourcePosition > index
|
||||||
|
) {
|
||||||
|
draft.presentationSourcePosition -= 1;
|
||||||
|
}
|
||||||
scheduleSave();
|
scheduleSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function presentationSourceChanged() {
|
||||||
|
draft.presentationMetadataFetchedAtUtc = null;
|
||||||
|
draft.presentationProvider = '';
|
||||||
|
draft.presentationProviderId = '';
|
||||||
|
sourceImageUnavailable = false;
|
||||||
|
if (!draft.presentationTitleManual) draft.presentationTitle = '';
|
||||||
|
if (!draft.presentationDescriptionManual) draft.presentationDescription = '';
|
||||||
|
if (!draft.presentationImageManual) draft.presentationImageUrl = '';
|
||||||
|
}
|
||||||
|
|
||||||
const enhanceSave: SubmitFunction = () => {
|
const enhanceSave: SubmitFunction = () => {
|
||||||
const submittedGeneration = generation;
|
const submittedGeneration = generation;
|
||||||
saving = true;
|
saving = true;
|
||||||
@@ -106,259 +198,418 @@
|
|||||||
|
|
||||||
<svelte:head><title>{draft.title} | Fundus | Sendewerk</title></svelte:head>
|
<svelte:head><title>{draft.title} | Fundus | Sendewerk</title></svelte:head>
|
||||||
|
|
||||||
<div class="page-wrap editor-page">
|
<div class="piece-editor-route">
|
||||||
<header class="editor-header">
|
{#if form?.error}<div class="form-message error route-editor-error" role="alert">
|
||||||
<div>
|
{form.error}
|
||||||
<a class="back-link" href={resolve('/fundus')}>← Fundus</a>
|
</div>{/if}
|
||||||
<h1>{draft.title}</h1>
|
<PieceEditorDialog
|
||||||
</div>
|
bind:this={editorDialog}
|
||||||
<div
|
bind:activeSection
|
||||||
class:problem={saveState === 'error' || saveState === 'conflict'}
|
labelledby="piece-editor-title"
|
||||||
class="save-indicator"
|
onrequestclose={requestClose}
|
||||||
role="status"
|
|
||||||
aria-live="polite"
|
|
||||||
>
|
|
||||||
<i></i><span>{saveMessage}</span>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
{#if form?.error}<div class="form-message error" role="alert">{form.error}</div>{/if}
|
|
||||||
|
|
||||||
<form
|
|
||||||
bind:this={editorForm}
|
|
||||||
use:enhance={enhanceSave}
|
|
||||||
method="POST"
|
|
||||||
action="?/save"
|
|
||||||
class="piece-editor"
|
|
||||||
oninput={scheduleSave}
|
|
||||||
onchange={scheduleSave}
|
|
||||||
>
|
>
|
||||||
<input type="hidden" name="revision" value={revision} />
|
{#snippet header()}
|
||||||
<section class="editor-section editor-basics">
|
<p class="eyebrow">Fundusfassung</p>
|
||||||
<div class="section-title">
|
<label class="piece-dialog-title">
|
||||||
<p class="eyebrow">Grundlagen</p>
|
<span class="sr-only">Titel</span>
|
||||||
<h2>Worum geht es?</h2>
|
<textarea
|
||||||
</div>
|
form="piece-editor-form"
|
||||||
<div class="editor-fields two-columns">
|
name="title"
|
||||||
<label class="wide-field"
|
required
|
||||||
>Titel<input name="title" required maxlength="200" bind:value={draft.title} /></label
|
rows="1"
|
||||||
>
|
maxlength="200"
|
||||||
<label
|
aria-label="Titel"
|
||||||
>Status<select name="status" bind:value={draft.status}
|
bind:value={draft.title}
|
||||||
><option value="inbox">Eingang</option><option value="preparing">In Vorbereitung</option
|
oninput={scheduleSave}></textarea>
|
||||||
><option value="ready">Sendefertig</option></select
|
</label>
|
||||||
></label
|
<h1 class="sr-only" id="piece-editor-title">{draft.title}</h1>
|
||||||
>
|
{/snippet}
|
||||||
<label
|
|
||||||
>Format<select name="formatId" bind:value={draft.formatId}
|
|
||||||
><option value={null}>Ohne Format</option
|
|
||||||
>{#each data.taxonomy.formats as item (item.id)}<option value={item.id}
|
|
||||||
>{item.name}</option
|
|
||||||
>{/each}</select
|
|
||||||
></label
|
|
||||||
>
|
|
||||||
<label
|
|
||||||
>Dauer in Minuten<input
|
|
||||||
name="durationMinutes"
|
|
||||||
type="number"
|
|
||||||
min="0"
|
|
||||||
max="1440"
|
|
||||||
step="any"
|
|
||||||
bind:value={durationMinutes}
|
|
||||||
/></label
|
|
||||||
>
|
|
||||||
<label class="wide-field"
|
|
||||||
>Kurzbeschreibung<textarea
|
|
||||||
name="summary"
|
|
||||||
rows="2"
|
|
||||||
maxlength="2000"
|
|
||||||
bind:value={draft.summary}></textarea></label
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="editor-section taxonomy-editor">
|
<form
|
||||||
<div class="section-title">
|
bind:this={editorForm}
|
||||||
<p class="eyebrow">Einordnung</p>
|
id="piece-editor-form"
|
||||||
<h2>Themen und Abschnitte</h2>
|
use:enhance={enhanceSave}
|
||||||
</div>
|
method="POST"
|
||||||
<fieldset>
|
action="?/save"
|
||||||
<legend>Themen</legend>
|
class="piece-dialog-form"
|
||||||
<div class="choice-grid">
|
oninput={scheduleSave}
|
||||||
{#each data.taxonomy.topics as item (item.id)}<label
|
onchange={scheduleSave}
|
||||||
><input
|
>
|
||||||
type="checkbox"
|
<input type="hidden" name="revision" value={revision} />
|
||||||
name="topicIds"
|
|
||||||
value={item.id}
|
|
||||||
bind:group={draft.topicIds}
|
|
||||||
/>{item.name}</label
|
|
||||||
>{/each}
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<legend>Vorgeschlagene Abschnittskategorien</legend>
|
|
||||||
<div class="choice-grid">
|
|
||||||
{#each data.taxonomy.categories as item (item.id)}<label
|
|
||||||
><input
|
|
||||||
type="checkbox"
|
|
||||||
name="categoryIds"
|
|
||||||
value={item.id}
|
|
||||||
bind:group={draft.categoryIds}
|
|
||||||
/><i style={`--choice-color:${item.color}`}></i>{item.name}</label
|
|
||||||
>{/each}
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="editor-section markdown-section">
|
<section class="piece-editor-panel" hidden={activeSection !== 'script'}>
|
||||||
<div class="section-title">
|
<div class="piece-panel-heading">
|
||||||
<p class="eyebrow">Redaktion</p>
|
<div>
|
||||||
<h2>Getrennte Arbeitsbereiche</h2>
|
<p class="eyebrow">Für die Moderation</p>
|
||||||
<small>Markdown wird unterstützt und vor der Anzeige bereinigt.</small>
|
<h2>Sendungstext</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="markdown-grid">
|
</div>
|
||||||
<label
|
<div class="piece-writing-stack">
|
||||||
><span>Einleitung</span><textarea
|
<MarkdownEditorField
|
||||||
name="intro"
|
name="intro"
|
||||||
rows="7"
|
label="Einleitung"
|
||||||
maxlength="50000"
|
placeholder="Wie beginnt dieses Thema in der Sendung?"
|
||||||
bind:value={draft.intro}></textarea>
|
bind:value={draft.intro}
|
||||||
<MarkdownPreview html={rendered.intro} /></label
|
/>
|
||||||
>
|
<MarkdownEditorField
|
||||||
<label class="private-field"
|
|
||||||
><span>Private Recherche</span><textarea
|
|
||||||
name="researchText"
|
|
||||||
rows="7"
|
|
||||||
maxlength="50000"
|
|
||||||
bind:value={draft.researchText}></textarea>
|
|
||||||
<MarkdownPreview html={rendered.research} /></label
|
|
||||||
>
|
|
||||||
<label
|
|
||||||
><span>Moderationsstichpunkte</span><textarea
|
|
||||||
name="moderationNotes"
|
name="moderationNotes"
|
||||||
rows="7"
|
label="Moderationsstichpunkte"
|
||||||
maxlength="50000"
|
placeholder="Argumente, Fragen und Ablaufpunkte"
|
||||||
bind:value={draft.moderationNotes}></textarea>
|
rows={10}
|
||||||
<MarkdownPreview html={rendered.moderation} /></label
|
bind:value={draft.moderationNotes}
|
||||||
>
|
/>
|
||||||
<label
|
<MarkdownEditorField
|
||||||
><span>Überleitung</span><textarea
|
|
||||||
name="transitionText"
|
name="transitionText"
|
||||||
rows="7"
|
label="Überleitung"
|
||||||
maxlength="50000"
|
placeholder="Wie geht es zum nächsten Thema weiter?"
|
||||||
bind:value={draft.transitionText}></textarea>
|
bind:value={draft.transitionText}
|
||||||
<MarkdownPreview html={rendered.transition} /></label
|
/>
|
||||||
>
|
|
||||||
<label class="wide-field"
|
|
||||||
><span>Präsentationstext</span><textarea
|
|
||||||
name="presentationText"
|
|
||||||
rows="7"
|
|
||||||
maxlength="50000"
|
|
||||||
bind:value={draft.presentationText}></textarea>
|
|
||||||
<MarkdownPreview html={rendered.presentation} /></label
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="editor-section source-editor">
|
|
||||||
<div class="section-title split-section-title">
|
|
||||||
<div>
|
|
||||||
<p class="eyebrow">Belege</p>
|
|
||||||
<h2>Quellen</h2>
|
|
||||||
</div>
|
</div>
|
||||||
<button class="secondary-button" type="button" onclick={addSource}>Quelle hinzufügen</button
|
<details class="piece-meta-details">
|
||||||
>
|
<summary>
|
||||||
</div>
|
<span>Status, Dauer und Einordnung</span>
|
||||||
{#if sources.length}<div class="source-list">
|
<small
|
||||||
{#each sources as source, index (index)}<div class="source-row">
|
>{statusLabels[draft.status as keyof typeof statusLabels]} · {durationMinutes || 0} Min.</small
|
||||||
|
>
|
||||||
|
</summary>
|
||||||
|
<div class="piece-meta-grid">
|
||||||
|
<label
|
||||||
|
>Status<select name="status" bind:value={draft.status}
|
||||||
|
><option value="inbox">Eingang</option><option value="preparing"
|
||||||
|
>In Vorbereitung</option
|
||||||
|
><option value="ready">Sendefertig</option></select
|
||||||
|
></label
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
>Dauer in Minuten<input
|
||||||
|
name="durationMinutes"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
max="1440"
|
||||||
|
step="any"
|
||||||
|
bind:value={durationMinutes}
|
||||||
|
/></label
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
>Format<select name="formatId" bind:value={draft.formatId}
|
||||||
|
><option value={null}>Ohne Format</option
|
||||||
|
>{#each data.taxonomy.formats as item (item.id)}<option value={item.id}
|
||||||
|
>{item.name}</option
|
||||||
|
>{/each}</select
|
||||||
|
></label
|
||||||
|
>
|
||||||
|
<label class="wide-field"
|
||||||
|
>Kurzbeschreibung<textarea
|
||||||
|
name="summary"
|
||||||
|
rows="3"
|
||||||
|
maxlength="2000"
|
||||||
|
placeholder="Worum geht es in wenigen Sätzen?"
|
||||||
|
bind:value={draft.summary}></textarea></label
|
||||||
|
>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Themen</legend>
|
||||||
|
<div class="choice-grid">
|
||||||
|
{#each data.taxonomy.topics as item (item.id)}<label
|
||||||
|
><input
|
||||||
|
type="checkbox"
|
||||||
|
name="topicIds"
|
||||||
|
value={item.id}
|
||||||
|
bind:group={draft.topicIds}
|
||||||
|
/>{item.name}</label
|
||||||
|
>{/each}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Vorgeschlagene Abschnittskategorien</legend>
|
||||||
|
<div class="choice-grid">
|
||||||
|
{#each data.taxonomy.categories as item (item.id)}<label
|
||||||
|
><input
|
||||||
|
type="checkbox"
|
||||||
|
name="categoryIds"
|
||||||
|
value={item.id}
|
||||||
|
bind:group={draft.categoryIds}
|
||||||
|
/><i style={`--choice-color:${item.color}`}></i>{item.name}</label
|
||||||
|
>{/each}
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="piece-editor-panel" hidden={activeSection !== 'research'}>
|
||||||
|
<div class="piece-panel-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Nicht öffentlich</p>
|
||||||
|
<h2>Recherche & Quellen</h2>
|
||||||
|
</div>
|
||||||
|
<small>Recherche und Material bleiben innerhalb der Redaktion.</small>
|
||||||
|
</div>
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="researchText"
|
||||||
|
label="Private Recherche"
|
||||||
|
placeholder="Hintergrund, Prüfung und offene Fragen"
|
||||||
|
rows={10}
|
||||||
|
privateField
|
||||||
|
bind:value={draft.researchText}
|
||||||
|
/>
|
||||||
|
<section class="piece-source-editor">
|
||||||
|
<div class="piece-subsection-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Fundstellen</p>
|
||||||
|
<h3>Quellen</h3>
|
||||||
|
</div>
|
||||||
|
<button class="secondary-button" type="button" onclick={addSource}
|
||||||
|
>Quelle hinzufügen</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{#if sources.length}<div class="source-list">
|
||||||
|
{#each sources as source, index (index)}<div class="source-row">
|
||||||
|
<label
|
||||||
|
>Name<input
|
||||||
|
name="sourceLabel"
|
||||||
|
maxlength="200"
|
||||||
|
placeholder="Name der Quelle"
|
||||||
|
bind:value={source.label}
|
||||||
|
/></label
|
||||||
|
><label
|
||||||
|
>URL<input
|
||||||
|
name="sourceUrl"
|
||||||
|
type="url"
|
||||||
|
maxlength="2000"
|
||||||
|
placeholder="https://…"
|
||||||
|
bind:value={source.url}
|
||||||
|
/></label
|
||||||
|
><label
|
||||||
|
>Zeitmarke in Sekunden<input
|
||||||
|
name="sourceTimecode"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
max="86400"
|
||||||
|
placeholder="Optional"
|
||||||
|
bind:value={source.timecodeSeconds}
|
||||||
|
/></label
|
||||||
|
><button
|
||||||
|
class="text-button danger-text"
|
||||||
|
type="button"
|
||||||
|
onclick={() => removeSource(index)}>Entfernen</button
|
||||||
|
>
|
||||||
|
</div>{/each}
|
||||||
|
</div>{:else}<p class="context-empty">Noch keine Quelle hinterlegt.</p>{/if}
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="piece-editor-panel" hidden={activeSection !== 'presentation'}>
|
||||||
|
<div class="piece-panel-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Öffentliche Ausgabe</p>
|
||||||
|
<h2>Präsentation</h2>
|
||||||
|
</div>
|
||||||
|
<a
|
||||||
|
class="secondary-button"
|
||||||
|
href={resolve('/fundus/[id]/praesentation', { id: data.piece.id })}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener">In neuem Fenster testen</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="piece-presentation-layout">
|
||||||
|
<div class="piece-presentation-controls">
|
||||||
|
<MarkdownEditorField
|
||||||
|
name="presentationText"
|
||||||
|
label="Öffentlicher Text"
|
||||||
|
placeholder="Text für die Publikumsausgabe"
|
||||||
|
rows={8}
|
||||||
|
bind:value={draft.presentationText}
|
||||||
|
/>
|
||||||
|
<div class="presentation-mode-picker" role="group" aria-label="Darstellung">
|
||||||
|
{#each [['text', 'Text'], ['link', 'Linkvorschau'], ['video', 'Video']] as mode (mode[0])}<label
|
||||||
|
><input
|
||||||
|
type="radio"
|
||||||
|
name="presentationMode"
|
||||||
|
value={mode[0]}
|
||||||
|
bind:group={draft.presentationMode}
|
||||||
|
/>{mode[1]}</label
|
||||||
|
>{/each}
|
||||||
|
</div>
|
||||||
|
<div class="presentation-settings">
|
||||||
<label
|
<label
|
||||||
>Name<input name="sourceLabel" maxlength="200" bind:value={source.label} /></label
|
>Quelle<select
|
||||||
><label
|
name="presentationSourcePosition"
|
||||||
>URL<input
|
bind:value={draft.presentationSourcePosition}
|
||||||
name="sourceUrl"
|
onchange={presentationSourceChanged}
|
||||||
|
><option value={null}>Quelle auswählen</option
|
||||||
|
>{#each sources as source, index (index)}{#if source.url}<option value={index}
|
||||||
|
>{source.label || source.url}</option
|
||||||
|
>{/if}{/each}</select
|
||||||
|
></label
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
>Titel<input
|
||||||
|
name="presentationTitle"
|
||||||
|
maxlength="300"
|
||||||
|
placeholder="Optionaler Anzeigetitel"
|
||||||
|
bind:value={draft.presentationTitle}
|
||||||
|
oninput={() => (draft.presentationTitleManual = true)}
|
||||||
|
/></label
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
>Bild-URL<input
|
||||||
|
name="presentationImageUrl"
|
||||||
type="url"
|
type="url"
|
||||||
maxlength="2000"
|
maxlength="2000"
|
||||||
bind:value={source.url}
|
placeholder="https://…"
|
||||||
|
bind:value={draft.presentationImageUrl}
|
||||||
|
oninput={() => (draft.presentationImageManual = true)}
|
||||||
/></label
|
/></label
|
||||||
><label
|
|
||||||
>Zeitmarke in Sekunden<input
|
|
||||||
name="sourceTimecode"
|
|
||||||
type="number"
|
|
||||||
min="0"
|
|
||||||
max="86400"
|
|
||||||
bind:value={source.timecodeSeconds}
|
|
||||||
/></label
|
|
||||||
><button
|
|
||||||
class="text-button danger-text"
|
|
||||||
type="button"
|
|
||||||
onclick={() => removeSource(index)}>Entfernen</button
|
|
||||||
>
|
>
|
||||||
</div>{/each}
|
<label class="wide-field"
|
||||||
</div>{:else}<p class="quiet-copy">Noch keine Quellen hinterlegt.</p>{/if}
|
>Anreißer<textarea
|
||||||
|
name="presentationDescription"
|
||||||
|
rows="3"
|
||||||
|
maxlength="1000"
|
||||||
|
placeholder="Kurzer Text zur Vorschau"
|
||||||
|
bind:value={draft.presentationDescription}
|
||||||
|
oninput={() => (draft.presentationDescriptionManual = true)}></textarea></label
|
||||||
|
>
|
||||||
|
<div class="presentation-preview-actions wide-field">
|
||||||
|
<button
|
||||||
|
class="secondary-button"
|
||||||
|
type="button"
|
||||||
|
onclick={() => previewForm.requestSubmit()}
|
||||||
|
disabled={actionsBlocked || draft.presentationSourcePosition === null}
|
||||||
|
>Vorschau laden</button
|
||||||
|
><small
|
||||||
|
>{draft.presentationMetadataFetchedAtUtc
|
||||||
|
? `Zuletzt geladen: ${new Date(draft.presentationMetadataFetchedAtUtc).toLocaleString('de-DE')}`
|
||||||
|
: 'Noch keine Metadaten geladen.'}</small
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<aside class="piece-presentation-preview" aria-label="Präsentationsvorschau">
|
||||||
|
<PresentationDisplay
|
||||||
|
content={previewContent}
|
||||||
|
imageSrc={sourceImageUnavailable ? '' : sourcePreviewImage}
|
||||||
|
/>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="presentationTitleManual"
|
||||||
|
value={draft.presentationTitleManual ? '1' : '0'}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="presentationDescriptionManual"
|
||||||
|
value={draft.presentationDescriptionManual ? '1' : '0'}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="presentationImageManual"
|
||||||
|
value={draft.presentationImageManual ? '1' : '0'}
|
||||||
|
/>
|
||||||
|
<input type="hidden" name="presentationSiteName" value={draft.presentationSiteName} />
|
||||||
|
<input type="hidden" name="presentationProvider" value={draft.presentationProvider} />
|
||||||
|
<input type="hidden" name="presentationProviderId" value={draft.presentationProviderId} />
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="presentationMetadataFetchedAtUtc"
|
||||||
|
value={draft.presentationMetadataFetchedAtUtc ?? ''}
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<section class="piece-editor-panel piece-media-panel" hidden={activeSection !== 'research'}>
|
||||||
|
<div class="piece-subsection-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">Private Dateien</p>
|
||||||
|
<h3>Material</h3>
|
||||||
|
</div>
|
||||||
|
<small>JPEG, PNG, WebP oder GIF bis 5 MB</small>
|
||||||
|
</div>
|
||||||
|
{#if data.piece.media.length}<div class="media-grid">
|
||||||
|
{#each data.piece.media as media (media.id)}<figure>
|
||||||
|
<img src={`/media/${media.id}`} alt={media.altText} />
|
||||||
|
<figcaption>
|
||||||
|
<span>{media.altText || media.originalName}</span>
|
||||||
|
<form method="POST" action="?/deleteImage">
|
||||||
|
<input type="hidden" name="revision" value={revision} /><input
|
||||||
|
type="hidden"
|
||||||
|
name="mediaId"
|
||||||
|
value={media.id}
|
||||||
|
/><button class="text-button danger-text" type="submit" disabled={actionsBlocked}
|
||||||
|
>Entfernen</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
</figcaption>
|
||||||
|
</figure>{/each}
|
||||||
|
</div>{/if}
|
||||||
|
<form method="POST" action="?/upload" enctype="multipart/form-data" class="upload-form">
|
||||||
|
<input type="hidden" name="revision" value={revision} /><label
|
||||||
|
>Bild<input
|
||||||
|
name="image"
|
||||||
|
type="file"
|
||||||
|
accept="image/jpeg,image/png,image/webp,image/gif"
|
||||||
|
required
|
||||||
|
/></label
|
||||||
|
><label
|
||||||
|
>Alternativtext<input
|
||||||
|
name="altText"
|
||||||
|
maxlength="300"
|
||||||
|
placeholder="Was ist auf dem Bild zu sehen?"
|
||||||
|
/></label
|
||||||
|
><button class="secondary-button" type="submit" disabled={actionsBlocked}
|
||||||
|
>Bild hochladen</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="editor-savebar">
|
{#snippet footer()}
|
||||||
<span class:problem={saveState === 'error' || saveState === 'conflict'}>{saveMessage}</span
|
<div class="piece-dialog-secondary-actions">
|
||||||
><button bind:this={saveButton} class="primary-button" type="submit" disabled={saving}
|
<form method="POST" action="?/duplicate">
|
||||||
>Jetzt speichern</button
|
<button class="text-button" type="submit" disabled={actionsBlocked}>Duplizieren</button>
|
||||||
>
|
</form>
|
||||||
</div>
|
<form method="POST" action="?/archive">
|
||||||
|
<input type="hidden" name="revision" value={revision} /><button
|
||||||
|
class="text-button danger-text"
|
||||||
|
type="submit"
|
||||||
|
aria-label="Piece archivieren"
|
||||||
|
disabled={actionsBlocked}>Archivieren</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="piece-dialog-primary-action">
|
||||||
|
<span
|
||||||
|
class="save-indicator"
|
||||||
|
class:problem={saveState === 'error' || saveState === 'conflict'}
|
||||||
|
role="status"
|
||||||
|
aria-live="polite">{saveMessage}</span
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
bind:this={saveButton}
|
||||||
|
class:primary-button={saveState === 'dirty' ||
|
||||||
|
saveState === 'error' ||
|
||||||
|
saveState === 'conflict'}
|
||||||
|
class:secondary-button={saveState === 'idle' ||
|
||||||
|
saveState === 'saved' ||
|
||||||
|
saveState === 'saving'}
|
||||||
|
type="submit"
|
||||||
|
form="piece-editor-form"
|
||||||
|
disabled={saving}
|
||||||
|
>{saveState === 'error' || saveState === 'conflict'
|
||||||
|
? 'Erneut speichern'
|
||||||
|
: 'Speichern'}</button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</PieceEditorDialog>
|
||||||
|
|
||||||
|
<form
|
||||||
|
bind:this={previewForm}
|
||||||
|
id="preview-load-form"
|
||||||
|
method="POST"
|
||||||
|
action="?/loadPreview"
|
||||||
|
use:enhance
|
||||||
|
>
|
||||||
|
<input type="hidden" name="revision" value={revision} />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<section class="editor-section media-editor">
|
|
||||||
<div class="section-title">
|
|
||||||
<p class="eyebrow">Private Dateien</p>
|
|
||||||
<h2>Bilder</h2>
|
|
||||||
<small>JPEG, PNG, WebP oder GIF bis 5 MB; nur angemeldet abrufbar.</small>
|
|
||||||
</div>
|
|
||||||
{#if data.piece.media.length}<div class="media-grid">
|
|
||||||
{#each data.piece.media as media (media.id)}<figure>
|
|
||||||
<img src={`/media/${media.id}`} alt={media.altText} />
|
|
||||||
<figcaption>
|
|
||||||
<span>{media.altText || media.originalName}</span>
|
|
||||||
<form method="POST" action="?/deleteImage">
|
|
||||||
<input type="hidden" name="revision" value={revision} /><input
|
|
||||||
type="hidden"
|
|
||||||
name="mediaId"
|
|
||||||
value={media.id}
|
|
||||||
/><button class="text-button danger-text" type="submit" disabled={actionsBlocked}
|
|
||||||
>Entfernen</button
|
|
||||||
>
|
|
||||||
</form>
|
|
||||||
</figcaption>
|
|
||||||
</figure>{/each}
|
|
||||||
</div>{/if}
|
|
||||||
<form method="POST" action="?/upload" enctype="multipart/form-data" class="upload-form">
|
|
||||||
<input type="hidden" name="revision" value={revision} /><label
|
|
||||||
>Bild<input
|
|
||||||
name="image"
|
|
||||||
type="file"
|
|
||||||
accept="image/jpeg,image/png,image/webp,image/gif"
|
|
||||||
required
|
|
||||||
/></label
|
|
||||||
><label
|
|
||||||
>Alternativtext<input
|
|
||||||
name="altText"
|
|
||||||
maxlength="300"
|
|
||||||
placeholder="Was ist auf dem Bild zu sehen?"
|
|
||||||
/></label
|
|
||||||
><button class="secondary-button" type="submit" disabled={actionsBlocked}
|
|
||||||
>Bild hochladen</button
|
|
||||||
>
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="editor-actions">
|
|
||||||
<form method="POST" action="?/duplicate">
|
|
||||||
<button class="secondary-button" type="submit" disabled={actionsBlocked}
|
|
||||||
>Piece duplizieren</button
|
|
||||||
>
|
|
||||||
</form>
|
|
||||||
<form method="POST" action="?/archive">
|
|
||||||
<input type="hidden" name="revision" value={revision} /><button
|
|
||||||
class="secondary-button danger-text"
|
|
||||||
type="submit"
|
|
||||||
disabled={actionsBlocked}>Piece archivieren</button
|
|
||||||
>
|
|
||||||
</form>
|
|
||||||
</section>
|
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { PageServerLoad } from './$types';
|
||||||
|
import { requireUser } from '#lib/server/auth.js';
|
||||||
|
import { getPiece } from '#lib/server/content.js';
|
||||||
|
import { renderMarkdown } from '#lib/server/markdown.js';
|
||||||
|
import { buildEmbedUrl, type PresentationContent } from '#lib/server/presentation.js';
|
||||||
|
|
||||||
|
export const load: PageServerLoad = ({ locals, params }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const piece = getPiece(params.id);
|
||||||
|
if (!piece) error(404, 'Piece nicht gefunden');
|
||||||
|
const source =
|
||||||
|
piece.presentationSourcePosition === null
|
||||||
|
? null
|
||||||
|
: (piece.sources[piece.presentationSourcePosition] ?? null);
|
||||||
|
const content: PresentationContent & {
|
||||||
|
sources: typeof piece.sources;
|
||||||
|
images: { id: string; altText: string }[];
|
||||||
|
} = {
|
||||||
|
mode: piece.presentationMode,
|
||||||
|
title: piece.title,
|
||||||
|
html: renderMarkdown(piece.presentationText),
|
||||||
|
source,
|
||||||
|
previewTitle: piece.presentationTitle,
|
||||||
|
description: piece.presentationDescription,
|
||||||
|
imageUrl: piece.presentationImageUrl,
|
||||||
|
siteName: piece.presentationSiteName,
|
||||||
|
provider:
|
||||||
|
piece.presentationProvider === 'youtube' || piece.presentationProvider === 'tiktok'
|
||||||
|
? piece.presentationProvider
|
||||||
|
: '',
|
||||||
|
providerId: piece.presentationProviderId,
|
||||||
|
embedUrl: buildEmbedUrl(
|
||||||
|
piece.presentationProvider === 'youtube' || piece.presentationProvider === 'tiktok'
|
||||||
|
? piece.presentationProvider
|
||||||
|
: '',
|
||||||
|
piece.presentationProviderId,
|
||||||
|
source?.timecodeSeconds ?? null
|
||||||
|
),
|
||||||
|
sources: piece.sources,
|
||||||
|
images: piece.media.map((item) => ({ id: item.id, altText: item.altText }))
|
||||||
|
};
|
||||||
|
return { pieceId: piece.id, content };
|
||||||
|
};
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import PresentationDisplay from '#lib/components/PresentationDisplay.svelte';
|
||||||
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
|
let { data }: PageProps = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>Präsentation testen | Sendewerk</title>
|
||||||
|
<meta name="robots" content="noindex, nofollow, noarchive" />
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
|
<main class="heinzlive-output presentation-test-output">
|
||||||
|
<div class="presentation-test-status" role="status">Isolierte Testansicht</div>
|
||||||
|
<PresentationDisplay
|
||||||
|
content={data.content}
|
||||||
|
imageSrc={data.content.mode === 'text'
|
||||||
|
? '/media'
|
||||||
|
: `/fundus/${data.pieceId}/praesentation/preview-image`}
|
||||||
|
/>
|
||||||
|
</main>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { RequestHandler } from './$types';
|
||||||
|
import { requireUser } from '#lib/server/auth.js';
|
||||||
|
import { getPiece } from '#lib/server/content.js';
|
||||||
|
import { fetchPresentationImage } from '#lib/server/presentation.js';
|
||||||
|
|
||||||
|
export const GET: RequestHandler = async ({ locals, params }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const piece = getPiece(params.id);
|
||||||
|
if (!piece?.presentationImageUrl) error(404, 'Vorschaubild nicht verfügbar');
|
||||||
|
try {
|
||||||
|
const image = await fetchPresentationImage(piece.presentationImageUrl);
|
||||||
|
return new Response(new Uint8Array(image.data), {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': image.mimeType,
|
||||||
|
'Content-Length': String(image.data.byteLength),
|
||||||
|
'Cache-Control': 'private, max-age=300',
|
||||||
|
'X-Content-Type-Options': 'nosniff',
|
||||||
|
'Cross-Origin-Resource-Policy': 'same-origin',
|
||||||
|
'Content-Security-Policy': "default-src 'none'; sandbox"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
error(404, 'Vorschaubild nicht verfügbar');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { PageServerLoad } from './$types';
|
||||||
|
import { getPresentationView } from '#lib/server/live.js';
|
||||||
|
|
||||||
|
export const load: PageServerLoad = ({ params }) => {
|
||||||
|
const view = getPresentationView(params.token);
|
||||||
|
if (!view) error(404, 'Präsentationsausgabe nicht gefunden');
|
||||||
|
return { view };
|
||||||
|
};
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { page } from '$app/state';
|
||||||
|
import { onMount, untrack } from 'svelte';
|
||||||
|
import PresentationDisplay from '#lib/components/PresentationDisplay.svelte';
|
||||||
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
|
let { data }: PageProps = $props();
|
||||||
|
let view = $state(untrack(() => data.view));
|
||||||
|
let connection = $state<'connected' | 'waiting' | 'interrupted'>('connected');
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
let stopped = false;
|
||||||
|
let timer: ReturnType<typeof setTimeout>;
|
||||||
|
async function refresh() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/heinzlive/${page.params.token}/state`, {
|
||||||
|
headers: { Accept: 'application/json' },
|
||||||
|
cache: 'no-store'
|
||||||
|
});
|
||||||
|
if (!response.ok) throw new Error('STATE_UNAVAILABLE');
|
||||||
|
const next = await response.json();
|
||||||
|
if (next.revision !== view.revision) view = next;
|
||||||
|
connection = 'connected';
|
||||||
|
} catch {
|
||||||
|
connection = 'interrupted';
|
||||||
|
}
|
||||||
|
if (!stopped) timer = setTimeout(refresh, connection === 'interrupted' ? 3000 : 1000);
|
||||||
|
}
|
||||||
|
connection = 'waiting';
|
||||||
|
timer = setTimeout(refresh, 500);
|
||||||
|
return () => {
|
||||||
|
stopped = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>heinzlive</title>
|
||||||
|
<meta name="robots" content="noindex, nofollow, noarchive" />
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
|
<main class="heinzlive-output">
|
||||||
|
<div class="output-connection sr-only" class:problem={connection === 'interrupted'} role="status">
|
||||||
|
<span></span>{connection === 'interrupted' ? 'Verbindung unterbrochen' : 'Verbunden'}
|
||||||
|
</div>
|
||||||
|
{#if view.content}
|
||||||
|
{#key view.revision}
|
||||||
|
<PresentationDisplay
|
||||||
|
content={view.content}
|
||||||
|
imageSrc={view.content.mode === 'text'
|
||||||
|
? `/heinzlive/${page.params.token}/media`
|
||||||
|
: `/heinzlive/${page.params.token}/preview-image`}
|
||||||
|
/>
|
||||||
|
{/key}
|
||||||
|
{:else}
|
||||||
|
<section class="output-idle">
|
||||||
|
<div class="brand-mark" aria-hidden="true"><i></i><i></i><i></i></div>
|
||||||
|
<h1>Bereit für den nächsten Inhalt</h1>
|
||||||
|
<p>Die Moderation wählt ausdrücklich aus, was hier erscheint.</p>
|
||||||
|
</section>
|
||||||
|
{/if}
|
||||||
|
</main>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { RequestHandler } from './$types';
|
||||||
|
import { getPresentationMedia } from '#lib/server/live.js';
|
||||||
|
|
||||||
|
export const GET: RequestHandler = async ({ params }) => {
|
||||||
|
const media = await getPresentationMedia(params.token, params.id);
|
||||||
|
if (!media) error(404, 'Bild nicht gefunden');
|
||||||
|
return new Response(media.data, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': media.mimeType,
|
||||||
|
'Content-Length': String(media.byteSize),
|
||||||
|
'Cache-Control': 'no-store',
|
||||||
|
'Content-Security-Policy': "default-src 'none'; sandbox",
|
||||||
|
'Cross-Origin-Resource-Policy': 'same-origin',
|
||||||
|
'X-Content-Type-Options': 'nosniff'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { RequestHandler } from './$types';
|
||||||
|
import { getPresentationPreviewImage } from '#lib/server/live.js';
|
||||||
|
|
||||||
|
export const GET: RequestHandler = async ({ params }) => {
|
||||||
|
const image = await getPresentationPreviewImage(params.token);
|
||||||
|
if (!image) error(404, 'Vorschaubild nicht verfügbar');
|
||||||
|
return new Response(new Uint8Array(image.data), {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': image.mimeType,
|
||||||
|
'Content-Length': String(image.data.byteLength),
|
||||||
|
'Cache-Control': 'private, max-age=300',
|
||||||
|
'X-Content-Type-Options': 'nosniff',
|
||||||
|
'Cross-Origin-Resource-Policy': 'same-origin',
|
||||||
|
'Content-Security-Policy': "default-src 'none'; sandbox"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { error, json } from '@sveltejs/kit';
|
||||||
|
import type { RequestHandler } from './$types';
|
||||||
|
import { getPresentationView } from '#lib/server/live.js';
|
||||||
|
|
||||||
|
export const GET: RequestHandler = ({ params }) => {
|
||||||
|
const view = getPresentationView(params.token);
|
||||||
|
if (!view) error(404, 'Präsentationsausgabe nicht gefunden');
|
||||||
|
return json(view, { headers: { 'Cache-Control': 'no-store' } });
|
||||||
|
};
|
||||||
+125
-13
@@ -1,15 +1,127 @@
|
|||||||
import { getShow } from '#lib/server/previews.js';
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import { error, fail } from '@sveltejs/kit';
|
||||||
|
import type { Actions, PageServerLoad } from './$types';
|
||||||
|
import { requireUser } from '#lib/server/auth.js';
|
||||||
|
import {
|
||||||
|
completeCurrent,
|
||||||
|
getLiveView,
|
||||||
|
goBack,
|
||||||
|
issuePresentationAccess,
|
||||||
|
moveOpenUsage,
|
||||||
|
presentUsage,
|
||||||
|
skipCurrent,
|
||||||
|
startOrResumeLive
|
||||||
|
} from '#lib/server/live.js';
|
||||||
|
import { listShows } from '#lib/server/shows.js';
|
||||||
|
|
||||||
export function load({ url }) {
|
function text(data: FormData, name: string) {
|
||||||
const show = getShow(url.searchParams.get('show') || undefined);
|
return String(data.get(name) || '');
|
||||||
const usages = show.sections.flatMap((section) =>
|
|
||||||
section.usages
|
|
||||||
.filter((usage) => !usage.isReserve)
|
|
||||||
.map((usage) => ({ ...usage, section: section.name }))
|
|
||||||
);
|
|
||||||
const currentIndex = Math.max(
|
|
||||||
0,
|
|
||||||
usages.findIndex((usage) => usage.status === 'current')
|
|
||||||
);
|
|
||||||
return { show, current: usages[currentIndex] ?? null, next: usages[currentIndex + 1] ?? null };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function actionError(cause: unknown) {
|
||||||
|
const code = cause instanceof Error ? cause.message : '';
|
||||||
|
if (code === 'CONFLICT')
|
||||||
|
return {
|
||||||
|
status: 409,
|
||||||
|
error: 'Der Live-Stand wurde bereits geändert. Die Ansicht wurde erneuert.'
|
||||||
|
};
|
||||||
|
if (code === 'NO_CURRENT') return { status: 409, error: 'Es ist kein aktuelles Piece aktiv.' };
|
||||||
|
if (code === 'NO_PREVIOUS') return { status: 409, error: 'Es gibt kein vorheriges Piece.' };
|
||||||
|
if (code === 'LIVE_ORDER_LOCKED')
|
||||||
|
return {
|
||||||
|
status: 409,
|
||||||
|
error: 'Nur offene Pieces hinter dem aktuellen Stand können sortiert werden.'
|
||||||
|
};
|
||||||
|
if (code === 'SHOW_COMPLETED')
|
||||||
|
return { status: 409, error: 'Abgeschlossene Sendungen können nicht live gesteuert werden.' };
|
||||||
|
if (code === 'NOT_FOUND')
|
||||||
|
return { status: 404, error: 'Sendung oder Piece wurde nicht gefunden.' };
|
||||||
|
if (code.startsWith('INVALID_')) return { status: 400, error: 'Die Live-Aktion ist ungültig.' };
|
||||||
|
return { status: 500, error: 'Die Live-Aktion konnte nicht gespeichert werden.' };
|
||||||
|
}
|
||||||
|
|
||||||
|
function attempt(intent: string, operation: () => unknown) {
|
||||||
|
try {
|
||||||
|
return { intent, success: true, result: operation() };
|
||||||
|
} catch (cause) {
|
||||||
|
const problem = actionError(cause);
|
||||||
|
return fail(problem.status, { intent, ...problem });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const load: PageServerLoad = ({ locals, url }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const showId = url.searchParams.get('show') || listShows()[0]?.id;
|
||||||
|
if (!showId) error(404, 'Keine Sendung vorhanden');
|
||||||
|
try {
|
||||||
|
return { live: getLiveView(showId), commandId: randomUUID() };
|
||||||
|
} catch (cause) {
|
||||||
|
if (cause instanceof Error && cause.message === 'NOT_FOUND')
|
||||||
|
error(404, 'Sendung nicht gefunden');
|
||||||
|
throw cause;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const actions = {
|
||||||
|
start: async ({ locals, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('start', () =>
|
||||||
|
startOrResumeLive(text(data, 'showId'), text(data, 'commandId'), Number(data.get('revision')))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
complete: async ({ locals, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('complete', () =>
|
||||||
|
completeCurrent(text(data, 'showId'), text(data, 'commandId'), Number(data.get('revision')))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
skip: async ({ locals, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('skip', () =>
|
||||||
|
skipCurrent(text(data, 'showId'), text(data, 'commandId'), Number(data.get('revision')))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
back: async ({ locals, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('back', () =>
|
||||||
|
goBack(text(data, 'showId'), text(data, 'commandId'), Number(data.get('revision')))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
present: async ({ locals, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('present', () =>
|
||||||
|
presentUsage(
|
||||||
|
text(data, 'showId'),
|
||||||
|
text(data, 'usageId') || null,
|
||||||
|
text(data, 'commandId'),
|
||||||
|
Number(data.get('revision'))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
moveUsage: async ({ locals, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('moveUsage', () =>
|
||||||
|
moveOpenUsage(text(data, 'showId'), text(data, 'usageId'), Number(data.get('showRevision')), {
|
||||||
|
sectionId: text(data, 'sectionId') || null,
|
||||||
|
position: Number(data.get('position'))
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
createOutput: async ({ locals, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
try {
|
||||||
|
const token = issuePresentationAccess(text(data, 'showId'));
|
||||||
|
return { intent: 'createOutput', success: true, outputUrl: `/heinzlive/${token}` };
|
||||||
|
} catch (cause) {
|
||||||
|
const problem = actionError(cause);
|
||||||
|
return fail(problem.status, { intent: 'createOutput', ...problem });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} satisfies Actions;
|
||||||
+371
-66
@@ -1,96 +1,401 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import PreviewNotice from '#lib/components/PreviewNotice.svelte';
|
import { enhance, type SubmitFunction } from '$app/forms';
|
||||||
import { formatClock } from '#lib/format.js';
|
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import type { PageData } from './$types';
|
import { onMount, untrack } from 'svelte';
|
||||||
|
import { formatClock, formatDuration } from '#lib/format.js';
|
||||||
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
let { data }: { data: PageData } = $props();
|
let { data, form }: PageProps = $props();
|
||||||
let promptSize = $state(1.55);
|
let promptSize = $state(1.55);
|
||||||
|
let showRail = $state(true);
|
||||||
|
let showTimes = $state(true);
|
||||||
|
let popupMessage = $state('');
|
||||||
|
let now = $state(Date.now());
|
||||||
|
let loadedAt = $state(Date.now());
|
||||||
|
let currentId = $state(untrack(() => data.live.current?.id ?? null));
|
||||||
|
let outputWindow: Window | null = null;
|
||||||
|
let progress = $derived(
|
||||||
|
data.live.totalCount ? Math.round((data.live.completedCount / data.live.totalCount) * 100) : 0
|
||||||
|
);
|
||||||
|
let currentActualSeconds = $derived(
|
||||||
|
(data.live.current?.actualDurationSeconds ?? 0) +
|
||||||
|
(data.live.current ? Math.max(0, Math.floor((now - loadedAt) / 1000)) : 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
const nextCurrentId = data.live.current?.id ?? null;
|
||||||
|
if (nextCurrentId !== currentId) {
|
||||||
|
currentId = nextCurrentId;
|
||||||
|
loadedAt = Date.now();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const key = `sendewerk-live-${data.live.show.id}`;
|
||||||
|
try {
|
||||||
|
const settings = JSON.parse(localStorage.getItem(key) || '{}');
|
||||||
|
if (typeof settings.promptSize === 'number') promptSize = settings.promptSize;
|
||||||
|
if (typeof settings.showRail === 'boolean') showRail = settings.showRail;
|
||||||
|
if (typeof settings.showTimes === 'boolean') showTimes = settings.showTimes;
|
||||||
|
if (typeof settings.scrollY === 'number')
|
||||||
|
requestAnimationFrame(() => scrollTo(0, settings.scrollY));
|
||||||
|
} catch {
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
}
|
||||||
|
const interval = setInterval(() => (now = Date.now()), 1000);
|
||||||
|
const persistScroll = () => persistSettings();
|
||||||
|
addEventListener('scroll', persistScroll, { passive: true });
|
||||||
|
return () => {
|
||||||
|
clearInterval(interval);
|
||||||
|
removeEventListener('scroll', persistScroll);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function persistSettings() {
|
||||||
|
localStorage.setItem(
|
||||||
|
`sendewerk-live-${data.live.show.id}`,
|
||||||
|
JSON.stringify({ promptSize, showRail, showTimes, scrollY })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePromptSize(delta: number) {
|
||||||
|
promptSize = Math.min(2.4, Math.max(1.1, promptSize + delta));
|
||||||
|
persistSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleRail() {
|
||||||
|
showRail = !showRail;
|
||||||
|
persistSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleTimes() {
|
||||||
|
showTimes = !showTimes;
|
||||||
|
persistSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
function liveAction(name: string) {
|
||||||
|
return `?show=${encodeURIComponent(data.live.show.id)}&/${name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const enhanceCommand: SubmitFunction = ({ formElement, formData, submitter }) => {
|
||||||
|
const command = formElement.elements.namedItem('commandId');
|
||||||
|
if (command instanceof HTMLInputElement) {
|
||||||
|
command.value = crypto.randomUUID();
|
||||||
|
formData.set('commandId', command.value);
|
||||||
|
}
|
||||||
|
if (submitter instanceof HTMLButtonElement) submitter.disabled = true;
|
||||||
|
return async ({ update }) => {
|
||||||
|
await update({ reset: false, invalidateAll: true });
|
||||||
|
if (submitter instanceof HTMLButtonElement) submitter.disabled = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const enhanceOutput: SubmitFunction = ({ submitter }) => {
|
||||||
|
popupMessage = '';
|
||||||
|
outputWindow = window.open('about:blank', 'heinzlive-output');
|
||||||
|
if (!outputWindow) popupMessage = 'Popup blockiert. Bitte Popups erlauben und erneut öffnen.';
|
||||||
|
if (submitter instanceof HTMLButtonElement) submitter.disabled = true;
|
||||||
|
return async ({ result, update }) => {
|
||||||
|
if (result.type === 'success') {
|
||||||
|
const response = result.data as { outputUrl: string };
|
||||||
|
if (outputWindow && !outputWindow.closed) {
|
||||||
|
outputWindow.location.href = response.outputUrl;
|
||||||
|
popupMessage = 'Präsentationsfenster verbunden.';
|
||||||
|
} else {
|
||||||
|
popupMessage = `Präsentationsfenster konnte nicht geöffnet werden: ${response.outputUrl}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
outputWindow?.close();
|
||||||
|
}
|
||||||
|
await update({ reset: false, invalidateAll: false });
|
||||||
|
if (submitter instanceof HTMLButtonElement) submitter.disabled = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head><title>Live-Vorschau | Sendewerk</title></svelte:head>
|
<svelte:head><title>Live | {data.live.show.title} | Sendewerk</title></svelte:head>
|
||||||
|
|
||||||
<div class="page-wrap live-page">
|
<div class="page-wrap live-page live-controller">
|
||||||
<header class="live-header">
|
<header class="live-header">
|
||||||
<div>
|
<div>
|
||||||
<p class="eyebrow"><span class="live-pulse"></span> Live-Modus · Vorschau</p>
|
<p class="eyebrow"><span class="live-pulse"></span> Live-Steuerung</p>
|
||||||
<h1>{data.show.title}</h1>
|
<h1>{data.live.show.title}</h1>
|
||||||
|
<p class="live-state-line">
|
||||||
|
{data.live.startedAtUtc
|
||||||
|
? 'Live-Stand wird automatisch gespeichert.'
|
||||||
|
: 'Noch nicht gestartet.'}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="live-header-actions">
|
<div class="live-header-actions">
|
||||||
<div class="font-control" aria-label="Prompter-Schriftgröße">
|
<div class="font-control" aria-label="Prompter-Schriftgröße">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onclick={() => (promptSize = Math.max(1.15, promptSize - 0.1))}
|
onclick={() => changePromptSize(-0.1)}
|
||||||
aria-label="Schrift verkleinern">A−</button
|
aria-label="Schrift verkleinern">A−</button
|
||||||
>
|
>
|
||||||
<button
|
<button type="button" onclick={() => changePromptSize(0.1)} aria-label="Schrift vergrößern"
|
||||||
type="button"
|
>A+</button
|
||||||
onclick={() => (promptSize = Math.min(2.1, promptSize + 0.1))}
|
|
||||||
aria-label="Schrift vergrößern">A+</button
|
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<a href={resolve('/sendungen/[id]', { id: data.show.id })}>Planung schließen</a>
|
<button type="button" class="text-button" aria-pressed={!showTimes} onclick={toggleTimes}
|
||||||
|
>{showTimes ? 'Zeiten ausblenden' : 'Zeiten einblenden'}</button
|
||||||
|
>
|
||||||
|
<button type="button" class="text-button" aria-pressed={!showRail} onclick={toggleRail}
|
||||||
|
>{showRail ? 'Ablauf ausblenden' : 'Ablauf einblenden'}</button
|
||||||
|
>
|
||||||
|
<a href={resolve('/sendungen/[id]', { id: data.live.show.id })}>Zur Planung</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<PreviewNotice area="Live-Modus" />
|
{#if form?.error}<div class="form-message error" role="alert">{form.error}</div>{/if}
|
||||||
|
{#if popupMessage}<div class="form-message" role="status">{popupMessage}</div>{/if}
|
||||||
|
|
||||||
<div class="live-grid">
|
<section class="live-toolbar" aria-label="Live-Sitzung">
|
||||||
{#if data.current}<section class="live-current" style={`--prompt-size: ${promptSize}rem`}>
|
<form method="POST" action={liveAction('start')} use:enhance={enhanceCommand}>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="revision" value={data.live.liveRevision} />
|
||||||
|
<input type="hidden" name="commandId" value={data.commandId} />
|
||||||
|
<button class="primary-button" type="submit">
|
||||||
|
{data.live.startedAtUtc ? 'Live-Stand wiederaufnehmen' : 'Sendung starten'}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<form method="POST" action={liveAction('createOutput')} use:enhance={enhanceOutput}>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<button class="secondary-button" type="submit">Präsentationsfenster öffnen</button>
|
||||||
|
</form>
|
||||||
|
<div class="live-session-summary">
|
||||||
|
<strong>{data.live.completedCount} / {data.live.totalCount}</strong>
|
||||||
|
<span>{progress}% bearbeitet</span>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class:without-rail={!showRail} class="live-grid">
|
||||||
|
{#if data.live.current}<main
|
||||||
|
class="live-current"
|
||||||
|
style={`--prompt-size: ${promptSize}rem`}
|
||||||
|
aria-labelledby="current-title"
|
||||||
|
>
|
||||||
<div class="live-kicker">
|
<div class="live-kicker">
|
||||||
<span>Aktuell · {data.current.section}</span><strong
|
<span>Aktuell · {data.live.current.sectionName}</span>
|
||||||
>{formatClock(data.current.durationSeconds)}</strong
|
{#if showTimes}<strong
|
||||||
>
|
>{formatClock(currentActualSeconds)} / {formatClock(
|
||||||
</div>
|
data.live.current.durationSeconds
|
||||||
<h2>{data.current.title}</h2>
|
)}</strong
|
||||||
<div class="prompter-copy">{data.current.intro}</div>
|
>{/if}
|
||||||
<div class="moderation-card">
|
|
||||||
<span>Moderationsstichpunkte</span>
|
|
||||||
<p>{data.current.moderation}</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
<h2 id="current-title">{data.live.current.title}</h2>
|
||||||
|
<!-- HTML is produced exclusively by the server-side allowlist sanitizer. -->
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
|
<div class="prompter-copy">{@html data.live.current.introHtml}</div>
|
||||||
|
{#if data.live.current.moderationHtml}<section class="moderation-card">
|
||||||
|
<span>Moderationsstichpunkte</span>
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
|
<div class="live-markdown">{@html data.live.current.moderationHtml}</div>
|
||||||
|
</section>{/if}
|
||||||
<details class="research-details">
|
<details class="research-details">
|
||||||
<summary>Recherche öffnen</summary>
|
<summary>Manuelle Recherche öffnen</summary>
|
||||||
<p>
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
Die Recherche bleibt im echten Live-Modus standardmäßig geschlossen und bewahrt beim
|
<div class="live-markdown">{@html data.live.current.researchHtml}</div>
|
||||||
Öffnen die Leseposition.
|
|
||||||
</p>
|
|
||||||
</details>
|
</details>
|
||||||
<div class="transition-card">
|
{#if data.live.current.transitionHtml}<section class="transition-card">
|
||||||
<span>Überleitung</span>
|
<span>Überleitung</span>
|
||||||
<p>{data.current.transition}</p>
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||||
</div>
|
<div class="live-markdown">{@html data.live.current.transitionHtml}</div>
|
||||||
</section>{:else}<section class="live-current live-empty">
|
</section>{/if}
|
||||||
<p class="eyebrow">Noch kein Piece eingeplant</p>
|
|
||||||
<h2>Diese Sendung hat noch keinen moderierbaren Inhalt.</h2>
|
|
||||||
<p>In der Planung kann zuerst ein sendefertiges Piece hinzugefügt werden.</p>
|
|
||||||
</section>{/if}
|
|
||||||
|
|
||||||
<aside class="live-rail">
|
<div class="live-current-actions">
|
||||||
<div class="next-card">
|
<form method="POST" action={liveAction('back')} use:enhance={enhanceCommand}>
|
||||||
<span>Als Nächstes</span>
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
{#if data.next}
|
<input type="hidden" name="revision" value={data.live.liveRevision} />
|
||||||
<h3>{data.next.title}</h3>
|
<input type="hidden" name="commandId" value={data.commandId} />
|
||||||
<p>{data.next.section} · {formatClock(data.next.durationSeconds)}</p>
|
<button class="secondary-button" type="submit">Zurück</button>
|
||||||
{:else}
|
</form>
|
||||||
<h3>Sendungsende</h3>
|
<form method="POST" action={liveAction('present')} use:enhance={enhanceCommand}>
|
||||||
<p>Kein weiteres Stück eingeplant.</p>
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
{/if}
|
<input type="hidden" name="usageId" value={data.live.current.id} />
|
||||||
</div>
|
<input type="hidden" name="revision" value={data.live.liveRevision} />
|
||||||
<div class="live-progress">
|
<input type="hidden" name="commandId" value={data.commandId} />
|
||||||
<header><span>Ablauf</span><strong>2 / 4</strong></header>
|
<button class="secondary-button" type="submit">
|
||||||
<div class="progress-track"><span></span></div>
|
{data.live.presentationUsageId === data.live.current.id
|
||||||
{#each data.show.sections as section, index (section.id)}
|
? 'Erneut präsentieren'
|
||||||
<div class:active={index === 1} class="rail-section">
|
: 'Präsentieren'}
|
||||||
<span>{String(index + 1).padStart(2, '0')}</span>
|
</button>
|
||||||
<div>
|
</form>
|
||||||
<strong>{section.name}</strong><small>{formatClock(section.durationSeconds)}</small>
|
<form method="POST" action={liveAction('skip')} use:enhance={enhanceCommand}>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="revision" value={data.live.liveRevision} />
|
||||||
|
<input type="hidden" name="commandId" value={data.commandId} />
|
||||||
|
<button class="text-button" type="submit">Überspringen</button>
|
||||||
|
</form>
|
||||||
|
<form method="POST" action={liveAction('complete')} use:enhance={enhanceCommand}>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="revision" value={data.live.liveRevision} />
|
||||||
|
<input type="hidden" name="commandId" value={data.commandId} />
|
||||||
|
<button class="primary-button" type="submit">Erledigen und weiter</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</main>{:else}<main class="live-current live-empty">
|
||||||
|
<p class="eyebrow">Kein aktives Piece</p>
|
||||||
|
<h2>{data.live.totalCount ? 'Live-Stand bereit' : 'Noch kein Piece eingeplant'}</h2>
|
||||||
|
<p>
|
||||||
|
{data.live.totalCount
|
||||||
|
? 'Sendung starten oder einen abgeschlossenen Schritt zurückgehen.'
|
||||||
|
: 'In der Planung kann zuerst ein sendefertiges Piece hinzugefügt werden.'}
|
||||||
|
</p>
|
||||||
|
{#if data.live.completedCount}<form
|
||||||
|
method="POST"
|
||||||
|
action={liveAction('back')}
|
||||||
|
use:enhance={enhanceCommand}
|
||||||
|
>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="revision" value={data.live.liveRevision} />
|
||||||
|
<input type="hidden" name="commandId" value={data.commandId} />
|
||||||
|
<button class="secondary-button" type="submit">Zum letzten Piece zurück</button>
|
||||||
|
</form>{/if}
|
||||||
|
</main>{/if}
|
||||||
|
|
||||||
|
{#if showRail}<aside class="live-rail">
|
||||||
|
<section class="next-card">
|
||||||
|
<span>Als Nächstes</span>
|
||||||
|
{#if data.live.next}
|
||||||
|
<h3>{data.live.next.title}</h3>
|
||||||
|
<p>
|
||||||
|
{data.live.next.sectionName}{#if showTimes}
|
||||||
|
· {formatClock(data.live.next.durationSeconds)}{/if}
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
<h3>Sendungsende</h3>
|
||||||
|
<p>Kein weiteres offenes Piece eingeplant.</p>
|
||||||
|
{/if}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="live-progress">
|
||||||
|
<header>
|
||||||
|
<span>Ablauf</span><strong>{data.live.completedCount} / {data.live.totalCount}</strong>
|
||||||
|
</header>
|
||||||
|
<div class="progress-track"><span style={`width:${progress}%`}></span></div>
|
||||||
|
{#each data.live.sections as section, sectionIndex (section.id)}
|
||||||
|
<div class:active={section.id === data.live.current?.sectionId} class="rail-section">
|
||||||
|
<span>{String(sectionIndex + 1).padStart(2, '0')}</span>
|
||||||
|
<div>
|
||||||
|
<strong>{section.name}</strong>
|
||||||
|
{#if showTimes}<small>{formatDuration(section.durationSeconds)}</small>{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{#each section.usages as usage, usageIndex (usage.id)}
|
||||||
{/each}
|
<div class:current={usage.id === data.live.current?.id} class="live-run-item">
|
||||||
</div>
|
<div>
|
||||||
<div class="readonly-actions" aria-label="Spätere Live-Aktionen">
|
<strong>{usage.title}</strong><small>{usage.status}</small>
|
||||||
<span>Zurück</span><strong>In Etappe 5 steuerbar</strong><span>Erledigen</span>
|
</div>
|
||||||
</div>
|
<div class="live-run-actions">
|
||||||
</aside>
|
{#if usage.status === 'open'}
|
||||||
|
<form
|
||||||
|
method="POST"
|
||||||
|
action={liveAction('moveUsage')}
|
||||||
|
use:enhance={enhanceCommand}
|
||||||
|
>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="showRevision" value={data.live.show.revision} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
<input type="hidden" name="sectionId" value={section.id} />
|
||||||
|
<input type="hidden" name="position" value={usageIndex - 1} />
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={usageIndex === 0 ||
|
||||||
|
section.usages[usageIndex - 1]?.status !== 'open'}
|
||||||
|
aria-label={`${usage.title} nach oben`}>↑</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<form
|
||||||
|
method="POST"
|
||||||
|
action={liveAction('moveUsage')}
|
||||||
|
use:enhance={enhanceCommand}
|
||||||
|
>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="showRevision" value={data.live.show.revision} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
<input type="hidden" name="sectionId" value={section.id} />
|
||||||
|
<input type="hidden" name="position" value={usageIndex + 1} />
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={usageIndex === section.usages.length - 1 ||
|
||||||
|
section.usages[usageIndex + 1]?.status !== 'open'}
|
||||||
|
aria-label={`${usage.title} nach unten`}>↓</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
<form method="POST" action={liveAction('present')} use:enhance={enhanceCommand}>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
<input type="hidden" name="revision" value={data.live.liveRevision} />
|
||||||
|
<input type="hidden" name="commandId" value={data.commandId} />
|
||||||
|
<button type="submit" aria-label={`${usage.title} präsentieren`}>↗</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
{/each}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="live-reserve">
|
||||||
|
<header><span>Reserve</span><strong>{data.live.reserve.length}</strong></header>
|
||||||
|
{#each data.live.reserve as usage, reserveIndex (usage.id)}
|
||||||
|
<div class="live-reserve-item">
|
||||||
|
<div>
|
||||||
|
<strong>{usage.title}</strong>{#if showTimes}<small
|
||||||
|
>{formatClock(usage.durationSeconds)}</small
|
||||||
|
>{/if}
|
||||||
|
</div>
|
||||||
|
<div class="live-run-actions">
|
||||||
|
<form method="POST" action={liveAction('moveUsage')} use:enhance={enhanceCommand}>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="showRevision" value={data.live.show.revision} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
<input type="hidden" name="sectionId" value="" />
|
||||||
|
<input type="hidden" name="position" value={reserveIndex - 1} />
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={reserveIndex === 0}
|
||||||
|
aria-label={`${usage.title} in Reserve nach oben`}>↑</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<form method="POST" action={liveAction('moveUsage')} use:enhance={enhanceCommand}>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="showRevision" value={data.live.show.revision} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
<input type="hidden" name="sectionId" value="" />
|
||||||
|
<input type="hidden" name="position" value={reserveIndex + 1} />
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={reserveIndex === data.live.reserve.length - 1}
|
||||||
|
aria-label={`${usage.title} in Reserve nach unten`}>↓</button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
{#if data.live.current || data.live.sections[0]}<form
|
||||||
|
method="POST"
|
||||||
|
action={liveAction('moveUsage')}
|
||||||
|
use:enhance={enhanceCommand}
|
||||||
|
>
|
||||||
|
<input type="hidden" name="showId" value={data.live.show.id} />
|
||||||
|
<input type="hidden" name="showRevision" value={data.live.show.revision} />
|
||||||
|
<input type="hidden" name="usageId" value={usage.id} />
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="sectionId"
|
||||||
|
value={data.live.current?.sectionId ?? data.live.sections[0]?.id}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="position"
|
||||||
|
value={(data.live.current?.position ?? -1) + 1}
|
||||||
|
/>
|
||||||
|
<button class="text-button" type="submit">Als Nächstes</button>
|
||||||
|
</form>{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
{#if !data.live.reserve.length}<p>Keine Pieces in Reserve.</p>{/if}
|
||||||
|
</section>
|
||||||
|
</aside>{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -5,16 +5,19 @@ import { getTaxonomy, listPieces } from '#lib/server/content.js';
|
|||||||
import {
|
import {
|
||||||
addPieceUsage,
|
addPieceUsage,
|
||||||
addShowSection,
|
addShowSection,
|
||||||
|
duplicatePieceUsage,
|
||||||
getShow,
|
getShow,
|
||||||
|
getPieceUsageContexts,
|
||||||
movePieceUsage,
|
movePieceUsage,
|
||||||
moveShowSection,
|
moveShowSection,
|
||||||
|
refreshPieceUsageFromOriginal,
|
||||||
removePieceUsage,
|
removePieceUsage,
|
||||||
removeShowSection,
|
removeShowSection,
|
||||||
saveShowMetadata,
|
saveShowMetadata,
|
||||||
updatePieceUsage,
|
updatePieceUsage,
|
||||||
updateShowSection,
|
updateShowSection,
|
||||||
type EditableShowStatus,
|
type EditableShowStatus,
|
||||||
type UsageStatus
|
type PieceUsageUpdate
|
||||||
} from '#lib/server/shows.js';
|
} from '#lib/server/shows.js';
|
||||||
|
|
||||||
function text(data: FormData, name: string) {
|
function text(data: FormData, name: string) {
|
||||||
@@ -84,6 +87,8 @@ function actionError(cause: unknown) {
|
|||||||
return { status: 409, error: 'Abgeschlossene Sendungen können nicht bearbeitet werden.' };
|
return { status: 409, error: 'Abgeschlossene Sendungen können nicht bearbeitet werden.' };
|
||||||
if (code === 'PIECE_NOT_READY')
|
if (code === 'PIECE_NOT_READY')
|
||||||
return { status: 400, error: 'Nur sendefertige Pieces können eingeplant werden.' };
|
return { status: 400, error: 'Nur sendefertige Pieces können eingeplant werden.' };
|
||||||
|
if (code === 'ORIGINAL_NOT_FOUND')
|
||||||
|
return { status: 409, error: 'Das zugehörige Fundus-Piece ist nicht mehr verfügbar.' };
|
||||||
if (code === 'NOT_FOUND') return { status: 404, error: 'Der Eintrag wurde nicht gefunden.' };
|
if (code === 'NOT_FOUND') return { status: 404, error: 'Der Eintrag wurde nicht gefunden.' };
|
||||||
if (code === 'INVALID_DURATION')
|
if (code === 'INVALID_DURATION')
|
||||||
return { status: 400, error: 'Piece-Dauern müssen zwischen 0 und 1.440 Minuten liegen.' };
|
return { status: 400, error: 'Piece-Dauern müssen zwischen 0 und 1.440 Minuten liegen.' };
|
||||||
@@ -104,18 +109,25 @@ export const load: PageServerLoad = ({ locals, params, url }) => {
|
|||||||
requireUser(locals.user);
|
requireUser(locals.user);
|
||||||
const show = getShow(params.id);
|
const show = getShow(params.id);
|
||||||
if (!show) error(404, 'Sendung nicht gefunden');
|
if (!show) error(404, 'Sendung nicht gefunden');
|
||||||
|
const pieces = listPieces({
|
||||||
|
statuses: ['ready'],
|
||||||
|
query: url.searchParams.get('q') ?? '',
|
||||||
|
categoryId: url.searchParams.get('category') ?? ''
|
||||||
|
});
|
||||||
|
const usageContexts = getPieceUsageContexts(
|
||||||
|
pieces.map((piece) => piece.id),
|
||||||
|
show.id
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
show,
|
show,
|
||||||
startsAtLocal: berlinInput(show.startsAtUtc),
|
startsAtLocal: berlinInput(show.startsAtUtc),
|
||||||
pieces: listPieces({
|
pieces: pieces.map((piece) => ({ ...piece, ...usageContexts[piece.id] })),
|
||||||
statuses: ['ready'],
|
|
||||||
query: url.searchParams.get('q') ?? '',
|
|
||||||
categoryId: url.searchParams.get('category') ?? ''
|
|
||||||
}),
|
|
||||||
taxonomy: getTaxonomy(),
|
taxonomy: getTaxonomy(),
|
||||||
filters: {
|
filters: {
|
||||||
query: url.searchParams.get('q') ?? '',
|
query: url.searchParams.get('q') ?? '',
|
||||||
categoryId: url.searchParams.get('category') ?? ''
|
categoryId: url.searchParams.get('category') ?? '',
|
||||||
|
includeUsed: url.searchParams.get('includeUsed') === '1',
|
||||||
|
includePlanned: url.searchParams.get('includePlanned') === '1'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -198,10 +210,33 @@ export const actions = {
|
|||||||
moderation: text(data, 'moderation'),
|
moderation: text(data, 'moderation'),
|
||||||
transition: text(data, 'transition'),
|
transition: text(data, 'transition'),
|
||||||
presentation: text(data, 'presentation'),
|
presentation: text(data, 'presentation'),
|
||||||
status: text(data, 'status') as UsageStatus
|
presentationMode: text(data, 'presentationMode') as PieceUsageUpdate['presentationMode'],
|
||||||
|
presentationSourceLabel: text(data, 'presentationSourceLabel'),
|
||||||
|
presentationSourceUrl: text(data, 'presentationSourceUrl'),
|
||||||
|
presentationSourceTimecodeSeconds: text(data, 'presentationSourceTimecodeSeconds')
|
||||||
|
? Number(data.get('presentationSourceTimecodeSeconds'))
|
||||||
|
: null,
|
||||||
|
presentationTitle: text(data, 'presentationTitle'),
|
||||||
|
presentationDescription: text(data, 'presentationDescription'),
|
||||||
|
presentationImageUrl: text(data, 'presentationImageUrl'),
|
||||||
|
presentationSiteName: text(data, 'presentationSiteName')
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
duplicateUsage: async ({ locals, params, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('duplicateUsage', () =>
|
||||||
|
duplicatePieceUsage(params.id, text(data, 'usageId'), Number(data.get('revision')))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
refreshUsage: async ({ locals, params, request }) => {
|
||||||
|
requireUser(locals.user);
|
||||||
|
const data = await request.formData();
|
||||||
|
return attempt('refreshUsage', () =>
|
||||||
|
refreshPieceUsageFromOriginal(params.id, text(data, 'usageId'), Number(data.get('revision')))
|
||||||
|
);
|
||||||
|
},
|
||||||
removeUsage: async ({ locals, params, request }) => {
|
removeUsage: async ({ locals, params, request }) => {
|
||||||
requireUser(locals.user);
|
requireUser(locals.user);
|
||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance, type SubmitFunction } from '$app/forms';
|
import { enhance, type SubmitFunction } from '$app/forms';
|
||||||
|
import { replaceState } from '$app/navigation';
|
||||||
import { resolve } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
|
import { page } from '$app/state';
|
||||||
import { flip } from 'svelte/animate';
|
import { flip } from 'svelte/animate';
|
||||||
|
import { onMount, untrack } from 'svelte';
|
||||||
|
import PieceUsageHistory from '#lib/components/PieceUsageHistory.svelte';
|
||||||
|
import UsageEditorDialog from '#lib/components/UsageEditorDialog.svelte';
|
||||||
import { formatClock, formatDuration } from '#lib/format.js';
|
import { formatClock, formatDuration } from '#lib/format.js';
|
||||||
import type { PageProps } from './$types';
|
import type { PageProps } from './$types';
|
||||||
|
|
||||||
@@ -23,9 +28,27 @@
|
|||||||
let dropSectionId = $state('');
|
let dropSectionId = $state('');
|
||||||
let dropPosition = $state(0);
|
let dropPosition = $state(0);
|
||||||
let copyMessage = $state('');
|
let copyMessage = $state('');
|
||||||
|
let showUsedPieces = $state(untrack(() => data.filters.includeUsed));
|
||||||
|
let showPlannedPieces = $state(untrack(() => data.filters.includePlanned));
|
||||||
|
let visiblePieces = $derived(
|
||||||
|
data.pieces.filter(
|
||||||
|
(piece) =>
|
||||||
|
(showUsedPieces || piece.sentHistory.length === 0) &&
|
||||||
|
(showPlannedPieces || !piece.isPlannedInCurrentShow)
|
||||||
|
)
|
||||||
|
);
|
||||||
let plannedCount = $derived(
|
let plannedCount = $derived(
|
||||||
data.show.sections.reduce((total, section) => total + section.usages.length, 0)
|
data.show.sections.reduce((total, section) => total + section.usages.length, 0)
|
||||||
);
|
);
|
||||||
|
onMount(() => {
|
||||||
|
const syncFiltersFromHistory = () => {
|
||||||
|
const search = new URL(window.location.href).searchParams;
|
||||||
|
showUsedPieces = search.get('includeUsed') === '1';
|
||||||
|
showPlannedPieces = search.get('includePlanned') === '1';
|
||||||
|
};
|
||||||
|
window.addEventListener('popstate', syncFiltersFromHistory);
|
||||||
|
return () => window.removeEventListener('popstate', syncFiltersFromHistory);
|
||||||
|
});
|
||||||
|
|
||||||
function berlinDate(value: string | null) {
|
function berlinDate(value: string | null) {
|
||||||
if (!value) return 'Termin offen';
|
if (!value) return 'Termin offen';
|
||||||
@@ -36,8 +59,15 @@
|
|||||||
}).format(new Date(value));
|
}).format(new Date(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
function durationInMinutes(seconds: number) {
|
function setSourceFilter(name: 'includeUsed' | 'includePlanned', checked: boolean) {
|
||||||
return Number((seconds / 60).toFixed(2));
|
if (name === 'includeUsed') showUsedPieces = checked;
|
||||||
|
else showPlannedPieces = checked;
|
||||||
|
const url = new URL(page.url.href);
|
||||||
|
if (checked) url.searchParams.set(name, '1');
|
||||||
|
else url.searchParams.delete(name);
|
||||||
|
// This URL is cloned from the current page; only same-route filter parameters change.
|
||||||
|
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
||||||
|
replaceState(url, page.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startDrag(kind: 'piece' | 'section' | 'usage', id: string, event: DragEvent) {
|
function startDrag(kind: 'piece' | 'section' | 'usage', id: string, event: DragEvent) {
|
||||||
@@ -142,6 +172,7 @@
|
|||||||
affected?.classList.add('is-updating');
|
affected?.classList.add('is-updating');
|
||||||
if (submitter instanceof HTMLButtonElement) submitter.disabled = true;
|
if (submitter instanceof HTMLButtonElement) submitter.disabled = true;
|
||||||
return async ({ result, update }) => {
|
return async ({ result, update }) => {
|
||||||
|
if (result.type === 'success') formElement.closest<HTMLDialogElement>('dialog')?.close();
|
||||||
await update({ reset: result.type === 'success', invalidateAll: true });
|
await update({ reset: result.type === 'success', invalidateAll: true });
|
||||||
affected?.classList.remove('is-updating');
|
affected?.classList.remove('is-updating');
|
||||||
if (submitter instanceof HTMLButtonElement) submitter.disabled = false;
|
if (submitter instanceof HTMLButtonElement) submitter.disabled = false;
|
||||||
@@ -175,7 +206,7 @@
|
|||||||
<strong>{formatDuration(data.show.totalDurationSeconds)}</strong><span>Planzeit</span>
|
<strong>{formatDuration(data.show.totalDurationSeconds)}</strong><span>Planzeit</span>
|
||||||
</div>
|
</div>
|
||||||
<a class="live-link" href={resolve(`/live?show=${encodeURIComponent(data.show.id)}`)}
|
<a class="live-link" href={resolve(`/live?show=${encodeURIComponent(data.show.id)}`)}
|
||||||
>Live-Vorschau <span>↗</span></a
|
>Live-Steuerung <span>↗</span></a
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -264,9 +295,9 @@
|
|||||||
<p class="eyebrow">Quelle</p>
|
<p class="eyebrow">Quelle</p>
|
||||||
<h2 id="source-title">Sendefertiger Fundus</h2>
|
<h2 id="source-title">Sendefertiger Fundus</h2>
|
||||||
</div>
|
</div>
|
||||||
<span>{data.pieces.length}</span>
|
<span>{visiblePieces.length}</span>
|
||||||
</header>
|
</header>
|
||||||
<form method="GET" class="builder-filter">
|
<form id="builder-filters" method="GET" class="builder-filter">
|
||||||
<label
|
<label
|
||||||
><span class="sr-only">Fundus durchsuchen</span><input
|
><span class="sr-only">Fundus durchsuchen</span><input
|
||||||
type="search"
|
type="search"
|
||||||
@@ -286,8 +317,32 @@
|
|||||||
>
|
>
|
||||||
<button class="text-button" type="submit">Filtern</button>
|
<button class="text-button" type="submit">Filtern</button>
|
||||||
</form>
|
</form>
|
||||||
|
<div class="builder-filter-options" aria-label="Fundusauswahl erweitern">
|
||||||
|
<label class="filter-checkbox">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="includeUsed"
|
||||||
|
value="1"
|
||||||
|
form="builder-filters"
|
||||||
|
checked={showUsedPieces}
|
||||||
|
onchange={(event) => setSourceFilter('includeUsed', event.currentTarget.checked)}
|
||||||
|
/>
|
||||||
|
<span>Auch verwendete Inhalte zeigen</span>
|
||||||
|
</label>
|
||||||
|
<label class="filter-checkbox">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="includePlanned"
|
||||||
|
value="1"
|
||||||
|
form="builder-filters"
|
||||||
|
checked={showPlannedPieces}
|
||||||
|
onchange={(event) => setSourceFilter('includePlanned', event.currentTarget.checked)}
|
||||||
|
/>
|
||||||
|
<span>Auch eingeplante Inhalte zeigen</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="builder-source-list">
|
<div class="builder-source-list">
|
||||||
{#each data.pieces as piece (piece.id)}
|
{#each visiblePieces as piece (piece.id)}
|
||||||
<article
|
<article
|
||||||
class="builder-source-card"
|
class="builder-source-card"
|
||||||
class:is-dragging={dragged?.kind === 'piece' && dragged.id === piece.id}
|
class:is-dragging={dragged?.kind === 'piece' && dragged.id === piece.id}
|
||||||
@@ -310,6 +365,8 @@
|
|||||||
<p>
|
<p>
|
||||||
{piece.format} · {piece.topics.map((item) => item.name).join(', ') || 'Ohne Thema'}
|
{piece.format} · {piece.topics.map((item) => item.name).join(', ') || 'Ohne Thema'}
|
||||||
</p>
|
</p>
|
||||||
|
{#if piece.isPlannedInCurrentShow}<span class="planned-label">Eingeplant</span>{/if}
|
||||||
|
<PieceUsageHistory history={piece.sentHistory} />
|
||||||
<small class="drag-hint">Ziehen oder Ziel auswählen</small>
|
<small class="drag-hint">Ziehen oder Ziel auswählen</small>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form
|
||||||
@@ -338,10 +395,13 @@
|
|||||||
</article>
|
</article>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{#if !data.pieces.length}<div class="empty-state">
|
{#if !visiblePieces.length}<div class="empty-state">
|
||||||
<span aria-hidden="true">⌕</span>
|
<span aria-hidden="true">⌕</span>
|
||||||
<h2>Nichts gefunden</h2>
|
<h2>Keine verfügbaren Pieces</h2>
|
||||||
<p>Filter ändern oder Pieces im Fundus sendefertig markieren.</p>
|
<p>
|
||||||
|
Suchfilter ändern, ausgeblendete Inhalte einblenden oder Pieces im Fundus sendefertig
|
||||||
|
markieren.
|
||||||
|
</p>
|
||||||
</div>{/if}
|
</div>{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -473,7 +533,7 @@
|
|||||||
ondragend={finishDrag}
|
ondragend={finishDrag}
|
||||||
>
|
>
|
||||||
<strong>{usage.title}</strong><small
|
<strong>{usage.title}</strong><small
|
||||||
>{formatClock(usage.durationSeconds)} · sendungsspezifische Kopie</small
|
>{formatClock(usage.durationSeconds)}</small
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-actions">
|
<div class="row-actions">
|
||||||
@@ -507,105 +567,15 @@
|
|||||||
aria-label={`${usage.title} nach unten`}>↓</button
|
aria-label={`${usage.title} nach unten`}>↓</button
|
||||||
>
|
>
|
||||||
</form>
|
</form>
|
||||||
|
<UsageEditorDialog
|
||||||
|
{usage}
|
||||||
|
revision={data.show.revision}
|
||||||
|
sectionId={section.id}
|
||||||
|
sections={data.show.sections}
|
||||||
|
error={form?.error}
|
||||||
|
{enhanceCommand}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<details class="usage-editor">
|
|
||||||
<summary>Bearbeiten und verschieben</summary>
|
|
||||||
<form
|
|
||||||
use:enhance={enhanceCommand}
|
|
||||||
method="POST"
|
|
||||||
action="?/updateUsage"
|
|
||||||
class="usage-edit-form"
|
|
||||||
>
|
|
||||||
<input type="hidden" name="revision" value={data.show.revision} /><input
|
|
||||||
type="hidden"
|
|
||||||
name="usageId"
|
|
||||||
value={usage.id}
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
>Titel<input
|
|
||||||
name="title"
|
|
||||||
required
|
|
||||||
maxlength="200"
|
|
||||||
value={usage.title}
|
|
||||||
/></label
|
|
||||||
><label
|
|
||||||
>Dauer in Minuten<input
|
|
||||||
name="durationMinutes"
|
|
||||||
type="number"
|
|
||||||
min="0"
|
|
||||||
max="1440"
|
|
||||||
step="any"
|
|
||||||
value={durationInMinutes(usage.durationSeconds)}
|
|
||||||
/></label
|
|
||||||
>
|
|
||||||
<label class="wide-field"
|
|
||||||
>Eigene Notizen<textarea name="ownNotes" rows="2"
|
|
||||||
>{usage.ownNotes}</textarea
|
|
||||||
></label
|
|
||||||
><label class="wide-field"
|
|
||||||
>Einleitung<textarea name="intro" rows="2">{usage.intro}</textarea
|
|
||||||
></label
|
|
||||||
><label class="wide-field"
|
|
||||||
>Recherche<textarea name="research" rows="2"
|
|
||||||
>{usage.research}</textarea
|
|
||||||
></label
|
|
||||||
><label class="wide-field"
|
|
||||||
>Moderation<textarea name="moderation" rows="2"
|
|
||||||
>{usage.moderation}</textarea
|
|
||||||
></label
|
|
||||||
><label class="wide-field"
|
|
||||||
>Überleitung<textarea name="transition" rows="2"
|
|
||||||
>{usage.transition}</textarea
|
|
||||||
></label
|
|
||||||
><label class="wide-field"
|
|
||||||
>Präsentation<textarea name="presentation" rows="2"
|
|
||||||
>{usage.presentation}</textarea
|
|
||||||
></label
|
|
||||||
>
|
|
||||||
<input type="hidden" name="status" value={usage.status} /><button
|
|
||||||
class="primary-button wide-field"
|
|
||||||
type="submit">Verwendung speichern</button
|
|
||||||
>
|
|
||||||
</form>
|
|
||||||
<div class="usage-command-row">
|
|
||||||
<form use:enhance={enhanceCommand} method="POST" action="?/moveUsage">
|
|
||||||
<input
|
|
||||||
type="hidden"
|
|
||||||
name="revision"
|
|
||||||
value={data.show.revision}
|
|
||||||
/><input type="hidden" name="usageId" value={usage.id} /><input
|
|
||||||
type="hidden"
|
|
||||||
name="position"
|
|
||||||
value="9999"
|
|
||||||
/><label
|
|
||||||
>Ziel<select name="sectionId"
|
|
||||||
><option value="">Reservebank</option
|
|
||||||
>{#each data.show.sections as target (target.id)}<option
|
|
||||||
value={target.id}
|
|
||||||
selected={target.id === section.id}>{target.name}</option
|
|
||||||
>{/each}</select
|
|
||||||
></label
|
|
||||||
><button class="secondary-button" type="submit">Verschieben</button>
|
|
||||||
</form>
|
|
||||||
<form
|
|
||||||
use:enhance={enhanceCommand}
|
|
||||||
method="POST"
|
|
||||||
action="?/removeUsage"
|
|
||||||
onsubmit={(event) =>
|
|
||||||
!confirm('Verwendung aus der Sendung entfernen?') &&
|
|
||||||
event.preventDefault()}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="hidden"
|
|
||||||
name="revision"
|
|
||||||
value={data.show.revision}
|
|
||||||
/><input type="hidden" name="usageId" value={usage.id} /><button
|
|
||||||
class="text-button danger-text"
|
|
||||||
type="submit">Entfernen</button
|
|
||||||
>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -811,6 +781,14 @@
|
|||||||
aria-label={`${usage.title} aus Reserve entfernen`}>Entfernen</button
|
aria-label={`${usage.title} aus Reserve entfernen`}>Entfernen</button
|
||||||
>
|
>
|
||||||
</form>
|
</form>
|
||||||
|
<UsageEditorDialog
|
||||||
|
{usage}
|
||||||
|
revision={data.show.revision}
|
||||||
|
sectionId=""
|
||||||
|
sections={data.show.sections}
|
||||||
|
error={form?.error}
|
||||||
|
{enhanceCommand}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
+654
-22
@@ -1,4 +1,5 @@
|
|||||||
import { expect, test, type Page } from '@playwright/test';
|
import { expect, test, type Page } from '@playwright/test';
|
||||||
|
import Database from 'better-sqlite3';
|
||||||
import { readFileSync, readdirSync } from 'node:fs';
|
import { readFileSync, readdirSync } from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
@@ -29,6 +30,16 @@ async function setTheme(page: Page, theme: 'light' | 'dark') {
|
|||||||
await page.evaluate((value) => localStorage.setItem('sendewerk-theme', value), theme);
|
await page.evaluate((value) => localStorage.setItem('sendewerk-theme', value), theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function openEditorialField(page: Page, heading: string) {
|
||||||
|
if (heading.includes('Recherche')) {
|
||||||
|
await page.getByRole('button', { name: 'Recherche & Quellen' }).click();
|
||||||
|
} else if (heading.includes('Präsentation')) {
|
||||||
|
await page.getByRole('button', { name: 'Präsentation', exact: true }).click();
|
||||||
|
} else {
|
||||||
|
await page.getByRole('button', { name: 'Sendungstext', exact: true }).click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function login(page: Page, email = adminEmail, password = adminPassword) {
|
async function login(page: Page, email = adminEmail, password = adminPassword) {
|
||||||
await page.goto('/login');
|
await page.goto('/login');
|
||||||
await page.getByLabel('E-Mail').fill(email);
|
await page.getByLabel('E-Mail').fill(email);
|
||||||
@@ -61,6 +72,124 @@ function latestMailLink(subject: string): string {
|
|||||||
return match[0];
|
return match[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSentHistoryFixture(pieceId: string) {
|
||||||
|
const dataDirectory = process.env.SENDEWERK_E2E_DATA_DIR;
|
||||||
|
if (!dataDirectory) throw new Error('E2E-Datenverzeichnis ist nicht konfiguriert.');
|
||||||
|
const database = new Database(path.join(dataDirectory, 'e2e.sqlite'));
|
||||||
|
database.pragma('foreign_keys = ON');
|
||||||
|
const insertShow = database.prepare(
|
||||||
|
`INSERT INTO shows (id, title, starts_at_utc, twitch_title, announcement_text, status,
|
||||||
|
revision, created_at_utc, updated_at_utc) VALUES (?, ?, ?, '', '', 'completed', 1, ?, ?)`
|
||||||
|
);
|
||||||
|
const insertSection = database.prepare(
|
||||||
|
`INSERT INTO show_sections (id, show_id, name, category_id, position,
|
||||||
|
explicit_duration_seconds, is_reserve_bank) VALUES (?, ?, 'Ablauf', NULL, 0, NULL, 0)`
|
||||||
|
);
|
||||||
|
const insertUsage = database.prepare(
|
||||||
|
`INSERT INTO piece_usages (id, show_section_id, original_piece_id, position, status,
|
||||||
|
duration_seconds, title_snapshot, intro_snapshot, research_snapshot, moderation_snapshot,
|
||||||
|
transition_snapshot, presentation_snapshot, own_notes, is_reserve)
|
||||||
|
VALUES (?, ?, ?, 0, 'done', 300, 'Historische Verwendung', '', '', '', '', '', '', 0)`
|
||||||
|
);
|
||||||
|
database.transaction(() => {
|
||||||
|
for (const [suffix, title, date] of [
|
||||||
|
['older', 'Rückblick im September', '2026-09-10T18:00:00.000Z'],
|
||||||
|
['latest', 'Rückblick im Oktober', '2026-10-10T18:00:00.000Z']
|
||||||
|
] as const) {
|
||||||
|
const showId = `e2e-history-${suffix}`;
|
||||||
|
const sectionId = `e2e-history-section-${suffix}`;
|
||||||
|
insertShow.run(showId, title, date, date, date);
|
||||||
|
insertSection.run(sectionId, showId);
|
||||||
|
insertUsage.run(`e2e-history-usage-${suffix}`, sectionId, pieceId);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeSentHistoryFixture() {
|
||||||
|
const dataDirectory = process.env.SENDEWERK_E2E_DATA_DIR;
|
||||||
|
if (!dataDirectory) return;
|
||||||
|
const database = new Database(path.join(dataDirectory, 'e2e.sqlite'));
|
||||||
|
database.pragma('foreign_keys = ON');
|
||||||
|
database.prepare("DELETE FROM shows WHERE id LIKE 'e2e-history-%'").run();
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPresentationFixture() {
|
||||||
|
const dataDirectory = process.env.SENDEWERK_E2E_DATA_DIR;
|
||||||
|
if (!dataDirectory) throw new Error('E2E-Datenverzeichnis ist nicht konfiguriert.');
|
||||||
|
const database = new Database(path.join(dataDirectory, 'e2e.sqlite'));
|
||||||
|
database.pragma('foreign_keys = ON');
|
||||||
|
const now = '2026-10-22T19:00:00.000Z';
|
||||||
|
database.transaction(() => {
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO shows (id, title, starts_at_utc, twitch_title, announcement_text, status,
|
||||||
|
revision, created_at_utc, updated_at_utc)
|
||||||
|
VALUES ('e2e-presentation', 'E2E Präsentation', ?, '', '', 'ready', 1, ?, ?)`
|
||||||
|
)
|
||||||
|
.run(now, now, now);
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
`INSERT INTO show_sections (id, show_id, name, category_id, position,
|
||||||
|
explicit_duration_seconds, is_reserve_bank)
|
||||||
|
VALUES ('e2e-presentation-section', 'e2e-presentation', 'Player', NULL, 0, NULL, 0),
|
||||||
|
('e2e-presentation-reserve', 'e2e-presentation', 'Reservebank', NULL, 1, NULL, 1)`
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
const insert = database.prepare(
|
||||||
|
`INSERT INTO piece_usages (id, show_section_id, original_piece_id, position, status,
|
||||||
|
duration_seconds, title_snapshot, intro_snapshot, research_snapshot, moderation_snapshot,
|
||||||
|
transition_snapshot, presentation_snapshot, own_notes, is_reserve,
|
||||||
|
presentation_mode_snapshot, presentation_source_label_snapshot,
|
||||||
|
presentation_source_url_snapshot, presentation_source_timecode_snapshot,
|
||||||
|
presentation_title_meta_snapshot, presentation_description_snapshot,
|
||||||
|
presentation_image_url_snapshot, presentation_site_name_snapshot,
|
||||||
|
presentation_provider_snapshot, presentation_provider_id_snapshot)
|
||||||
|
VALUES (?, 'e2e-presentation-section', NULL, ?, 'open', 300, ?, '', ?, ?, '', '', '', 0,
|
||||||
|
'video', ?, ?, ?, ?, '', '', ?, ?, ?)`
|
||||||
|
);
|
||||||
|
insert.run(
|
||||||
|
'e2e-youtube',
|
||||||
|
0,
|
||||||
|
'YouTube Kurzlink',
|
||||||
|
'PRIVATE_RESEARCH_YOUTUBE',
|
||||||
|
'PRIVATE_MODERATION_YOUTUBE',
|
||||||
|
'YouTube',
|
||||||
|
'https://youtu.be/dQw4w9WgXcQ',
|
||||||
|
75,
|
||||||
|
'YouTube Vorschau',
|
||||||
|
'YouTube',
|
||||||
|
'youtube',
|
||||||
|
'dQw4w9WgXcQ'
|
||||||
|
);
|
||||||
|
insert.run(
|
||||||
|
'e2e-tiktok',
|
||||||
|
1,
|
||||||
|
'TikTok Hochformat',
|
||||||
|
'PRIVATE_RESEARCH_TIKTOK',
|
||||||
|
'PRIVATE_MODERATION_TIKTOK',
|
||||||
|
'TikTok',
|
||||||
|
'https://www.tiktok.com/@scout2015/video/6718335390845095173',
|
||||||
|
12,
|
||||||
|
'TikTok Vorschau',
|
||||||
|
'TikTok',
|
||||||
|
'tiktok',
|
||||||
|
'6718335390845095173'
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function removePresentationFixture() {
|
||||||
|
const dataDirectory = process.env.SENDEWERK_E2E_DATA_DIR;
|
||||||
|
if (!dataDirectory) return;
|
||||||
|
const database = new Database(path.join(dataDirectory, 'e2e.sqlite'));
|
||||||
|
database.pragma('foreign_keys = ON');
|
||||||
|
database.prepare("DELETE FROM shows WHERE id = 'e2e-presentation'").run();
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
test.beforeAll(async ({ browser }) => {
|
test.beforeAll(async ({ browser }) => {
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
@@ -176,6 +305,8 @@ test('desktop fundus is a compact, filterable list with persistent themes', asyn
|
|||||||
await expect(page.locator('.sidebar')).toBeVisible();
|
await expect(page.locator('.sidebar')).toBeVisible();
|
||||||
await expect(page.locator('.mobile-navigation')).toBeHidden();
|
await expect(page.locator('.mobile-navigation')).toBeHidden();
|
||||||
await expect(page.locator('.utility-navigation a')).toHaveText('Verwaltung');
|
await expect(page.locator('.utility-navigation a')).toHaveText('Verwaltung');
|
||||||
|
await expect(page.locator('.piece-card')).toHaveCount(1);
|
||||||
|
await page.getByLabel('Auch eingeplante Inhalte zeigen').check();
|
||||||
await expect(page.locator('.piece-card')).toHaveCount(4);
|
await expect(page.locator('.piece-card')).toHaveCount(4);
|
||||||
|
|
||||||
const firstRow = await page.locator('.piece-card').nth(0).boundingBox();
|
const firstRow = await page.locator('.piece-card').nth(0).boundingBox();
|
||||||
@@ -193,8 +324,8 @@ test('desktop fundus is a compact, filterable list with persistent themes', asyn
|
|||||||
await page.getByLabel('Status').selectOption('preparing');
|
await page.getByLabel('Status').selectOption('preparing');
|
||||||
await page.getByRole('button', { name: 'Anwenden' }).click();
|
await page.getByRole('button', { name: 'Anwenden' }).click();
|
||||||
await expect(page.getByRole('heading', { name: 'Kein passendes Piece' })).toBeVisible();
|
await expect(page.getByRole('heading', { name: 'Kein passendes Piece' })).toBeVisible();
|
||||||
await page.getByRole('link', { name: 'Filter zurücksetzen' }).click();
|
await page.getByRole('button', { name: 'Zurücksetzen' }).click();
|
||||||
await expect(page.locator('.piece-card')).toHaveCount(4);
|
await expect(page.locator('.piece-card')).toHaveCount(1);
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Darstellung: System' }).click();
|
await page.getByRole('button', { name: 'Darstellung: System' }).click();
|
||||||
await expect(page.locator('html')).toHaveAttribute('data-theme-preference', 'light');
|
await expect(page.locator('html')).toHaveAttribute('data-theme-preference', 'light');
|
||||||
@@ -205,6 +336,118 @@ test('desktop fundus is a compact, filterable list with persistent themes', asyn
|
|||||||
await page.screenshot({ path: testInfo.outputPath('fundus-desktop-light.png'), fullPage: true });
|
await page.screenshot({ path: testInfo.outputPath('fundus-desktop-light.png'), fullPage: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('sent and planned source filters stay independent and removing the last usage offers the piece again', async ({
|
||||||
|
page
|
||||||
|
}, testInfo) => {
|
||||||
|
addSentHistoryFixture('piece-effects');
|
||||||
|
try {
|
||||||
|
await page.goto('/fundus');
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: 'Warum praktische Effekte wieder auffallen' })
|
||||||
|
).toHaveCount(0);
|
||||||
|
await page.evaluate(() => (document.body.dataset.filterDocument = 'stable'));
|
||||||
|
await page.getByLabel('Auch verwendete Inhalte zeigen').check();
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: 'Warum praktische Effekte wieder auffallen' })
|
||||||
|
).toHaveCount(0);
|
||||||
|
await page.getByLabel('Auch eingeplante Inhalte zeigen').check();
|
||||||
|
const usedPiece = page
|
||||||
|
.locator('.piece-card')
|
||||||
|
.filter({ hasText: 'Warum praktische Effekte wieder auffallen' });
|
||||||
|
await expect(usedPiece).toBeVisible();
|
||||||
|
await expect(usedPiece).toContainText('Gesendet am 10.10.2026');
|
||||||
|
await expect(usedPiece).toContainText('+ 1 weitere');
|
||||||
|
await expect(usedPiece.getByRole('link', { name: 'Rückblick im Oktober' })).toHaveAttribute(
|
||||||
|
'href',
|
||||||
|
'/sendungen/e2e-history-latest'
|
||||||
|
);
|
||||||
|
await usedPiece.getByText('Vollständige Verwendungshistorie').click();
|
||||||
|
await expect(usedPiece.locator('.piece-usage-history li')).toHaveCount(2);
|
||||||
|
await expect(page.locator('body')).toHaveAttribute('data-filter-document', 'stable');
|
||||||
|
await page.getByRole('searchbox', { name: 'Fundus durchsuchen' }).fill('praktische Effekte');
|
||||||
|
await page.getByRole('button', { name: 'Anwenden' }).click();
|
||||||
|
await expect(page.getByLabel('Auch verwendete Inhalte zeigen')).toBeChecked();
|
||||||
|
await expect(usedPiece).toBeVisible();
|
||||||
|
await page.screenshot({
|
||||||
|
path: testInfo.outputPath('fundus-verwendungshistorie-desktop.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.goto('/sendungen');
|
||||||
|
await page.getByLabel('Titel').fill('E2E Filterprüfung');
|
||||||
|
await page.getByLabel('Ausgangspunkt').selectOption('template-default');
|
||||||
|
await page.getByRole('button', { name: 'Sendung anlegen' }).click();
|
||||||
|
await page.getByPlaceholder('Fundus durchsuchen').fill('kleine Konsole');
|
||||||
|
await page.getByRole('button', { name: 'Filtern' }).click();
|
||||||
|
const consolePiece = page
|
||||||
|
.locator('.builder-source-card')
|
||||||
|
.filter({ hasText: 'Die kleine Konsole mit dem großen Dreh' });
|
||||||
|
await consolePiece.getByRole('button', { name: 'Hinzufügen' }).click();
|
||||||
|
await expect(consolePiece).toHaveCount(0);
|
||||||
|
|
||||||
|
await page.getByPlaceholder('Fundus durchsuchen').fill('');
|
||||||
|
await page.getByRole('button', { name: 'Filtern' }).click();
|
||||||
|
await page.getByLabel('Auch eingeplante Inhalte zeigen').check();
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('.builder-source-card')
|
||||||
|
.filter({ hasText: 'Die kleine Konsole mit dem großen Dreh' })
|
||||||
|
).toContainText('Eingeplant');
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('.builder-source-card')
|
||||||
|
.filter({ hasText: 'Warum praktische Effekte wieder auffallen' })
|
||||||
|
).toHaveCount(0);
|
||||||
|
await page.getByPlaceholder('Fundus durchsuchen').fill('kleine Konsole');
|
||||||
|
await page.getByRole('button', { name: 'Filtern' }).click();
|
||||||
|
await expect(page.getByLabel('Auch eingeplante Inhalte zeigen')).toBeChecked();
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('.builder-source-card')
|
||||||
|
.filter({ hasText: 'Die kleine Konsole mit dem großen Dreh' })
|
||||||
|
).toContainText('Eingeplant');
|
||||||
|
await page.getByPlaceholder('Fundus durchsuchen').fill('');
|
||||||
|
await page.getByRole('button', { name: 'Filtern' }).click();
|
||||||
|
|
||||||
|
await page.getByLabel('Auch eingeplante Inhalte zeigen').uncheck();
|
||||||
|
await page.getByLabel('Auch verwendete Inhalte zeigen').check();
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('.builder-source-card')
|
||||||
|
.filter({ hasText: 'Die kleine Konsole mit dem großen Dreh' })
|
||||||
|
).toHaveCount(0);
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('.builder-source-card')
|
||||||
|
.filter({ hasText: 'Warum praktische Effekte wieder auffallen' })
|
||||||
|
).toContainText('Rückblick im Oktober');
|
||||||
|
await page.screenshot({
|
||||||
|
path: testInfo.outputPath('sendungsfilter-desktop.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
|
||||||
|
await page
|
||||||
|
.locator('.reserve-usage')
|
||||||
|
.getByRole('button', { name: /aus Reserve entfernen/ })
|
||||||
|
.click();
|
||||||
|
await page.getByLabel('Auch verwendete Inhalte zeigen').uncheck();
|
||||||
|
await expect(
|
||||||
|
page
|
||||||
|
.locator('.builder-source-card')
|
||||||
|
.filter({ hasText: 'Die kleine Konsole mit dem großen Dreh' })
|
||||||
|
).toBeVisible();
|
||||||
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
|
await page.getByRole('button', { name: 'Fundus', exact: true }).click();
|
||||||
|
await expectNoHorizontalOverflow(page);
|
||||||
|
await page.screenshot({
|
||||||
|
path: testInfo.outputPath('sendungsfilter-mobile.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
removeSentHistoryFixture();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('desktop builder keeps the fundus beside the wider run sheet', async ({ page }, testInfo) => {
|
test('desktop builder keeps the fundus beside the wider run sheet', async ({ page }, testInfo) => {
|
||||||
await page.setViewportSize({ width: 1280, height: 900 });
|
await page.setViewportSize({ width: 1280, height: 900 });
|
||||||
await page.goto('/fundus');
|
await page.goto('/fundus');
|
||||||
@@ -322,10 +565,12 @@ test('a show can be planned from a template with independent usages and reserve'
|
|||||||
await expect(source).toHaveClass(/is-dragging/);
|
await expect(source).toHaveClass(/is-dragging/);
|
||||||
await expect(source).toHaveCSS('opacity', '0.45');
|
await expect(source).toHaveCSS('opacity', '0.45');
|
||||||
await emptyReactionTarget.dispatchEvent('drop', { dataTransfer });
|
await emptyReactionTarget.dispatchEvent('drop', { dataTransfer });
|
||||||
await sourceDragHandle.dispatchEvent('dragend', { dataTransfer });
|
|
||||||
await dataTransfer.dispose();
|
await dataTransfer.dispose();
|
||||||
await expect(reactionSection.locator('.editable-usage')).toHaveCount(1);
|
await expect(reactionSection.locator('.editable-usage')).toHaveCount(1);
|
||||||
await expect(page.locator('body')).toHaveAttribute('data-builder-document', 'stable');
|
await expect(page.locator('body')).toHaveAttribute('data-builder-document', 'stable');
|
||||||
|
await expect(source).toHaveCount(0);
|
||||||
|
await page.getByLabel('Auch eingeplante Inhalte zeigen').check();
|
||||||
|
await expect(source).toContainText('Eingeplant');
|
||||||
await sourceDragHandle.dragTo(reactionSection.locator('.editable-usage'));
|
await sourceDragHandle.dragTo(reactionSection.locator('.editable-usage'));
|
||||||
|
|
||||||
let usages = page
|
let usages = page
|
||||||
@@ -333,7 +578,41 @@ test('a show can be planned from a template with independent usages and reserve'
|
|||||||
.filter({ has: page.getByRole('heading', { name: 'JC / Reaction' }) })
|
.filter({ has: page.getByRole('heading', { name: 'JC / Reaction' }) })
|
||||||
.locator('.editable-usage');
|
.locator('.editable-usage');
|
||||||
await expect(usages).toHaveCount(2);
|
await expect(usages).toHaveCount(2);
|
||||||
await usages.nth(0).locator('summary').click();
|
await usages
|
||||||
|
.nth(0)
|
||||||
|
.getByRole('button', {
|
||||||
|
name: 'Die kleine Konsole mit dem großen Dreh bearbeiten und verschieben'
|
||||||
|
})
|
||||||
|
.click();
|
||||||
|
await expect(page.locator('dialog[open]')).toContainText('Sendungsspezifische Kopie');
|
||||||
|
const desktopEditorItems = await page
|
||||||
|
.locator('dialog[open] .usage-dialog-editor')
|
||||||
|
.evaluate((element) =>
|
||||||
|
Array.from(element.children)
|
||||||
|
.filter((child) => child.matches('section, button'))
|
||||||
|
.map((child) => child.getBoundingClientRect().top)
|
||||||
|
);
|
||||||
|
expect(Math.abs(desktopEditorItems[0] - desktopEditorItems[1])).toBeLessThan(2);
|
||||||
|
expect(desktopEditorItems[2]).toBeGreaterThan(desktopEditorItems[1]);
|
||||||
|
await page.screenshot({
|
||||||
|
path: testInfo.outputPath('verwendungseditor-desktop.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
await page
|
||||||
|
.locator('dialog[open]')
|
||||||
|
.getByRole('button', { name: 'Aus Fundus aktualisieren' })
|
||||||
|
.click();
|
||||||
|
await expect(page.locator('dialog[open]')).toHaveCount(0);
|
||||||
|
usages = page
|
||||||
|
.locator('.run-section')
|
||||||
|
.filter({ has: page.getByRole('heading', { name: 'JC / Reaction' }) })
|
||||||
|
.locator('.editable-usage');
|
||||||
|
await usages
|
||||||
|
.nth(0)
|
||||||
|
.getByRole('button', {
|
||||||
|
name: 'Die kleine Konsole mit dem großen Dreh bearbeiten und verschieben'
|
||||||
|
})
|
||||||
|
.click();
|
||||||
await usages.nth(0).getByLabel('Titel').fill('Konsole als Auftakt');
|
await usages.nth(0).getByLabel('Titel').fill('Konsole als Auftakt');
|
||||||
await usages.nth(0).getByLabel('Dauer in Minuten').fill('5');
|
await usages.nth(0).getByLabel('Dauer in Minuten').fill('5');
|
||||||
await usages.nth(0).getByLabel('Eigene Notizen').fill('Kurbel zuerst zeigen');
|
await usages.nth(0).getByLabel('Eigene Notizen').fill('Kurbel zuerst zeigen');
|
||||||
@@ -344,20 +623,51 @@ test('a show can be planned from a template with independent usages and reserve'
|
|||||||
.locator('.run-section')
|
.locator('.run-section')
|
||||||
.filter({ has: page.getByRole('heading', { name: 'JC / Reaction' }) })
|
.filter({ has: page.getByRole('heading', { name: 'JC / Reaction' }) })
|
||||||
.locator('.editable-usage');
|
.locator('.editable-usage');
|
||||||
await usages.nth(1).locator('summary').click();
|
await usages
|
||||||
|
.nth(1)
|
||||||
|
.getByRole('button', {
|
||||||
|
name: 'Die kleine Konsole mit dem großen Dreh bearbeiten und verschieben'
|
||||||
|
})
|
||||||
|
.click();
|
||||||
await usages.nth(1).getByLabel('Titel').fill('Konsole als Rückblick');
|
await usages.nth(1).getByLabel('Titel').fill('Konsole als Rückblick');
|
||||||
await usages.nth(1).getByLabel('Dauer in Minuten').fill('15');
|
await usages.nth(1).getByLabel('Dauer in Minuten').fill('15');
|
||||||
await usages.nth(1).getByLabel('Eigene Notizen').fill('Andere Perspektive');
|
await usages.nth(1).getByLabel('Eigene Notizen').fill('Andere Perspektive');
|
||||||
await usages.nth(1).getByRole('button', { name: 'Verwendung speichern' }).click();
|
await usages.nth(1).getByRole('button', { name: 'Verwendung speichern' }).click();
|
||||||
await expect(page.locator('.show-summary')).toContainText('2 Std. 25 Min.');
|
await expect(page.locator('.show-summary')).toContainText('2 Std. 25 Min.');
|
||||||
|
|
||||||
|
usages = page
|
||||||
|
.locator('.run-section')
|
||||||
|
.filter({ has: page.getByRole('heading', { name: 'JC / Reaction' }) })
|
||||||
|
.locator('.editable-usage');
|
||||||
|
await usages
|
||||||
|
.nth(1)
|
||||||
|
.getByRole('button', { name: 'Konsole als Rückblick bearbeiten und verschieben' })
|
||||||
|
.click();
|
||||||
|
await usages.nth(1).getByRole('button', { name: 'Duplizieren' }).click();
|
||||||
|
await expect(reactionSection.locator('.editable-usage')).toHaveCount(3);
|
||||||
|
await expect(reactionSection.locator('.editable-usage').nth(2)).toContainText(
|
||||||
|
'Konsole als Rückblick'
|
||||||
|
);
|
||||||
|
await expect(page.locator('.show-summary')).toContainText('2 Std. 40 Min.');
|
||||||
|
|
||||||
const planTimeBeforeReserve = await page.locator('.show-summary').textContent();
|
const planTimeBeforeReserve = await page.locator('.show-summary').textContent();
|
||||||
await source.getByLabel(/Ziel für/).selectOption('');
|
await source.getByLabel(/Ziel für/).selectOption('');
|
||||||
await source.getByRole('button', { name: 'Hinzufügen' }).click();
|
await source.getByRole('button', { name: 'Hinzufügen' }).click();
|
||||||
await expect(page.locator('.reserve-usage')).toHaveCount(1);
|
await expect(page.locator('.reserve-usage')).toHaveCount(1);
|
||||||
expect(await page.locator('.show-summary').textContent()).toBe(planTimeBeforeReserve);
|
expect(await page.locator('.show-summary').textContent()).toBe(planTimeBeforeReserve);
|
||||||
|
await page
|
||||||
|
.locator('.reserve-usage')
|
||||||
|
.getByRole('button', {
|
||||||
|
name: 'Die kleine Konsole mit dem großen Dreh bearbeiten und verschieben'
|
||||||
|
})
|
||||||
|
.click();
|
||||||
|
await expect(page.locator('dialog[open]')).toContainText('Sendungsspezifische Kopie');
|
||||||
|
await expect(
|
||||||
|
page.locator('dialog[open]').getByRole('button', { name: 'Duplizieren' })
|
||||||
|
).toBeVisible();
|
||||||
|
await page.locator('dialog[open]').getByRole('button', { name: 'Editor schließen' }).click();
|
||||||
|
|
||||||
const moveUp = page.getByRole('button', { name: 'Konsole als Rückblick nach oben' });
|
const moveUp = page.getByRole('button', { name: 'Konsole als Rückblick nach oben' }).first();
|
||||||
await moveUp.focus();
|
await moveUp.focus();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await expect(
|
await expect(
|
||||||
@@ -384,12 +694,60 @@ test('a show can be planned from a template with independent usages and reserve'
|
|||||||
await expect(page.locator('.reserve-usage')).toHaveCount(0);
|
await expect(page.locator('.reserve-usage')).toHaveCount(0);
|
||||||
await expect(page.locator('body')).toHaveAttribute('data-builder-document', 'stable');
|
await expect(page.locator('body')).toHaveAttribute('data-builder-document', 'stable');
|
||||||
await page.reload();
|
await page.reload();
|
||||||
await expect(page.locator('.editable-usage')).toHaveCount(3);
|
await expect(page.locator('.editable-usage')).toHaveCount(4);
|
||||||
const savedUsage = page.locator('.editable-usage').filter({ hasText: 'Konsole als Auftakt' });
|
const savedUsage = page.locator('.editable-usage').filter({ hasText: 'Konsole als Auftakt' });
|
||||||
await savedUsage.locator('summary').click();
|
await savedUsage
|
||||||
|
.getByRole('button', { name: 'Konsole als Auftakt bearbeiten und verschieben' })
|
||||||
|
.click();
|
||||||
await expect(savedUsage.getByLabel('Eigene Notizen')).toHaveValue('Kurbel zuerst zeigen');
|
await expect(savedUsage.getByLabel('Eigene Notizen')).toHaveValue('Kurbel zuerst zeigen');
|
||||||
|
await page.locator('dialog[open]').getByRole('button', { name: 'Editor schließen' }).click();
|
||||||
|
const duplicatedUsage = page
|
||||||
|
.locator('.editable-usage')
|
||||||
|
.filter({ hasText: 'Konsole als Rückblick' });
|
||||||
|
await expect(duplicatedUsage).toHaveCount(2);
|
||||||
|
await duplicatedUsage
|
||||||
|
.nth(1)
|
||||||
|
.getByRole('button', { name: 'Konsole als Rückblick bearbeiten und verschieben' })
|
||||||
|
.click();
|
||||||
|
await expect(duplicatedUsage.nth(1).getByLabel('Dauer in Minuten')).toHaveValue('15');
|
||||||
|
await expect(duplicatedUsage.nth(1).getByLabel('Eigene Notizen')).toHaveValue(
|
||||||
|
'Andere Perspektive'
|
||||||
|
);
|
||||||
|
await page.locator('dialog[open]').getByRole('button', { name: 'Editor schließen' }).click();
|
||||||
|
|
||||||
await page.setViewportSize({ width: 390, height: 844 });
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
|
await savedUsage
|
||||||
|
.getByRole('button', { name: 'Konsole als Auftakt bearbeiten und verschieben' })
|
||||||
|
.click();
|
||||||
|
const mobileEditorItems = await page
|
||||||
|
.locator('dialog[open] .usage-dialog-editor')
|
||||||
|
.evaluate((element) =>
|
||||||
|
Array.from(element.children)
|
||||||
|
.filter((child) => child.matches('section, button'))
|
||||||
|
.map((child) => child.getBoundingClientRect().top)
|
||||||
|
);
|
||||||
|
expect(mobileEditorItems[1]).toBeGreaterThan(mobileEditorItems[0]);
|
||||||
|
expect(mobileEditorItems[2]).toBeGreaterThan(mobileEditorItems[1]);
|
||||||
|
await expectNoHorizontalOverflow(page);
|
||||||
|
await page.screenshot({
|
||||||
|
path: testInfo.outputPath('verwendungseditor-mobile.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
await page
|
||||||
|
.locator('dialog[open]')
|
||||||
|
.getByRole('button', { name: 'Entfernen' })
|
||||||
|
.scrollIntoViewIfNeeded();
|
||||||
|
await expect(
|
||||||
|
page.locator('dialog[open]').getByRole('button', { name: 'Entfernen' })
|
||||||
|
).toBeVisible();
|
||||||
|
await page
|
||||||
|
.locator('dialog[open] form[action="?/updateUsage"] input[name="revision"]')
|
||||||
|
.evaluate((element) => ((element as HTMLInputElement).value = '1'));
|
||||||
|
await page.locator('dialog[open]').getByRole('button', { name: 'Verwendung speichern' }).click();
|
||||||
|
await expect(page.locator('dialog[open]').getByRole('alert')).toContainText(
|
||||||
|
'inzwischen geändert'
|
||||||
|
);
|
||||||
|
await page.locator('dialog[open]').getByRole('button', { name: 'Editor schließen' }).click();
|
||||||
await page.getByRole('button', { name: 'Ablauf', exact: true }).click();
|
await page.getByRole('button', { name: 'Ablauf', exact: true }).click();
|
||||||
await page.getByPlaceholder('Neuer Abschnitt').fill('Finales Spiel');
|
await page.getByPlaceholder('Neuer Abschnitt').fill('Finales Spiel');
|
||||||
await page.getByRole('button', { name: 'Abschnitt hinzufügen' }).click();
|
await page.getByRole('button', { name: 'Abschnitt hinzufügen' }).click();
|
||||||
@@ -397,7 +755,7 @@ test('a show can be planned from a template with independent usages and reserve'
|
|||||||
await expectNoHorizontalOverflow(page);
|
await expectNoHorizontalOverflow(page);
|
||||||
await page.screenshot({ path: testInfo.outputPath('sendungsbau-mobile.png'), fullPage: true });
|
await page.screenshot({ path: testInfo.outputPath('sendungsbau-mobile.png'), fullPage: true });
|
||||||
|
|
||||||
await page.goto('/fundus?q=kleine+Konsole');
|
await page.goto('/fundus?q=kleine+Konsole&includePlanned=1');
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('heading', { name: 'Die kleine Konsole mit dem großen Dreh' })
|
page.getByRole('heading', { name: 'Die kleine Konsole mit dem großen Dreh' })
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
@@ -430,7 +788,7 @@ test('all work areas fit at required widths in light and dark mode', async ({ pa
|
|||||||
test('long titles and longer fundus lists reflow without overflow', async ({ page }, testInfo) => {
|
test('long titles and longer fundus lists reflow without overflow', async ({ page }, testInfo) => {
|
||||||
await page.setViewportSize({ width: 1280, height: 900 });
|
await page.setViewportSize({ width: 1280, height: 900 });
|
||||||
await page.goto('/fundus');
|
await page.goto('/fundus');
|
||||||
await expect(page.locator('.piece-card')).toHaveCount(4);
|
await expect(page.locator('.piece-card')).toHaveCount(1);
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const list = document.querySelector('.piece-grid');
|
const list = document.querySelector('.piece-grid');
|
||||||
const rows = Array.from(document.querySelectorAll('.piece-card'));
|
const rows = Array.from(document.querySelectorAll('.piece-card'));
|
||||||
@@ -444,7 +802,7 @@ test('long titles and longer fundus lists reflow without overflow', async ({ pag
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await expect(page.locator('.piece-card')).toHaveCount(16);
|
await expect(page.locator('.piece-card')).toHaveCount(4);
|
||||||
await expectNoHorizontalOverflow(page);
|
await expectNoHorizontalOverflow(page);
|
||||||
await page.setViewportSize({ width: 390, height: 844 });
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
await expectNoHorizontalOverflow(page);
|
await expectNoHorizontalOverflow(page);
|
||||||
@@ -486,22 +844,167 @@ test('inbox, archive and administration stay concise', async ({ page }) => {
|
|||||||
expect(boxes[1]?.y).toBe(boxes[2]?.y);
|
expect(boxes[1]?.y).toBe(boxes[2]?.y);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('live preview retains its existing readable controls', async ({ page }) => {
|
test('validated YouTube and TikTok players switch without exposing private fields', async ({
|
||||||
await page.setViewportSize({ width: 1280, height: 900 });
|
page
|
||||||
await page.goto('/live');
|
}, testInfo) => {
|
||||||
|
addPresentationFixture();
|
||||||
|
try {
|
||||||
|
await page.context().route('https://www.youtube-nocookie.com/**', (route) =>
|
||||||
|
route.fulfill({
|
||||||
|
contentType: 'text/html',
|
||||||
|
body: '<!doctype html><title>YouTube Test</title>'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await page.context().route('https://www.tiktok.com/player/**', (route) =>
|
||||||
|
route.fulfill({
|
||||||
|
contentType: 'text/html',
|
||||||
|
body: '<!doctype html><title>TikTok Test</title>'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await page.goto('/live?show=e2e-presentation');
|
||||||
|
const popupPromise = page.waitForEvent('popup');
|
||||||
|
await page.getByRole('button', { name: 'Präsentationsfenster öffnen' }).click();
|
||||||
|
const output = await popupPromise;
|
||||||
|
await output.waitForLoadState('networkidle');
|
||||||
|
await expect(output.getByText('Bereit für den nächsten Inhalt')).toBeVisible();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'YouTube Kurzlink präsentieren' }).click();
|
||||||
|
const youtube = output.locator('iframe[title="YouTube Vorschau"]');
|
||||||
|
await expect(youtube).toHaveAttribute(
|
||||||
|
'src',
|
||||||
|
'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?start=75'
|
||||||
|
);
|
||||||
|
await expect(output.locator('.output-connection')).toHaveClass(/sr-only/);
|
||||||
|
const publicState = await output.evaluate(async () =>
|
||||||
|
JSON.stringify(await fetch(`${location.pathname}/state`).then((response) => response.json()))
|
||||||
|
);
|
||||||
|
expect(publicState).not.toContain('PRIVATE_RESEARCH');
|
||||||
|
expect(publicState).not.toContain('PRIVATE_MODERATION');
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'TikTok Hochformat präsentieren' }).click();
|
||||||
|
await expect(youtube).toHaveCount(0);
|
||||||
|
await expect(output.locator('iframe[title="TikTok Vorschau"]')).toHaveAttribute(
|
||||||
|
'src',
|
||||||
|
'https://www.tiktok.com/player/v1/6718335390845095173?autoplay=0&controls=1'
|
||||||
|
);
|
||||||
|
await expect(output.getByRole('link', { name: 'Original öffnen' })).toHaveAttribute(
|
||||||
|
'href',
|
||||||
|
'https://www.tiktok.com/@scout2015/video/6718335390845095173'
|
||||||
|
);
|
||||||
|
await output.setViewportSize({ width: 390, height: 844 });
|
||||||
|
await expectNoHorizontalOverflow(output);
|
||||||
|
await output.screenshot({
|
||||||
|
path: testInfo.outputPath('heinzlive-video-mobile.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
await output.close();
|
||||||
|
} finally {
|
||||||
|
removePresentationFixture();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('live control persists state and exposes only explicit presentation data', async ({
|
||||||
|
page,
|
||||||
|
browser
|
||||||
|
}, testInfo) => {
|
||||||
|
await page.setViewportSize({ width: 1280, height: 900 });
|
||||||
|
await page.goto('/fundus?q=kleine+Konsole&includePlanned=1');
|
||||||
|
await page.getByRole('heading', { name: 'Die kleine Konsole mit dem großen Dreh' }).click();
|
||||||
|
const png = Buffer.from(
|
||||||
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
|
||||||
|
'base64'
|
||||||
|
);
|
||||||
|
await page.getByLabel('Bild', { exact: true }).setInputFiles({
|
||||||
|
name: 'live-konsole.png',
|
||||||
|
mimeType: 'image/png',
|
||||||
|
buffer: png
|
||||||
|
});
|
||||||
|
await page.getByLabel('Alternativtext').fill('Kleine Konsole im Live-Bild');
|
||||||
|
await page.getByRole('button', { name: 'Bild hochladen' }).click();
|
||||||
|
|
||||||
|
await page.goto('/live?show=show-october');
|
||||||
|
await expect(page.getByText('Noch nicht gestartet.')).toBeVisible();
|
||||||
|
await page.getByRole('button', { name: 'Sendung starten' }).click();
|
||||||
|
await expect(page.locator('#current-title')).toHaveText('Die kleine Konsole mit dem großen Dreh');
|
||||||
|
await expect(
|
||||||
|
page.getByText('Herstellerangaben gegen unabhängige Tests prüfen')
|
||||||
|
).not.toBeVisible();
|
||||||
|
|
||||||
await expect(page.getByText('Vorschau · Live-Modus', { exact: true })).toBeVisible();
|
|
||||||
await expect(page.getByText('Eine Kurbel, ein gelber Knopf und sehr viel Charme')).toBeVisible();
|
|
||||||
const before = await page
|
const before = await page
|
||||||
.locator('.live-current')
|
.locator('.live-current')
|
||||||
.evaluate((element) => getComputedStyle(element).getPropertyValue('--prompt-size'));
|
.evaluate((element) => getComputedStyle(element).getPropertyValue('--prompt-size'));
|
||||||
await page.getByRole('button', { name: 'Schrift vergrößern' }).click();
|
await page.getByRole('button', { name: 'Schrift vergrößern' }).click();
|
||||||
const after = await page
|
await page.reload();
|
||||||
|
const restored = await page
|
||||||
.locator('.live-current')
|
.locator('.live-current')
|
||||||
.evaluate((element) => getComputedStyle(element).getPropertyValue('--prompt-size'));
|
.evaluate((element) => getComputedStyle(element).getPropertyValue('--prompt-size'));
|
||||||
expect(after).not.toBe(before);
|
expect(restored).not.toBe(before);
|
||||||
await page.getByText('Recherche öffnen').click();
|
await page.getByText('Manuelle Recherche öffnen').click();
|
||||||
await expect(page.locator('.research-details')).toHaveAttribute('open', '');
|
await expect(page.locator('.research-details')).toHaveAttribute('open', '');
|
||||||
|
|
||||||
|
const [popup] = await Promise.all([
|
||||||
|
page.waitForEvent('popup'),
|
||||||
|
page.getByRole('button', { name: 'Präsentationsfenster öffnen' }).click()
|
||||||
|
]);
|
||||||
|
await popup.waitForURL(/\/heinzlive\/[A-Za-z0-9_-]+$/);
|
||||||
|
const outputUrl = popup.url();
|
||||||
|
const anonymous = await browser.newContext();
|
||||||
|
const output = await anonymous.newPage();
|
||||||
|
await output.goto(outputUrl);
|
||||||
|
await expect(
|
||||||
|
output.getByRole('heading', { name: 'Bereit für den nächsten Inhalt' })
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Präsentieren', exact: true }).click();
|
||||||
|
await expect(
|
||||||
|
output.getByRole('heading', { name: 'Die kleine Konsole mit dem großen Dreh' })
|
||||||
|
).toBeVisible({
|
||||||
|
timeout: 10_000
|
||||||
|
});
|
||||||
|
await expect(output.getByText('Weniger Leistung, mehr Idee.')).toBeVisible();
|
||||||
|
await expect(output.getByAltText('Kleine Konsole im Live-Bild')).toBeVisible();
|
||||||
|
await output.screenshot({ path: testInfo.outputPath('heinzlive-output.png'), fullPage: true });
|
||||||
|
const outputHtml = await output.content();
|
||||||
|
expect(outputHtml).not.toContain('Herstellerangaben');
|
||||||
|
expect(outputHtml).not.toContain('Erst Formfaktor zeigen');
|
||||||
|
expect(outputHtml).not.toContain(adminEmail);
|
||||||
|
expect(outputHtml).not.toContain('live-konsole.png');
|
||||||
|
const outputState = await anonymous.request.get(`${outputUrl}/state`);
|
||||||
|
expect(outputState.status()).toBe(200);
|
||||||
|
const outputJson = await outputState.text();
|
||||||
|
expect(outputJson).toContain('Weniger Leistung');
|
||||||
|
expect(outputJson).not.toContain('Herstellerangaben');
|
||||||
|
expect(outputJson).not.toContain('Moderationsstichpunkte');
|
||||||
|
expect(outputJson).not.toContain('live-konsole.png');
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Als Nächstes' }).click();
|
||||||
|
await expect(page.locator('.next-card')).toContainText('Pixelart');
|
||||||
|
await page.getByRole('button', { name: 'Erledigen und weiter' }).click();
|
||||||
|
await expect(page.locator('.live-current')).toContainText('Pixelart');
|
||||||
|
await page.getByRole('button', { name: 'Überspringen' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Zurück' }).click();
|
||||||
|
await expect(page.locator('.live-current')).toContainText('Pixelart');
|
||||||
|
await output.route('**/state', (route) => route.abort());
|
||||||
|
await expect(output.getByText('Verbindung unterbrochen')).toBeVisible({ timeout: 5_000 });
|
||||||
|
await output.unroute('**/state');
|
||||||
|
await expect(output.getByText('Verbunden')).toBeVisible({ timeout: 5_000 });
|
||||||
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
|
await expectNoHorizontalOverflow(page);
|
||||||
|
await page.screenshot({
|
||||||
|
path: testInfo.outputPath('live-controller-mobile.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
await page.setViewportSize({ width: 1280, height: 900 });
|
||||||
|
|
||||||
|
await page.evaluate(() => {
|
||||||
|
window.open = () => null;
|
||||||
|
});
|
||||||
|
await page.getByRole('button', { name: 'Präsentationsfenster öffnen' }).click();
|
||||||
|
await expect(
|
||||||
|
page.getByText('Popup blockiert. Bitte Popups erlauben und erneut öffnen.')
|
||||||
|
).toBeVisible();
|
||||||
|
await anonymous.close();
|
||||||
|
await popup.close();
|
||||||
await expectNoHorizontalOverflow(page);
|
await expectNoHorizontalOverflow(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -521,16 +1024,26 @@ test('pieces autosave safely, detect conflicts and protect uploaded images', asy
|
|||||||
await expect(page).toHaveURL(/\/fundus$/);
|
await expect(page).toHaveURL(/\/fundus$/);
|
||||||
await page.getByRole('heading', { name: 'E2E Fundstück mit Markdown' }).click();
|
await page.getByRole('heading', { name: 'E2E Fundstück mit Markdown' }).click();
|
||||||
await expect(page).toHaveURL(pieceUrl);
|
await expect(page).toHaveURL(pieceUrl);
|
||||||
|
await page.getByText('Status, Dauer und Einordnung').click();
|
||||||
await page
|
await page
|
||||||
.getByLabel('Kurzbeschreibung')
|
.getByLabel('Kurzbeschreibung')
|
||||||
.fill('Persistiert nach Neuladen und ist gezielt suchbar.');
|
.fill('Persistiert nach Neuladen und ist gezielt suchbar.');
|
||||||
await page.getByLabel('Status').selectOption('ready');
|
await page.getByLabel('Status').selectOption('ready');
|
||||||
await page.getByLabel('Dauer in Minuten').fill('10.25');
|
await page.getByLabel('Dauer in Minuten').fill('10.25');
|
||||||
await page.getByLabel('Gaming').check();
|
await page.getByLabel('Gaming').check();
|
||||||
|
await openEditorialField(page, 'Private Recherche');
|
||||||
await page.getByLabel('Private Recherche').fill('Nur intern: **Hintergrund prüfen**.');
|
await page.getByLabel('Private Recherche').fill('Nur intern: **Hintergrund prüfen**.');
|
||||||
|
await openEditorialField(page, 'Moderationsstichpunkte');
|
||||||
|
await page.getByLabel('Moderationsstichpunkte').fill('Den Kern in zwei Sätzen erklären.');
|
||||||
|
await openEditorialField(page, 'Private Recherche');
|
||||||
|
await expect(page.getByLabel('Private Recherche')).toHaveValue(
|
||||||
|
'Nur intern: **Hintergrund prüfen**.'
|
||||||
|
);
|
||||||
|
await openEditorialField(page, 'Präsentationstext');
|
||||||
await page
|
await page
|
||||||
.getByLabel('Präsentationstext')
|
.getByLabel('Öffentlicher Text')
|
||||||
.fill('## Sichere Vorschau\n\n<script>globalThis.e2eXss = true</script> **sichtbar**');
|
.fill('## Sichere Vorschau\n\n<script>globalThis.e2eXss = true</script> **sichtbar**');
|
||||||
|
await openEditorialField(page, 'Private Recherche');
|
||||||
await page.getByRole('button', { name: 'Quelle hinzufügen' }).click();
|
await page.getByRole('button', { name: 'Quelle hinzufügen' }).click();
|
||||||
const source = page.locator('.source-row').last();
|
const source = page.locator('.source-row').last();
|
||||||
await source.getByLabel('Name').fill('Originalbeitrag');
|
await source.getByLabel('Name').fill('Originalbeitrag');
|
||||||
@@ -539,11 +1052,14 @@ test('pieces autosave safely, detect conflicts and protect uploaded images', asy
|
|||||||
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
||||||
await page.waitForTimeout(1_200);
|
await page.waitForTimeout(1_200);
|
||||||
await expect(page.locator('.save-indicator')).toContainText('Gespeichert');
|
await expect(page.locator('.save-indicator')).toContainText('Gespeichert');
|
||||||
await expect(page.locator('.markdown-preview script')).toHaveCount(0);
|
await openEditorialField(page, 'Präsentationstext');
|
||||||
await expect(page.locator('.markdown-preview').last()).toContainText('Sichere Vorschau');
|
await expect(page.locator('.piece-presentation-preview script')).toHaveCount(0);
|
||||||
|
await expect(page.locator('.piece-presentation-preview')).toContainText('Sichere Vorschau');
|
||||||
await page.reload();
|
await page.reload();
|
||||||
await expect(page.getByLabel('Titel')).toHaveValue('E2E Fundstück mit Markdown');
|
await expect(page.getByLabel('Titel')).toHaveValue('E2E Fundstück mit Markdown');
|
||||||
|
await page.getByText('Status, Dauer und Einordnung').click();
|
||||||
await expect(page.getByLabel('Dauer in Minuten')).toHaveValue('10.25');
|
await expect(page.getByLabel('Dauer in Minuten')).toHaveValue('10.25');
|
||||||
|
await openEditorialField(page, 'Private Recherche');
|
||||||
await expect(page.getByLabel('Private Recherche')).toHaveValue(
|
await expect(page.getByLabel('Private Recherche')).toHaveValue(
|
||||||
'Nur intern: **Hintergrund prüfen**.'
|
'Nur intern: **Hintergrund prüfen**.'
|
||||||
);
|
);
|
||||||
@@ -574,6 +1090,7 @@ test('pieces autosave safely, detect conflicts and protect uploaded images', asy
|
|||||||
await concurrent.goto(pieceUrl);
|
await concurrent.goto(pieceUrl);
|
||||||
await page.getByLabel('Titel').fill('E2E Fundstück, extern aktualisiert');
|
await page.getByLabel('Titel').fill('E2E Fundstück, extern aktualisiert');
|
||||||
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
||||||
|
await concurrent.getByText('Status, Dauer und Einordnung').click();
|
||||||
await concurrent
|
await concurrent
|
||||||
.getByLabel('Kurzbeschreibung')
|
.getByLabel('Kurzbeschreibung')
|
||||||
.fill('Diese veraltete Änderung darf nicht gewinnen.');
|
.fill('Diese veraltete Änderung darf nicht gewinnen.');
|
||||||
@@ -582,6 +1099,7 @@ test('pieces autosave safely, detect conflicts and protect uploaded images', asy
|
|||||||
});
|
});
|
||||||
await concurrent.reload();
|
await concurrent.reload();
|
||||||
await expect(concurrent.getByLabel('Titel')).toHaveValue('E2E Fundstück, extern aktualisiert');
|
await expect(concurrent.getByLabel('Titel')).toHaveValue('E2E Fundstück, extern aktualisiert');
|
||||||
|
await concurrent.getByText('Status, Dauer und Einordnung').click();
|
||||||
await expect(concurrent.getByLabel('Kurzbeschreibung')).not.toHaveValue(
|
await expect(concurrent.getByLabel('Kurzbeschreibung')).not.toHaveValue(
|
||||||
'Diese veraltete Änderung darf nicht gewinnen.'
|
'Diese veraltete Änderung darf nicht gewinnen.'
|
||||||
);
|
);
|
||||||
@@ -606,12 +1124,126 @@ test('pieces autosave safely, detect conflicts and protect uploaded images', asy
|
|||||||
'Kopie von E2E Fundstück, extern aktualisiert'
|
'Kopie von E2E Fundstück, extern aktualisiert'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await page.context().setOffline(true);
|
||||||
|
await page.getByLabel('Titel').fill('Kopie mit unterbrochener Verbindung');
|
||||||
|
await expect(page.locator('.save-indicator')).toContainText('Speichern fehlgeschlagen', {
|
||||||
|
timeout: 10_000
|
||||||
|
});
|
||||||
|
await page.context().setOffline(false);
|
||||||
|
await page.getByRole('button', { name: 'Jetzt speichern' }).click();
|
||||||
|
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
||||||
|
|
||||||
await page.setViewportSize({ width: 390, height: 844 });
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
await setTheme(page, 'dark');
|
await setTheme(page, 'dark');
|
||||||
await page.reload();
|
await page.reload();
|
||||||
|
await page.getByRole('button', { name: 'Recherche & Quellen' }).click();
|
||||||
|
await expect(page.getByRole('heading', { name: 'Quellen', exact: true })).toBeVisible();
|
||||||
await expectNoHorizontalOverflow(page);
|
await expectNoHorizontalOverflow(page);
|
||||||
await page.screenshot({
|
await page.screenshot({
|
||||||
path: testInfo.outputPath('piece-editor-mobile-dark.png'),
|
path: testInfo.outputPath('piece-editor-mobile-dark.png'),
|
||||||
fullPage: true
|
fullPage: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a quickly captured video can be written and previewed before classification', async ({
|
||||||
|
page
|
||||||
|
}) => {
|
||||||
|
await page.context().route('https://www.youtube-nocookie.com/**', (route) =>
|
||||||
|
route.fulfill({
|
||||||
|
contentType: 'text/html',
|
||||||
|
body: '<!doctype html><title>YouTube Test</title>'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await page.goto('/eingang');
|
||||||
|
await page.getByLabel('Gedanke').fill('Schnelles Video-Fundstück');
|
||||||
|
await page.getByLabel('Link').fill('https://youtu.be/dQw4w9WgXcQ');
|
||||||
|
await page.getByRole('button', { name: 'Im Eingang ablegen' }).click();
|
||||||
|
await expect(page).toHaveURL(/\/eingang(?:\?\/capture)?$/);
|
||||||
|
await page.locator('.inbox-item').filter({ hasText: 'Schnelles Video-Fundstück' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Recherche & Quellen' }).click();
|
||||||
|
await expect(page.locator('.source-row').getByLabel('URL')).toHaveValue(
|
||||||
|
'https://youtu.be/dQw4w9WgXcQ'
|
||||||
|
);
|
||||||
|
await expect(page.getByLabel('Status')).toBeHidden();
|
||||||
|
|
||||||
|
await openEditorialField(page, 'Private Recherche');
|
||||||
|
await page
|
||||||
|
.getByLabel('Private Recherche')
|
||||||
|
.fill('Warum funktioniert der Einstieg so unmittelbar?');
|
||||||
|
await openEditorialField(page, 'Moderationsstichpunkte');
|
||||||
|
await page
|
||||||
|
.getByLabel('Moderationsstichpunkte')
|
||||||
|
.fill('Erst Clip zeigen, dann die Beobachtung öffnen.');
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Präsentation', exact: true }).click();
|
||||||
|
await page.getByLabel('Video').check();
|
||||||
|
await page.getByRole('combobox', { name: 'Quelle', exact: true }).selectOption('0');
|
||||||
|
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
||||||
|
|
||||||
|
const previewPromise = page.waitForEvent('popup');
|
||||||
|
await page.getByRole('link', { name: 'In neuem Fenster testen' }).click();
|
||||||
|
const preview = await previewPromise;
|
||||||
|
await expect(preview.locator('iframe[title="Schnelles Video-Fundstück"]')).toHaveAttribute(
|
||||||
|
'src',
|
||||||
|
'https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ'
|
||||||
|
);
|
||||||
|
await preview.close();
|
||||||
|
|
||||||
|
await page.setViewportSize({ width: 390, height: 844 });
|
||||||
|
await page.getByRole('button', { name: 'Präsentation', exact: true }).click();
|
||||||
|
await expect(page.getByLabel('Video')).toBeVisible();
|
||||||
|
await page.getByRole('button', { name: 'Recherche & Quellen' }).click();
|
||||||
|
await expect(page.getByLabel('Private Recherche')).toBeVisible();
|
||||||
|
await expectNoHorizontalOverflow(page);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('link preview uses one existing source, persists manual fields and isolates its test view', async ({
|
||||||
|
page
|
||||||
|
}, testInfo) => {
|
||||||
|
await page.goto('/fundus/piece-console');
|
||||||
|
await page.getByRole('button', { name: 'Präsentation', exact: true }).click();
|
||||||
|
await page.getByLabel('Linkvorschau').check();
|
||||||
|
await page.getByRole('combobox', { name: 'Quelle', exact: true }).selectOption('0');
|
||||||
|
await page.getByLabel('Titel', { exact: true }).last().fill('Manuell korrigierte Linkvorschau');
|
||||||
|
await page.getByLabel('Anreißer').fill('Ein kurzer manueller Anreißer ohne Vorschaubild.');
|
||||||
|
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
||||||
|
await page.reload();
|
||||||
|
await page.getByRole('button', { name: 'Präsentation', exact: true }).click();
|
||||||
|
await expect(page.getByLabel('Linkvorschau')).toBeChecked();
|
||||||
|
await expect(page.getByLabel('Titel', { exact: true }).last()).toHaveValue(
|
||||||
|
'Manuell korrigierte Linkvorschau'
|
||||||
|
);
|
||||||
|
|
||||||
|
const previewPromise = page.waitForEvent('popup');
|
||||||
|
await page.getByRole('link', { name: 'In neuem Fenster testen' }).click();
|
||||||
|
const preview = await previewPromise;
|
||||||
|
await preview.waitForLoadState('networkidle');
|
||||||
|
await expect(preview.getByText('Isolierte Testansicht')).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
preview.getByRole('heading', { name: 'Manuell korrigierte Linkvorschau' })
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(preview.getByText('Ein kurzer manueller Anreißer ohne Vorschaubild.')).toBeVisible();
|
||||||
|
await expect(preview.locator('.output-link-image')).toHaveCount(0);
|
||||||
|
await preview.screenshot({
|
||||||
|
path: testInfo.outputPath('linkvorschau-desktop.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
await preview.setViewportSize({ width: 390, height: 844 });
|
||||||
|
await expectNoHorizontalOverflow(preview);
|
||||||
|
await preview.screenshot({
|
||||||
|
path: testInfo.outputPath('linkvorschau-mobile.png'),
|
||||||
|
fullPage: true
|
||||||
|
});
|
||||||
|
await preview.close();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Recherche & Quellen' }).click();
|
||||||
|
await page.locator('.source-row').first().getByLabel('URL').fill('http://127.0.0.1/private');
|
||||||
|
await expect(page.locator('.save-indicator')).toContainText('Gespeichert', { timeout: 10_000 });
|
||||||
|
await page.getByRole('button', { name: 'Präsentation', exact: true }).click();
|
||||||
|
const blockedPreview = page.waitForResponse((response) =>
|
||||||
|
response.url().includes('?/loadPreview')
|
||||||
|
);
|
||||||
|
await page.getByRole('button', { name: 'Vorschau laden' }).click();
|
||||||
|
expect((await blockedPreview).status()).toBe(400);
|
||||||
|
await expect(page.getByRole('alert')).toContainText('Interne oder private Netzwerkziele');
|
||||||
|
});
|
||||||
Reference in new issue
Block a user