Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c61869f8aa | ||
|
|
08d03d0f56 | ||
|
|
ea4244487f |
No files matched your search
@@ -26,7 +26,7 @@
|
||||
* erscheint nur, wenn die Redaktion sie ausdrücklich wählt. Nie: Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte,
|
||||
* Ausgabeadressen. Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der
|
||||
* Redaktionsvorschau und kann in der Karte ausdrücklich als Website-Bild übernommen werden (FilmStill).
|
||||
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
* Eine Karte spielt höchstens den für die Website freigegebenen Trailer ab (CardClip), bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class PublicMaterialReader
|
||||
{
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\PresentationAssignment;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Der kurze Clip, den eine Premium-Karte beim Überfahren oder Antippen abspielt.
|
||||
*
|
||||
* Gelesen wird nur, was die Redaktion ohnehin für die Website freigegeben hat (WebsiteMedia, Route website.media):
|
||||
* 1. der Trailer des Fachobjekts (Präsentationsrolle „Trailer“), sonst der Vorschauclip,
|
||||
* 2. bei einem Film ersatzweise dessen eigener freigegebener Teaser.
|
||||
* Der vollständige Film, die Originaldatei und nicht freigegebene Clips kommen nie über die Karte. Die Karte gibt
|
||||
* nichts frei; ohne freigegebenen Clip bleibt es beim Kartenbild.
|
||||
*
|
||||
* In der Redaktionsvorschau erklärt `notice`, warum kein Clip läuft (zugeordnet, aber nicht freigegeben).
|
||||
*/
|
||||
class CardClip
|
||||
{
|
||||
/** Rollen in der Reihenfolge, in der ein Clip gesucht wird. */
|
||||
public const ROLES = ['trailer', 'vorschauclip'];
|
||||
|
||||
public function __construct(private readonly WebsiteMedia $media) {}
|
||||
|
||||
/**
|
||||
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||
*/
|
||||
public function for(Model $subject, bool $preview): array
|
||||
{
|
||||
$assigned = PresentationAssignment::query()
|
||||
->with(['role', 'element'])
|
||||
->where('subject_type', $subject->getMorphClass())
|
||||
->where('subject_id', $subject->getKey())
|
||||
->whereHas('role', fn ($query) => $query->whereIn('slug', self::ROLES))
|
||||
->orderBy('position')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->sortBy(fn (PresentationAssignment $row): int => (int) array_search($row->role?->slug, self::ROLES, true))
|
||||
->values();
|
||||
|
||||
$unreleased = null;
|
||||
|
||||
foreach ($assigned as $assignment) {
|
||||
$element = $assignment->element;
|
||||
|
||||
if (! $element instanceof ContentElement || $element->archived_at !== null || $element->output_class !== 'film') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$present = $this->media->present($element);
|
||||
|
||||
if ($present !== null && $present->kind === 'film') {
|
||||
return $this->found($present->url, $present->title, $assignment->role?->slug === 'trailer' ? 'trailer' : 'vorschauclip');
|
||||
}
|
||||
|
||||
$unreleased ??= $element;
|
||||
}
|
||||
|
||||
if ($subject instanceof ContentElement && $subject->output_class === 'film') {
|
||||
$own = $this->media->present($subject);
|
||||
|
||||
if ($own !== null && $own->kind === 'film') {
|
||||
return $this->found($own->url, $own->title, 'teaser');
|
||||
}
|
||||
}
|
||||
|
||||
if (! $preview) {
|
||||
return $this->none();
|
||||
}
|
||||
|
||||
if ($unreleased instanceof ContentElement) {
|
||||
$title = (string) ($unreleased->display_title ?: $unreleased->working_title);
|
||||
|
||||
return $this->none('Der Trailer „'.$title.'“ ist nicht für die Website freigegeben; öffentlich bleibt es beim Kartenbild (Medium öffnen → Reiter „Website“ → freigeben).');
|
||||
}
|
||||
|
||||
return $this->none(null, 'Kein Trailer zugeordnet; die Karte zeigt nur das Bild (Rolle „Trailer“ in der Präsentation des Mediums).');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||
*/
|
||||
private function found(string $url, string $title, string $source): array
|
||||
{
|
||||
return ['url' => $url, 'title' => $title, 'source' => $source, 'notice' => null, 'hint' => null];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||
*/
|
||||
private function none(?string $notice = null, ?string $hint = null): array
|
||||
{
|
||||
return ['url' => null, 'title' => '', 'source' => 'none', 'notice' => $notice, 'hint' => $hint];
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,13 @@
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
||||
* Ausgabeart. Filme erscheinen als Medienkarte (grüne Aktion, Filmtafel ohne freigegebenes Bild), Dokumente und andere
|
||||
* Materialien als Materialkarte (Materialsymbol). Öffentlich nur nach den Regeln von PublicMaterialReader; die Aktion
|
||||
* führt auf die öffentliche Programmseite. Die Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
* führt auf die öffentliche Programmseite. Die Karte spielt höchstens den für die Website freigegebenen Trailer ab (CardClip), bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class MediaCardWidget extends PremiumCardWidget
|
||||
{
|
||||
@@ -32,7 +33,7 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, kein Abspielen, kein Download.';
|
||||
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, Trailer nur wenn freigegeben, kein Download.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -145,6 +146,18 @@ protected function textChoices(): array
|
||||
];
|
||||
}
|
||||
|
||||
protected function supportsClip(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function clipSubject(mixed $id): ?Model
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||
|
||||
return $element instanceof ContentElement ? $element : null;
|
||||
}
|
||||
|
||||
protected function centralCoverId(mixed $id): ?int
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
@@ -15,6 +16,7 @@
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
@@ -67,6 +69,15 @@ protected function imageSourceFields(): array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fachobjekt, dessen Trailer die Karte beim Überfahren oder Antippen abspielt (Medium, Programm, Modul).
|
||||
* Null: diese Karte hat keinen Clip (Thema). Der Clip kommt aus der Präsentation des Objekts (CardClip).
|
||||
*/
|
||||
protected function clipSubject(mixed $id): ?Model
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zentrale Texte des Fachobjekts, aus denen die Redaktion den Kartentext wählen kann: Wert => Bezeichnung.
|
||||
* Leer: keine Wahl (die Karte nimmt den Text ihrer Vorgabe). Mit Wahl gilt „auto“ als Vorgabe.
|
||||
@@ -154,7 +165,7 @@ public function settings(): array
|
||||
{
|
||||
$choices = $this->textChoices();
|
||||
|
||||
return ($choices === [] ? [] : ['text_source' => $choices]) + [
|
||||
return ($choices === [] ? [] : ['text_source' => $choices]) + ($this->supportsClip() ? ['clip' => ['yes' => 'Abspielen', 'no' => 'Nicht abspielen']] : []) + [
|
||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
||||
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||
@@ -169,6 +180,7 @@ public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'text_source' => ['Text der Karte', 'Welche Angabe aus der Redaktion die Karte zeigt. Vorgabe: Automatisch. Der gewählte Text erscheint öffentlich, wenn die Karte öffentlich ist; ist er nicht gepflegt, bleibt die Karte ohne Text.'],
|
||||
'clip' => ['Trailer auf der Karte', 'Spielt den freigegebenen Trailer stumm ab, solange die Maus auf der Karte steht; am Handy mit Tippen auf das Bild, per Tastatur über die Schaltfläche am Bild. Gewählt wird der Trailer (sonst der Vorschauclip) in der Präsentation des Objekts, bei einem Film ersatzweise sein freigegebener Teaser. Ohne freigegebenen Clip bleibt das Kartenbild. Vorgabe: Abspielen.'],
|
||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bilddarstellung', 'Vorgabe: Ausschnitt. „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
@@ -309,8 +321,16 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
$storedImage = WebsiteImage::normalize($widget['refs']['image'] ?? null);
|
||||
$imageRef = $storedImage ?? $this->centralCoverId($widget['refs'][$this->refKey()] ?? null);
|
||||
|
||||
$clip = null;
|
||||
|
||||
if ($this->supportsClip() && $option('clip', 'yes') === 'yes' && $subject instanceof CardSubject) {
|
||||
$owner = $this->clipSubject($widget['refs'][$this->refKey()] ?? null);
|
||||
$clip = $owner instanceof Model ? app(CardClip::class)->for($owner, $context->preview) : null;
|
||||
}
|
||||
|
||||
return [
|
||||
'subject' => $subject,
|
||||
'clip' => $clip,
|
||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
||||
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||
@@ -350,6 +370,11 @@ protected function centralCoverId(mixed $id): ?int
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function supportsClip(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zentraler Anzeigename oder Teaser des gewählten Objekts (Redaktionsstand) für Platzhalter im Editor.
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
||||
@@ -156,6 +157,18 @@ protected function cardStyle(): string
|
||||
return 'catalog';
|
||||
}
|
||||
|
||||
protected function supportsClip(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function clipSubject(mixed $id): ?Model
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||
|
||||
return $composition instanceof Composition ? $composition : null;
|
||||
}
|
||||
|
||||
protected function centralCoverId(mixed $id): ?int
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||
|
||||
@@ -4,39 +4,72 @@
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Jobs\StorePresentationFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Legt die technische Ableitung eines Präsentationsmediums an der Medienidentität ab.
|
||||
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung.
|
||||
* Legt die technische Ableitung eines Präsentationsmediums (Website-Datei) an der Medienidentität ab.
|
||||
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung. Eine vorhandene Inhaltsfassung bleibt
|
||||
* unverändert und geschützt; die Website-Datei ist eine eigene, bewusst gewählte Datei daneben.
|
||||
*
|
||||
* Der Web-Prozess hat `derived/` nur lesend. Er prüft deshalb nur und gibt das Kopieren an die Warteschlange
|
||||
* (`StorePresentationFile`, ruft `place()` auf).
|
||||
*/
|
||||
class PresentationFile
|
||||
{
|
||||
public function store(ContentElement $element, string $incoming): void
|
||||
/**
|
||||
* Dateiendungen, die ein Browser auf der Website abspielen kann.
|
||||
*
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
public const EXTENSIONS = [
|
||||
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
||||
'audio' => ['mp3', 'm4a', 'ogg'],
|
||||
'film' => ['mp4', 'webm'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Prüft die Datei im Eingang, ohne etwas zu verändern. Wirft eine verständliche Regelverletzung.
|
||||
*/
|
||||
public function validate(string $outputClass, string $incoming): void
|
||||
{
|
||||
if (! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
|
||||
if (! isset(self::EXTENSIONS[$outputClass])) {
|
||||
throw new DomainRuleException('Eine Präsentationsdatei ist ein Bild, ein Film oder ein Hörstück.');
|
||||
}
|
||||
|
||||
if ($element->versions()->exists()) {
|
||||
throw new DomainRuleException('Dieses Medium hat bereits eine Inhaltsfassung. Die Präsentationsdatei ersetzt sie nicht.');
|
||||
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
||||
|
||||
if (! in_array($extension, self::EXTENSIONS[$outputClass], true)) {
|
||||
throw new DomainRuleException(sprintf(
|
||||
'Für die Website geht nur %s. Eine %s-Datei kann der Browser nicht direkt abspielen; wandle sie vorher um oder lade sie ohne „Eigenständiges Präsentationsmedium“ hoch.',
|
||||
$this->formats($outputClass),
|
||||
$extension === '' ? 'Datei ohne Endung' : '.'.$extension,
|
||||
));
|
||||
}
|
||||
|
||||
if (! $this->readable($incoming)) {
|
||||
throw new DomainRuleException('Die Datei liegt nicht im Eingang.');
|
||||
}
|
||||
}
|
||||
|
||||
public function store(ContentElement $element, string $incoming): void
|
||||
{
|
||||
$this->validate((string) $element->output_class, $incoming);
|
||||
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
|
||||
StorePresentationFile::dispatch($element->id, $incoming);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kopiert die Datei nach `derived/`. Läuft nur in der Warteschlange, die dort schreiben darf.
|
||||
*/
|
||||
public function place(ContentElement $element, string $incoming): void
|
||||
{
|
||||
$this->validate((string) $element->output_class, $incoming);
|
||||
|
||||
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
||||
$allowed = match ($element->output_class) {
|
||||
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
||||
'audio' => ['mp3', 'm4a', 'ogg'],
|
||||
default => ['mp4', 'webm'],
|
||||
};
|
||||
|
||||
if (! in_array($extension, $allowed, true)) {
|
||||
throw new DomainRuleException('Diese Datei ist keine freigebbare Ableitung. Es wird keine Inhaltsfassung angelegt.');
|
||||
}
|
||||
|
||||
$prefix = $element->output_class === 'bild' ? 'vorschau' : 'teaser';
|
||||
$target = $prefix.'/'.$element->id.'/datei.'.$extension;
|
||||
$stream = Storage::disk('cms_incoming')->readStream($incoming);
|
||||
@@ -46,11 +79,15 @@ public function store(ContentElement $element, string $incoming): void
|
||||
}
|
||||
|
||||
try {
|
||||
Storage::disk('media_derived')->writeStream($target, $stream);
|
||||
$written = Storage::disk('media_derived')->writeStream($target, $stream);
|
||||
} finally {
|
||||
fclose($stream);
|
||||
}
|
||||
|
||||
if ($written === false) {
|
||||
throw new DomainRuleException('Die Datei ließ sich nicht ablegen.');
|
||||
}
|
||||
|
||||
if ($element->output_class === 'bild') {
|
||||
$element->thumbnail_path = $target;
|
||||
$element->thumbnail_source = 'eigen';
|
||||
@@ -58,7 +95,18 @@ public function store(ContentElement $element, string $incoming): void
|
||||
$element->preview_path = $target;
|
||||
}
|
||||
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
Storage::disk('cms_incoming')->delete($incoming);
|
||||
}
|
||||
|
||||
public function formats(string $outputClass): string
|
||||
{
|
||||
return match ($outputClass) {
|
||||
'bild' => 'JPG, PNG, WebP oder GIF',
|
||||
'audio' => 'MP3, M4A oder OGG',
|
||||
default => 'MP4 (H.264) oder WebM',
|
||||
};
|
||||
}
|
||||
|
||||
private function readable(string $path): bool
|
||||
|
||||
@@ -44,7 +44,7 @@ public function refusal(ContentElement $element): ?string
|
||||
}
|
||||
|
||||
if ($this->derivedPath($element) === null) {
|
||||
return 'Für die Website fehlt eine freigebbare Ableitung. Beim Bild ist das das Vorschaubild. Film und Hörstück ohne Inhaltsfassung nutzen die Datei am Medium unter teaser/. Ein Film mit Inhaltsfassung nutzt die Teaserfassung seiner bereitgestellten Fassung. Die Originaldatei bleibt geschützt.';
|
||||
return 'Für die Website fehlt eine freigebbare Datei. Beim Bild ist das das Vorschaubild. Bei Film und Hörstück lädst du unter „Website-Freigabe“ eine Website-Datei hoch (Film als MP4 oder WebM); die geschützte Originaldatei bleibt unberührt.';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\WebsiteImageUsage;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
@@ -92,6 +93,9 @@ class ViewContentElement extends ViewRecord
|
||||
|
||||
public string $websiteFeedback = '';
|
||||
|
||||
/** Gewählte Website-Datei für Film oder Hörstück (ungeschützt, getrennt von der Inhaltsfassung). */
|
||||
public mixed $websiteUpload = null;
|
||||
|
||||
public int|string|null $kindId = null;
|
||||
|
||||
/** @var list<int|string> */
|
||||
@@ -844,6 +848,61 @@ public function releaseForWebsite(): void
|
||||
$element->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt die Datei ab, die auf der Website laufen soll (zum Beispiel ein Trailer). Die geschützte Inhaltsfassung
|
||||
* bleibt unberührt; öffentlich wird die Datei erst mit der Website-Freigabe.
|
||||
*/
|
||||
public function storeWebsiteFile(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
if (! in_array($element->output_class, ['film', 'audio'], true)) {
|
||||
$this->websiteFeedback = 'Eine Website-Datei gibt es nur für Filme und Hörstücke.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $this->websiteUpload instanceof TemporaryUploadedFile) {
|
||||
$this->websiteFeedback = 'Wähle zuerst eine Datei.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$files = app(PresentationFile::class);
|
||||
$extension = strtolower($this->websiteUpload->getClientOriginalExtension());
|
||||
|
||||
if (! in_array($extension, PresentationFile::EXTENSIONS[$element->output_class], true)) {
|
||||
$this->websiteFeedback = 'Für die Website geht nur '.$files->formats($element->output_class).'. Eine .'.$extension.'-Datei kann der Browser nicht direkt abspielen.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$path = $this->websiteUpload->storeAs('inhalte', 'web-'.bin2hex(random_bytes(6)).'.'.$extension, 'cms_incoming');
|
||||
$this->websiteUpload = null;
|
||||
|
||||
if (! is_string($path)) {
|
||||
$this->websiteFeedback = 'Die Datei wurde nicht übernommen.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$files->store($element, $path);
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->websiteFeedback = $e->getMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$element->refresh();
|
||||
$this->websiteFeedback = filled($element->thumbnail_error)
|
||||
? (string) $element->thumbnail_error
|
||||
: 'Die Website-Datei ist übernommen. Sie ist erst nach „Für die Website freigeben“ öffentlich. Ein bereits freigegebenes Medium zeigt danach die neue Datei.';
|
||||
}
|
||||
|
||||
public function withdrawWebsite(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
@@ -43,7 +43,7 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
||||
->required(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text');
|
||||
$fields[] = Checkbox::make('without_version')
|
||||
->label('Eigenständiges Präsentationsmedium')
|
||||
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung. Die Datei bleibt eine technische Ableitung am Medium. Sie wird nicht lizenziert und nicht automatisch für die Website freigegeben.')
|
||||
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung, zum Beispiel ein Trailer, der ungeschützt auf der Website laufen soll. Der Film muss dafür MP4 (H.264) oder WebM sein. Er wird nicht lizenziert und erst nach „Für die Website freigeben“ öffentlich.')
|
||||
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
|
||||
} elseif ($element?->output_class === 'text') {
|
||||
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
||||
@@ -94,20 +94,10 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
{
|
||||
$service = app(ContentService::class);
|
||||
[$kind, $output] = self::shape($data['shape'] ?? null);
|
||||
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
||||
self::remember($element, $data);
|
||||
$incoming = null;
|
||||
|
||||
if ($output === 'text') {
|
||||
$body = trim((string) ($data['body'] ?? ''));
|
||||
|
||||
if ($body === '') {
|
||||
throw new DomainRuleException('Der Text braucht einen Inhalt.');
|
||||
}
|
||||
|
||||
$hold
|
||||
? $service->draftElementVersion($element, $body)
|
||||
: $service->publishElementVersion($element, $body);
|
||||
} else {
|
||||
if ($output !== 'text') {
|
||||
// Alles prüfen, bevor etwas angelegt wird: Eine abgelehnte Datei darf kein leeres Medium hinterlassen.
|
||||
$incoming = IncomingFile::store($data['incoming'] ?? null);
|
||||
|
||||
if ($incoming === null) {
|
||||
@@ -126,6 +116,25 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
||||
}
|
||||
|
||||
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||
app(PresentationFile::class)->validate($output, $incoming);
|
||||
}
|
||||
}
|
||||
|
||||
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
||||
self::remember($element, $data);
|
||||
|
||||
if ($output === 'text') {
|
||||
$body = trim((string) ($data['body'] ?? ''));
|
||||
|
||||
if ($body === '') {
|
||||
throw new DomainRuleException('Der Text braucht einen Inhalt.');
|
||||
}
|
||||
|
||||
$hold
|
||||
? $service->draftElementVersion($element, $body)
|
||||
: $service->publishElementVersion($element, $body);
|
||||
} else {
|
||||
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||
app(PresentationFile::class)->store($element, $incoming);
|
||||
} else {
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class WebsiteMediaController extends Controller
|
||||
{
|
||||
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||
private const CHUNK = 262144;
|
||||
|
||||
public function show(Request $request, ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||
{
|
||||
$presentation = $media->present($element);
|
||||
abort_if($presentation === null, 404);
|
||||
@@ -17,9 +20,81 @@ public function show(ContentElement $element, WebsiteMedia $media): StreamedResp
|
||||
$path = $element->website_public_path;
|
||||
abort_if(! is_string($path), 404);
|
||||
|
||||
return Storage::disk('media_public')->response($path, null, [
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
'X-Content-Type-Options' => 'nosniff',
|
||||
'Accept-Ranges' => 'bytes',
|
||||
];
|
||||
|
||||
$range = $request->header('Range');
|
||||
|
||||
// Filme und Hörstücke brauchen Bereichsabrufe (Safari und iOS spielen sonst nicht ab, Springen ist sonst unmöglich).
|
||||
if (! is_string($range) || $presentation->kind === 'bild') {
|
||||
return Storage::disk('media_public')->response($path, null, $headers);
|
||||
}
|
||||
|
||||
$disk = Storage::disk('media_public');
|
||||
$size = (int) $disk->size($path);
|
||||
$bounds = $this->bounds($range, $size);
|
||||
|
||||
if ($bounds === null) {
|
||||
return response()->stream(fn () => null, 416, $headers + ['Content-Range' => 'bytes */'.$size]);
|
||||
}
|
||||
|
||||
[$start, $end] = $bounds;
|
||||
$length = $end - $start + 1;
|
||||
$stream = $disk->readStream($path);
|
||||
abort_if(! is_resource($stream), 404);
|
||||
|
||||
return response()->stream(function () use ($stream, $start, $length): void {
|
||||
fseek($stream, $start);
|
||||
$left = $length;
|
||||
|
||||
while ($left > 0 && ! feof($stream)) {
|
||||
$chunk = fread($stream, min(self::CHUNK, $left));
|
||||
|
||||
if ($chunk === false || $chunk === '') {
|
||||
break;
|
||||
}
|
||||
|
||||
echo $chunk;
|
||||
$left -= strlen($chunk);
|
||||
}
|
||||
|
||||
fclose($stream);
|
||||
}, 206, $headers + [
|
||||
'Content-Type' => (string) ($disk->mimeType($path) ?: 'application/octet-stream'),
|
||||
'Content-Length' => (string) $length,
|
||||
'Content-Range' => 'bytes '.$start.'-'.$end.'/'.$size,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erster Bereich aus „bytes=a-b“, „bytes=a-“ oder „bytes=-n“; null, wenn er nicht erfüllbar ist.
|
||||
*
|
||||
* @return array{0: int, 1: int}|null
|
||||
*/
|
||||
private function bounds(string $header, int $size): ?array
|
||||
{
|
||||
if ($size < 1 || preg_match('/^bytes=(\d*)-(\d*)(?:,.*)?$/', trim($header), $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[, $from, $to] = $match;
|
||||
|
||||
if ($from === '' && $to === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($from === '') {
|
||||
$suffix = min((int) $to, $size);
|
||||
|
||||
return $suffix < 1 ? null : [$size - $suffix, $size - 1];
|
||||
}
|
||||
|
||||
$start = (int) $from;
|
||||
$end = $to === '' ? $size - 1 : min((int) $to, $size - 1);
|
||||
|
||||
return $start > $end || $start >= $size ? null : [$start, $end];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Kopiert die Website-Datei eines Mediums nach `derived/`. Nur die Warteschlange darf dort schreiben.
|
||||
* Ein Fehler wird am Medium vermerkt (`thumbnail_error`), damit die Verwaltung ihn zeigen kann.
|
||||
*/
|
||||
class StorePresentationFile implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $timeout = 3600;
|
||||
|
||||
public function __construct(
|
||||
public int $elementId,
|
||||
public string $incoming,
|
||||
) {}
|
||||
|
||||
public function handle(PresentationFile $file): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if (! $element instanceof ContentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$file->place($element, $this->incoming);
|
||||
|
||||
// Ein schon freigegebenes Medium zeigt sonst weiter die alte öffentliche Kopie.
|
||||
if ($element->website_released_at !== null) {
|
||||
PublishWebsiteMedia::dispatch($element->id, 'release');
|
||||
}
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->remember($element, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(\Throwable $e): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if ($element instanceof ContentElement) {
|
||||
$this->remember($element, 'Die Datei ließ sich nicht übernehmen: '.Str::limit($e->getMessage(), 120));
|
||||
}
|
||||
}
|
||||
|
||||
private function remember(ContentElement $element, string $message): void
|
||||
{
|
||||
$element->thumbnail_error = $message;
|
||||
$element->save();
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ ## Übersicht der Architekturentscheidungen
|
||||
| ADR-40 | Zentrale Medienverwaltung im CMS | Umgesetzt auf Test (19.11.2026); Abnahme offen | CMS-Bilder sind Medien des Medienmanagers (Kennung statt Pfad), öffentlich nur mit Website-Freigabe; frühere CMS-Bilder übernommen |
|
||||
| ADR-41 | Gemeinsame Redaktionsbasis | Auf Test (19.11.2026, `develop` `f29ea58`); Betreiberabnahme offen. Technische Abbildung ist eine Arbeitsannahme, keine neue fachliche Freigabe | Klasse-A-Texte, Fachdimensionen und Präsentationsreferenzen an den bestehenden Fachobjekten; keine zweite Inhalts- oder Produktverwaltung |
|
||||
| ADR-42 | Angebot und Warenkorb | Fachlich beschlossen | Gemeinsame Angebotsseite mit Lizenzwahl, Mehrangebotswarenkorb und Geltung der Bestellfassung je Position |
|
||||
| ADR-43 | Trailer auf Karten | Umgesetzt auf Test (21.11.2026); Abnahme offen | Medien-, Programm- und Modulkarte spielen den für die Website freigegebenen Trailer beim Überfahren oder Antippen; ohne Freigabe nur das Bild |
|
||||
|
||||
---
|
||||
|
||||
@@ -562,3 +563,19 @@ ## ADR-42 – Öffentliche Angebotsdarstellung und Mehrangebotswarenkorb
|
||||
Die bestehende vorbelegte Angebotsmaske bleibt für Etappe 1 maßgeblich. Neue Fassungen werden ausdrücklich aktiviert. Abbrechen verwirft offene Eingaben. Im Warenkorb bleibt eine identisch bereits erworbene Lizenz gekennzeichnet und entfernbar. Sie geht weder in die Kaufsumme noch in die Bestellpositionen ein. Der ursprüngliche Erwerb bleibt der Nachweis.
|
||||
|
||||
Pro Bestellung gilt höchstens ein Rabattcode. Allgemeine und produktspezifische Geltung sowie ein mehrfach nutzbarer Zertifizierungscode für geprüfte Konten gehören zum Verkaufsumfang. Verkaufskreis ist Deutschland einschließlich Privatkunden, Vereinen und Organisationen. Der Startumfang enthält keine freiwilligen Teilerstattungen und behandelt Bundles bei Rückgabe als Einheit. Zahlungs- und Rechnungsregeln stehen in ADR-14 und ADR-21.
|
||||
|
||||
## ADR-43 – Trailer auf Karten
|
||||
|
||||
**Status am 21.11.2026:** Umgesetzt auf `develop`/Testinstanz (Branch `feature/karten-trailer`); Abnahme durch den Betreiber offen.
|
||||
**Kontext.** FACH-46 fordert öffentliche Teaservideos; die Rollen Trailer und Vorschauclip gibt es im Medienmanager, ein freigegebener Clip wird über `website.media` ausgeliefert. Auf einer Karte war bisher nur ein Bild vorgesehen („kein Abspielen“, ADR-39). Die Grenze galt dem vollständigen Film und dem Bibliotheksmaterial, nicht einem für die Website bestimmten Trailer. Ein Trailer ist kein Lizenzelement; er braucht keine Lizenzentscheidung, nur die Website-Freigabe nach ADR-40.
|
||||
**Entscheidung.**
|
||||
- **Welche Karten:** Medien- und Materialkarte, Programm- und Modulkarte. Die Themenkarte hat keinen Trailer.
|
||||
- **Welcher Clip:** der Trailer des Fachobjekts (Präsentationsrolle „Trailer“), sonst der Vorschauclip. Bei einem Film ersatzweise sein eigener für die Website freigegebener Teaser. Gewählt wird einmal in der Präsentation des Mediums, Programms oder Moduls; alle Karten desselben Objekts zeigen denselben Clip. Je Karte lässt sich der Trailer ausschalten (Darstellung → „Trailer auf der Karte“, Vorgabe: Abspielen).
|
||||
- **Wann er läuft:** Am Desktop spielt er stumm und in Schleife, solange die Maus auf der Karte steht, und endet beim Verlassen. Am Handy und auf Wunsch auch am Desktop startet und stoppt ihn ein Tipp auf das Bild oder die Schaltfläche „Trailer“ am Bild, die auch die Tastatur bedient (`aria-pressed`). Es spielt nie mehr als ein Clip zugleich; er hält an, wenn die Karte aus dem Bild scrollt oder die Seite verdeckt wird.
|
||||
- **Rücksicht:** Bei „reduzierte Bewegung“ und im Datensparmodus startet nichts von selbst, nur auf ausdrückliche Bedienung und dann ohne Schleife. Der Clip wird erst beim ersten Start geladen (`preload="none"`, Quelle erst dann gesetzt). Ohne JavaScript bleibt es beim Kartenbild.
|
||||
- **Rechte:** Es spielt nur ein für die Website freigegebener Clip. Der vollständige Film, die Originaldatei und nicht freigegebene Clips kommen nie über eine Karte, auch nicht in der Redaktionsvorschau; diese nennt stattdessen, dass der Trailer nicht freigegeben ist. Die Karte gibt nichts frei und bietet keinen Download. Die Karte einer Traineranleitung erscheint weiter öffentlich nie.
|
||||
- **Auslieferung:** Die Route `website.media` beantwortet Bereichsabrufe (`Range`, Antwort 206/416) für Filme und Hörstücke. Safari und iOS spielen sonst nicht ab.
|
||||
**Alternativen.** Clip je Karte frei wählen (verworfen: mehrere Wege, doppelte Pflege); Autoplay mit Ton oder ohne Bedienung (verworfen: Barrierefreiheit, Datenvolumen); Clip aus dem vollständigen Film erzeugen (verworfen: Rechte, kein freigegebener Clip).
|
||||
**Folgen.** Neue Einstellung `clip` an der Medien-, Programm- und Modulkarte, Klasse `CardClip`, Skript `resources/js/card-clip.js`; keine Migration. Bereits gespeicherte Karten ohne Wahl spielen einen freigegebenen Trailer ab (Vorgabe Abspielen). Offen: Trailer im Hero-Widget als Hintergrund (nicht entschieden); Hinweis „Mit Ton starten“ nicht vorgesehen.
|
||||
**Quelle.** `docs/ux/verwaltung/04-fachliche-anforderungen.md` FACH-46; `medienzugriff-fuer-komponenten.md`; `cms-widget-registry.md`; ADR-39, ADR-40, ADR-41.
|
||||
|
||||
@@ -312,6 +312,8 @@ ## 13. Premium-Karten (Brand-UI-Kit v1.7, ADR-39)
|
||||
|
||||
**Darstellung** (Reiter „Darstellung“): Variante `adaptive` (ab 520 px Bild neben Text) oder `stacked` (Bild immer oben); Höhe `auto` oder `fill` („An die Zeile angleichen“); `settings.format` (`landscape` 16:9 Vorgabe, `square`, `portrait` 3:4); `settings.fit` (`cover` Vorgabe, `contain` für Dokumente und Poster); `settings.heading_level` (`h3` Vorgabe, `h2`, `h4`); Anzeigen/Ausblenden von Kurzbeschreibung, Art (nicht bei Programm/Modul), Zusatzangaben und Aktion. Bildhöhe höchstens min(70vh, 640 px).
|
||||
|
||||
**Trailer auf der Karte (Medien-, Programm- und Modulkarte).** Einstellung `settings.clip` (`yes` Vorgabe, `no`). Der Clip ist der Trailer des Objekts (Präsentationsrolle „Trailer“, sonst „Vorschauclip“, bei einem Film ersatzweise sein freigegebener Teaser), nur wenn er für die Website freigegeben ist (`CardClip`). Er liegt stumm über dem Kartenbild und startet beim Überfahren mit der Maus, am Handy mit Tippen, per Tastatur über die Schaltfläche am Bild; `resources/js/card-clip.js`. Ohne Freigabe bleibt das Bild; die Redaktionsvorschau nennt den Grund. Entscheidung: ADR-43.
|
||||
|
||||
**Text der Karte.** Einstellung `settings.text_source` (`auto` Vorgabe, `teaser`, `summary`, `description`; an der Programm- und Modulkarte zusätzlich `goal`, das Lernziel der Fassung). `auto` entspricht dem bisherigen Verhalten je Karte (Medien: Kurzbeschreibung, sonst Teaser; Programm und Modul: Teaser, sonst Kurzbeschreibung, sonst Lernziel); die Themenkarte hat nur einen Text und keine Wahl. Eine ausdrückliche Wahl ersetzt nicht still durch ein anderes Feld. Die ausführliche Beschreibung erscheint nur auf diese Wahl (öffentlich, sofern die Karte öffentlich ist). Der eigene Text der Karte (`data.summary`) hat Vorrang.
|
||||
|
||||
**Bild aus dem Film (Medienkarte).** Reiter „Medien“, nur bei einem Film: eine Stelle mit Regler und Live-Bild wählen („Diese Stelle übernehmen“) oder „Vorschaubild des Films übernehmen“. An der Programm- und Modulkarte entsprechend „Vorschaubild übernehmen“ (`CompositionStill`). `FilmStill` legt das Einzelbild (bis 1600 px) einmal als Bild-Medium ab; `refs.image` trägt dessen Kennung. Details und Grenzen: `medienzugriff-fuer-komponenten.md`, Abschnitt „Text der Medien- und Materialkarte, Bild aus dem Film“.
|
||||
@@ -320,7 +322,7 @@ ## 13. Premium-Karten (Brand-UI-Kit v1.7, ADR-39)
|
||||
|
||||
**Raster.** Eine Karte je Platz. Gemischte Raster entstehen über die Abschnittsraster, zum Beispiel 1 + 1 + 2 (`u1_1_2`), 2 + 2, 1 + 1 + 1 + 1. Gleiche Höhe: alle Karten einer Zeile auf „An die Zeile angleichen“ stellen; die Aktion steht dann am unteren Rand. Eine öffentlich nicht sichtbare Karte lässt ihren Platz entfallen; die übrigen Plätze teilen sich die Breite. Solche Karten daher in einen eigenen Abschnitt setzen oder mit einem Platz kombinieren, der allein gut aussieht.
|
||||
|
||||
**Sicherheit.** Der einzuhaltende Weg steht in `medienzugriff-fuer-komponenten.md`. Vorschaubilder der Bibliothek (Filmstandbilder, Modulvorschau) nur über `editorial.card` (Redaktionsanmeldung) und nur in der Redaktionsvorschau; öffentlich nie. Keine Adressen unter `/bereich/` oder `/redaktion/` auf öffentlichen Seiten, kein Abspielen, kein Download, kein Preis, keine Kaufaktion. Nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtexte, Traineranleitungen. Eine Karte begründet keine Berechtigung (Tests `CmsPremiumCardsTest`).
|
||||
**Sicherheit.** Der einzuhaltende Weg steht in `medienzugriff-fuer-komponenten.md`. Vorschaubilder der Bibliothek (Filmstandbilder, Modulvorschau) nur über `editorial.card` (Redaktionsanmeldung) und nur in der Redaktionsvorschau; öffentlich nie. Keine Adressen unter `/bereich/` oder `/redaktion/` auf öffentlichen Seiten, kein Abspielen außer eines für die Website freigegebenen Trailers (ADR-43), kein Download, kein Preis, keine Kaufaktion. Nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtexte, Traineranleitungen. Eine Karte begründet keine Berechtigung (Tests `CmsPremiumCardsTest`).
|
||||
|
||||
**Erweiterungsbedarf für öffentliche Vorschaubilder und Filmvorschauen (nicht umgesetzt, minimal):**
|
||||
1. *Vorschaubild für die Website freigeben:* je `ContentElement` und `Composition` ein Freigabevermerk (`thumbnail_public_at`, `thumbnail_public_by`, Bezug auf `thumbnail_source`), gesetzt nur durch eine ausdrückliche Aktion „Vorschaubild für die Website freigeben“ in der Medien- bzw. Modulbearbeitung. Die Hintergrundverarbeitung kopiert das freigegebene Standbild nach `media_public` (eigener Pfad, zum Beispiel `katalog/`), Zurücknehmen löscht die Kopie. Die Karte nimmt dieses Bild, wenn kein Kartenbild gewählt ist. Der Web-Prozess schreibt weiterhin nicht in den Medienbestand.
|
||||
|
||||
@@ -78,7 +78,7 @@ ### Neues Bild aus dem CMS
|
||||
|
||||
Originaldatei, Master-Fassung und Traineranleitungen werden abgelehnt. Eine Quellenzeile (`website_credit`) und ein Alternativtext (`website_alt`) gehören zu den Anzeigedaten und erzeugen keine neue Fassung. Die Quellenzeile erscheint nur, solange die Freigabe besteht. Der interne Vermerk bleibt intern.
|
||||
|
||||
Ein neues Website-Bild nimmt `WebsiteIntake` auf und gibt es nach der Ableitung frei. Ein eigenständiges Präsentationsmedium legt `PresentationFile` ohne Inhaltsfassung an und gibt es nicht von selbst frei. Öffentliche Profile nach ADR-29 sind damit nicht umgesetzt.
|
||||
Ein neues Website-Bild nimmt `WebsiteIntake` auf und gibt es nach der Ableitung frei. Ein eigenständiges Präsentationsmedium legt `PresentationFile` ohne Inhaltsfassung an und gibt es nicht von selbst frei. Der Web-Prozess liest `derived/` nur; er prüft die Datei (Film: MP4 oder WebM, Hörstück: MP3, M4A oder OGG) und übergibt das Kopieren an die Warteschlange (`StorePresentationFile`). Dieselbe Website-Datei lässt sich unter „Website-Freigabe“ am Medium auch zu einem Film mit geschützter Inhaltsfassung hinzufügen, zum Beispiel für einen ungeschützten Trailer; die Fassung bleibt dabei unverändert. Öffentliche Profile nach ADR-29 sind damit nicht umgesetzt.
|
||||
|
||||
## Was eine Komponente einhält
|
||||
|
||||
@@ -182,3 +182,7 @@ ### Vorschaubild eines Programms oder Moduls (Programm- und Modulkarte)
|
||||
|
||||
Das Vorschaubild eines Programms oder Moduls (Redaktionsmanager) ist ebenfalls ein geschütztes Bibliotheksbild. Im Reiter „Medien“ der Programm- und Modulkarte übernimmt „Vorschaubild übernehmen“ es als Bild-Medium („Titelbild: {Titel}“); `CompositionStill` arbeitet wie `FilmStill`: einmal kopiert (bis zur Größe der Vorschaudatei, 640 px), über `WebsiteIntake` abgelegt, Herkunft in `composition_still_sources` (dasselbe Vorschaubild ergibt dasselbe Medium), ein gescheitertes oder archiviertes Bild wird nicht wiederverwendet, die Meldung nennt den tatsächlichen Stand (auch bei zurückgenommener Freigabe). Ein Programm ohne Vorschaubild zeigt den Hinweis, es im Redaktionsmanager zu setzen. Eine Stelle aus einem Film des Programms zu wählen gibt es hier nicht; das Vorschaubild des Programms selbst lässt sich im Redaktionsmanager aus einem Film setzen.
|
||||
|
||||
### Trailer auf Medien-, Programm- und Modulkarten
|
||||
|
||||
Ein Trailer ist ein eigenes Medium (Film ohne Fassung, Ableitung unter `teaser/`), das im Medienmanager einem Medium, Programm oder Modul in der Präsentation mit der Rolle „Trailer“ oder „Vorschauclip“ zugeordnet wird. Die Karte spielt ihn ab, wenn er für die Website freigegeben ist (Reiter „Website“ am Trailer). Lesende Klasse: `CardClip` (Trailer, sonst Vorschauclip, bei einem Film ersatzweise sein eigener freigegebener Teaser). Ausgeliefert wird über `website.media`, die Bereichsabrufe (`Range`) beantwortet. Nicht freigegebene Clips, der vollständige Film und Originale kommen nie über die Karte. Die Redaktionsvorschau spielt ebenfalls nur freigegebene Clips und nennt sonst den Grund. Verhalten (Maus, Tipp, Tastatur, reduzierte Bewegung, Datensparmodus): ADR-43.
|
||||
|
||||
@@ -229,7 +229,7 @@ .lf-pc__panel-accent {
|
||||
color: var(--pc-accent);
|
||||
}
|
||||
|
||||
/* Film ohne freigegebenes Bild: Filmtafel (Navy, Filmstreifen-Symbol, kein Abspielsymbol – die Karte spielt nichts ab). */
|
||||
/* Film ohne freigegebenes Bild: Filmtafel (Navy, Filmstreifen-Symbol, der Clip, falls freigegeben, liegt über dem Bildbereich). */
|
||||
.lf-pc__panel-icon {
|
||||
display: block;
|
||||
inline-size: 44px;
|
||||
@@ -340,3 +340,93 @@ @container slot (min-width: 520px) {
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lf-pc__cta { transition: none; }
|
||||
}
|
||||
|
||||
/*
|
||||
* Trailer (CardClip, resources/js/card-clip.js): Der Clip liegt über dem Bildbereich und blendet erst mit dem ersten
|
||||
* Bild ein; bis dahin und danach bleibt das Kartenbild stehen. Ohne JavaScript erscheint die Schaltfläche nicht.
|
||||
* Bei einem Film ohne Kartenbild liegt der Clip über der Filmtafel (lf-pc__visual--panel).
|
||||
*/
|
||||
.lf-pc__visual--panel {
|
||||
display: flex;
|
||||
align-self: start;
|
||||
}
|
||||
|
||||
.lf-pc .lf-pc__visual--panel > .lf-pc__panel {
|
||||
flex: 1 1 auto;
|
||||
min-inline-size: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.lf-pc__clip {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
inline-size: 100%;
|
||||
block-size: 100%;
|
||||
object-fit: cover;
|
||||
object-position: var(--pc-focus-x, 66%) var(--pc-focus-y, 45%);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--lf-navy);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.lf-pc--contain .lf-pc__clip {
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.is-clip-playing > .lf-pc__clip {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.lf-pc__clip-toggle {
|
||||
position: absolute;
|
||||
inset: 12px 12px auto auto;
|
||||
display: none;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-block-size: 44px;
|
||||
padding: 8px 14px 8px 10px;
|
||||
border: 0;
|
||||
border-radius: var(--radius-pill);
|
||||
color: var(--lf-white);
|
||||
background: rgb(3 37 81 / 86%);
|
||||
font: 600 0.8125rem/1.2 var(--font-reading);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.is-clip-ready > .lf-pc__clip-toggle {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.lf-pc__clip-toggle:hover {
|
||||
background: var(--lf-navy-deep, var(--lf-navy));
|
||||
}
|
||||
|
||||
.lf-pc__clip-toggle:focus-visible {
|
||||
outline: 3px solid var(--color-focus);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.lf-pc__clip-icon {
|
||||
inline-size: 20px;
|
||||
block-size: 20px;
|
||||
}
|
||||
|
||||
.lf-pc__clip-pause,
|
||||
.lf-pc__clip-toggle[aria-pressed="true"] .lf-pc__clip-play {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.lf-pc__clip-toggle[aria-pressed="true"] .lf-pc__clip-pause {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.is-clip-playing > .lf-pc__badge {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lf-pc__clip { transition: none; }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Hls from 'hls.js';
|
||||
import './site-nav.js';
|
||||
import './card-clip.js';
|
||||
|
||||
function attachPlayback(video) {
|
||||
if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') {
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Trailer auf Premium-Karten (Medien-, Programm- und Modulkarte).
|
||||
*
|
||||
* Eine Karte mit [data-card-clip] trägt einen für die Website freigegebenen Clip (data-clip-src). Der Clip
|
||||
* - startet beim Überfahren mit der Maus und endet beim Verlassen (nur Zeigergeräte mit Maus),
|
||||
* - startet am Handy und auf Wunsch auch am Desktop mit der Schaltfläche oder einem Tipp auf das Bild und endet mit dem nächsten,
|
||||
* - läuft stumm; solange er nicht spielt, bleibt das Kartenbild sichtbar (der Clip blendet erst mit dem ersten Bild ein),
|
||||
* - spielt bei „reduzierte Bewegung“ und im Datensparmodus nie von selbst, sondern nur auf ausdrückliche Bedienung, dann ohne Schleife,
|
||||
* - wird erst beim ersten Start geladen (preload="none", Quelle erst dann gesetzt),
|
||||
* - hält an, sobald die Karte aus dem Bild scrollt, und es spielt immer nur ein Clip zugleich.
|
||||
* Ohne JavaScript bleibt es beim Kartenbild; die Schaltfläche erscheint erst, wenn dieses Skript sie freigibt.
|
||||
*/
|
||||
const REDUCED = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : { matches: false };
|
||||
|
||||
let active = null;
|
||||
|
||||
function saveData() {
|
||||
return Boolean(navigator.connection && navigator.connection.saveData);
|
||||
}
|
||||
|
||||
function setup(card) {
|
||||
if (card.dataset.clipReady === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
const video = card.querySelector('video.lf-pc__clip');
|
||||
const toggle = card.querySelector('[data-clip-toggle]');
|
||||
const source = card.dataset.clipSrc;
|
||||
|
||||
if (!(video instanceof HTMLVideoElement) || !toggle || !source) {
|
||||
return;
|
||||
}
|
||||
|
||||
card.dataset.clipReady = '1';
|
||||
|
||||
const title = card.dataset.clipTitle || '';
|
||||
const host = card.closest('.lf-pc') || card;
|
||||
let mode = 'off'; // off | hover | manual
|
||||
let failed = false;
|
||||
|
||||
function label(playing) {
|
||||
toggle.setAttribute('aria-pressed', playing ? 'true' : 'false');
|
||||
toggle.setAttribute('aria-label', (playing ? 'Trailer anhalten: ' : 'Trailer abspielen: ') + title);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
mode = 'off';
|
||||
card.classList.remove('is-clip-playing');
|
||||
video.pause();
|
||||
|
||||
try {
|
||||
video.currentTime = 0;
|
||||
} catch (error) {
|
||||
// Noch keine Daten geladen: nichts zurückzusetzen.
|
||||
}
|
||||
|
||||
label(false);
|
||||
|
||||
if (active === stop) {
|
||||
active = null;
|
||||
}
|
||||
}
|
||||
|
||||
function start(nextMode) {
|
||||
if (failed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (active && active !== stop) {
|
||||
active();
|
||||
}
|
||||
|
||||
if (!video.getAttribute('src')) {
|
||||
video.src = source;
|
||||
}
|
||||
|
||||
video.muted = true;
|
||||
video.loop = !REDUCED.matches;
|
||||
mode = nextMode;
|
||||
active = stop;
|
||||
label(true);
|
||||
|
||||
const attempt = video.play();
|
||||
|
||||
if (attempt && typeof attempt.catch === 'function') {
|
||||
attempt.catch(() => {
|
||||
if (mode === nextMode) {
|
||||
stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
video.addEventListener('playing', () => {
|
||||
if (mode !== 'off') {
|
||||
card.classList.add('is-clip-playing');
|
||||
}
|
||||
});
|
||||
|
||||
video.addEventListener('ended', stop);
|
||||
|
||||
video.addEventListener('error', () => {
|
||||
failed = true;
|
||||
stop();
|
||||
card.classList.add('is-clip-failed');
|
||||
toggle.hidden = true;
|
||||
});
|
||||
|
||||
toggle.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
|
||||
if (mode === 'off') {
|
||||
start('manual');
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
});
|
||||
|
||||
// Tipp auf das Bild (Handy): wie die Schaltfläche.
|
||||
card.addEventListener('click', (event) => {
|
||||
if (event.target.closest('a, button')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === 'off') {
|
||||
start('manual');
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
});
|
||||
|
||||
host.addEventListener('pointerenter', (event) => {
|
||||
if (event.pointerType !== 'mouse' || REDUCED.matches || saveData() || mode !== 'off') {
|
||||
return;
|
||||
}
|
||||
|
||||
start('hover');
|
||||
});
|
||||
|
||||
host.addEventListener('pointerleave', (event) => {
|
||||
if (event.pointerType === 'mouse' && mode === 'hover') {
|
||||
stop();
|
||||
}
|
||||
});
|
||||
|
||||
if ('IntersectionObserver' in window) {
|
||||
new IntersectionObserver((entries) => {
|
||||
entries.forEach((entry) => {
|
||||
if (!entry.isIntersecting && mode !== 'off') {
|
||||
stop();
|
||||
}
|
||||
});
|
||||
}, { threshold: 0.2 }).observe(card);
|
||||
}
|
||||
|
||||
label(false);
|
||||
card.classList.add('is-clip-ready');
|
||||
}
|
||||
|
||||
function scan(root) {
|
||||
if (root instanceof Element) {
|
||||
if (root.matches('[data-card-clip]')) {
|
||||
setup(root);
|
||||
}
|
||||
|
||||
root.querySelectorAll('[data-card-clip]').forEach(setup);
|
||||
}
|
||||
}
|
||||
|
||||
scan(document.documentElement);
|
||||
|
||||
new MutationObserver((records) => {
|
||||
records.forEach((record) => record.addedNodes.forEach(scan));
|
||||
}).observe(document.documentElement, { childList: true, subtree: true });
|
||||
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.hidden && active) {
|
||||
active();
|
||||
}
|
||||
});
|
||||
@@ -340,6 +340,32 @@
|
||||
@if ($this->websiteFeedback !== '')
|
||||
<p class="vw-meldung" role="status"><span>{{ $this->websiteFeedback }}</span></p>
|
||||
@endif
|
||||
@if (in_array($element->output_class, ['film', 'audio'], true))
|
||||
@php
|
||||
$webDatei = filled($element->preview_path);
|
||||
$webFehler = ! $webDatei && filled($element->thumbnail_error) ? $element->thumbnail_error : null;
|
||||
$webTypen = $element->output_class === 'audio' ? '.mp3,.m4a,.ogg' : '.mp4,.webm';
|
||||
@endphp
|
||||
<dl class="vw-angaben">
|
||||
<dt>Website-Datei</dt>
|
||||
<dd>{{ $webDatei ? 'Vorhanden (ungeschützte Datei für die Website)' : 'Noch keine. Ohne sie lässt sich nur eine bereitgestellte Fassung mit Teaser freigeben.' }}</dd>
|
||||
</dl>
|
||||
@if ($webFehler)
|
||||
<p class="vw-meldung is-fehler" role="alert"><span>{{ $webFehler }}</span></p>
|
||||
@endif
|
||||
@if ($editable)
|
||||
<div style="display: grid; gap: 0.4rem; max-width: 34rem;">
|
||||
<label class="vw-feld-label" for="website-datei">{{ $webDatei ? 'Website-Datei ersetzen' : 'Website-Datei hochladen' }}</label>
|
||||
<input id="website-datei" type="file" accept="{{ $webTypen }}" wire:model="websiteUpload">
|
||||
<p class="vw-feld-hilfe">{{ $element->output_class === 'audio' ? 'MP3, M4A oder OGG.' : 'MP4 (H.264) oder WebM; andere Formate spielt der Browser nicht.' }} Die Datei ist nicht geschützt und läuft ohne Lizenz. Die geschützte Fassung bleibt unverändert.</p>
|
||||
@if ($this->websiteUpload instanceof \Livewire\Features\SupportFileUploads\TemporaryUploadedFile)
|
||||
<p class="vw-feld-hilfe">Ausgewählt, noch nicht übernommen: {{ $this->websiteUpload->getClientOriginalName() }}
|
||||
<button type="button" class="vw-link is-quiet" wire:click="$set('websiteUpload', null)">Auswahl verwerfen</button></p>
|
||||
@endif
|
||||
<div><button type="button" class="vw-btn" wire:click="storeWebsiteFile">Website-Datei übernehmen</button></div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
@if ($editable)
|
||||
<div>
|
||||
@if ($webOffen)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{{--
|
||||
Trailer der Premium-Karte (CardClip): stummer Clip über dem Kartenbild plus Schaltfläche. Das <video> bekommt seine
|
||||
Quelle erst beim ersten Start (resources/js/card-clip.js, preload="none"). Der Clip ist Beiwerk; Titel und Text der
|
||||
Karte stehen daneben, deshalb ist das Video für Hilfstechnik verborgen und die Schaltfläche trägt die Bedeutung.
|
||||
--}}
|
||||
@if (($clipUrl ?? null) !== null)
|
||||
<video class="lf-pc__clip" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
||||
<button type="button" class="lf-pc__clip-toggle" aria-pressed="false" data-clip-toggle aria-label="Trailer abspielen: {{ $clipTitle }}">
|
||||
<svg class="lf-pc__clip-icon" viewBox="0 0 24 24" focusable="false" aria-hidden="true"><path class="lf-pc__clip-play" d="M8 5.5v13l11-6.5z" fill="currentColor"/><path class="lf-pc__clip-pause" d="M7 5h4v14H7zM13 5h4v14h-4z" fill="currentColor"/></svg>
|
||||
<span class="lf-pc__clip-label" aria-hidden="true">Trailer</span>
|
||||
</button>
|
||||
@endif
|
||||
@@ -9,6 +9,11 @@
|
||||
öffentlich markiert. Es hat keine Freigabe für die Website und wird öffentlich nie ausgegeben.
|
||||
3. Tafel nach Fachobjekt: Programm/Modul (Navy), Film (Filmtafel), Material (Materialsymbol); Thema ohne Bildbereich.
|
||||
Hinweise auf fehlende Inhalte stehen nur in der Redaktionsvorschau, öffentlich nie.
|
||||
|
||||
Trailer: Ist für das Objekt ein für die Website freigegebener Clip da ($clip['url'], CardClip), liegt er stumm und
|
||||
unsichtbar über dem Bildbereich und startet beim Überfahren mit der Maus, am Handy mit Tippen auf das Bild, per
|
||||
Tastatur über die Schaltfläche (resources/js/card-clip.js). Ohne JavaScript bleibt es beim Bild. Der Clip wird erst
|
||||
beim ersten Start geladen.
|
||||
--}}
|
||||
@if ($subject === null)
|
||||
@if ($context->preview)
|
||||
@@ -21,6 +26,11 @@
|
||||
$action = $show['action'] && $subject->url !== null ? ['url' => $subject->url, 'label' => $actionLabel] : null;
|
||||
$meta = $show['meta'] ? $subject->meta : [];
|
||||
$hints = $subject->missing;
|
||||
$clipUrl = $clip['url'] ?? null;
|
||||
$clipTitle = (string) ($clip['title'] ?? '') !== '' ? $clip['title'] : $subject->title;
|
||||
if ($context->preview && ! empty($clip['hint'])) {
|
||||
$hints[] = $clip['hint'];
|
||||
}
|
||||
$panelName = ['catalog' => 'die Navy-Tafel', 'film' => 'die Filmtafel', 'material' => 'das Materialsymbol'][$subject->visual] ?? 'die Karte ohne Bild';
|
||||
if ($context->preview && $imageUrl === null) {
|
||||
$hints[] = $subject->previewImage !== null
|
||||
@@ -38,8 +48,9 @@
|
||||
'lf-pc--internal' => ! $subject->public,
|
||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
||||
@if ($imageUrl !== null || $libraryImage !== null)
|
||||
<div class="lf-pc__visual">
|
||||
<div class="lf-pc__visual" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
||||
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
||||
@include('widgets.partials.card-clip')
|
||||
@if ($show['kind'] && $subject->badge !== null)
|
||||
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
||||
@endif
|
||||
@@ -47,6 +58,14 @@
|
||||
<span class="lf-pc__library-flag">Bibliotheksbild · nur Vorschau</span>
|
||||
@endif
|
||||
</div>
|
||||
@elseif ($panel !== null && $clipUrl !== null)
|
||||
<div class="lf-pc__visual lf-pc__visual--panel" data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}">
|
||||
<div class="lf-pc__panel lf-pc__panel--{{ $panel }}" aria-hidden="true">
|
||||
<span class="lf-pc__panel-label">{{ $subject->visualLabel ?? $subject->kind }}</span>
|
||||
<x-brand.underline class="lf-pc__panel-accent" />
|
||||
</div>
|
||||
@include('widgets.partials.card-clip')
|
||||
</div>
|
||||
@elseif ($panel !== null)
|
||||
<div class="lf-pc__panel lf-pc__panel--{{ $panel }}" aria-hidden="true">
|
||||
@if ($panel === 'film')
|
||||
@@ -105,4 +124,7 @@
|
||||
</div>
|
||||
</article>
|
||||
@include('widgets.partials.image-notice')
|
||||
@if ($context->preview && ! empty($clip['notice']))
|
||||
<p class="preview-note">{{ $clip['notice'] }}</p>
|
||||
@endif
|
||||
@endif
|
||||
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\PresentationAssignment;
|
||||
use App\Domain\Catalog\PresentationRole;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Trailer auf Medien-, Programm- und Modulkarte: Die Karte spielt beim Überfahren oder Antippen nur einen für die
|
||||
* Website freigegebenen Clip ab (Präsentationsrolle „Trailer“, sonst „Vorschauclip“, bei einem Film ersatzweise sein
|
||||
* freigegebener Teaser). Ohne freigegebenen Clip bleibt es beim Bild; der Film selbst kommt nie über die Karte.
|
||||
*/
|
||||
class CmsCardTrailerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private const BYTES = '0123456789abcdefghij';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
}
|
||||
|
||||
public function test_a_released_trailer_is_offered_on_the_public_media_card(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
$this->assign($film, 'trailer', $trailer);
|
||||
$this->release($trailer);
|
||||
|
||||
$this->publish('/trailer', [$this->mediaCard($film)]);
|
||||
|
||||
$card = $this->card($this->get('/trailer')->assertOk()->getContent());
|
||||
$this->assertStringContainsString('data-card-clip', $card);
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||
$this->assertStringContainsString('<video class="lf-pc__clip" muted loop playsinline preload="none"', $card, 'Stumm, nur Schleife, nichts wird vorab geladen.');
|
||||
$this->assertDoesNotMatchRegularExpression('/<video[^>]* src=/', $card, 'Die Quelle wird erst beim ersten Start gesetzt.');
|
||||
$this->assertStringNotContainsString('autoplay', $card);
|
||||
$this->assertStringContainsString('aria-label="Trailer abspielen: Trailer Denkpause"', $card);
|
||||
$this->assertStringContainsString('lf-pc__visual--panel', $card, 'Ohne Kartenbild liegt der Clip über der Filmtafel.');
|
||||
$this->assertStringNotContainsString('originals/', $card);
|
||||
$this->assertStringNotContainsString('teaser/', $card);
|
||||
$this->assertStringNotContainsString('Der Trailer', $card, 'Hinweise für die Redaktion erscheinen öffentlich nie.');
|
||||
}
|
||||
|
||||
public function test_the_trailer_lies_over_the_card_image_when_there_is_one(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
$image = $this->image('Kartenbild Denkpause');
|
||||
$this->assign($film, 'trailer', $trailer);
|
||||
$this->release($trailer);
|
||||
$this->release($image);
|
||||
|
||||
$this->publish('/trailer-bild', [$this->mediaCard($film, ['image' => $image->id])]);
|
||||
|
||||
$card = $this->card($this->get('/trailer-bild')->assertOk()->getContent());
|
||||
$this->assertStringContainsString('<img class="lf-pc__image" src="'.route('website.media', $image).'"', $card);
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||
$this->assertStringNotContainsString('lf-pc__visual--panel', $card);
|
||||
}
|
||||
|
||||
public function test_an_unreleased_trailer_is_not_played_publicly_and_explained_in_the_preview(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$trailer = $this->clip('Trailer ohne Freigabe');
|
||||
$this->assign($film, 'trailer', $trailer);
|
||||
|
||||
$revision = $this->publish('/trailer-offen', [$this->mediaCard($film)]);
|
||||
|
||||
$public = $this->get('/trailer-offen')->assertOk()->getContent();
|
||||
$this->assertStringNotContainsString('data-card-clip', $public);
|
||||
$this->assertStringNotContainsString('<video', $public);
|
||||
$this->assertStringNotContainsString('Trailer ohne Freigabe', $public);
|
||||
$this->get(route('website.media', $trailer))->assertNotFound();
|
||||
|
||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||
$this->assertStringNotContainsString('<video', $preview, 'Auch die Redaktionsvorschau spielt keinen nicht freigegebenen Clip.');
|
||||
$this->assertStringContainsString('Der Trailer „Trailer ohne Freigabe“ ist nicht für die Website freigegeben', $preview);
|
||||
}
|
||||
|
||||
public function test_withdrawing_the_release_removes_the_trailer_from_the_page(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
$this->assign($film, 'trailer', $trailer);
|
||||
$this->release($trailer);
|
||||
$this->publish('/trailer-zurueck', [$this->mediaCard($film)]);
|
||||
|
||||
$this->assertStringContainsString('data-card-clip', $this->get('/trailer-zurueck')->getContent());
|
||||
|
||||
app(WebsiteRelease::class)->withdraw($trailer->fresh());
|
||||
$this->flushScoped();
|
||||
|
||||
$this->assertStringNotContainsString('data-card-clip', $this->get('/trailer-zurueck')->assertOk()->getContent());
|
||||
$this->get(route('website.media', $trailer))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_the_trailer_role_wins_over_the_preview_clip_and_the_film_teaser_is_the_last_resort(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$clip = $this->clip('Vorschauclip Denkpause');
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
$this->assign($film, 'vorschauclip', $clip);
|
||||
$this->assign($film, 'trailer', $trailer);
|
||||
$this->release($clip);
|
||||
$this->release($trailer);
|
||||
$this->publish('/trailer-rollen', [$this->mediaCard($film)]);
|
||||
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $this->get('/trailer-rollen')->getContent());
|
||||
|
||||
app(WebsiteRelease::class)->withdraw($trailer->fresh());
|
||||
$this->flushScoped();
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $clip).'"', $this->get('/trailer-rollen')->getContent(), 'Ohne freigegebenen Trailer gilt der Vorschauclip.');
|
||||
|
||||
PresentationAssignment::query()->delete();
|
||||
$this->flushScoped();
|
||||
$this->assertStringNotContainsString('data-card-clip', $this->get('/trailer-rollen')->getContent());
|
||||
}
|
||||
|
||||
public function test_a_film_released_for_the_website_is_its_own_teaser_clip(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$film->forceFill(['preview_path' => 'teaser/film-'.$film->id.'.mp4'])->save();
|
||||
Storage::disk('media_derived')->put($film->preview_path, self::BYTES);
|
||||
$this->release($film);
|
||||
|
||||
$this->publish('/trailer-teaser', [$this->mediaCard($film)]);
|
||||
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $film).'"', $this->get('/trailer-teaser')->assertOk()->getContent(), 'Ersatzweise der eigene freigegebene Teaser des Films.');
|
||||
}
|
||||
|
||||
public function test_other_roles_and_images_never_become_a_clip(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$interview = $this->clip('Interview Denkpause');
|
||||
$image = $this->image('Bild als Trailer');
|
||||
$this->assign($film, 'interview', $interview);
|
||||
$this->assign($film, 'trailer', $image);
|
||||
$this->release($interview);
|
||||
$this->release($image);
|
||||
|
||||
$this->publish('/trailer-falsch', [$this->mediaCard($film)]);
|
||||
|
||||
$this->assertStringNotContainsString('data-card-clip', $this->get('/trailer-falsch')->assertOk()->getContent());
|
||||
}
|
||||
|
||||
public function test_the_editor_can_switch_the_trailer_off_per_card_and_the_choice_is_validated(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
$this->assign($film, 'trailer', $trailer);
|
||||
$this->release($trailer);
|
||||
|
||||
$this->publish('/trailer-aus', [[
|
||||
'layout' => 'u1_1_1_1',
|
||||
'style' => [],
|
||||
'slots' => [
|
||||
$this->mediaCard($film, [], ['clip' => 'yes'])['slots'][0],
|
||||
$this->mediaCard($film, [], ['clip' => 'no'])['slots'][0],
|
||||
$this->mediaCard($film)['slots'][0],
|
||||
],
|
||||
]]);
|
||||
|
||||
$cards = $this->cards($this->get('/trailer-aus')->assertOk()->getContent());
|
||||
$this->assertCount(3, $cards);
|
||||
$this->assertStringContainsString('data-card-clip', $cards[0]);
|
||||
$this->assertStringNotContainsString('data-card-clip', $cards[1], 'Ausgeschaltet bleibt es beim Bild.');
|
||||
$this->assertStringContainsString('data-card-clip', $cards[2], 'Vorgabe: Abspielen, auch für schon gespeicherte Karten ohne Wahl.');
|
||||
|
||||
$registry = app(WidgetRegistry::class);
|
||||
$this->assertSame(['yes', 'no'], array_keys($registry->get('media_card')->settingOptions()['clip']));
|
||||
$this->assertSame(['yes', 'no'], array_keys($registry->get('program_card')->settingOptions()['clip']));
|
||||
$this->assertArrayNotHasKey('clip', $registry->get('topic_card')->settingOptions(), 'Ein Thema hat keinen Trailer.');
|
||||
|
||||
try {
|
||||
$registry->normalize([['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => ['clip' => 'immer'], 'data' => [], 'refs' => ['element' => $film->id]]]);
|
||||
$this->fail('Eine unbekannte Trailer-Wahl wurde angenommen.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('blocks.0.settings.clip', $exception->errors());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_the_program_card_plays_the_trailer_of_the_program(): void
|
||||
{
|
||||
$program = $this->program('Programm Mut');
|
||||
$trailer = $this->clip('Trailer Mut');
|
||||
$this->assign($program, 'trailer', $trailer);
|
||||
$this->release($trailer);
|
||||
|
||||
$this->publish('/trailer-programm', [['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'program_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['composition' => $program->id]],
|
||||
]]]);
|
||||
|
||||
$card = $this->card($this->get('/trailer-programm')->assertOk()->getContent());
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||
$this->assertStringContainsString('lf-pc__visual--panel', $card);
|
||||
}
|
||||
|
||||
public function test_a_confidential_film_never_offers_a_trailer(): void
|
||||
{
|
||||
$film = $this->publicFilm(kind: 'traineranleitung');
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
$this->assign($film, 'trailer', $trailer);
|
||||
$this->release($trailer);
|
||||
|
||||
$this->publish('/trailer-vertraulich', [$this->mediaCard($film)]);
|
||||
|
||||
$html = $this->get('/trailer-vertraulich')->assertOk()->getContent();
|
||||
$this->assertStringNotContainsString('data-card-clip', $html);
|
||||
$this->assertStringNotContainsString('Denkpause', $html, 'Die Karte einer Traineranleitung erscheint öffentlich nie.');
|
||||
}
|
||||
|
||||
public function test_the_media_route_serves_byte_ranges_for_clips(): void
|
||||
{
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
$this->release($trailer);
|
||||
$url = route('website.media', $trailer);
|
||||
|
||||
$whole = $this->get($url)->assertOk();
|
||||
$this->assertSame('bytes', $whole->headers->get('Accept-Ranges'));
|
||||
$whole->assertStreamedContent(self::BYTES);
|
||||
|
||||
$part = $this->get($url, ['Range' => 'bytes=2-5'])->assertStatus(206);
|
||||
$this->assertSame('bytes 2-5/20', $part->headers->get('Content-Range'));
|
||||
$this->assertSame('4', $part->headers->get('Content-Length'));
|
||||
$part->assertStreamedContent('2345');
|
||||
|
||||
$this->get($url, ['Range' => 'bytes=15-'])->assertStatus(206)->assertStreamedContent('fghij');
|
||||
$this->get($url, ['Range' => 'bytes=-3'])->assertStatus(206)->assertStreamedContent('hij');
|
||||
$this->get($url, ['Range' => 'bytes=0-999'])->assertStatus(206)->assertStreamedContent(self::BYTES);
|
||||
|
||||
$unsatisfiable = $this->get($url, ['Range' => 'bytes=40-50'])->assertStatus(416);
|
||||
$this->assertSame('bytes */20', $unsatisfiable->headers->get('Content-Range'));
|
||||
$this->get($url, ['Range' => 'bytes=abc'])->assertStatus(416);
|
||||
|
||||
app(WebsiteRelease::class)->withdraw($trailer->fresh());
|
||||
$this->get($url, ['Range' => 'bytes=0-3'])->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_images_ignore_range_requests(): void
|
||||
{
|
||||
$image = $this->image('Bild ohne Bereich');
|
||||
$this->release($image);
|
||||
|
||||
$this->get(route('website.media', $image), ['Range' => 'bytes=0-3'])->assertOk();
|
||||
}
|
||||
|
||||
private function publicFilm(string $kind = 'unterrichtsfilm'): ContentElement
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Denkpause Rohschnitt');
|
||||
$film->update(['display_title' => 'Eine Pause, die stark macht', 'summary' => 'KURZ-TEXT']);
|
||||
$film->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', $kind)->value('id')])->save();
|
||||
$version = $content->publishElementVersion($film, 'Film');
|
||||
$composition = $content->createComposition('Programm Denkpause');
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->save();
|
||||
$shown = $content->publishComposition($composition, [['role' => 'Film', 'target' => $version]]);
|
||||
app(CompositionDisplayRelease::class)->release($shown, User::factory()->create());
|
||||
|
||||
return $film->refresh();
|
||||
}
|
||||
|
||||
private function program(string $designation): Composition
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$composition = $content->createComposition($designation);
|
||||
$composition->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'programm')->value('id'), 'summary' => 'KURZ-TEXT'])->save();
|
||||
$version = $content->publishComposition(
|
||||
$composition,
|
||||
[['role' => 'Text', 'target' => $content->publishElementVersion($content->createElement('text', 'text', $designation.' Blatt'), 'Inhalt')]],
|
||||
);
|
||||
app(CompositionDisplayRelease::class)->release($version, User::factory()->create());
|
||||
|
||||
return $composition->refresh();
|
||||
}
|
||||
|
||||
/** Ein kurzer Clip als eigenes Medium ohne Fassung, wie ihn die Präsentation anlegt. */
|
||||
private function clip(string $title): ContentElement
|
||||
{
|
||||
return $this->presentation('film', $title, self::BYTES, 'mp4');
|
||||
}
|
||||
|
||||
private function image(string $title): ContentElement
|
||||
{
|
||||
return $this->presentation('bild', $title, 'bild-bytes', 'jpg');
|
||||
}
|
||||
|
||||
private function presentation(string $output, string $title, string $bytes, string $extension): ContentElement
|
||||
{
|
||||
$path = 'inhalte/'.md5($title).'.'.$extension;
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
$element = app(ContentService::class)->createElement($output, $output, $title);
|
||||
$element->display_title = $title;
|
||||
$element->save();
|
||||
app(PresentationFile::class)->store($element, $path);
|
||||
|
||||
return $element->fresh();
|
||||
}
|
||||
|
||||
private function assign(Composition|ContentElement $subject, string $role, ContentElement $clip): void
|
||||
{
|
||||
PresentationAssignment::query()->create([
|
||||
'subject_type' => $subject->getMorphClass(),
|
||||
'subject_id' => $subject->getKey(),
|
||||
'content_element_id' => $clip->id,
|
||||
'presentation_role_id' => PresentationRole::query()->where('slug', $role)->value('id'),
|
||||
'position' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
private function release(ContentElement $element): void
|
||||
{
|
||||
app(WebsiteRelease::class)->release($element->fresh());
|
||||
$this->flushScoped();
|
||||
}
|
||||
|
||||
private function flushScoped(): void
|
||||
{
|
||||
foreach ([WebsiteImage::class, CardClip::class, WebsiteMedia::class] as $class) {
|
||||
$this->app->forgetInstance($class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $refs
|
||||
* @param array<string, string> $settings
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function mediaCard(ContentElement $film, array $refs = [], array $settings = []): array
|
||||
{
|
||||
return ['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => $settings, 'data' => [], 'refs' => ['element' => $film->id] + $refs],
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections
|
||||
*/
|
||||
private function publish(string $path, array $sections): PageRevision
|
||||
{
|
||||
$page = Page::query()->create(['path' => $path]);
|
||||
$service = app(PageService::class);
|
||||
$revision = $service->saveRevision($page, $sections, null, null, null);
|
||||
$service->publish($page, $revision);
|
||||
|
||||
return $revision;
|
||||
}
|
||||
|
||||
private function card(string $html): string
|
||||
{
|
||||
return $this->cards($html)[0] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function cards(string $html): array
|
||||
{
|
||||
preg_match_all('#<article class="lf-pc .*?</article>#s', $html, $matches);
|
||||
|
||||
return $matches[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||
use App\Filament\Support\MediumForm;
|
||||
use App\Jobs\PublishWebsiteMedia;
|
||||
use App\Jobs\StorePresentationFile;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Website-Datei eines Films (zum Beispiel ein Trailer ohne Schutz). Der Web-Prozess hat `derived/` nur lesend
|
||||
* (docker-compose.yml); die Datei muss deshalb die Warteschlange ablegen.
|
||||
*/
|
||||
class WebsiteFileTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
}
|
||||
|
||||
public function test_the_web_process_does_not_write_to_the_derived_store_but_hands_the_copy_to_the_queue(): void
|
||||
{
|
||||
Queue::fake();
|
||||
Storage::disk('cms_incoming')->put('inhalte/trailer.mp4', 'trailer-bytes');
|
||||
$this->actingAs($this->editor(), 'staff');
|
||||
|
||||
$element = MediumForm::create([
|
||||
'working_title' => 'Trailer',
|
||||
'shape' => 'film',
|
||||
'incoming' => 'inhalte/trailer.mp4',
|
||||
'without_version' => true,
|
||||
], hold: false);
|
||||
|
||||
Queue::assertPushed(StorePresentationFile::class, fn (StorePresentationFile $job): bool => $job->elementId === $element->id);
|
||||
$this->assertEmpty(Storage::disk('media_derived')->allFiles());
|
||||
$this->assertNull($element->fresh()->preview_path);
|
||||
$this->assertSame(0, $element->versions()->count());
|
||||
}
|
||||
|
||||
public function test_the_queue_places_the_file_and_the_film_can_then_be_released_without_a_license(): void
|
||||
{
|
||||
Storage::disk('cms_incoming')->put('inhalte/trailer.mp4', 'trailer-bytes');
|
||||
$this->actingAs($this->editor(), 'staff');
|
||||
|
||||
$element = MediumForm::create([
|
||||
'working_title' => 'Trailer',
|
||||
'shape' => 'film',
|
||||
'incoming' => 'inhalte/trailer.mp4',
|
||||
'without_version' => true,
|
||||
], hold: false)->fresh();
|
||||
|
||||
$this->assertSame('teaser/'.$element->id.'/datei.mp4', $element->preview_path);
|
||||
Storage::disk('media_derived')->assertExists($element->preview_path);
|
||||
Storage::disk('cms_incoming')->assertMissing('inhalte/trailer.mp4');
|
||||
|
||||
$this->assertNull(app(WebsiteRelease::class)->refusal($element));
|
||||
app(WebsiteRelease::class)->release($element);
|
||||
$this->assertNotNull(app(WebsiteMedia::class)->present($element->fresh()));
|
||||
$this->assertSame(0, Grant::query()->count());
|
||||
Storage::disk('media_originals')->assertDirectoryEmpty('/');
|
||||
}
|
||||
|
||||
public function test_a_film_format_the_browser_cannot_play_is_refused_before_anything_is_created(): void
|
||||
{
|
||||
Storage::disk('cms_incoming')->put('inhalte/trailer.mov', 'mov-bytes');
|
||||
$this->actingAs($this->editor(), 'staff');
|
||||
|
||||
try {
|
||||
MediumForm::create([
|
||||
'working_title' => 'Trailer als MOV',
|
||||
'shape' => 'film',
|
||||
'incoming' => 'inhalte/trailer.mov',
|
||||
'without_version' => true,
|
||||
], hold: false);
|
||||
$this->fail('Eine MOV-Datei darf keine Website-Datei werden.');
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->assertStringContainsString('.mov', $e->getMessage());
|
||||
$this->assertStringContainsString('MP4', $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame(0, ContentElement::query()->count());
|
||||
}
|
||||
|
||||
public function test_a_failed_copy_is_shown_at_the_medium_instead_of_getting_lost(): void
|
||||
{
|
||||
$element = app(ContentService::class)->createElement('film', 'film', 'Trailer');
|
||||
|
||||
(new StorePresentationFile($element->id, 'inhalte/fehlt.mp4'))->handle(app(PresentationFile::class));
|
||||
|
||||
$this->assertStringContainsString('nicht im Eingang', (string) $element->fresh()->thumbnail_error);
|
||||
$this->assertNull($element->fresh()->preview_path);
|
||||
}
|
||||
|
||||
public function test_a_film_with_a_protected_version_gets_a_separate_unprotected_website_file(): void
|
||||
{
|
||||
Queue::fake([PublishWebsiteMedia::class]);
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Unterrichtsfilm');
|
||||
$version = $content->publishElementVersion($film, null, ['incoming' => 'inhalte/ganz.mp4']);
|
||||
$this->assertNotNull(app(WebsiteRelease::class)->refusal($film->fresh()));
|
||||
|
||||
$this->actingAs($this->editor(), 'staff');
|
||||
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
|
||||
->set('bereich', 'website')
|
||||
->set('websiteUpload', UploadedFile::fake()->create('trailer.mp4', 100, 'video/mp4'))
|
||||
->call('storeWebsiteFile')
|
||||
->assertSee('Die Website-Datei ist übernommen');
|
||||
|
||||
$film = $film->fresh();
|
||||
$this->assertSame('teaser/'.$film->id.'/datei.mp4', $film->preview_path);
|
||||
$this->assertSame([$version->id], $film->versions()->pluck('id')->all());
|
||||
$this->assertNull(app(WebsiteRelease::class)->refusal($film));
|
||||
}
|
||||
|
||||
public function test_the_upload_in_the_viewer_refuses_wrong_formats_and_missing_files(): void
|
||||
{
|
||||
$film = app(ContentService::class)->createElement('film', 'film', 'Film');
|
||||
$this->actingAs($this->editor(), 'staff');
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
|
||||
->set('bereich', 'website')
|
||||
->call('storeWebsiteFile')
|
||||
->assertSee('Wähle zuerst eine Datei.')
|
||||
->set('websiteUpload', UploadedFile::fake()->create('trailer.mov', 10))
|
||||
->call('storeWebsiteFile')
|
||||
->assertSee('kann der Browser nicht direkt abspielen');
|
||||
|
||||
$this->assertNull($film->fresh()->preview_path);
|
||||
}
|
||||
|
||||
public function test_replacing_the_file_of_a_released_film_publishes_the_new_copy(): void
|
||||
{
|
||||
Storage::disk('cms_incoming')->put('inhalte/neu.mp4', 'neu');
|
||||
$film = app(ContentService::class)->createElement('film', 'film', 'Trailer');
|
||||
$film->website_released_at = now();
|
||||
$film->save();
|
||||
Queue::fake([PublishWebsiteMedia::class]);
|
||||
|
||||
app(PresentationFile::class)->store($film, 'inhalte/neu.mp4');
|
||||
|
||||
Queue::assertPushed(PublishWebsiteMedia::class, fn (PublishWebsiteMedia $job): bool => $job->elementId === $film->id && $job->action === 'release');
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $editor;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user