Bildfassungen und Aufräumen des CMS #22
No files matched your search
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt für vorhandene Bilder die kleineren Fassungen an (docs/architektur/bildvarianten.md). Neue Bilder bekommen sie beim
|
||||||
|
* Ableiten; dieser Befehl holt den Bestand nach. Die Arbeit macht die Warteschlange (nur sie darf in derived/ und public/
|
||||||
|
* schreiben); mit --now läuft sie hier im Prozess, den man dafür im Queue-Container startet.
|
||||||
|
*/
|
||||||
|
class DeriveMediaVariants extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'media:varianten {--now : Sofort hier ausführen statt in die Warteschlange zu legen} {--pretend : Nur zählen}';
|
||||||
|
|
||||||
|
protected $description = 'Legt für vorhandene Vorschaubilder und freigegebene Website-Bilder die kleineren Fassungen an';
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$derived = Storage::disk('media_derived');
|
||||||
|
$paths = [];
|
||||||
|
|
||||||
|
foreach ([ContentElement::query(), Composition::query()] as $query) {
|
||||||
|
$query->where('thumbnail_path', 'like', 'vorschau/%')
|
||||||
|
->pluck('thumbnail_path')
|
||||||
|
->each(function (mixed $path) use (&$paths): void {
|
||||||
|
if (is_string($path)) {
|
||||||
|
$paths[$path] = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$missing = array_values(array_filter(
|
||||||
|
array_keys($paths),
|
||||||
|
fn (string $path): bool => ! str_contains($path, '..')
|
||||||
|
&& ! $derived->exists(ImageVariants::path($path, 'klein'))
|
||||||
|
&& $derived->exists($path),
|
||||||
|
));
|
||||||
|
|
||||||
|
$websiteIds = ContentElement::query()
|
||||||
|
->where('output_class', 'bild')
|
||||||
|
->whereNotNull('website_released_at')
|
||||||
|
->whereNotNull('website_public_path')
|
||||||
|
->pluck('id')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
$this->info(count($missing).' Vorschaubilder ohne Fassungen, '.count($websiteIds).' freigegebene Website-Bilder.');
|
||||||
|
|
||||||
|
if ($this->option('pretend')) {
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($missing as $path) {
|
||||||
|
$this->option('now') ? DeriveImageVariants::dispatchSync($path) : DeriveImageVariants::dispatch($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($websiteIds as $id) {
|
||||||
|
$this->option('now') ? DeriveWebsiteVariants::dispatchSync((int) $id) : DeriveWebsiteVariants::dispatch((int) $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info($this->option('now') ? 'Fassungen angelegt.' : 'In die Warteschlange gelegt.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,7 +49,7 @@ public function rows(Model $subject): array
|
|||||||
? (string) ($element->display_title ?: $element->working_title)
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
: 'Medium fehlt',
|
: 'Medium fehlt',
|
||||||
'image' => $element instanceof ContentElement
|
'image' => $element instanceof ContentElement
|
||||||
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'kind' => $element?->editorialContentKind?->label,
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
@@ -134,7 +134,7 @@ public function describe(array $staged): array
|
|||||||
? (string) ($element->display_title ?: $element->working_title)
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
: 'Medium fehlt',
|
: 'Medium fehlt',
|
||||||
'image' => $element instanceof ContentElement
|
'image' => $element instanceof ContentElement
|
||||||
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'kind' => $element?->editorialContentKind?->label,
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public static function previewUrl(?string $target): ?string
|
|||||||
return route('website.media', $element);
|
return route('website.media', $element);
|
||||||
}
|
}
|
||||||
|
|
||||||
return app(EditorialCatalog::class)->cardUrl('element', $element->id, $element->thumbnail_path);
|
return app(EditorialCatalog::class)->cardUrl('element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
|||||||
notice: $notice,
|
notice: $notice,
|
||||||
visual: 'catalog',
|
visual: 'catalog',
|
||||||
visualLabel: $kind,
|
visualLabel: $kind,
|
||||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at) : null,
|
||||||
missing: $missing,
|
missing: $missing,
|
||||||
texts: $texts,
|
texts: $texts,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
|||||||
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null;
|
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path, 'mittel', $shown->updated_at) : null;
|
||||||
|
|
||||||
return new CardSubject(
|
return new CardSubject(
|
||||||
title: $title,
|
title: $title,
|
||||||
|
|||||||
@@ -364,13 +364,10 @@ private function normalizeLabels(array $section, string $prefix, array &$errors,
|
|||||||
|
|
||||||
if (is_string($rawAnchor) && trim($rawAnchor) !== '') {
|
if (is_string($rawAnchor) && trim($rawAnchor) !== '') {
|
||||||
$candidate = mb_strtolower(trim($rawAnchor));
|
$candidate = mb_strtolower(trim($rawAnchor));
|
||||||
|
$problem = self::anchorProblem($candidate, array_keys($seenAnchors));
|
||||||
|
|
||||||
if (strlen($candidate) > self::MAX_ANCHOR || preg_match(self::ANCHOR_PATTERN, $candidate) !== 1) {
|
if ($problem !== null) {
|
||||||
$errors["$prefix.anchor"] = ['Eine Sprungmarke besteht aus Kleinbuchstaben, Ziffern und einzelnen Bindestrichen (höchstens '.self::MAX_ANCHOR.' Zeichen), zum Beispiel „anmeldung“.'];
|
$errors["$prefix.anchor"] = [$problem];
|
||||||
} elseif (in_array($candidate, self::RESERVED_ANCHORS, true) || str_starts_with($candidate, 'bereich-')) {
|
|
||||||
$errors["$prefix.anchor"] = ['Diese Sprungmarke ist im Seitengerüst schon vergeben. Bitte eine andere wählen.'];
|
|
||||||
} elseif (isset($seenAnchors[$candidate])) {
|
|
||||||
$errors["$prefix.anchor"] = ['Diese Sprungmarke gibt es auf der Seite schon. Jede Sprungmarke darf nur einmal vorkommen.'];
|
|
||||||
} else {
|
} else {
|
||||||
$seenAnchors[$candidate] = true;
|
$seenAnchors[$candidate] = true;
|
||||||
$anchor = $candidate;
|
$anchor = $candidate;
|
||||||
@@ -382,6 +379,29 @@ private function normalizeLabels(array $section, string $prefix, array &$errors,
|
|||||||
return [$name, $anchor];
|
return [$name, $anchor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warum eine Sprungmarke nicht zulässig ist (Form, reserviert, schon vergeben), sonst null. Gilt beim Speichern der
|
||||||
|
* Seite und im Einstellungsdialog des Abschnitts mit demselben Wortlaut.
|
||||||
|
*
|
||||||
|
* @param list<string|int> $taken Sprungmarken der übrigen Abschnitte
|
||||||
|
*/
|
||||||
|
public static function anchorProblem(string $candidate, array $taken): ?string
|
||||||
|
{
|
||||||
|
if (strlen($candidate) > self::MAX_ANCHOR || preg_match(self::ANCHOR_PATTERN, $candidate) !== 1) {
|
||||||
|
return 'Eine Sprungmarke besteht aus Kleinbuchstaben, Ziffern und einzelnen Bindestrichen (höchstens '.self::MAX_ANCHOR.' Zeichen), zum Beispiel „anmeldung“.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($candidate, self::RESERVED_ANCHORS, true) || str_starts_with($candidate, 'bereich-')) {
|
||||||
|
return 'Diese Sprungmarke ist im Seitengerüst schon vergeben. Bitte eine andere wählen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($candidate, array_map('strval', $taken), true)) {
|
||||||
|
return 'Diese Sprungmarke gibt es auf der Seite schon. Jede Sprungmarke darf nur einmal vorkommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Interner Name: Leerraum vereinheitlicht, ohne Steuerzeichen; leer oder über 80 Zeichen ergibt null. */
|
/** Interner Name: Leerraum vereinheitlicht, ohne Steuerzeichen; leer oder über 80 Zeichen ergibt null. */
|
||||||
public static function cleanName(mixed $value): ?string
|
public static function cleanName(mixed $value): ?string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ private function renderSection(array $section, array $cells, int $index, RenderC
|
|||||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||||
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
||||||
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
||||||
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview) : null;
|
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview, 1920) : null;
|
||||||
$hasImage = $imageUrl !== null;
|
$hasImage = $imageUrl !== null;
|
||||||
|
|
||||||
$classes = [
|
$classes = [
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public function elementId(mixed $value): ?int
|
|||||||
return is_int($id) ? $id : null;
|
return is_int($id) ? $id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function presentation(mixed $value): ?WebsitePresentation
|
public function presentation(mixed $value, ?ContentElement $loaded = null): ?WebsitePresentation
|
||||||
{
|
{
|
||||||
$id = $this->elementId($value);
|
$id = $this->elementId($value);
|
||||||
|
|
||||||
@@ -95,7 +95,8 @@ public function presentation(mixed $value): ?WebsitePresentation
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! array_key_exists($id, $this->presentations)) {
|
if (! array_key_exists($id, $this->presentations)) {
|
||||||
$this->presentations[$id] = $this->media->present($id) ?? false;
|
// Ein schon geladenes Medium wird weitergereicht (kein zweiter Zugriff je Eintrag in der Auswahl).
|
||||||
|
$this->presentations[$id] = $this->media->present($loaded?->getKey() === $id ? $loaded : $id) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->presentations[$id] ?: null;
|
return $this->presentations[$id] ?: null;
|
||||||
@@ -105,12 +106,12 @@ public function presentation(mixed $value): ?WebsitePresentation
|
|||||||
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
||||||
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
||||||
*/
|
*/
|
||||||
public function url(mixed $value, bool $preview = false): ?string
|
public function url(mixed $value, bool $preview = false, ?int $width = null): ?string
|
||||||
{
|
{
|
||||||
$presentation = $this->presentation($value);
|
$presentation = $this->presentation($value);
|
||||||
|
|
||||||
if ($presentation !== null) {
|
if ($presentation !== null) {
|
||||||
return $presentation->kind === 'bild' ? $presentation->url : null;
|
return $presentation->kind === 'bild' ? $presentation->urlForWidth($width) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->elementId($value);
|
$id = $this->elementId($value);
|
||||||
@@ -122,7 +123,7 @@ public function url(mixed $value, bool $preview = false): ?string
|
|||||||
|
|
||||||
$element = ContentElement::query()->find($id);
|
$element = ContentElement::query()->find($id);
|
||||||
|
|
||||||
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
$legacy = self::normalize($value);
|
$legacy = self::normalize($value);
|
||||||
@@ -134,6 +135,14 @@ public function url(mixed $value, bool $preview = false): ?string
|
|||||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** `srcset` des freigegebenen Bildes (mehrere Breiten), sonst null. Für Hero, Bild mit Text, Karten. */
|
||||||
|
public function srcset(mixed $value): ?string
|
||||||
|
{
|
||||||
|
$presentation = $this->presentation($value);
|
||||||
|
|
||||||
|
return $presentation !== null && $presentation->kind === 'bild' ? $presentation->srcset : null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
||||||
public function alt(mixed $value, mixed $override = null): string
|
public function alt(mixed $value, mixed $override = null): string
|
||||||
{
|
{
|
||||||
@@ -169,7 +178,7 @@ public function previewNotice(mixed $value, string $label = 'Das gewählte Bild'
|
|||||||
*
|
*
|
||||||
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
||||||
*/
|
*/
|
||||||
public function status(mixed $value): ?array
|
public function status(mixed $value, ?ContentElement $loaded = null): ?array
|
||||||
{
|
{
|
||||||
$value = self::normalize($value);
|
$value = self::normalize($value);
|
||||||
|
|
||||||
@@ -194,16 +203,16 @@ public function status(mixed $value): ?array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
$element = $loaded?->getKey() === $id ? $loaded : ContentElement::query()->with('editorialContentKind')->find($id);
|
||||||
|
|
||||||
if ($element === null) {
|
if ($element === null) {
|
||||||
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => null];
|
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = (string) ($element->display_title ?: $element->working_title);
|
$title = (string) ($element->display_title ?: $element->working_title);
|
||||||
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
||||||
$public = $this->presentation($id) !== null;
|
$public = $this->presentation($id, $element) !== null;
|
||||||
|
|
||||||
$note = match (true) {
|
$note = match (true) {
|
||||||
$public => 'Für die Website freigegeben.',
|
$public => 'Für die Website freigegeben.',
|
||||||
@@ -292,7 +301,7 @@ public function options(?string $search = null, int $limit = 60): array
|
|||||||
$options = [];
|
$options = [];
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if (self::isSelectable($element)) {
|
if (self::isSelectable($element)) {
|
||||||
$options[$element->id] = $this->optionHtml($element->id);
|
$options[$element->id] = $this->optionHtml($element->id, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,9 +309,9 @@ public function options(?string $search = null, int $limit = 60): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
||||||
public function optionHtml(mixed $value): ?string
|
public function optionHtml(mixed $value, ?ContentElement $loaded = null): ?string
|
||||||
{
|
{
|
||||||
$status = $this->status($value);
|
$status = $this->status($value, $loaded);
|
||||||
|
|
||||||
if ($status === null) {
|
if ($status === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -315,7 +324,7 @@ public function optionHtml(mixed $value): ?string
|
|||||||
default => ['warn', 'Website: nicht freigegeben'],
|
default => ['warn', 'Website: nicht freigegeben'],
|
||||||
};
|
};
|
||||||
$thumb = $status['thumb'] !== null
|
$thumb = $status['thumb'] !== null
|
||||||
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy">'
|
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy" decoding="async">'
|
||||||
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
||||||
|
|
||||||
return '<span class="luf-media-option">'.$thumb
|
return '<span class="luf-media-option">'.$thumb
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
||||||
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
||||||
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
||||||
|
'imageSrcset' => $images->srcset($item['image'] ?? null),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
return [
|
return [
|
||||||
'video' => $video,
|
'video' => $video,
|
||||||
'imageUrl' => $images->url($image, $context->preview),
|
'imageUrl' => $images->url($image, $context->preview),
|
||||||
|
'imageSrcset' => $images->srcset($image),
|
||||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'imageUrl' => $imageUrl,
|
'imageUrl' => $imageUrl,
|
||||||
|
'imageSrcset' => $imageUrl === null ? null : $images->srcset($image),
|
||||||
'imageAlt' => $imageAlt,
|
'imageAlt' => $imageAlt,
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'video' => $video,
|
'video' => $video,
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ protected function filmFieldData(?ContentElement $film): array
|
|||||||
? route('content.website-frame', ['element' => $film])
|
? route('content.website-frame', ['element' => $film])
|
||||||
: null,
|
: null,
|
||||||
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||||
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path, 'mittel', $film->updated_at) : null,
|
||||||
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
'clip' => $clip,
|
'clip' => $clip,
|
||||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||||
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
||||||
|
'imageSrcset' => app(WebsiteImage::class)->srcset($imageRef),
|
||||||
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||||
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
||||||
'focus' => PremiumFields::focus($data, 66, 45),
|
'focus' => PremiumFields::focus($data, 66, 45),
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ protected function imageSourceFields(): array
|
|||||||
'composition' => $composition,
|
'composition' => $composition,
|
||||||
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
||||||
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
||||||
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at)
|
||||||
: null,
|
: null,
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Größenstufen eines Bildes (docs/architektur/bildvarianten.md).
|
||||||
|
*
|
||||||
|
* Neben der Hauptdatei (`vorschau/element-12.jpg`, „voll“: bis 2400 px bei Bildern, 640 px sonst) liegen daneben
|
||||||
|
* kleinere JPEG-Fassungen, benannt nach der Hauptdatei (`element-12-klein.jpg`). Es gibt keine Spalte dafür: Die Hauptdatei
|
||||||
|
* bleibt `thumbnail_path`, die Fassungen folgen der Namensregel. Fehlt eine Fassung, gilt die Hauptdatei (kein Bruch bei
|
||||||
|
* Bestand, der noch nicht abgeleitet ist).
|
||||||
|
*
|
||||||
|
* Verwaltungsoberfläche (Disk `media_derived`):
|
||||||
|
* - `klein` 360 px: Auswahl, Listen, Karten (Anzeige bis etwa 180 px, doppelt für scharfe Bildschirme)
|
||||||
|
* - `mittel` 960 px: Detailansicht, Vorschau, Titelbild im Editor
|
||||||
|
* - voll: die Hauptdatei
|
||||||
|
*
|
||||||
|
* Website (Disk `media_public`, `website/{id}/datei-{breite}.jpg`): Breiten {@see self::PUBLIC_WIDTHS}, daneben die
|
||||||
|
* Hauptdatei `datei.jpg`. Eine Fassung entsteht nur, wenn die Quelle breiter ist (nie vergrößern).
|
||||||
|
*
|
||||||
|
* Geschrieben wird nur in der Warteschlange; der Web-Prozess liest.
|
||||||
|
*/
|
||||||
|
class ImageVariants
|
||||||
|
{
|
||||||
|
/** @var array<string, int> */
|
||||||
|
public const SIZES = ['klein' => 360, 'mittel' => 960];
|
||||||
|
|
||||||
|
/** @var list<int> */
|
||||||
|
public const PUBLIC_WIDTHS = [640, 1280, 1920];
|
||||||
|
|
||||||
|
private const QUALITY = 80;
|
||||||
|
|
||||||
|
public static function isSize(mixed $size): bool
|
||||||
|
{
|
||||||
|
return is_string($size) && array_key_exists($size, self::SIZES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isPublicWidth(mixed $width): bool
|
||||||
|
{
|
||||||
|
return is_int($width) && in_array($width, self::PUBLIC_WIDTHS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `vorschau/element-12.jpg` → `vorschau/element-12-klein.jpg` */
|
||||||
|
public static function path(string $base, string $size): string
|
||||||
|
{
|
||||||
|
$extension = pathinfo($base, PATHINFO_EXTENSION);
|
||||||
|
$stem = $extension === '' ? $base : substr($base, 0, -(strlen($extension) + 1));
|
||||||
|
|
||||||
|
return $stem.'-'.$size.'.jpg';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `website/12/datei.jpg` → `website/12/datei-640.jpg` */
|
||||||
|
public static function publicPath(string $base, int $width): string
|
||||||
|
{
|
||||||
|
return self::path($base, (string) $width);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pfad, der für die Größe ausgeliefert wird: die Fassung, wenn es sie gibt, sonst die Hauptdatei.
|
||||||
|
*/
|
||||||
|
public static function resolve(Filesystem $disk, string $base, ?string $size): string
|
||||||
|
{
|
||||||
|
if (! self::isSize($size)) {
|
||||||
|
return $base;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = self::path($base, (string) $size);
|
||||||
|
|
||||||
|
return $disk->exists($variant) ? $variant : $base;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Fassungen der Verwaltungsoberfläche zur Hauptdatei an (Warteschlange). Ist die Quelle nicht breiter als die
|
||||||
|
* Stufe, entfällt die Fassung, und eine ältere wird entfernt.
|
||||||
|
*
|
||||||
|
* @return list<string> Pfade der geschriebenen Fassungen
|
||||||
|
*/
|
||||||
|
public static function generate(Filesystem $disk, string $base): array
|
||||||
|
{
|
||||||
|
$targets = [];
|
||||||
|
|
||||||
|
foreach (self::SIZES as $name => $width) {
|
||||||
|
$targets[self::path($base, $name)] = $width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::write($disk, $disk, $base, $targets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Breiten für die Website neben der öffentlichen Hauptdatei an. Nur JPEG-Quellen: andere Formate (PNG, GIF,
|
||||||
|
* WebP) können Transparenz tragen, die ein JPEG nicht hält; sie bleiben unverändert.
|
||||||
|
*
|
||||||
|
* @return list<string> Pfade der geschriebenen Fassungen
|
||||||
|
*/
|
||||||
|
public static function generatePublic(Filesystem $source, Filesystem $target, string $sourcePath, string $publicBase): array
|
||||||
|
{
|
||||||
|
if (! in_array(strtolower(pathinfo($publicBase, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$targets = [];
|
||||||
|
|
||||||
|
foreach (self::PUBLIC_WIDTHS as $width) {
|
||||||
|
$targets[self::publicPath($publicBase, $width)] = $width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::write($source, $target, $sourcePath, $targets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Entfernt alle Fassungen zu einer öffentlichen Hauptdatei (Rücknahme, Ersatz). */
|
||||||
|
public static function deletePublic(Filesystem $disk, string $publicBase): void
|
||||||
|
{
|
||||||
|
foreach (self::PUBLIC_WIDTHS as $width) {
|
||||||
|
$disk->delete(self::publicPath($publicBase, $width));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, int> $targets Zielpfad → Breite
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private static function write(Filesystem $source, Filesystem $target, string $sourcePath, array $targets): array
|
||||||
|
{
|
||||||
|
if (! $source->exists($sourcePath)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes = $source->get($sourcePath);
|
||||||
|
$image = is_string($bytes) && $bytes !== '' ? @imagecreatefromstring($bytes) : false;
|
||||||
|
|
||||||
|
if ($image === false) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$width = imagesx($image);
|
||||||
|
$height = imagesy($image);
|
||||||
|
$written = [];
|
||||||
|
|
||||||
|
foreach ($targets as $path => $targetWidth) {
|
||||||
|
if ($width <= $targetWidth) {
|
||||||
|
$target->delete($path);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$encoded = self::scaled($image, $width, $height, $targetWidth);
|
||||||
|
|
||||||
|
if ($encoded !== null && $target->put($path, $encoded)) {
|
||||||
|
$written[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imagedestroy($image);
|
||||||
|
|
||||||
|
return $written;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function scaled(\GdImage $image, int $width, int $height, int $targetWidth): ?string
|
||||||
|
{
|
||||||
|
$targetHeight = (int) max(1, round($height * ($targetWidth / max(1, $width))));
|
||||||
|
$canvas = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||||
|
imagefill($canvas, 0, 0, (int) imagecolorallocate($canvas, 255, 255, 255));
|
||||||
|
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
|
||||||
|
imageinterlace($canvas, true);
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($canvas, null, self::QUALITY);
|
||||||
|
$bytes = ob_get_clean();
|
||||||
|
imagedestroy($canvas);
|
||||||
|
|
||||||
|
return is_string($bytes) && $bytes !== '' ? $bytes : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,6 +89,7 @@ public function place(ContentElement $element, string $incoming): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($element->output_class === 'bild') {
|
if ($element->output_class === 'bild') {
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $target);
|
||||||
$element->thumbnail_path = $target;
|
$element->thumbnail_path = $target;
|
||||||
$element->thumbnail_source = 'eigen';
|
$element->thumbnail_source = 'eigen';
|
||||||
} else {
|
} else {
|
||||||
@@ -97,6 +98,7 @@ public function place(ContentElement $element, string $incoming): void
|
|||||||
|
|
||||||
$element->thumbnail_error = null;
|
$element->thumbnail_error = null;
|
||||||
$element->save();
|
$element->save();
|
||||||
|
$element->touch();
|
||||||
Storage::disk('cms_incoming')->delete($incoming);
|
Storage::disk('cms_incoming')->delete($incoming);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -335,6 +335,7 @@ private function frame(ContentElement $element, ContentElementVersion $version,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageVariants::generate($disk, $target);
|
||||||
$element->thumbnail_path = $target;
|
$element->thumbnail_path = $target;
|
||||||
if (! filled($element->thumbnail_alt)) {
|
if (! filled($element->thumbnail_alt)) {
|
||||||
$element->thumbnail_alt = $element->working_title;
|
$element->thumbnail_alt = $element->working_title;
|
||||||
@@ -344,6 +345,7 @@ private function frame(ContentElement $element, ContentElementVersion $version,
|
|||||||
$element->thumbnail_source = 'frame:'.$version->id.'@0';
|
$element->thumbnail_source = 'frame:'.$version->id.'@0';
|
||||||
}
|
}
|
||||||
$element->save();
|
$element->save();
|
||||||
|
$element->touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function still(ContentElement|Composition $subject, Filesystem $disk, string $file, string $name): void
|
private function still(ContentElement|Composition $subject, Filesystem $disk, string $file, string $name): void
|
||||||
@@ -388,6 +390,7 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
|||||||
|
|
||||||
$path = 'vorschau/'.$name.'.jpg';
|
$path = 'vorschau/'.$name.'.jpg';
|
||||||
Storage::disk('media_derived')->put($path, $bytes);
|
Storage::disk('media_derived')->put($path, $bytes);
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $path);
|
||||||
$subject->thumbnail_path = $path;
|
$subject->thumbnail_path = $path;
|
||||||
|
|
||||||
if (! filled($subject->thumbnail_alt)) {
|
if (! filled($subject->thumbnail_alt)) {
|
||||||
@@ -396,6 +399,9 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
|||||||
|
|
||||||
$subject->thumbnail_error = null;
|
$subject->thumbnail_error = null;
|
||||||
$subject->save();
|
$subject->save();
|
||||||
|
// Die Adresse trägt die Version (updated_at) und wird dauerhaft zwischengespeichert: Ein neu abgeleitetes Bild
|
||||||
|
// unter gleichem Pfad muss die Version ändern, auch wenn sonst nichts an der Zeile anders ist.
|
||||||
|
$subject->touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rememberElement(ContentElement $element, string $source): void
|
private function rememberElement(ContentElement $element, string $source): void
|
||||||
|
|||||||
@@ -2,14 +2,37 @@
|
|||||||
|
|
||||||
namespace App\Domain\Media;
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
|
||||||
class ThumbnailRef
|
class ThumbnailRef
|
||||||
{
|
{
|
||||||
public static function url(string $route, string $kind, int $id, mixed $path): ?string
|
/**
|
||||||
|
* Adresse eines Vorschaubildes.
|
||||||
|
*
|
||||||
|
* @param string|null $size `klein` (Auswahl, Listen, Karten), `mittel` (Detail, Vorschau) oder null für die volle Datei
|
||||||
|
* @param CarbonInterface|int|string|null $version Stand des Bildes (zum Beispiel `updated_at`). Mit Version darf der Browser das Bild
|
||||||
|
* dauerhaft behalten; ohne Version fragt er jedes Mal nach (ETag).
|
||||||
|
*/
|
||||||
|
public static function url(string $route, string $kind, int $id, mixed $path, ?string $size = null, CarbonInterface|int|string|null $version = null): ?string
|
||||||
{
|
{
|
||||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return route($route, ['kind' => $kind, 'subject' => $id]);
|
$query = [];
|
||||||
|
|
||||||
|
if (ImageVariants::isSize($size)) {
|
||||||
|
$query['g'] = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version instanceof CarbonInterface) {
|
||||||
|
$version = $version->getTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version !== null && $version !== '') {
|
||||||
|
$query['v'] = $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return route($route, ['kind' => $kind, 'subject' => $id] + $query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,37 @@ public function present(ContentElement|int $element): ?WebsitePresentation
|
|||||||
'audio' => 'audio',
|
'audio' => 'audio',
|
||||||
default => 'bild',
|
default => 'bild',
|
||||||
},
|
},
|
||||||
url: route('website.media', $element),
|
// Bilder tragen den Zeitpunkt der Freigabe in der Adresse (dauerhaft zwischenspeicherbar); Film und Hörstück bleiben unverändert.
|
||||||
|
url: $element->output_class === 'film' || $element->output_class === 'audio'
|
||||||
|
? route('website.media', $element)
|
||||||
|
: route('website.media', ['element' => $element, 'v' => $element->website_released_at->getTimestamp()]),
|
||||||
|
srcset: $this->srcset($element, $path),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `srcset` eines freigegebenen JPEG-Bildes: die Breiten aus {@see ImageVariants::PUBLIC_WIDTHS} und die volle Datei.
|
||||||
|
* Fehlt eine Breite noch (Bestand), liefert die Adresse die volle Datei und stößt das Anlegen an; die Beschreibung bleibt
|
||||||
|
* dann ungenau, das Bild aber richtig. PNG, GIF und WebP bleiben ohne Fassungen (Transparenz).
|
||||||
|
*/
|
||||||
|
private function srcset(ContentElement $element, string $path): ?string
|
||||||
|
{
|
||||||
|
if ($element->output_class !== 'bild' || ! in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $element->website_released_at->getTimestamp();
|
||||||
|
$entries = [];
|
||||||
|
|
||||||
|
foreach (ImageVariants::PUBLIC_WIDTHS as $width) {
|
||||||
|
$entries[] = route('website.media', ['element' => $element, 'w' => $width, 'v' => $version]).' '.$width.'w';
|
||||||
|
}
|
||||||
|
|
||||||
|
$entries[] = route('website.media', ['element' => $element, 'v' => $version]).' 2400w';
|
||||||
|
|
||||||
|
return implode(', ', $entries);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,5 +15,19 @@ public function __construct(
|
|||||||
public readonly ?string $credit,
|
public readonly ?string $credit,
|
||||||
public readonly string $kind,
|
public readonly string $kind,
|
||||||
public readonly string $url,
|
public readonly string $url,
|
||||||
|
/** Bildadressen in mehreren Breiten für `srcset` (nur Bilder, deren Breiten die Warteschlange anlegt), sonst null. */
|
||||||
|
public readonly ?string $srcset = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adresse in einer der Breiten aus {@see ImageVariants::PUBLIC_WIDTHS}; ohne Breiten (oder bei anderer Breite) die volle Datei.
|
||||||
|
*/
|
||||||
|
public function urlForWidth(?int $width): string
|
||||||
|
{
|
||||||
|
if ($width === null || $this->srcset === null || ! ImageVariants::isPublicWidth($width)) {
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->url.(str_contains($this->url, '?') ? '&' : '?').'w='.$width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ public function form(Schema $schema): Schema
|
|||||||
Placeholder::make('thumbnail_current')->label('Aktuelles Vorschaubild')->content(function (): HtmlString {
|
Placeholder::make('thumbnail_current')->label('Aktuelles Vorschaubild')->content(function (): HtmlString {
|
||||||
/** @var ContentElement $element */
|
/** @var ContentElement $element */
|
||||||
$element = $this->getRecord();
|
$element = $this->getRecord();
|
||||||
$url = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
$url = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
$caption = match ($element->thumbnail_source) {
|
$caption = match ($element->thumbnail_source) {
|
||||||
'eigen' => 'Eigenes Vorschaubild.',
|
'eigen' => 'Eigenes Vorschaubild.',
|
||||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ private function viewerData(): array
|
|||||||
&& $element->output_class === 'text'
|
&& $element->output_class === 'text'
|
||||||
&& $shown->status !== ContentVersionStatus::Gesperrt,
|
&& $shown->status !== ContentVersionStatus::Gesperrt,
|
||||||
'bodyCommitted' => $committed,
|
'bodyCommitted' => $committed,
|
||||||
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at),
|
||||||
'pictureCaption' => $this->pictureCaption($element),
|
'pictureCaption' => $this->pictureCaption($element),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -1076,7 +1076,7 @@ public function previewHtml(): string
|
|||||||
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||||
'hide_status' => true,
|
'hide_status' => true,
|
||||||
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
||||||
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at),
|
||||||
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ protected function catalogRows(): array
|
|||||||
'titel' => $title,
|
'titel' => $title,
|
||||||
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
||||||
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
||||||
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path) : null,
|
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path, 'klein', $cover->updated_at) : null,
|
||||||
'symbol' => 'dokument',
|
'symbol' => 'dokument',
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'chips' => $chips,
|
'chips' => $chips,
|
||||||
|
|||||||
@@ -176,6 +176,11 @@ public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotificat
|
|||||||
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
|
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
|
||||||
$this->showFailingSection(array_keys($exception->errors()));
|
$this->showFailingSection(array_keys($exception->errors()));
|
||||||
|
|
||||||
|
// Name und Sprungmarke stehen im Einstellungsdialog; die Meldung am Abschnitt führt dorthin. Hierher scrollen.
|
||||||
|
if (preg_match('/data\.sections\.[^.]+\.(name|anchor)(\.|\s|$)/', $keys) === 1) {
|
||||||
|
$this->js("requestAnimationFrame(() => requestAnimationFrame(() => document.querySelector('[data-abschnitt-fehler]')?.scrollIntoView({ block: 'center' })))");
|
||||||
|
}
|
||||||
|
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,14 @@
|
|||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Catalog\OfferStatus;
|
use App\Domain\Catalog\OfferStatus;
|
||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Filament\Resources\Combinations\CombinationResource;
|
use App\Filament\Resources\Combinations\CombinationResource;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\Courses\CourseResource;
|
use App\Filament\Resources\Courses\CourseResource;
|
||||||
use App\Filament\Resources\Documents\DocumentResource;
|
use App\Filament\Resources\Documents\DocumentResource;
|
||||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||||
use App\Filament\Resources\Practices\PracticeResource;
|
use App\Filament\Resources\Practices\PracticeResource;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -115,7 +117,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
'usage_note' => (string) ($element->usage_note ?? ''),
|
'usage_note' => (string) ($element->usage_note ?? ''),
|
||||||
'license_note' => (string) ($element->license_note ?? ''),
|
'license_note' => (string) ($element->license_note ?? ''),
|
||||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||||
'image' => $this->cardUrl('element', $element->id, $element->thumbnail_path),
|
'image' => $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at),
|
||||||
'version_label' => match ($version->status) {
|
'version_label' => match ($version->status) {
|
||||||
ContentVersionStatus::Entwurf => 'Entwurf',
|
ContentVersionStatus::Entwurf => 'Entwurf',
|
||||||
ContentVersionStatus::Gesperrt => 'deaktiviert',
|
ContentVersionStatus::Gesperrt => 'deaktiviert',
|
||||||
@@ -163,7 +165,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
'kind' => $kind,
|
'kind' => $kind,
|
||||||
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
||||||
'tone' => $this->tone('', $kind),
|
'tone' => $this->tone('', $kind),
|
||||||
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
|
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at),
|
||||||
'version_label' => $version->status === ContentVersionStatus::Gesperrt
|
'version_label' => $version->status === ContentVersionStatus::Gesperrt
|
||||||
? 'deaktiviert'
|
? 'deaktiviert'
|
||||||
: 'Fassung '.$version->number,
|
: 'Fassung '.$version->number,
|
||||||
@@ -198,7 +200,7 @@ private function draftCompositionRow(int $compositionId, int $exceptCompositionI
|
|||||||
'kind' => $kind,
|
'kind' => $kind,
|
||||||
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
||||||
'tone' => $this->tone('', $kind),
|
'tone' => $this->tone('', $kind),
|
||||||
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
|
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at),
|
||||||
'version_label' => 'Entwurf',
|
'version_label' => 'Entwurf',
|
||||||
'identity' => 'zusammenstellung:'.$composition->id,
|
'identity' => 'zusammenstellung:'.$composition->id,
|
||||||
'open_url' => route('editorial.draft-preview', ['composition' => $composition]),
|
'open_url' => route('editorial.draft-preview', ['composition' => $composition]),
|
||||||
@@ -524,7 +526,7 @@ private function rowForPresentationMedium(int $id): ?array
|
|||||||
'license_note' => (string) ($element->license_note ?? ''),
|
'license_note' => (string) ($element->license_note ?? ''),
|
||||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||||
'image' => $element->output_class === 'bild'
|
'image' => $element->output_class === 'bild'
|
||||||
? $this->cardUrl('element', $element->id, $element->thumbnail_path)
|
? $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'version_label' => 'Ohne Inhaltsfassung',
|
'version_label' => 'Ohne Inhaltsfassung',
|
||||||
'committed' => false,
|
'committed' => false,
|
||||||
@@ -548,13 +550,9 @@ public function tone(string $outputClass, string $kindLabel): string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cardUrl(string $kind, int $id, ?string $path): ?string
|
public function cardUrl(string $kind, int $id, ?string $path, ?string $size = null, CarbonInterface|int|string|null $version = null): ?string
|
||||||
{
|
{
|
||||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
return ThumbnailRef::url('editorial.card', $kind, $id, $path, $size, $version);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return route('editorial.card', ['kind' => $kind, 'subject' => $id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -891,7 +889,7 @@ public function filmPictures(array $members): array
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
|
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
|
|
||||||
if ($image === null || isset($pictures[$element->id])) {
|
if ($image === null || isset($pictures[$element->id])) {
|
||||||
continue;
|
continue;
|
||||||
@@ -933,7 +931,7 @@ public function mediaPictures(string $query): array
|
|||||||
->limit(12)
|
->limit(12)
|
||||||
->get()
|
->get()
|
||||||
->map(function (ContentElement $element): ?array {
|
->map(function (ContentElement $element): ?array {
|
||||||
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
|
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
|
|
||||||
if ($image === null) {
|
if ($image === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -957,7 +955,7 @@ public function mediaPictures(string $query): array
|
|||||||
*/
|
*/
|
||||||
public function cover(Composition $composition, array $members): array
|
public function cover(Composition $composition, array $members): array
|
||||||
{
|
{
|
||||||
$own = $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path);
|
$own = $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at);
|
||||||
|
|
||||||
if ($own !== null) {
|
if ($own !== null) {
|
||||||
return ['url' => $own, 'note' => null, 'own' => true];
|
return ['url' => $own, 'note' => null, 'own' => true];
|
||||||
@@ -970,7 +968,7 @@ public function cover(Composition $composition, array $members): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt'),
|
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt', 'mittel'),
|
||||||
'note' => $picture['note'],
|
'note' => $picture['note'],
|
||||||
'own' => false,
|
'own' => false,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
|||||||
'description' => $description === '' ? null : $description,
|
'description' => $description === '' ? null : $description,
|
||||||
'usageNote' => $usageNote === '' ? null : $usageNote,
|
'usageNote' => $usageNote === '' ? null : $usageNote,
|
||||||
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
||||||
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at),
|
||||||
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||||
'imageNote' => $this->imageNote($element),
|
'imageNote' => $this->imageNote($element),
|
||||||
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
use App\Domain\Cms\Sections\SectionStyle;
|
use App\Domain\Cms\Sections\SectionStyle;
|
||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
|
use Closure;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Filament\Schemas\Components\Utilities\Set;
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -70,6 +73,8 @@ public static function repeater(string $name = 'sections'): Repeater
|
|||||||
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
||||||
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
||||||
->extraItemActions([
|
->extraItemActions([
|
||||||
|
// Name, Sprungmarke und Sichtbarkeit: im Dialog statt als Eingabeblock in jedem Abschnitt.
|
||||||
|
self::settingsAction(),
|
||||||
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
||||||
Action::make('gestalten')
|
Action::make('gestalten')
|
||||||
->label('Abschnitt gestalten')
|
->label('Abschnitt gestalten')
|
||||||
@@ -93,7 +98,11 @@ private static function sectionSchema(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Hidden::make('id'),
|
Hidden::make('id'),
|
||||||
self::labelSection(),
|
// Name, Sprungmarke und Sichtbarkeit werden im Einstellungsdialog geändert; der Zustand bleibt am Abschnitt.
|
||||||
|
Hidden::make('name'),
|
||||||
|
Hidden::make('anchor'),
|
||||||
|
Hidden::make('hidden'),
|
||||||
|
View::make('filament.cms.abschnitt-meldung')->columnSpanFull(),
|
||||||
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
||||||
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
||||||
Section::make('Raster und Breite')
|
Section::make('Raster und Breite')
|
||||||
@@ -158,22 +167,60 @@ private static function sectionSchema(): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name, Sprungmarke und Sichtbarkeit: stehen im Seitenaufbau am Abschnitt, damit man sie beim Ordnen der Seite sieht.
|
* Einstellungsdialog des Abschnitts: Name, Sprungmarke und Sichtbarkeit. „Übernehmen“ ändert nur den Seitenentwurf
|
||||||
|
* (gespeichert wird mit „Entwurf speichern“); Abbrechen, Schließen und Esc verwerfen die Eingaben des Dialogs.
|
||||||
*/
|
*/
|
||||||
private static function labelSection(): Section
|
private static function settingsAction(): Action
|
||||||
{
|
{
|
||||||
return Section::make('Name, Sprungmarke und Sichtbarkeit')
|
return Action::make('einstellungen')
|
||||||
->columnSpanFull()
|
->label('Abschnitt-Einstellungen: Name, Sprungmarke und Sichtbarkeit')
|
||||||
->compact()
|
->tooltip('Name, Sprungmarke und Sichtbarkeit')
|
||||||
->collapsible()
|
->icon('heroicon-o-cog-6-tooth')
|
||||||
->collapsed(fn (Get $get): bool => blank($get('name')) && blank($get('anchor')) && ! $get('hidden'))
|
->iconButton()
|
||||||
->extraAttributes(['class' => 'luf-abschnitt-bezeichnung'])
|
->color('gray')
|
||||||
->schema([
|
->extraAttributes(['data-luf-einstellungen' => ''])
|
||||||
|
->modalWidth(Width::Large)
|
||||||
|
->modalHeading(fn (array $arguments, Repeater $component): string => 'Abschnitt '.self::position($component->getRawState(), (string) ($arguments['item'] ?? '')).': Einstellungen')
|
||||||
|
->modalDescription('„Übernehmen“ ändert den Seitenentwurf; gespeichert wird mit „Entwurf speichern“. Abbrechen, Schließen und Esc verwerfen die Änderungen.')
|
||||||
|
->modalSubmitActionLabel('Übernehmen')
|
||||||
|
->modalCancelActionLabel('Abbrechen')
|
||||||
|
->fillForm(fn (array $arguments, Repeater $component): array => self::settingsOf($component->getRawState(), (string) ($arguments['item'] ?? '')))
|
||||||
|
->schema(fn (array $arguments, Repeater $component): array => self::settingsFields(self::otherAnchors($component->getRawState(), (string) ($arguments['item'] ?? ''))))
|
||||||
|
->action(function (array $data, array $arguments, Repeater $component): void {
|
||||||
|
$item = (string) ($arguments['item'] ?? '');
|
||||||
|
$state = $component->getRawState();
|
||||||
|
|
||||||
|
if (! is_array($state) || ! isset($state[$item]) || ! is_array($state[$item])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nur diese drei Angaben des Abschnitts ändern sich; Raster, Gestaltung und Bausteine bleiben unberührt.
|
||||||
|
$state[$item]['name'] = filled($data['name'] ?? null) ? trim((string) $data['name']) : null;
|
||||||
|
$state[$item]['anchor'] = self::slugAnchor($data['anchor'] ?? null);
|
||||||
|
$state[$item]['hidden'] = (bool) ($data['hidden'] ?? false);
|
||||||
|
|
||||||
|
$component->rawState($state);
|
||||||
|
$component->callAfterStateUpdated();
|
||||||
|
$livewire = $component->getLivewire();
|
||||||
|
|
||||||
|
// Nach einer Dialogaktion rendert Filament sonst nur den Dialog neu; Kopf und Zusammenfassung blieben alt.
|
||||||
|
if (method_exists($livewire, 'forceRender')) {
|
||||||
|
$livewire->forceRender();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<Hidden|TextInput|Toggle>
|
||||||
|
*/
|
||||||
|
private static function settingsFields(array $takenAnchors): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
TextInput::make('name')
|
TextInput::make('name')
|
||||||
->label('Name des Abschnitts')
|
->label('Name des Abschnitts')
|
||||||
->placeholder('Zum Beispiel „Kursübersicht“')
|
->placeholder('Zum Beispiel „Kursübersicht“')
|
||||||
->maxLength(PageSections::MAX_NAME)
|
->maxLength(PageSections::MAX_NAME)
|
||||||
->live(onBlur: true)
|
->autofocus()
|
||||||
->hintIcon('heroicon-m-information-circle', tooltip: 'Nur zur Orientierung im Seitenaufbau und in der Linkauswahl. Der Name erscheint nie auf der Website.')
|
->hintIcon('heroicon-m-information-circle', tooltip: 'Nur zur Orientierung im Seitenaufbau und in der Linkauswahl. Der Name erscheint nie auf der Website.')
|
||||||
->hintColor('gray'),
|
->hintColor('gray'),
|
||||||
TextInput::make('anchor')
|
TextInput::make('anchor')
|
||||||
@@ -185,6 +232,15 @@ private static function labelSection(): Section
|
|||||||
->afterStateUpdated(function (?string $state, Set $set): void {
|
->afterStateUpdated(function (?string $state, Set $set): void {
|
||||||
$set('anchor', filled($state) ? Str::slug($state, '-', 'de') : null);
|
$set('anchor', filled($state) ? Str::slug($state, '-', 'de') : null);
|
||||||
})
|
})
|
||||||
|
->rules([
|
||||||
|
fn (): Closure => function (string $attribute, mixed $value, Closure $fail) use ($takenAnchors): void {
|
||||||
|
$problem = PageSections::anchorProblem((string) self::slugAnchor($value), $takenAnchors);
|
||||||
|
|
||||||
|
if ($problem !== null) {
|
||||||
|
$fail($problem);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
->suffixAction(Action::make('anchorFromName')
|
->suffixAction(Action::make('anchorFromName')
|
||||||
->label('Sprungmarke aus dem Namen vorschlagen')
|
->label('Sprungmarke aus dem Namen vorschlagen')
|
||||||
->icon('heroicon-o-sparkles')
|
->icon('heroicon-o-sparkles')
|
||||||
@@ -195,12 +251,64 @@ private static function labelSection(): Section
|
|||||||
->helperText(fn (Get $get, $livewire): ?string => self::anchorLinkText($get('anchor'), $livewire)),
|
->helperText(fn (Get $get, $livewire): ?string => self::anchorLinkText($get('anchor'), $livewire)),
|
||||||
Toggle::make('hidden')
|
Toggle::make('hidden')
|
||||||
->label('Auf der Website ausblenden')
|
->label('Auf der Website ausblenden')
|
||||||
->live()
|
|
||||||
->hintIcon('heroicon-m-information-circle', tooltip: 'Der Abschnitt bleibt im Entwurf erhalten, erscheint aber nicht auf der Website. Auch eine Sprungmarke dieses Abschnitts führt dann ins Leere. In der Seitenvorschau steht an seiner Stelle ein Hinweis.')
|
->hintIcon('heroicon-m-information-circle', tooltip: 'Der Abschnitt bleibt im Entwurf erhalten, erscheint aber nicht auf der Website. Auch eine Sprungmarke dieses Abschnitts führt dann ins Leere. In der Seitenvorschau steht an seiner Stelle ein Hinweis.')
|
||||||
->hintColor('gray')
|
->hintColor('gray'),
|
||||||
->columnSpanFull(),
|
];
|
||||||
])
|
}
|
||||||
->columns(['default' => 1, 'md' => 2]);
|
|
||||||
|
/**
|
||||||
|
* Sprungmarke in die zulässige Form bringen (wie beim Verlassen des Feldes); leer ergibt null.
|
||||||
|
*/
|
||||||
|
private static function slugAnchor(mixed $value): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($value) || trim($value) === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$slug = Str::limit(Str::slug($value, '-', 'de'), PageSections::MAX_ANCHOR, '');
|
||||||
|
|
||||||
|
return $slug === '' ? null : $slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{name: ?string, anchor: ?string, hidden: bool}
|
||||||
|
*/
|
||||||
|
private static function settingsOf(mixed $state, string $item): array
|
||||||
|
{
|
||||||
|
$section = is_array($state) && is_array($state[$item] ?? null) ? $state[$item] : [];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => is_string($section['name'] ?? null) ? $section['name'] : null,
|
||||||
|
'anchor' => is_string($section['anchor'] ?? null) ? $section['anchor'] : null,
|
||||||
|
'hidden' => (bool) ($section['hidden'] ?? false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarken der anderen Abschnitte (auch ungespeicherte): Eine Marke gibt es je Seite nur einmal.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private static function otherAnchors(mixed $state, string $item): array
|
||||||
|
{
|
||||||
|
$anchors = [];
|
||||||
|
|
||||||
|
foreach (is_array($state) ? $state : [] as $key => $section) {
|
||||||
|
if ((string) $key === $item || ! is_array($section) || ! is_string($section['anchor'] ?? null) || trim($section['anchor']) === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchors[] = mb_strtolower(trim($section['anchor']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $anchors;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function position(mixed $state, string $item): int
|
||||||
|
{
|
||||||
|
$index = array_search($item, array_map('strval', array_keys(is_array($state) ? $state : [])), true);
|
||||||
|
|
||||||
|
return $index === false ? 1 : $index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Concerns;
|
||||||
|
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liefert ein Bild einer Disk mit Zwischenspeicherung aus (docs/architektur/bildvarianten.md).
|
||||||
|
*
|
||||||
|
* Mit Versionsangabe in der Adresse (`?v=`) ändert sich die Adresse, sobald sich das Bild ändert; der Browser darf es
|
||||||
|
* dann ein Jahr behalten. Ohne Version bleibt es bei einer Rückfrage mit ETag und Last-Modified (304 ohne Inhalt).
|
||||||
|
*/
|
||||||
|
trait ServesImages
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param 'public'|'private' $scope `private` für alles, was eine Anmeldung oder Berechtigung voraussetzt
|
||||||
|
*/
|
||||||
|
protected function respondWithImage(Request $request, string $diskName, string $path, string $scope = 'private', bool $versioned = false): Response
|
||||||
|
{
|
||||||
|
$disk = Storage::disk($diskName);
|
||||||
|
$headers = [
|
||||||
|
'Content-Disposition' => 'inline',
|
||||||
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
|
];
|
||||||
|
$response = $disk->response($path, null, $headers);
|
||||||
|
$modified = (int) $disk->lastModified($path);
|
||||||
|
$size = (int) $disk->size($path);
|
||||||
|
|
||||||
|
$response->setEtag(md5($path.'|'.$modified.'|'.$size));
|
||||||
|
$response->setLastModified(Carbon::createFromTimestamp($modified));
|
||||||
|
|
||||||
|
if ($versioned) {
|
||||||
|
$response->headers->set('Cache-Control', $scope.', max-age=31536000, immutable');
|
||||||
|
} else {
|
||||||
|
$response->headers->set('Cache-Control', $scope.', max-age=0, must-revalidate');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->isNotModified($request);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pfad der angefragten Größe (`?g=klein|mittel`), sonst die Hauptdatei. */
|
||||||
|
protected function imagePathFor(Request $request, string $diskName, string $path): string
|
||||||
|
{
|
||||||
|
$size = $request->query('g');
|
||||||
|
$resolved = ImageVariants::resolve(Storage::disk($diskName), $path, is_string($size) ? $size : null);
|
||||||
|
|
||||||
|
// Bestand ohne Fassungen: Die Hauptdatei geht hinaus, und die Warteschlange legt die Fassungen an (der Web-Prozess
|
||||||
|
// schreibt nie). Höchstens einmal je Tag und Bild; ist die Quelle schmaler als die Stufe, bleibt es bei der Hauptdatei.
|
||||||
|
if ($resolved === $path && ImageVariants::isSize($size) && Cache::add('bildvarianten.'.md5($path), true, now()->addDay())) {
|
||||||
|
DeriveImageVariants::dispatch($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `?v=` ist da und eine einfache Zahl (Zeitstempel). */
|
||||||
|
protected function hasImageVersion(Request $request): bool
|
||||||
|
{
|
||||||
|
$version = $request->query('v');
|
||||||
|
|
||||||
|
return is_string($version) && preg_match('/^[0-9]{1,12}$/', $version) === 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,15 +12,18 @@
|
|||||||
use App\Domain\Identity\StaffRole;
|
use App\Domain\Identity\StaffRole;
|
||||||
use App\Domain\Media\ThumbnailDeriver;
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
use App\Filament\Support\EditorialCatalog;
|
use App\Filament\Support\EditorialCatalog;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
|
|
||||||
class EditorialPreviewController extends Controller
|
class EditorialPreviewController extends Controller
|
||||||
{
|
{
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
public function show(Composition $composition, ?CompositionVersion $version = null): View
|
public function show(Composition $composition, ?CompositionVersion $version = null): View
|
||||||
{
|
{
|
||||||
$this->authorizeStaff();
|
$this->authorizeStaff();
|
||||||
@@ -104,7 +107,7 @@ public function draft(Composition $composition): View
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function card(string $kind, int $subject): StreamedResponse
|
public function card(Request $request, string $kind, int $subject): SymfonyResponse
|
||||||
{
|
{
|
||||||
$this->authorizeStaff();
|
$this->authorizeStaff();
|
||||||
abort_unless(in_array($kind, ['element', 'komposition'], true), 404);
|
abort_unless(in_array($kind, ['element', 'komposition'], true), 404);
|
||||||
@@ -116,7 +119,13 @@ public function card(string $kind, int $subject): StreamedResponse
|
|||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($path), 404);
|
abort_unless($disk->exists($path), 404);
|
||||||
|
|
||||||
return $disk->response($path);
|
return $this->respondWithImage(
|
||||||
|
$request,
|
||||||
|
'media_derived',
|
||||||
|
$this->imagePathFor($request, 'media_derived', $path),
|
||||||
|
'private',
|
||||||
|
$this->hasImageVersion($request),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
use App\Domain\Media\FilmPlayback;
|
use App\Domain\Media\FilmPlayback;
|
||||||
use App\Domain\Media\HlsPlaylist;
|
use App\Domain\Media\HlsPlaylist;
|
||||||
use App\Domain\Media\MediaRendition;
|
use App\Domain\Media\MediaRendition;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\CourseOutline;
|
use App\Http\CourseOutline;
|
||||||
use App\Http\LibraryCatalog;
|
use App\Http\LibraryCatalog;
|
||||||
@@ -32,10 +33,13 @@
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class LibraryController extends Controller
|
class LibraryController extends Controller
|
||||||
{
|
{
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
/** Inhaltsarten der Bibliothek (Schlüssel der Adresse und des Filters). */
|
/** Inhaltsarten der Bibliothek (Schlüssel der Adresse und des Filters). */
|
||||||
public const TYPES = [
|
public const TYPES = [
|
||||||
'programm' => 'Programme',
|
'programm' => 'Programme',
|
||||||
@@ -361,7 +365,7 @@ public function rendition(
|
|||||||
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function thumbnail(Request $request, string $kind, int $subject): StreamedResponse
|
public function thumbnail(Request $request, string $kind, int $subject): SymfonyResponse
|
||||||
{
|
{
|
||||||
abort_unless(in_array($kind, ['komposition', 'element'], true), 404);
|
abort_unless(in_array($kind, ['komposition', 'element'], true), 404);
|
||||||
$model = $kind === 'komposition'
|
$model = $kind === 'komposition'
|
||||||
@@ -373,7 +377,13 @@ public function thumbnail(Request $request, string $kind, int $subject): Streame
|
|||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($path), 404);
|
abort_unless($disk->exists($path), 404);
|
||||||
|
|
||||||
return $disk->response($path);
|
return $this->respondWithImage(
|
||||||
|
$request,
|
||||||
|
'media_derived',
|
||||||
|
$this->imagePathFor($request, 'media_derived', $path),
|
||||||
|
'private',
|
||||||
|
$this->hasImageVersion($request),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,16 +3,22 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
use App\Domain\Media\WebsiteMedia;
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use App\Http\Controllers\Concerns\ServesByteRanges;
|
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class WebsiteMediaController extends Controller
|
class WebsiteMediaController extends Controller
|
||||||
{
|
{
|
||||||
use ServesByteRanges;
|
use ServesByteRanges;
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
public function show(Request $request, ContentElement $element, WebsiteMedia $media): StreamedResponse
|
public function show(Request $request, ContentElement $element, WebsiteMedia $media): Response
|
||||||
{
|
{
|
||||||
$presentation = $media->present($element);
|
$presentation = $media->present($element);
|
||||||
abort_if($presentation === null, 404);
|
abort_if($presentation === null, 404);
|
||||||
@@ -20,6 +26,45 @@ public function show(Request $request, ContentElement $element, WebsiteMedia $me
|
|||||||
$path = $element->website_public_path;
|
$path = $element->website_public_path;
|
||||||
abort_if(! is_string($path), 404);
|
abort_if(! is_string($path), 404);
|
||||||
|
|
||||||
return $this->respondWithRanges($request, 'media_public', $path, $presentation->kind !== 'bild');
|
if ($presentation->kind !== 'bild') {
|
||||||
|
return $this->respondWithRanges($request, 'media_public', $path, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $this->widthPath($request, $element, $path);
|
||||||
|
// Die Adresse trägt den Zeitpunkt der Freigabe. Gilt er noch, ändert sich der Inhalt unter dieser Adresse nicht mehr
|
||||||
|
// (eine neue Freigabe liefert eine neue Adresse); eine veraltete Adresse wird nur kurz vorgehalten und geprüft.
|
||||||
|
$current = $this->hasImageVersion($request)
|
||||||
|
&& (int) $request->query('v') === $element->website_released_at?->getTimestamp();
|
||||||
|
|
||||||
|
return $this->respondWithImage($request, 'media_public', $path, 'public', $current);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die angefragte Breite (`?w=640|1280|1920`), sonst die volle Datei. Fehlt die Breite noch, geht die volle Datei hinaus,
|
||||||
|
* und die Warteschlange legt die Breiten an (höchstens einmal je Stunde und Bild; der Web-Prozess schreibt nie).
|
||||||
|
*/
|
||||||
|
private function widthPath(Request $request, ContentElement $element, string $path): string
|
||||||
|
{
|
||||||
|
$width = $request->query('w');
|
||||||
|
|
||||||
|
if (! is_string($width) || preg_match('/^[0-9]{3,4}$/', $width) !== 1 || ! ImageVariants::isPublicWidth((int) $width)) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = ImageVariants::publicPath($path, (int) $width);
|
||||||
|
|
||||||
|
if (Storage::disk('media_public')->exists($variant)) {
|
||||||
|
return $variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Cache::add('bildvarianten.website.'.$element->id, true, now()->addHour())) {
|
||||||
|
DeriveWebsiteVariants::dispatch($element->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +92,7 @@ public function index(User $user): array
|
|||||||
'image_url' => $picture === null ? null : route('member.thumbnail', [
|
'image_url' => $picture === null ? null : route('member.thumbnail', [
|
||||||
'kind' => $picture['kind'],
|
'kind' => $picture['kind'],
|
||||||
'subject' => $picture['subject'],
|
'subject' => $picture['subject'],
|
||||||
|
'g' => 'mittel',
|
||||||
]),
|
]),
|
||||||
'url' => route('member.program', $composition),
|
'url' => route('member.program', $composition),
|
||||||
];
|
];
|
||||||
@@ -113,7 +114,7 @@ public function index(User $user): array
|
|||||||
: ($element?->id !== null ? 'element-'.$element->id : 'artikel-'.$article->id);
|
: ($element?->id !== null ? 'element-'.$element->id : 'artikel-'.$article->id);
|
||||||
$subject = $element ?? $composition ?? $article;
|
$subject = $element ?? $composition ?? $article;
|
||||||
$text = $element !== null ? $this->text($element) : null;
|
$text = $element !== null ? $this->text($element) : null;
|
||||||
$imageUrl = $element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path);
|
$imageUrl = $element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
$media[$key] = ($media[$key] ?? []) + [
|
$media[$key] = ($media[$key] ?? []) + [
|
||||||
'used_in' => [],
|
'used_in' => [],
|
||||||
'versions' => [],
|
'versions' => [],
|
||||||
@@ -376,7 +377,7 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($view !== null && $element !== null) {
|
if ($view !== null && $element !== null) {
|
||||||
$poster = ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path);
|
$poster = ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ private function entry(User $user, Grant $grant): array
|
|||||||
|
|
||||||
if ($grant->status === GrantStatus::Aktiv) {
|
if ($grant->status === GrantStatus::Aktiv) {
|
||||||
$imageUrl = $composition !== null
|
$imageUrl = $composition !== null
|
||||||
? ThumbnailRef::url('member.thumbnail', 'komposition', $composition->id, $composition->thumbnail_path)
|
? ThumbnailRef::url('member.thumbnail', 'komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at)
|
||||||
: ($element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path));
|
: ($element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at));
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $composition !== null
|
$title = $composition !== null
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die kleineren Fassungen (klein, mittel) zu einem vorhandenen Vorschaubild an. Läuft nur in der Warteschlange, die in
|
||||||
|
* derived/ schreiben darf. Auslöser: Bestand ohne Fassungen, den die Auslieferung oder der Befehl `media:varianten` findet.
|
||||||
|
*/
|
||||||
|
class DeriveImageVariants implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(public readonly string $path) {}
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
if (preg_match('#^vorschau/[A-Za-z0-9._\-/]+$#', $this->path) !== 1 || str_contains($this->path, '..')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $this->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Breiten für die Website zu einem bereits freigegebenen Bild an (Bestand von vor den Bildfassungen). Verändert
|
||||||
|
* weder die Freigabe noch den Prüfverlauf; die Freigabe selbst schreibt die Fassungen in {@see PublishWebsiteMedia}.
|
||||||
|
*/
|
||||||
|
class DeriveWebsiteVariants implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(public readonly int $elementId) {}
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || $element->output_class !== 'bild' || $element->website_released_at === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
|
||||||
|
if (! is_string($path) || preg_match('#^website/'.$element->id.'/datei\.[a-z0-9]+$#', $path) !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$disk = Storage::disk('media_public');
|
||||||
|
ImageVariants::generatePublic($disk, $disk, $path, $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\IdentityChange;
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
use App\Domain\Media\WebsiteRelease;
|
use App\Domain\Media\WebsiteRelease;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
@@ -51,6 +52,12 @@ public function handle(WebsiteRelease $release): void
|
|||||||
|
|
||||||
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
||||||
Storage::disk('media_public')->delete($previous);
|
Storage::disk('media_public')->delete($previous);
|
||||||
|
ImageVariants::deletePublic(Storage::disk('media_public'), $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class === 'bild') {
|
||||||
|
// Breiten für die Website neben der Hauptdatei; ohne sie liefert die Website immer die volle Datei.
|
||||||
|
ImageVariants::generatePublic(Storage::disk('media_derived'), Storage::disk('media_public'), $derived, $target);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
||||||
@@ -69,6 +76,8 @@ private function deletePublicFile(ContentElement $element): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
Storage::disk('media_public')->delete($path);
|
Storage::disk('media_public')->delete($path);
|
||||||
|
// Auch die Breiten: Sonst bliebe ein zurückgenommenes Bild unter dem Namen einer Fassung erreichbar.
|
||||||
|
ImageVariants::deletePublic(Storage::disk('media_public'), $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
||||||
|
|||||||
@@ -943,3 +943,33 @@ ## ADR-62 – Kommunikation: Formularansicht mit Ziehen und Ablegen statt Builde
|
|||||||
**Alternativen.** Filament-Builder mit besseren Blocktiteln (verworfen: bleibt eine aufklappbare Endlosliste ohne sichtbare Zugehörigkeit). Neue Datenstruktur mit verschachtelten Teilbereichen im Entwurf (ausgeschlossen: kein neues Datenmodell; die Zugehörigkeit steht schon als Feldgruppe im Katalog). Eigenes Ziehen ohne Bibliothek (verworfen: Berührung, Animation und Randfälle liefert SortableJS).
|
**Alternativen.** Filament-Builder mit besseren Blocktiteln (verworfen: bleibt eine aufklappbare Endlosliste ohne sichtbare Zugehörigkeit). Neue Datenstruktur mit verschachtelten Teilbereichen im Entwurf (ausgeschlossen: kein neues Datenmodell; die Zugehörigkeit steht schon als Feldgruppe im Katalog). Eigenes Ziehen ohne Bibliothek (verworfen: Berührung, Animation und Randfälle liefert SortableJS).
|
||||||
**Folgen.** Keine Migration. Die Livewire-Tests des Editors wurden bewusst auf den Baumtext umgestellt (der Builder entfällt). Rückfall auf ADR-61: Der Entwurf bleibt gültig; die ältere Ansicht liest ihn wieder. Das Ziehen bietet auf Berührungsbildschirmen SortableJS-Standardverhalten, wurde dort aber nicht geprüft.
|
**Folgen.** Keine Migration. Die Livewire-Tests des Editors wurden bewusst auf den Baumtext umgestellt (der Builder entfällt). Rückfall auf ADR-61: Der Entwurf bleibt gültig; die ältere Ansicht liest ihn wieder. Das Ziehen bietet auf Berührungsbildschirmen SortableJS-Standardverhalten, wurde dort aber nicht geprüft.
|
||||||
**Quelle.** Rückmeldung von Lars vom 28.11.2026 zur Bedienung des Formular-Editors; ADR-61.
|
**Quelle.** Rückmeldung von Lars vom 28.11.2026 zur Bedienung des Formular-Editors; ADR-61.
|
||||||
|
|
||||||
|
## ADR-63 – Bildfassungen: Thumbnail, Web und Vollauflösung
|
||||||
|
|
||||||
|
**Status am 28.11.2026:** Umgesetzt auf `feature/bildvarianten`; Messung und Abnahme auf `luf-test` offen. Beschreibung: `docs/architektur/bildvarianten.md`.
|
||||||
|
**Kontext.** Medienauswahl, Contentmanager und Listen luden für jedes Kachelbild dieselbe Datei wie die Vorschau (bei Bildern bis 2400 px), die Website lieferte immer die volle Fassung. Jedes Bild war eine PHP-Anfrage mit Sitzung (`Set-Cookie`, Zeile in `sessions`) und `Cache-Control: no-cache, private`; der Browser behielt nichts. Gemessen auf `luf-test`: 120 bis 260 KB je Vorschaubild, ein PNG mit 1,2 MB als Website-Datei.
|
||||||
|
**Entscheidung.**
|
||||||
|
- **Drei Stufen je Bild.** Verwaltung: `klein` (360 px), `mittel` (960 px) und die volle Datei (`thumbnail_path`, unverändert). Website: Breiten 640, 1280 und 1920 px neben der vollen Datei (`website/{id}/datei-{breite}.jpg`). Fassungen entstehen nur, wenn die Quelle breiter ist; nie vergrößert.
|
||||||
|
- **Namensregel statt Spalte.** `element-12-klein.jpg` liegt neben `element-12.jpg`. Keine Migration. Fehlt eine Fassung, gilt die nächstgrößere Datei; Bestand bricht nicht.
|
||||||
|
- **Geschrieben wird nur in der Warteschlange** (`ThumbnailDeriver`, `PresentationFile::place`, `PublishWebsiteMedia`). Der Web-Prozess liest nur. Bestand ohne Fassungen füllt sich selbst: Die Auslieferung nimmt die volle Datei und legt einen Auftrag an (Website: `DeriveWebsiteVariants`, höchstens einmal je Stunde und Bild; Verwaltung und Mitgliederbereich: `DeriveImageVariants`, höchstens einmal je Tag und Bild); `media:varianten` holt alles auf einmal nach, ohne Zugriff auf den Server.
|
||||||
|
- **Zwischenspeicherung.** Adressen tragen Größe (`g`) und Version (`v`, `updated_at` des Mediums bzw. Zeitpunkt der Freigabe). Mit Version: ein Jahr, `immutable` (`private` in der Verwaltung und im Mitgliederbereich, `public` auf der Website). Ohne Version: ETag und Last-Modified, `304` ohne Inhalt. Eine neue Ableitung setzt die Version (`touch`).
|
||||||
|
- **Website ohne Sitzung.** Die Route `website.media` läuft ohne Sitzung, Cookies und CSRF: keine Sitzungszeile, kein `Set-Cookie`, zwischenspeicherbar.
|
||||||
|
- **`srcset`** in Hero, Bild mit Text, Karten und Medienkarte; Abschnittshintergründe nehmen die Breite 1920. Nur JPEG-Quellen erhalten Breiten (PNG, GIF, WebP können Transparenz tragen).
|
||||||
|
- **Rücknahme** der Website-Freigabe löscht auch die Breiten.
|
||||||
|
- **Auswahl im CMS:** Die Optionsliste fragte je Eintrag das Medium dreimal ab; geladene Medien werden jetzt weitergereicht.
|
||||||
|
**Alternativen.** WebP (verworfen für jetzt: das Docker-Image baut GD ohne WebP; eigener Schritt mit Dockerfile-Änderung). Fassungen im Aufruf berechnen und zwischenspeichern (verworfen: der Web-Prozess darf nicht schreiben). Spalten für Fassungen (verworfen: Namensregel genügt, keine Migration). Statische Auslieferung durch den Webserver (verworfen: private Medien bleiben hinter der Berechtigung).
|
||||||
|
**Folgen.** Keine Migration. Tests mit festen Adressen der Website-Bilder wurden bewusst geändert (Adresse trägt `?v=`, Bild-Tags tragen `srcset`). Rückfall: Ein Stand ohne ADR-63 kennt `g`/`v` nicht und liefert die volle Datei; die Fassungsdateien bleiben liegen und stören nicht. Offen: EXIF-Drehung (Handyfotos), WebP.
|
||||||
|
**Quelle.** Rückmeldung von Lars vom 28.11.2026 zu den Ladezeiten von Medienauswahl, Contentmanager und Website.
|
||||||
|
|
||||||
|
## ADR-64 – CMS-Seiteneditor: Abschnittseinstellungen im Dialog und kompakterer Seitenaufbau
|
||||||
|
|
||||||
|
**Status am 28.11.2026:** Umgesetzt auf `feature/cms-seitenaufbau-kompakt`; praktische Abnahme durch den Betreiber auf `luf-test` offen. Ändert nur Darstellung und Bedienung des Seiteneditors (ADR zur Seitenarbeitsfläche, Abschnitte mit Name und Sprungmarke). Abnahme: `docs/ux/verwaltung/abnahme/cms-seitenaufbau.md`.
|
||||||
|
**Kontext.** Jeder Abschnitt zeigte einen eigenen Block „Name, Sprungmarke und Sichtbarkeit“, dazu gestrichelte Rahmen um jeden Platz und Rahmen um Bausteinvorschauen. Bei Seiten mit mehreren Abschnitten füllten wiederholte Einstellungen und verschachtelte Rahmen den Bildschirm; Aufbau und Inhalt der Seite waren schwer zu überblicken.
|
||||||
|
**Entscheidung.**
|
||||||
|
- **Einstellungsdialog:** Ein Zahnrad im Abschnittskopf öffnet „Abschnitt N: Einstellungen“ (Name, Sprungmarke mit Vorschlag und Linkhinweis, „Auf der Website ausblenden“). Umgesetzt als Filament-Aktion am Abschnitt (`SectionEditor::settingsAction`); die drei Angaben bleiben als verdeckte Felder im Formularzustand, damit Speichern, Fingerabdruck („nicht gespeichert“) und Revisionen unverändert funktionieren.
|
||||||
|
- **Speicherverhalten:** „Übernehmen“ ändert nur den Seitenarbeitsstand (andere offene Eingaben der Seite bleiben); Abbrechen, Schließen und Esc verwerfen. Dauerhaft speichert weiter „Entwurf speichern“.
|
||||||
|
- **Prüfung:** Die Sprungmarke wird im Dialog in die zulässige Form gebracht und mit denselben Regeln und Texten geprüft wie beim Speichern (`PageSections::anchorProblem`), auch gegen noch ungespeicherte Marken der anderen Abschnitte. Lehnt das Speichern der Seite Name oder Sprungmarke ab, steht die Meldung am Abschnitt mit „Einstellungen öffnen“, und die Seite scrollt dorthin.
|
||||||
|
- **Kompakter Aufbau (nur Stile):** Der Einstellungsblock entfällt; Abstände in Abschnitt und Platzraster sind kleiner, ein Platz ist eine leise Fläche statt eines gestrichelten Rahmens (nur ein leerer Platz bleibt umrandet), Rahmen um Baustein und Vorschau entfallen. Abschnittskante, Raster mit bis zu vier Einheiten, Konfigurieren, Duplizieren, Verschieben, Entfernen und Einklappen sind unverändert.
|
||||||
|
**Alternativen.** Eigenes Overlay statt Filament-Aktion (verworfen: Fokus, Esc und Abbrechen liefert die Aktion bereits). Einstellungen beim Abschnitt eingeklappt lassen (verworfen: der Kopf des eingeklappten Blocks belegt weiter eine Zeile je Abschnitt).
|
||||||
|
**Folgen.** Keine Migration, kein neues Seitenformat. Rückfall: Der ältere Stand zeigt die Eingabefelder wieder im Abschnitt; gespeicherte Werte bleiben erhalten.
|
||||||
|
**Quelle.** Auftrag von Lars vom 28.11.2026 (Überarbeitung der Übersicht des CMS-Seiteneditors).
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Bildfassungen (ADR-63)
|
||||||
|
|
||||||
|
Stand 28.11.2026. Gilt für alle Bilder, die die Anwendung anzeigt: Vorschaubilder der Verwaltung (Medienauswahl, Listen, Karten, Aufbau), Bilder im CMS und auf der Website.
|
||||||
|
|
||||||
|
## Stufen
|
||||||
|
|
||||||
|
| Stufe | Wo | Breite | Verwendung |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `klein` | `derived/vorschau/…-klein.jpg` | 360 px | Auswahl, Listen, Kacheln, Zeilen im Aufbau |
|
||||||
|
| `mittel` | `derived/vorschau/…-mittel.jpg` | 960 px | Detailansicht, Vorschau im Editor, Kartenbilder in Seitenvorschauen, Poster |
|
||||||
|
| voll | `derived/vorschau/element-N.jpg` (`thumbnail_path`) | Bilder bis 2400 px, sonst 640 px | Quelle für die Website-Freigabe |
|
||||||
|
| Website | `public/website/N/datei-{640,1280,1920}.jpg` | 640, 1280, 1920 | `srcset` von Hero, Bild mit Text, Karten; Hintergrund 1920 |
|
||||||
|
| Website voll | `public/website/N/datei.jpg` | bis 2400 px | Rückfall und `src` |
|
||||||
|
| Original | `originals/…`, `derived/inhalte/…` | unverändert | nur Hintergrundverarbeitung, nie ausgeliefert |
|
||||||
|
|
||||||
|
Die Fassungen heißen wie die Hauptdatei mit Suffix (`ImageVariants::path`). Es gibt keine Spalte. **Fehlt eine Fassung, gilt die nächstgrößere Datei.**
|
||||||
|
|
||||||
|
## Wer schreibt
|
||||||
|
|
||||||
|
Nur die Warteschlange (`queue`); der Web-Prozess liest:
|
||||||
|
|
||||||
|
- `ThumbnailDeriver::still()` und `frame()` (jede Ableitung eines Vorschaubildes) und `PresentationFile::place()` rufen `ImageVariants::generate`.
|
||||||
|
- `PublishWebsiteMedia` (Freigabe) ruft `ImageVariants::generatePublic`; Rücknahme und Ersatz löschen die Breiten.
|
||||||
|
- `DeriveImageVariants` und `DeriveWebsiteVariants` füllen Bestand nach. Sie werden vom Befehl `php artisan media:varianten` (`--now`, `--pretend`) oder von der Auslieferung angestoßen, wenn eine Breite fehlt (höchstens einmal je Stunde und Bild).
|
||||||
|
|
||||||
|
Eine Fassung entsteht nur, wenn die Quelle breiter ist; sonst wird eine ältere gelöscht. Fassungen sind JPEG (Qualität 80, progressiv), transparente Flächen werden weiß. Website-Breiten gibt es nur für JPEG-Quellen.
|
||||||
|
|
||||||
|
## Auslieferung
|
||||||
|
|
||||||
|
- **Verwaltung** `GET /redaktion/karte/{kind}/{subject}?g=klein|mittel&v=…` (nur angemeldete Redaktion) und **Mitgliederbereich** `member.thumbnail` mit denselben Parametern (Berechtigung unverändert).
|
||||||
|
- **Website** `GET /website-medien/{id}?w=640|1280|1920&v=…` (nur freigegebene Medien).
|
||||||
|
- `ThumbnailRef::url(route, kind, id, path, size, version)` und `EditorialCatalog::cardUrl` bauen die Adressen. Wer ein Bild neu anzeigt, wählt `klein` für alles unter etwa 180 px Anzeigebreite, sonst `mittel`, und übergibt `updated_at` als Version.
|
||||||
|
- Mit `v` in der Adresse: `Cache-Control: private|public, max-age=31536000, immutable`. Ohne `v` oder bei veralteter Website-Version: `max-age=0, must-revalidate` mit ETag und Last-Modified, `304` bei unverändertem Bild.
|
||||||
|
- Die Website-Route läuft ohne Sitzung und Cookies.
|
||||||
|
|
||||||
|
## Nachprüfen
|
||||||
|
|
||||||
|
Auf dem Server nur lesend: `ls derived/vorschau | grep -- -klein`, `ls public/website/*/`. Im Browser: Netzwerk-Reiter, `Cache-Control` und Größe der Bilder; zweiter Aufruf der Medienauswahl lädt die Bilder aus dem Browser-Cache.
|
||||||
|
|
||||||
|
## Nicht enthalten
|
||||||
|
|
||||||
|
EXIF-Drehung von Handyfotos (bisher nicht beachtet), WebP/AVIF (das Image baut GD ohne WebP), Fassungen für Film-Standbilder über 640 px.
|
||||||
@@ -275,7 +275,7 @@ ## 11. Abschnitte und Plätze
|
|||||||
- `anchor`: Sprungmarke (Kleinbuchstaben, Ziffern, einzelne Bindestriche, höchstens 60 Zeichen), je Seite eindeutig, ohne reservierte Kennungen (`inhalt`, `main`, `top`, `site-nav`, `fuss-themen`, `mb-account-menu`, Vorsilbe `bereich-`). Der Renderer gibt sie als `id` des Abschnitts aus; ohne Sprungmarke bleibt `bereich-<Kennung>`. Der Versatz zur festen Kopfzeile kommt aus `scroll-padding-top` (`resources/css/base.css`). Ein Link „#marke“ gilt auf derselben Seite, „/pfad#marke“ von anderen Seiten, „https://Adresse/pfad#marke“ von außen.
|
- `anchor`: Sprungmarke (Kleinbuchstaben, Ziffern, einzelne Bindestriche, höchstens 60 Zeichen), je Seite eindeutig, ohne reservierte Kennungen (`inhalt`, `main`, `top`, `site-nav`, `fuss-themen`, `mb-account-menu`, Vorsilbe `bereich-`). Der Renderer gibt sie als `id` des Abschnitts aus; ohne Sprungmarke bleibt `bereich-<Kennung>`. Der Versatz zur festen Kopfzeile kommt aus `scroll-padding-top` (`resources/css/base.css`). Ein Link „#marke“ gilt auf derselben Seite, „/pfad#marke“ von anderen Seiten, „https://Adresse/pfad#marke“ von außen.
|
||||||
- `hidden`: `true` blendet den Abschnitt auf der Website aus. Er zählt weder für die Hauptüberschrift (H1) noch für Trenner; Bilder und Medien bleiben erfasst, damit sie nicht als ungenutzt gelten. Die Seitenvorschau zeigt an seiner Stelle einen schmalen Hinweis. `pageTitle()` übergeht ausgeblendete Abschnitte.
|
- `hidden`: `true` blendet den Abschnitt auf der Website aus. Er zählt weder für die Hauptüberschrift (H1) noch für Trenner; Bilder und Medien bleiben erfasst, damit sie nicht als ungenutzt gelten. Die Seitenvorschau zeigt an seiner Stelle einen schmalen Hinweis. `pageTitle()` übergeht ausgeblendete Abschnitte.
|
||||||
- Fehler: `sections.N.name`, `sections.N.anchor` (Form, reserviert, doppelt). Ein kopierter Abschnitt gibt seine Sprungmarke ab (Namen erhalten „(Kopie)“), damit die Seite speicherbar bleibt.
|
- Fehler: `sections.N.name`, `sections.N.anchor` (Form, reserviert, doppelt). Ein kopierter Abschnitt gibt seine Sprungmarke ab (Namen erhalten „(Kopie)“), damit die Seite speicherbar bleibt.
|
||||||
- Im Seitenaufbau stehen die Felder am Abschnitt („Name, Sprungmarke und Sichtbarkeit“); die Kopfzeile des Abschnitts zeigt Name, `#marke` und „Ausgeblendet“.
|
- Im Seitenaufbau stehen die Felder nicht mehr als Eingabeblock im Abschnitt: Der Einstellungsbutton (Zahnrad) im Abschnittskopf öffnet einen Dialog „Abschnitt N: Einstellungen“ mit Name, Sprungmarke (samt „aus dem Namen vorschlagen“ und Linkhinweis) und „Auf der Website ausblenden“. „Übernehmen“ ändert nur den Seitenentwurf; Abbrechen, Schließen und Esc verwerfen. Die Kopfzeile des Abschnitts zeigt Name, `#marke` und „Ausgeblendet“ als Zusammenfassung. Der Dialog prüft die Sprungmarke mit denselben Regeln und Texten wie das Speichern (`PageSections::anchorProblem`), auch gegen noch ungespeicherte Marken der anderen Abschnitte. Lehnt das Speichern der Seite Name oder Sprungmarke ab, steht die Meldung am Abschnitt mit „Einstellungen öffnen“. Das gespeicherte Format ändert sich nicht.
|
||||||
|
|
||||||
**Linkziele.** `SafeUrl` erlaubt Seitenpfade (auch mit `#marke`), `#marke` (nur diese Seite) und http(s)-Adressen. Alle Linkfelder der Widgets (Schaltflächen von Einstieg und Bild-Text, Handlungsaufforderung, Karten, Merkmale) sind `WidgetsSupportinkfield`: ein Textfeld mit Linksymbol, das den Dialog „Interne Seite wählen“ (`ChoosesLinkTargets`, `filament.cms.link-picker`) öffnet. Schritt 1 wählt die Seite (oder „Diese Seite“) mit Veröffentlichungszustand, Schritt 2 eine Sprungmarke; nicht veröffentlichte Marken und ausgeblendete Abschnitte sind gekennzeichnet. Die Marken der bearbeiteten Seite stammen aus dem Formular (auch ungespeicherte). Der Dialog schreibt nur die Adresse in das Feld. Im formatierten Text (Fließtext, Einleitung der Überschrift, Bild-Text) setzt das Werkzeug „Interne Seite oder Sprungmarke verlinken“ (`InternalLinkPlugin`) den Link am markierten Text. Menüeinträge: Spalte `navigation_items.anchor`, zweiter Schritt in „Ziel ändern“; der Link bleibt an die Zielseite gebunden.
|
**Linkziele.** `SafeUrl` erlaubt Seitenpfade (auch mit `#marke`), `#marke` (nur diese Seite) und http(s)-Adressen. Alle Linkfelder der Widgets (Schaltflächen von Einstieg und Bild-Text, Handlungsaufforderung, Karten, Merkmale) sind `WidgetsSupportinkfield`: ein Textfeld mit Linksymbol, das den Dialog „Interne Seite wählen“ (`ChoosesLinkTargets`, `filament.cms.link-picker`) öffnet. Schritt 1 wählt die Seite (oder „Diese Seite“) mit Veröffentlichungszustand, Schritt 2 eine Sprungmarke; nicht veröffentlichte Marken und ausgeblendete Abschnitte sind gekennzeichnet. Die Marken der bearbeiteten Seite stammen aus dem Formular (auch ungespeicherte). Der Dialog schreibt nur die Adresse in das Feld. Im formatierten Text (Fließtext, Einleitung der Überschrift, Bild-Text) setzt das Werkzeug „Interne Seite oder Sprungmarke verlinken“ (`InternalLinkPlugin`) den Link am markierten Text. Menüeinträge: Spalte `navigation_items.anchor`, zweiter Schritt in „Ziel ändern“; der Link bleibt an die Zielseite gebunden.
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ ## 1. Inhalt (Stand 21.11.2026 abends: 22 Commits seit `main`)
|
|||||||
| Reiter „Darstellung“ gegliedert | Aufbau, Gruppen je Widget, Erklärungen im (i), Einzelschalter für Texte verschwinden bei „Texte auf der Karte: Ausblenden“; Bezeichnungen vereinheitlicht. Keine Migration, gespeicherte Werte unverändert | Claude |
|
| Reiter „Darstellung“ gegliedert | Aufbau, Gruppen je Widget, Erklärungen im (i), Einzelschalter für Texte verschwinden bei „Texte auf der Karte: Ausblenden“; Bezeichnungen vereinheitlicht. Keine Migration, gespeicherte Werte unverändert | Claude |
|
||||||
| Abschnitte: Name, Sprungmarke, Ausblenden | Abschnitte lassen sich benennen (nur zur Orientierung), als Sprungmarke nutzen (Link „#marke“, „/pfad#marke“, von außen „Adresse#marke“) und für die Website ausblenden; Anzeige im Seitenaufbau. Keine Migration (neue optionale Felder in `sections`). **Rollback:** ältere Stände kennen „ausgeblendet“ nicht und zeigen solche Abschnitte wieder | Claude |
|
| Abschnitte: Name, Sprungmarke, Ausblenden | Abschnitte lassen sich benennen (nur zur Orientierung), als Sprungmarke nutzen (Link „#marke“, „/pfad#marke“, von außen „Adresse#marke“) und für die Website ausblenden; Anzeige im Seitenaufbau. Keine Migration (neue optionale Felder in `sections`). **Rollback:** ältere Stände kennen „ausgeblendet“ nicht und zeigen solche Abschnitte wieder | Claude |
|
||||||
| Interne Links wählen | Alle Linkfelder der Widgets und das Werkzeug im formatierten Text bieten einen Dialog für Seiten und Sprungmarken; Menüeinträge können auf eine Sprungmarke zeigen. Migration `2026_12_02_100000_add_anchor_to_navigation_items` (additiv) | Claude |
|
| Interne Links wählen | Alle Linkfelder der Widgets und das Werkzeug im formatierten Text bieten einen Dialog für Seiten und Sprungmarken; Menüeinträge können auf eine Sprungmarke zeigen. Migration `2026_12_02_100000_add_anchor_to_navigation_items` (additiv) | Claude |
|
||||||
|
| CMS-Seiteneditor: Abschnittseinstellungen im Dialog, kompakter Seitenaufbau (ADR-64) | Name, Sprungmarke und Sichtbarkeit eines Abschnitts stehen nicht mehr als Eingabeblock im Seitenaufbau, sondern im Dialog hinter dem Zahnrad im Abschnittskopf („Übernehmen“ ändert nur den Entwurf). Rahmen und Abstände um Abschnitte, Plätze und Bausteine verschlankt. Nur Darstellung und Bedienung: Seitenformat, Revisionen, Veröffentlichung und Website-Ausgabe unverändert, keine Migration. Rückfall: Der ältere Stand zeigt die Eingabefelder wieder im Abschnitt, gespeicherte Werte bleiben. | Claude |
|
||||||
| Kommunikationsverwaltung und Widget „Anfrage“ | Neue Gruppe „Kommunikation“ (Anfragen, Anliegen, Feldkatalog, Feldgruppen, Anfragevorlagen, Anfrage-Einstiege, Einstellungen), öffentliche Schnittstelle `/anfrage/{einstieg}` und CMS-Widget `inquiry` (ADR-60). **Vor dem Merge:** Mailversand in `/etc/luf/prod.env` prüfen (`MAIL_*`), Empfänger und Datenschutzhinweis festlegen, Testnachricht in den Einstellungen senden; Beispielkonfiguration auf Prod nur auf ausdrücklichen Wunsch anlegen. Rückfall: ältere Stände kennen das Widget nicht und zeigen es nicht | Claude |
|
| Kommunikationsverwaltung und Widget „Anfrage“ | Neue Gruppe „Kommunikation“ (Anfragen, Anliegen, Feldkatalog, Feldgruppen, Anfragevorlagen, Anfrage-Einstiege, Einstellungen), öffentliche Schnittstelle `/anfrage/{einstieg}` und CMS-Widget `inquiry` (ADR-60). **Vor dem Merge:** Mailversand in `/etc/luf/prod.env` prüfen (`MAIL_*`), Empfänger und Datenschutzhinweis festlegen, Testnachricht in den Einstellungen senden; Beispielkonfiguration auf Prod nur auf ausdrücklichen Wunsch anlegen. Rückfall: ältere Stände kennen das Widget nicht und zeigen es nicht | Claude |
|
||||||
| Kommunikation: Formular-Editor und Anfragegründe (ADR-61) | Navigation Anfragen, Formulare & Befragungen, Einstellungen; ein Editor für Bereiche, Felder und Bedingungen; Widget „Anfrage“ mit Anfragegründen statt Einstieg, Formularführung und Präsentation (Dialog) getrennt, Auslieferung `/anfrage/formular/{vorlage}`. Keine Migration. Rückfall: ein Stand ohne ADR-61 zeigt ein Widget mit Anfragegründen nicht an (Seite bleibt gültig), Formulare und Anfragen bleiben unverändert. Zwei Widget-Tests bewusst geändert. | Claude |
|
| Kommunikation: Formular-Editor und Anfragegründe (ADR-61) | Navigation Anfragen, Formulare & Befragungen, Einstellungen; ein Editor für Bereiche, Felder und Bedingungen; Widget „Anfrage“ mit Anfragegründen statt Einstieg, Formularführung und Präsentation (Dialog) getrennt, Auslieferung `/anfrage/formular/{vorlage}`. Keine Migration. Rückfall: ein Stand ohne ADR-61 zeigt ein Widget mit Anfragegründen nicht an (Seite bleibt gültig), Formulare und Anfragen bleiben unverändert. Zwei Widget-Tests bewusst geändert. | Claude |
|
||||||
| Kommunikation: Formularansicht des Aufbaus (ADR-62) | Der Aufbau eines Formulars ist eine eigene Ansicht mit Ziehen und Ablegen, Pop-ups für Hilfetext, Auswahlwerte und Bedingung (statt Builder-Liste). Keine Migration, Daten unverändert. Rückfall auf ADR-61 liest denselben Entwurf. Livewire-Tests des Editors bewusst auf den Baumtext umgestellt. | Claude |
|
| Kommunikation: Formularansicht des Aufbaus (ADR-62) | Der Aufbau eines Formulars ist eine eigene Ansicht mit Ziehen und Ablegen, Pop-ups für Hilfetext, Auswahlwerte und Bedingung (statt Builder-Liste). Keine Migration, Daten unverändert. Rückfall auf ADR-61 liest denselben Entwurf. Livewire-Tests des Editors bewusst auf den Baumtext umgestellt. | Claude |
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 299 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 151 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
@@ -17,7 +17,7 @@
|
|||||||
<{{ $as }} {{ $attributes->class('vw-eintrag') }}>
|
<{{ $as }} {{ $attributes->class('vw-eintrag') }}>
|
||||||
<span class="vw-bild">
|
<span class="vw-bild">
|
||||||
@if (filled($bild))
|
@if (filled($bild))
|
||||||
<img src="{{ $bild }}" alt="{{ $bildAlt }}" loading="lazy">
|
<img src="{{ $bild }}" alt="{{ $bildAlt }}" loading="lazy" decoding="async">
|
||||||
@else
|
@else
|
||||||
<span class="vw-bild-ersatz" data-symbol="{{ $symbol }}">@include('filament.verwaltung.icon', ['name' => $symbol])@if (filled($bildFehlt))<span class="vw-sr">{{ $bildFehlt }}</span>@endif</span>
|
<span class="vw-bild-ersatz" data-symbol="{{ $symbol }}">@include('filament.verwaltung.icon', ['name' => $symbol])@if (filled($bildFehlt))<span class="vw-sr">{{ $bildFehlt }}</span>@endif</span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
@php
|
@php
|
||||||
$metadata = is_array($version->metadata) ? $version->metadata : [];
|
$metadata = is_array($version->metadata) ? $version->metadata : [];
|
||||||
$class = $version->element->output_class;
|
$class = $version->element->output_class;
|
||||||
$poster = \App\Domain\Media\ThumbnailRef::url('editorial.card', 'element', $version->element->id, $version->element->thumbnail_path);
|
$poster = \App\Domain\Media\ThumbnailRef::url('editorial.card', 'element', $version->element->id, $version->element->thumbnail_path, 'mittel', $version->element->updated_at);
|
||||||
$playback = $class === 'film' ? app(\App\Http\Controllers\ContentPreviewController::class)->playback($version) : null;
|
$playback = $class === 'film' ? app(\App\Http\Controllers\ContentPreviewController::class)->playback($version) : null;
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{{--
|
||||||
|
Meldung am Abschnitt, wenn das Speichern der Seite Name oder Sprungmarke des Abschnitts abgewiesen hat. Die Eingabefelder
|
||||||
|
stehen im Einstellungsdialog; hier steht der Grund mit einem Weg dorthin.
|
||||||
|
--}}
|
||||||
|
@php
|
||||||
|
$abschnitt = $getStatePath();
|
||||||
|
$meldungen = array_values(array_unique([...$errors->get($abschnitt.'.name'), ...$errors->get($abschnitt.'.anchor')]));
|
||||||
|
@endphp
|
||||||
|
@if ($meldungen !== [])
|
||||||
|
<div class="luf-abschnitt-fehler" role="alert" data-abschnitt-fehler>
|
||||||
|
<span>
|
||||||
|
<strong>Name oder Sprungmarke dieses Abschnitts prüfen:</strong>
|
||||||
|
{{ implode(' ', $meldungen) }}
|
||||||
|
</span>
|
||||||
|
<button type="button" class="luf-abschnitt-fehler-aktion"
|
||||||
|
x-on:click="$el.closest('.fi-fo-repeater-item')?.querySelector('[data-luf-einstellungen]')?.click()">
|
||||||
|
Einstellungen öffnen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@@ -27,12 +27,17 @@
|
|||||||
|
|
||||||
/* Seitenaufbau (CMS-Abschluss): Abschnitt als Hauptgruppe, Plätze über Lage und Breite, Bausteine mit kurzem
|
/* Seitenaufbau (CMS-Abschluss): Abschnitt als Hauptgruppe, Plätze über Lage und Breite, Bausteine mit kurzem
|
||||||
Namen und Miniaturvorschau. Mehrere Abschnitte bleiben auf einem Desktopbildschirm überblickbar. */
|
Namen und Miniaturvorschau. Mehrere Abschnitte bleiben auf einem Desktopbildschirm überblickbar. */
|
||||||
.luf-sections > .fi-fo-repeater-items { gap: .75rem; }
|
.luf-sections > .fi-fo-repeater-items { gap: .5rem; }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item { border-left: 4px solid rgb(3 37 81 / 70%); }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item { border-left: 4px solid rgb(3 37 81 / 70%); }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header { padding: .25rem .75rem; min-height: 0; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header { padding: .1rem .6rem; min-height: 0; }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content { padding: .4rem .6rem .6rem; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content { padding: .25rem .5rem .5rem; }
|
||||||
.luf-sections .fi-fo-repeater-item-header-label { font-weight: 600; white-space: normal; }
|
.luf-sections .fi-fo-repeater-item-header-label { font-weight: 600; white-space: normal; }
|
||||||
.luf-abschnitt { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .65rem; }
|
.luf-abschnitt { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .65rem; }
|
||||||
|
/* Schmale Fenster: Name und Zusammenfassung des Abschnitts stehen in der ersten Zeile, die Aktionen darunter. */
|
||||||
|
@media (max-width: 40rem) {
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header { flex-wrap: wrap; row-gap: .1rem; }
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header > .fi-fo-repeater-item-header-label { order: -1; flex: 1 1 100%; }
|
||||||
|
}
|
||||||
.luf-abschnitt-nr { font-weight: 700; }
|
.luf-abschnitt-nr { font-weight: 700; }
|
||||||
.luf-abschnitt-meta { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
.luf-abschnitt-meta { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
||||||
.luf-abschnitt-nummer { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
.luf-abschnitt-nummer { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
||||||
@@ -41,7 +46,14 @@
|
|||||||
/* Ausgeblendeter Abschnitt: gestrichelte Kante und zurückgenommener Inhalt, der Kopf bleibt gut lesbar. */
|
/* Ausgeblendeter Abschnitt: gestrichelte Kante und zurückgenommener Inhalt, der Kopf bleibt gut lesbar. */
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) { border-left-style: dashed; border-left-color: #c98a00; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) { border-left-style: dashed; border-left-color: #c98a00; }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) > .fi-fo-repeater-item-content { opacity: .72; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) > .fi-fo-repeater-item-content { opacity: .72; }
|
||||||
.luf-abschnitt-bezeichnung { margin-bottom: .5rem; }
|
/* Meldung am Abschnitt, wenn Name oder Sprungmarke beim Speichern abgewiesen wurden (Eingabe im Einstellungsdialog). */
|
||||||
|
.luf-abschnitt-fehler { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem .75rem; margin-bottom: .35rem; padding: .35rem .6rem; border: 1px solid var(--vw-error); border-radius: var(--vw-radius-small); background: var(--vw-error-soft); color: var(--vw-error); font-size: var(--vw-small); }
|
||||||
|
.luf-abschnitt-fehler-aktion { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
|
||||||
|
.luf-sections .fi-fo-repeater-item-header [data-luf-einstellungen] { flex: none; }
|
||||||
|
/* Verdeckte Felder und leere Meldungen belegen keine Zeile im Abschnitt (sonst addiert sich der Zeilenabstand). */
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content > .fi-sc { gap: .4rem; }
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content > .fi-sc > .fi-sc-component:has(> input[type='hidden']),
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content > .fi-sc > .fi-sc-component:not(:has(*)) { display: none; }
|
||||||
.luf-link-pfad { font-family: ui-monospace, monospace; font-size: .85em; overflow-wrap: anywhere; }
|
.luf-link-pfad { font-family: ui-monospace, monospace; font-size: .85em; overflow-wrap: anywhere; }
|
||||||
|
|
||||||
/* Rasterauswahl als grafische Kacheln */
|
/* Rasterauswahl als grafische Kacheln */
|
||||||
@@ -55,19 +67,21 @@
|
|||||||
|
|
||||||
/* Plätze im Verhältnis des Desktop-Rasters; auf schmalen Bildschirmen untereinander. Ein Platz hat keinen eigenen
|
/* Plätze im Verhältnis des Desktop-Rasters; auf schmalen Bildschirmen untereinander. Ein Platz hat keinen eigenen
|
||||||
Kopf: links der Griff zum Verschieben des Bausteins, daneben der Baustein. */
|
Kopf: links der Griff zum Verschieben des Bausteins, daneben der Baustein. */
|
||||||
.luf-slots > .fi-fo-repeater-items { display: grid; gap: .5rem; grid-template-columns: minmax(0, 1fr); }
|
.luf-slots > .fi-fo-repeater-items { display: grid; gap: .35rem; grid-template-columns: minmax(0, 1fr); }
|
||||||
@media (min-width: 64rem) {
|
@media (min-width: 64rem) {
|
||||||
.luf-slots > .fi-fo-repeater-items { grid-template-columns: var(--luf-slot-cols, minmax(0, 1fr)); }
|
.luf-slots > .fi-fo-repeater-items { grid-template-columns: var(--luf-slot-cols, minmax(0, 1fr)); }
|
||||||
}
|
}
|
||||||
.luf-slots .fi-fo-repeater-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; background: transparent; border: 1px dashed rgb(3 37 81 / 18%); box-shadow: none; }
|
/* Ein Platz ist eine leise Fläche statt eines gestrichelten Rahmens; nur ein leerer Platz bleibt gestrichelt. */
|
||||||
.luf-slots .fi-fo-repeater-item-header { padding: .3rem 0 .3rem .15rem; border: 0; background: transparent; min-height: 0; }
|
.luf-slots .fi-fo-repeater-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; background: var(--vw-paper); border: 0; border-radius: var(--vw-radius-small); box-shadow: none; }
|
||||||
|
.luf-slots .fi-fo-repeater-item:not(:has(.fi-fo-builder-item)) { background: transparent; box-shadow: inset 0 0 0 1px var(--vw-line-strong); }
|
||||||
|
.luf-slots .fi-fo-repeater-item-header { padding: .2rem 0 .2rem .1rem; border: 0; background: transparent; min-height: 0; }
|
||||||
.luf-slots .fi-fo-repeater-item:has(.luf-platz-warnung) { grid-template-columns: minmax(0, 1fr); }
|
.luf-slots .fi-fo-repeater-item:has(.luf-platz-warnung) { grid-template-columns: minmax(0, 1fr); }
|
||||||
.luf-platz-warnung { display: block; padding: .25rem .5rem; border-radius: .35rem; background: #fff6dc; color: #9a5b00; font-size: .8rem; font-weight: 600; }
|
.luf-platz-warnung { display: block; padding: .25rem .5rem; border-radius: .35rem; background: #fff6dc; color: #9a5b00; font-size: .8rem; font-weight: 600; }
|
||||||
.luf-slots .fi-fo-repeater-item-content { padding: .3rem .4rem .4rem .25rem; min-width: 0; }
|
.luf-slots .fi-fo-repeater-item-content { padding: .2rem .35rem .3rem .15rem; border: 0; min-width: 0; }
|
||||||
.luf-slots .fi-fo-builder-item { border: 0; box-shadow: none; background: transparent; }
|
.luf-slots .fi-fo-builder-item { border: 0; box-shadow: none; background: transparent; }
|
||||||
.luf-slots .fi-fo-builder-item-header { padding: 0 0 .25rem; gap: .25rem .35rem; flex-wrap: wrap; min-height: 0; }
|
.luf-slots .fi-fo-builder-item-header { padding: 0 0 .15rem; gap: .15rem .35rem; flex-wrap: wrap; min-height: 0; }
|
||||||
.luf-slots .fi-fo-builder-item-header .fi-btn { min-height: 1.9rem; padding-block: .15rem; }
|
.luf-slots .fi-fo-builder-item-header .fi-btn { min-height: 1.9rem; padding-block: .15rem; }
|
||||||
.luf-slots .fi-fo-builder-item-content { padding: 0; }
|
.luf-slots .fi-fo-builder-item-content { padding: 0; border: 0; }
|
||||||
.luf-slots .fi-fo-builder-add-action-ctn,
|
.luf-slots .fi-fo-builder-add-action-ctn,
|
||||||
.luf-slots .fi-fo-builder .fi-fo-builder-add-btn-ctn { justify-content: center; }
|
.luf-slots .fi-fo-builder .fi-fo-builder-add-btn-ctn { justify-content: center; }
|
||||||
.luf-baustein { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; min-width: 0; line-height: 1.3; }
|
.luf-baustein { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; min-width: 0; line-height: 1.3; }
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
x-on:keydown.alt.arrow-down.prevent="$wire.movePart({{ $index }}, 1)">
|
x-on:keydown.alt.arrow-down.prevent="$wire.movePart({{ $index }}, 1)">
|
||||||
<span class="vw-bild is-klein">
|
<span class="vw-bild is-klein">
|
||||||
@if (! empty($member['image']))
|
@if (! empty($member['image']))
|
||||||
<img src="{{ $member['image'] }}" alt="" loading="lazy">
|
<img src="{{ $member['image'] }}" alt="" loading="lazy" decoding="async">
|
||||||
@else
|
@else
|
||||||
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($member['tone'] ?? null)])</span>
|
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($member['tone'] ?? null)])</span>
|
||||||
@endif
|
@endif
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
@forelse ($kinder as $kind)
|
@forelse ($kinder as $kind)
|
||||||
<div class="vw-quellenzeile">
|
<div class="vw-quellenzeile">
|
||||||
<span class="vw-bild is-mini">
|
<span class="vw-bild is-mini">
|
||||||
@if (! empty($kind['image']))<img src="{{ $kind['image'] }}" alt="" loading="lazy">@else<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($kind['tone'])])</span>@endif
|
@if (! empty($kind['image']))<img src="{{ $kind['image'] }}" alt="" loading="lazy" decoding="async">@else<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($kind['tone'])])</span>@endif
|
||||||
</span>
|
</span>
|
||||||
<span><strong>{{ $kind['title'] }}</strong><br><span class="vw-feld-hilfe">{{ $kind['kind'] }}@if ($kind['role'] !== '') · {{ $kind['role'] }}@endif</span></span>
|
<span><strong>{{ $kind['title'] }}</strong><br><span class="vw-feld-hilfe">{{ $kind['kind'] }}@if ($kind['role'] !== '') · {{ $kind['role'] }}@endif</span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
@endunless
|
@endunless
|
||||||
<span class="vw-bild">
|
<span class="vw-bild">
|
||||||
@if (! empty($row['image']))
|
@if (! empty($row['image']))
|
||||||
<img src="{{ $row['image'] }}" alt="" loading="lazy">
|
<img src="{{ $row['image'] }}" alt="" loading="lazy" decoding="async">
|
||||||
@else
|
@else
|
||||||
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($row['output'])])</span>
|
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($row['output'])])</span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<div class="mb-player player">
|
<div class="mb-player player">
|
||||||
@include('content.video', [
|
@include('content.video', [
|
||||||
'playback' => ['mode' => $entry['playback'] ?? 'file', 'url' => $entry['url']],
|
'playback' => ['mode' => $entry['playback'] ?? 'file', 'url' => $entry['url']],
|
||||||
'poster' => \App\Domain\Media\ThumbnailRef::url('member.thumbnail', 'element', $entry['version']->element->id, $entry['version']->element->thumbnail_path),
|
'poster' => \App\Domain\Media\ThumbnailRef::url('member.thumbnail', 'element', $entry['version']->element->id, $entry['version']->element->thumbnail_path, 'mittel', $entry['version']->element->updated_at),
|
||||||
])
|
])
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-actions">
|
<div class="mb-actions">
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<header class="mb-detail-head">
|
<header class="mb-detail-head">
|
||||||
<div class="mb-detail-visual">
|
<div class="mb-detail-visual">
|
||||||
@if ($picture)
|
@if ($picture)
|
||||||
<img src="{{ route('member.thumbnail', ['kind' => $picture['kind'], 'subject' => $picture['subject']]) }}" alt="{{ $picture['alt'] ?: '' }}">
|
<img src="{{ route('member.thumbnail', ['kind' => $picture['kind'], 'subject' => $picture['subject'], 'g' => 'mittel']) }}" alt="{{ $picture['alt'] ?: '' }}">
|
||||||
@else
|
@else
|
||||||
<span class="mb-card-placeholder" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.($is_module ? 'rectangle-stack' : 'squares-2x2')" /></span>
|
<span class="mb-card-placeholder" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.($is_module ? 'rectangle-stack' : 'squares-2x2')" /></span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
])>
|
])>
|
||||||
@if ($item['imageUrl'])
|
@if ($item['imageUrl'])
|
||||||
<div class="card-media">
|
<div class="card-media">
|
||||||
<img class="card-image" src="{{ $item['imageUrl'] }}" alt="" loading="lazy" decoding="async">
|
<img class="card-image" src="{{ $item['imageUrl'] }}" @if (! empty($item['imageSrcset'])) srcset="{{ $item['imageSrcset'] }}" sizes="(min-width: 900px) 40vw, 100vw" @endif alt="" loading="lazy" decoding="async">
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
style="--lf-hero-focus-x: {{ $focus['x'] }}%; --lf-hero-focus-y: {{ $focus['y'] }}%"
|
style="--lf-hero-focus-x: {{ $focus['x'] }}%; --lf-hero-focus-y: {{ $focus['y'] }}%"
|
||||||
@if ($videoUrl !== null) data-hero-video data-clip-src="{{ $videoUrl }}" data-clip-title="{{ $videoTitle }}" @endif>
|
@if ($videoUrl !== null) data-hero-video data-clip-src="{{ $videoUrl }}" data-clip-title="{{ $videoTitle }}" @endif>
|
||||||
@if ($layout === 'photo-split' && $imageUrl)
|
@if ($layout === 'photo-split' && $imageUrl)
|
||||||
<img class="lf-hero__photo" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
<img class="lf-hero__photo" src="{{ $imageUrl }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="100vw"@endif alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
||||||
@endif
|
@endif
|
||||||
@if ($videoUrl !== null)
|
@if ($videoUrl !== null)
|
||||||
<video class="lf-hero__video" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
<video class="lf-hero__video" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
@endif
|
@endif
|
||||||
@if ($imageUrl)
|
@if ($imageUrl)
|
||||||
<div class="lf-bt__media" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
<div class="lf-bt__media" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
||||||
<img class="lf-bt__image" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
<img class="lf-bt__image" src="{{ $imageUrl }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="100vw" @endif alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
||||||
@include('widgets.partials.card-clip')
|
@include('widgets.partials.card-clip')
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
||||||
@if ($imageUrl !== null || $libraryImage !== null)
|
@if ($imageUrl !== null || $libraryImage !== null)
|
||||||
<div class="lf-pc__visual" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
<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">
|
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" @if ($imageUrl !== null && ! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="(min-width: 900px) 50vw, 100vw" @endif alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
||||||
@include('widgets.partials.card-clip')
|
@include('widgets.partials.card-clip')
|
||||||
@if ($show['kind'] && $subject->badge !== null && empty($bare))
|
@if ($show['kind'] && $subject->badge !== null && empty($bare))
|
||||||
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
||||||
|
|||||||
+19
-1
@@ -28,7 +28,13 @@
|
|||||||
use App\Http\Controllers\WebsiteMediaController;
|
use App\Http\Controllers\WebsiteMediaController;
|
||||||
use App\Http\Middleware\EnsureCheckoutOpen;
|
use App\Http\Middleware\EnsureCheckoutOpen;
|
||||||
use App\Http\Middleware\EnsureShopVisible;
|
use App\Http\Middleware\EnsureShopVisible;
|
||||||
|
use App\Http\Middleware\SanitizeIntendedUrl;
|
||||||
|
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||||
|
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
||||||
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
|
|
||||||
Route::get('/', [PageController::class, 'home'])->name('home');
|
Route::get('/', [PageController::class, 'home'])->name('home');
|
||||||
Route::get('/sitemap.xml', [PageController::class, 'sitemap'])->name('sitemap');
|
Route::get('/sitemap.xml', [PageController::class, 'sitemap'])->name('sitemap');
|
||||||
@@ -38,7 +44,19 @@
|
|||||||
Route::get('/pakete/{bundle}', [PublicCatalogController::class, 'package'])->whereNumber('bundle')->name('public.package');
|
Route::get('/pakete/{bundle}', [PublicCatalogController::class, 'package'])->whereNumber('bundle')->name('public.package');
|
||||||
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
||||||
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
||||||
Route::get('/website-medien/{element}', [WebsiteMediaController::class, 'show'])->whereNumber('element')->name('website.media');
|
// Öffentliche Medien brauchen weder Sitzung noch Cookies: Ohne sie legt die Anfrage keine Sitzungszeile an, setzt kein Cookie
|
||||||
|
// und darf von Browsern und Zwischenspeichern behalten werden.
|
||||||
|
Route::get('/website-medien/{element}', [WebsiteMediaController::class, 'show'])
|
||||||
|
->whereNumber('element')
|
||||||
|
->withoutMiddleware([
|
||||||
|
EncryptCookies::class,
|
||||||
|
AddQueuedCookiesToResponse::class,
|
||||||
|
StartSession::class,
|
||||||
|
ShareErrorsFromSession::class,
|
||||||
|
PreventRequestForgery::class,
|
||||||
|
SanitizeIntendedUrl::class,
|
||||||
|
])
|
||||||
|
->name('website.media');
|
||||||
|
|
||||||
// Schalter 1 (Shop sichtbar): Übersicht, Produktseiten und die Hinweisseite. Schalter 2 (Checkout offen): Warenkorb und
|
// Schalter 1 (Shop sichtbar): Übersicht, Produktseiten und die Hinweisseite. Schalter 2 (Checkout offen): Warenkorb und
|
||||||
// Kasse; ist der Shop nur sichtbar, führen sie auf die Hinweisseite (EnsureCheckoutOpen).
|
// Kasse; ist der Shop nur sichtbar, führen sie auf die Hinweisseite (EnsureCheckoutOpen).
|
||||||
|
|||||||
@@ -0,0 +1,353 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Domain\Media\WebsiteIntake;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Filament\Support\MediaLibrary;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bildfassungen (docs/architektur/bildvarianten.md): klein, mittel und voll für die Verwaltung, Breiten für die Website,
|
||||||
|
* Auslieferung mit Zwischenspeicherung und Ausweichen auf die volle Datei.
|
||||||
|
*/
|
||||||
|
class BildvariantenTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Storage::fake('cms_incoming');
|
||||||
|
Storage::fake('media_derived');
|
||||||
|
Storage::fake('media_public');
|
||||||
|
Storage::fake('media_originals');
|
||||||
|
Cache::flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_variants_are_written_next_to_the_main_file_and_never_enlarged(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put('vorschau/element-1.jpg', $this->jpeg(2000, 1000));
|
||||||
|
|
||||||
|
$written = ImageVariants::generate($disk, 'vorschau/element-1.jpg');
|
||||||
|
|
||||||
|
$this->assertSame(['vorschau/element-1-klein.jpg', 'vorschau/element-1-mittel.jpg'], $written);
|
||||||
|
$this->assertSame([360, 180], array_slice(getimagesizefromstring($disk->get('vorschau/element-1-klein.jpg')), 0, 2));
|
||||||
|
$this->assertSame([960, 480], array_slice(getimagesizefromstring($disk->get('vorschau/element-1-mittel.jpg')), 0, 2));
|
||||||
|
$this->assertLessThan(strlen($disk->get('vorschau/element-1.jpg')), strlen($disk->get('vorschau/element-1-klein.jpg')));
|
||||||
|
|
||||||
|
$disk->put('vorschau/element-2.jpg', $this->jpeg(640, 320));
|
||||||
|
$this->assertSame(['vorschau/element-2-klein.jpg'], ImageVariants::generate($disk, 'vorschau/element-2.jpg'));
|
||||||
|
$disk->assertMissing('vorschau/element-2-mittel.jpg');
|
||||||
|
|
||||||
|
// Wird die Hauptdatei durch ein kleineres Bild ersetzt, verschwindet die zu große Fassung.
|
||||||
|
$disk->put('vorschau/element-1.jpg', $this->jpeg(300, 150));
|
||||||
|
ImageVariants::generate($disk, 'vorschau/element-1.jpg');
|
||||||
|
$disk->assertMissing('vorschau/element-1-klein.jpg');
|
||||||
|
$disk->assertMissing('vorschau/element-1-mittel.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_unreadable_files_produce_no_variants_and_no_error(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put('vorschau/kaputt.jpg', 'kein-bild');
|
||||||
|
|
||||||
|
$this->assertSame([], ImageVariants::generate($disk, 'vorschau/kaputt.jpg'));
|
||||||
|
$this->assertSame([], ImageVariants::generate($disk, 'vorschau/fehlt.jpg'));
|
||||||
|
$this->assertSame('vorschau/kaputt.jpg', ImageVariants::resolve($disk, 'vorschau/kaputt.jpg', 'klein'));
|
||||||
|
$this->assertSame('vorschau/kaputt.jpg', ImageVariants::resolve($disk, 'vorschau/kaputt.jpg', '../x'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_deriving_a_thumbnail_creates_the_variants_and_changes_the_version(): void
|
||||||
|
{
|
||||||
|
$element = app(ContentService::class)->createElement('bild', 'bild', 'Park');
|
||||||
|
$version = app(ContentService::class)->publishElementVersion($element, null, ['file' => 'inhalte/park.jpg']);
|
||||||
|
Storage::disk('media_derived')->put('inhalte/park.jpg', $this->jpeg(3000, 1500));
|
||||||
|
$this->assertNotNull($version);
|
||||||
|
|
||||||
|
$before = now()->subDay();
|
||||||
|
ContentElement::query()->whereKey($element->id)->update(['updated_at' => $before]);
|
||||||
|
|
||||||
|
app(ThumbnailDeriver::class)->forElement($element->refresh());
|
||||||
|
$element->refresh();
|
||||||
|
|
||||||
|
$this->assertSame('vorschau/element-'.$element->id.'.jpg', $element->thumbnail_path);
|
||||||
|
$this->assertSame(2400, getimagesizefromstring(Storage::disk('media_derived')->get($element->thumbnail_path))[0]);
|
||||||
|
Storage::disk('media_derived')->assertExists('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
Storage::disk('media_derived')->assertExists('vorschau/element-'.$element->id.'-mittel.jpg');
|
||||||
|
$this->assertTrue($element->updated_at->greaterThan($before), 'Die Version der Adresse ändert sich mit dem Bild.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_library_card_serves_the_requested_size_with_a_fallback_and_caches_by_version(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
ImageVariants::generate($disk, $element->thumbnail_path);
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
|
||||||
|
$klein = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']));
|
||||||
|
$klein->assertOk();
|
||||||
|
$this->assertSame($disk->get('vorschau/element-'.$element->id.'-klein.jpg'), $klein->streamedContent());
|
||||||
|
$this->assertStringContainsString('must-revalidate', (string) $klein->headers->get('Cache-Control'));
|
||||||
|
$this->assertNotNull($klein->headers->get('ETag'));
|
||||||
|
|
||||||
|
$voll = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id]));
|
||||||
|
$this->assertSame($disk->get($element->thumbnail_path), $voll->streamedContent());
|
||||||
|
|
||||||
|
$versioned = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein', 'v' => 1700000000]));
|
||||||
|
$cache = (string) $versioned->headers->get('Cache-Control');
|
||||||
|
$this->assertStringContainsString('immutable', $cache);
|
||||||
|
$this->assertStringContainsString('private', $cache);
|
||||||
|
$this->assertStringContainsString('max-age=31536000', $cache);
|
||||||
|
|
||||||
|
$again = $this->actingAs($editor, 'staff')->get(
|
||||||
|
route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']),
|
||||||
|
['If-None-Match' => $klein->headers->get('ETag')],
|
||||||
|
);
|
||||||
|
$again->assertStatus(304);
|
||||||
|
|
||||||
|
$disk->delete('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
$fallback = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']));
|
||||||
|
$this->assertSame($disk->get($element->thumbnail_path), $fallback->streamedContent(), 'Ohne Fassung gilt die Hauptdatei.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_missing_variant_is_derived_by_the_queue_once_per_day(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
Queue::fake();
|
||||||
|
|
||||||
|
$url = route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']);
|
||||||
|
$this->actingAs($editor, 'staff')->get($url)->assertOk();
|
||||||
|
$this->actingAs($editor, 'staff')->get($url)->assertOk();
|
||||||
|
$this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id]))->assertOk();
|
||||||
|
|
||||||
|
Queue::assertPushed(DeriveImageVariants::class, 1);
|
||||||
|
$disk->assertMissing('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_card_route_stays_closed_for_visitors_and_ignores_unknown_sizes(): void
|
||||||
|
{
|
||||||
|
[$element] = $this->elementWithThumbnail(800, 400);
|
||||||
|
|
||||||
|
$this->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']))->assertRedirect();
|
||||||
|
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$this->actingAs($editor, 'staff')
|
||||||
|
->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => '../../etc']))
|
||||||
|
->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_adresses_carry_size_and_version(): void
|
||||||
|
{
|
||||||
|
[$element] = $this->elementWithThumbnail(800, 400);
|
||||||
|
$element->refresh();
|
||||||
|
$card = app(MediaLibrary::class)->cardFor($element, false);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('g=klein', (string) $card['image']);
|
||||||
|
$this->assertStringContainsString('v='.$element->updated_at->getTimestamp(), (string) $card['image']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_released_image_gets_website_widths_and_serves_them_with_long_caching_and_no_cookie(): void
|
||||||
|
{
|
||||||
|
$medium = $this->releasedImage('Lara im Park', 2600, 1300);
|
||||||
|
$path = $medium->website_public_path;
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->assertExists(ImageVariants::publicPath($path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
$presentation = app(WebsiteMedia::class)->present($medium);
|
||||||
|
$this->assertNotNull($presentation);
|
||||||
|
$this->assertStringContainsString('v='.$medium->website_released_at->getTimestamp(), $presentation->url);
|
||||||
|
$this->assertStringContainsString('w=640', (string) $presentation->srcset);
|
||||||
|
$this->assertStringContainsString('1920w', (string) $presentation->srcset);
|
||||||
|
$this->assertStringContainsString('w=1920', $presentation->urlForWidth(1920));
|
||||||
|
$this->assertSame($presentation->url, $presentation->urlForWidth(999));
|
||||||
|
|
||||||
|
$small = $this->get(route('website.media', ['element' => $medium, 'w' => 640, 'v' => $medium->website_released_at->getTimestamp()]));
|
||||||
|
$small->assertOk();
|
||||||
|
$this->assertSame(640, getimagesizefromstring($small->streamedContent())[0]);
|
||||||
|
$cache = (string) $small->headers->get('Cache-Control');
|
||||||
|
$this->assertStringContainsString('public', $cache);
|
||||||
|
$this->assertStringContainsString('immutable', $cache);
|
||||||
|
$this->assertEmpty($small->headers->getCookies(), 'Öffentliche Bilder setzen kein Cookie.');
|
||||||
|
|
||||||
|
$stale = $this->get(route('website.media', ['element' => $medium, 'v' => 1]));
|
||||||
|
$this->assertStringNotContainsString('immutable', (string) $stale->headers->get('Cache-Control'));
|
||||||
|
|
||||||
|
$full = $this->get(route('website.media', ['element' => $medium]));
|
||||||
|
$this->assertSame(2400, getimagesizefromstring($full->streamedContent())[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_released_image_without_widths_falls_back_to_the_full_file_and_asks_the_queue_once(): void
|
||||||
|
{
|
||||||
|
$medium = $this->releasedImage('Bestand', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->delete(ImageVariants::publicPath($medium->website_public_path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
Queue::fake();
|
||||||
|
|
||||||
|
$first = $this->get(route('website.media', ['element' => $medium, 'w' => 1280]));
|
||||||
|
$this->assertSame(2400, getimagesizefromstring($first->streamedContent())[0]);
|
||||||
|
$this->get(route('website.media', ['element' => $medium, 'w' => 640]))->assertOk();
|
||||||
|
|
||||||
|
Queue::assertPushed(DeriveWebsiteVariants::class, 1);
|
||||||
|
|
||||||
|
Queue::fake([]);
|
||||||
|
(new DeriveWebsiteVariants($medium->id))->handle();
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->assertExists(ImageVariants::publicPath($medium->website_public_path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->get(route('website.media', ['element' => $medium, 'w' => 4000]))->assertOk();
|
||||||
|
$this->get(route('website.media', ['element' => $medium, 'w' => '../x']))->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_withdrawing_a_release_removes_the_widths_too(): void
|
||||||
|
{
|
||||||
|
$medium = $this->releasedImage('Zurück', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
$widthUrl = route('website.media', ['element' => $medium, 'w' => 640]);
|
||||||
|
$this->get($widthUrl)->assertOk();
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($medium);
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->assertMissing('website/'.$medium->id.'/datei-'.$width.'.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
$public->assertMissing('website/'.$medium->id.'/datei.jpg');
|
||||||
|
$this->get($widthUrl)->assertNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_images_with_transparency_formats_keep_no_widths(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_public');
|
||||||
|
$disk->put('website/9/datei.png', $this->jpeg(2600, 1300));
|
||||||
|
|
||||||
|
$this->assertSame([], ImageVariants::generatePublic($disk, $disk, 'website/9/datei.png', 'website/9/datei.png'));
|
||||||
|
$disk->assertMissing('website/9/datei-640.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_picker_options_do_not_query_per_entry(): void
|
||||||
|
{
|
||||||
|
foreach (range(1, 2) as $number) {
|
||||||
|
$this->releasedImage('Bild '.$number, 800, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::enableQueryLog();
|
||||||
|
app(WebsiteImage::class)->options();
|
||||||
|
$few = count(DB::getQueryLog());
|
||||||
|
|
||||||
|
foreach (range(3, 10) as $number) {
|
||||||
|
$this->releasedImage('Bild '.$number, 800, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::flushQueryLog();
|
||||||
|
$options = app(WebsiteImage::class)->options();
|
||||||
|
$many = count(DB::getQueryLog());
|
||||||
|
|
||||||
|
$this->assertCount(10, $options);
|
||||||
|
$this->assertSame($few, $many, 'Die Zahl der Abfragen wächst nicht mit der Zahl der Einträge.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_command_backfills_existing_images_through_the_queue(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
$medium = $this->releasedImage('Alt', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->delete(ImageVariants::publicPath($medium->website_public_path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
$disk->assertMissing('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
|
||||||
|
Queue::fake();
|
||||||
|
$this->artisan('media:varianten')->assertSuccessful();
|
||||||
|
Queue::assertPushed(DeriveImageVariants::class, fn (DeriveImageVariants $job): bool => $job->path === $element->thumbnail_path);
|
||||||
|
Queue::assertPushed(DeriveWebsiteVariants::class, fn (DeriveWebsiteVariants $job): bool => $job->elementId === $medium->id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_command_can_backfill_at_once(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
$medium = $this->releasedImage('Alt', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
$public->delete(ImageVariants::publicPath($medium->website_public_path, 640));
|
||||||
|
|
||||||
|
$this->artisan('media:varianten', ['--now' => true])->assertSuccessful();
|
||||||
|
|
||||||
|
$disk->assertExists('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
$public->assertExists(ImageVariants::publicPath($medium->website_public_path, 640));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_derive_job_refuses_foreign_paths(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put('inhalte/geheim.jpg', $this->jpeg(2000, 1000));
|
||||||
|
|
||||||
|
(new DeriveImageVariants('inhalte/geheim.jpg'))->handle();
|
||||||
|
(new DeriveImageVariants('vorschau/../inhalte/geheim.jpg'))->handle();
|
||||||
|
|
||||||
|
$disk->assertMissing('inhalte/geheim-klein.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{0: ContentElement, 1: Filesystem}
|
||||||
|
*/
|
||||||
|
private function elementWithThumbnail(int $width, int $height): array
|
||||||
|
{
|
||||||
|
$element = app(ContentService::class)->createElement('bild', 'bild', 'Bild '.Str::random(4));
|
||||||
|
$element->forceFill(['thumbnail_path' => 'vorschau/element-'.$element->id.'.jpg'])->save();
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put($element->thumbnail_path, $this->jpeg($width, $height));
|
||||||
|
|
||||||
|
return [$element->refresh(), $disk];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function releasedImage(string $title, int $width, int $height): ContentElement
|
||||||
|
{
|
||||||
|
$path = 'cms/'.Str::slug($title).'-'.Str::lower(Str::random(4)).'.jpg';
|
||||||
|
Storage::disk('cms_incoming')->put($path, $this->jpeg($width, $height));
|
||||||
|
|
||||||
|
$element = app(WebsiteIntake::class)->acceptImage($path, $title, 'Foto: Lara und Felix', $title)->refresh();
|
||||||
|
$this->assertNotNull($element->website_released_at, 'Das Bild ist freigegeben.');
|
||||||
|
|
||||||
|
return $element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function jpeg(int $width, int $height): string
|
||||||
|
{
|
||||||
|
$image = imagecreatetruecolor($width, $height);
|
||||||
|
imagefill($image, 0, 0, (int) imagecolorallocate($image, 200, 120, 40));
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($image);
|
||||||
|
|
||||||
|
return (string) ob_get_clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,7 +80,7 @@ public function test_the_trailer_lies_over_the_card_image_when_there_is_one(): v
|
|||||||
$this->publish('/trailer-bild', [$this->mediaCard($film, ['image' => $image->id])]);
|
$this->publish('/trailer-bild', [$this->mediaCard($film, ['image' => $image->id])]);
|
||||||
|
|
||||||
$card = $this->card($this->get('/trailer-bild')->assertOk()->getContent());
|
$card = $this->card($this->get('/trailer-bild')->assertOk()->getContent());
|
||||||
$this->assertStringContainsString('<img class="lf-pc__image" src="'.route('website.media', $image).'"', $card);
|
$this->assertStringContainsString('<img class="lf-pc__image" src="'.app(WebsiteMedia::class)->present($image->id)->url.'"', $card);
|
||||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||||
$this->assertStringNotContainsString('lf-pc__visual--panel', $card);
|
$this->assertStringNotContainsString('lf-pc__visual--panel', $card);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ public function test_an_image_can_stand_alone_without_any_text(): void
|
|||||||
|
|
||||||
$this->assertStringContainsString('lf-bt--without-text', $html);
|
$this->assertStringContainsString('lf-bt--without-text', $html);
|
||||||
$this->assertStringNotContainsString('lf-bt__copy', $html, 'Ohne Text gibt es keine leere Textspalte.');
|
$this->assertStringNotContainsString('lf-bt__copy', $html, 'Ohne Text gibt es keine leere Textspalte.');
|
||||||
$this->assertStringContainsString('<img class="lf-bt__image" src="'.route('website.media', $image).'" alt="Gruppe im Park"', $html);
|
$this->assertStringContainsString('<img class="lf-bt__image" src="'.app(WebsiteMedia::class)->present($image->id)->url.'"', $html);
|
||||||
|
$this->assertStringContainsString('alt="Gruppe im Park"', $html);
|
||||||
|
$this->assertStringContainsString('srcset="', $html);
|
||||||
|
|
||||||
$normalized = app(WidgetRegistry::class)->normalize($this->widget([], ['image' => $image->id])[0]['slots']);
|
$normalized = app(WidgetRegistry::class)->normalize($this->widget([], ['image' => $image->id])[0]['slots']);
|
||||||
$this->assertSame($image->id, $normalized[0]['refs']['image']);
|
$this->assertSame($image->id, $normalized[0]['refs']['image']);
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public function test_media_card_is_public_only_as_part_of_a_public_program_and_n
|
|||||||
|
|
||||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||||
// Redaktionsvorschau: Filmstandbild der Bibliothek, deutlich als nicht öffentlich markiert, und Hinweise auf Fehlendes.
|
// Redaktionsvorschau: Filmstandbild der Bibliothek, deutlich als nicht öffentlich markiert, und Hinweise auf Fehlendes.
|
||||||
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'element', 'subject' => $film->id]).'"', $preview);
|
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'element', 'subject' => $film->id, 'g' => 'mittel']).'&v=', $preview);
|
||||||
$this->assertStringContainsString('Bibliotheksbild · nur Vorschau', $preview);
|
$this->assertStringContainsString('Bibliotheksbild · nur Vorschau', $preview);
|
||||||
$this->assertStringContainsString('Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben', $preview);
|
$this->assertStringContainsString('Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben', $preview);
|
||||||
$this->assertStringContainsString('Traineranleitung Abstand', $preview);
|
$this->assertStringContainsString('Traineranleitung Abstand', $preview);
|
||||||
@@ -242,7 +242,7 @@ public function test_draft_media_and_unreleased_compositions_can_be_prepared_but
|
|||||||
$this->assertStringContainsString('Das Programm hat keine Anzeigefreigabe.', $preview);
|
$this->assertStringContainsString('Das Programm hat keine Anzeigefreigabe.', $preview);
|
||||||
$this->assertStringContainsString('Kinder erkennen eigene Grenzen.', $preview, 'Ohne Kurzbeschreibung zeigt die Karte das Lernziel.');
|
$this->assertStringContainsString('Kinder erkennen eigene Grenzen.', $preview, 'Ohne Kurzbeschreibung zeigt die Karte das Lernziel.');
|
||||||
$this->assertStringContainsString('<li>Dauer 25 Min.</li>', $preview);
|
$this->assertStringContainsString('<li>Dauer 25 Min.</li>', $preview);
|
||||||
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'komposition', 'subject' => $program->composition_id]).'"', $preview);
|
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'komposition', 'subject' => $program->composition_id, 'g' => 'mittel']).'&v=', $preview);
|
||||||
$this->assertStringContainsString('Für Module gibt es noch keine öffentliche Seitenart', $preview);
|
$this->assertStringContainsString('Für Module gibt es noch keine öffentliche Seitenart', $preview);
|
||||||
$this->assertStringNotContainsString(route('public.program', $module->composition_id), $preview, 'Module erhalten keinen künstlichen Link.');
|
$this->assertStringNotContainsString(route('public.program', $module->composition_id), $preview, 'Module erhalten keinen künstlichen Link.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\PageService;
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Actions\Testing\TestAction;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Livewire\Features\SupportTesting\Testable;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Einstellungsdialog des Abschnitts im Seiteneditor: Name, Sprungmarke und Sichtbarkeit stehen nicht mehr als
|
||||||
|
* Eingabeblock in jedem Abschnitt, sondern im Dialog. „Übernehmen“ ändert nur den Seitenentwurf.
|
||||||
|
*/
|
||||||
|
class CmsSectionSettingsTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private function editor(): User
|
||||||
|
{
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
|
||||||
|
return $editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $extra
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function section(string $heading, array $extra = []): array
|
||||||
|
{
|
||||||
|
return $extra + ['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'heading', 'v' => 1, 'data' => ['heading' => $heading]]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $sections
|
||||||
|
*/
|
||||||
|
private function page(string $path, array $sections): Page
|
||||||
|
{
|
||||||
|
$page = Page::query()->create(['path' => $path]);
|
||||||
|
app(PageService::class)->saveRevision($page, $sections, null, null, null);
|
||||||
|
|
||||||
|
return $page->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function editorFor(Page $page): Testable
|
||||||
|
{
|
||||||
|
return Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function settings(string $key): TestAction
|
||||||
|
{
|
||||||
|
return TestAction::make('einstellungen')->schemaComponent('sections')->arguments(['item' => $key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_dialog_shows_the_values_of_the_section_and_applies_them_to_the_draft_only(): void
|
||||||
|
{
|
||||||
|
$page = $this->page('/einstellungen', [$this->section('A', ['name' => 'Alt', 'anchor' => 'alt']), $this->section('B')]);
|
||||||
|
$revisions = $page->revisions()->count();
|
||||||
|
$component = $this->editorFor($page);
|
||||||
|
$keys = array_keys($component->get('data.sections'));
|
||||||
|
$slotsBefore = $component->get("data.sections.{$keys[0]}.slots");
|
||||||
|
$styleBefore = $component->get("data.sections.{$keys[0]}.style");
|
||||||
|
$otherBefore = $component->get("data.sections.{$keys[1]}");
|
||||||
|
|
||||||
|
$component->mountAction($this->settings($keys[0]))
|
||||||
|
->assertActionDataSet(['name' => 'Alt', 'anchor' => 'alt', 'hidden' => false])
|
||||||
|
->callMountedAction()
|
||||||
|
->assertHasNoActionErrors();
|
||||||
|
|
||||||
|
$this->assertSame('Alt', $component->get("data.sections.{$keys[0]}.name"), 'Ohne Änderung bleibt alles wie es war.');
|
||||||
|
|
||||||
|
$component->callAction($this->settings($keys[0]), ['name' => ' Kurse 2026 ', 'anchor' => 'Kurse 2026', 'hidden' => true])->assertHasNoActionErrors();
|
||||||
|
|
||||||
|
$this->assertSame('Kurse 2026', $component->get("data.sections.{$keys[0]}.name"));
|
||||||
|
$this->assertSame('kurse-2026', $component->get("data.sections.{$keys[0]}.anchor"), 'Die Sprungmarke wird in die zulässige Form gebracht.');
|
||||||
|
$this->assertTrue($component->get("data.sections.{$keys[0]}.hidden"));
|
||||||
|
$this->assertSame($slotsBefore, $component->get("data.sections.{$keys[0]}.slots"), 'Plätze und Bausteine bleiben unberührt.');
|
||||||
|
$this->assertSame($styleBefore, $component->get("data.sections.{$keys[0]}.style"));
|
||||||
|
$this->assertSame($otherBefore, $component->get("data.sections.{$keys[1]}"), 'Ein anderer Abschnitt bleibt unberührt.');
|
||||||
|
|
||||||
|
$this->assertTrue($component->instance()->hasUnsavedEditorChanges());
|
||||||
|
$this->assertSame($revisions, $page->revisions()->count(), 'Übernehmen speichert keine Revision.');
|
||||||
|
$this->assertSame('Alt', $page->fresh()->latestRevision->sections()[0]['name']);
|
||||||
|
|
||||||
|
$component->call('save')->assertHasNoFormErrors();
|
||||||
|
$stored = $page->fresh()->latestRevision->sections();
|
||||||
|
$this->assertSame(['Kurse 2026', 'kurse-2026', true], [$stored[0]['name'], $stored[0]['anchor'], $stored[0]['hidden']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_closing_the_dialog_without_applying_changes_nothing(): void
|
||||||
|
{
|
||||||
|
$page = $this->page('/abbrechen', [$this->section('A', ['name' => 'Bleibt'])]);
|
||||||
|
$component = $this->editorFor($page);
|
||||||
|
$key = array_key_first($component->get('data.sections'));
|
||||||
|
|
||||||
|
$component->mountAction($this->settings($key))->unmountAction();
|
||||||
|
|
||||||
|
$this->assertSame('Bleibt', $component->get("data.sections.{$key}.name"));
|
||||||
|
$this->assertFalse($component->instance()->hasUnsavedEditorChanges());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_dialog_rejects_invalid_reserved_and_duplicate_anchors_with_the_save_wording(): void
|
||||||
|
{
|
||||||
|
$page = $this->page('/pruefung', [$this->section('A', ['anchor' => 'kurse']), $this->section('B')]);
|
||||||
|
$component = $this->editorFor($page);
|
||||||
|
$keys = array_keys($component->get('data.sections'));
|
||||||
|
|
||||||
|
// Doppelte Sprungmarke (auch ungespeicherte Eingaben der anderen Abschnitte zählen).
|
||||||
|
$component->callAction($this->settings($keys[1]), ['name' => null, 'anchor' => 'KURSE', 'hidden' => false])->assertHasActionErrors(['anchor'])->unmountAction();
|
||||||
|
$this->assertNull($component->get("data.sections.{$keys[1]}.anchor"));
|
||||||
|
|
||||||
|
// Reserviert.
|
||||||
|
$component->callAction($this->settings($keys[1]), ['name' => null, 'anchor' => 'inhalt', 'hidden' => false])->assertHasActionErrors(['anchor'])->unmountAction();
|
||||||
|
|
||||||
|
// Eine Eingabe, aus der nichts Zulässiges entsteht, wird wie beim Verlassen des Feldes zu „keine Sprungmarke“.
|
||||||
|
$component->callAction($this->settings($keys[1]), ['name' => null, 'anchor' => '!!!', 'hidden' => false])->assertHasNoActionErrors();
|
||||||
|
$this->assertNull($component->get("data.sections.{$keys[1]}.anchor"));
|
||||||
|
|
||||||
|
// Die eigene Marke des Abschnitts ist kein Duplikat; leer entfernt sie.
|
||||||
|
$component->callAction($this->settings($keys[0]), ['name' => null, 'anchor' => 'kurse', 'hidden' => false])->assertHasNoActionErrors();
|
||||||
|
$component->callAction($this->settings($keys[0]), ['name' => null, 'anchor' => '', 'hidden' => false])->assertHasNoActionErrors();
|
||||||
|
$this->assertNull($component->get("data.sections.{$keys[0]}.anchor"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_section_list_has_no_input_block_for_name_and_anchor_but_the_settings_button(): void
|
||||||
|
{
|
||||||
|
$page = $this->page('/ohne-block', [$this->section('A', ['name' => 'Kursübersicht', 'anchor' => 'kurse']), $this->section('B', ['hidden' => true])]);
|
||||||
|
|
||||||
|
$html = $this->editorFor($page)->html();
|
||||||
|
|
||||||
|
$this->assertStringNotContainsString('Name des Abschnitts', $html, 'Die Eingabefelder stehen nur im Dialog.');
|
||||||
|
$this->assertStringNotContainsString('luf-abschnitt-bezeichnung', $html);
|
||||||
|
$this->assertSame(2, substr_count($html, 'data-luf-einstellungen'), 'Jeder Abschnittskopf trägt den Einstellungsbutton.');
|
||||||
|
$this->assertStringContainsString('Kursübersicht', $html);
|
||||||
|
$this->assertStringContainsString('#kurse', $html);
|
||||||
|
$this->assertStringContainsString('Ausgeblendet', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_save_error_for_name_or_anchor_is_shown_at_the_section_with_a_way_to_the_dialog(): void
|
||||||
|
{
|
||||||
|
$page = $this->page('/fehler', [$this->section('A', ['anchor' => 'kurse']), $this->section('B')]);
|
||||||
|
$component = $this->editorFor($page);
|
||||||
|
$keys = array_keys($component->get('data.sections'));
|
||||||
|
|
||||||
|
$component->set("data.sections.{$keys[1]}.anchor", 'kurse')->call('save')->assertHasFormErrors(["sections.{$keys[1]}.anchor"]);
|
||||||
|
|
||||||
|
$html = $component->html();
|
||||||
|
$this->assertSame(1, substr_count($html, 'data-abschnitt-fehler'), 'Die Meldung steht genau am betroffenen Abschnitt.');
|
||||||
|
$this->assertStringContainsString('Diese Sprungmarke gibt es auf der Seite schon', $html);
|
||||||
|
$this->assertStringContainsString('Einstellungen öffnen', $html);
|
||||||
|
|
||||||
|
// Nach der Korrektur im Dialog lässt sich speichern.
|
||||||
|
$component->callAction($this->settings($keys[1]), ['name' => null, 'anchor' => 'anderes-ziel', 'hidden' => false])->assertHasNoActionErrors();
|
||||||
|
$component->call('save')->assertHasNoFormErrors();
|
||||||
|
$this->assertSame('anderes-ziel', $page->fresh()->latestRevision->sections()[1]['anchor']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_other_open_inputs_of_the_page_survive_the_dialog(): void
|
||||||
|
{
|
||||||
|
$page = $this->page('/offen', [$this->section('A')]);
|
||||||
|
$component = $this->editorFor($page);
|
||||||
|
$key = array_key_first($component->get('data.sections'));
|
||||||
|
|
||||||
|
$component->set('data.seo_title', 'Offener Titel')
|
||||||
|
->callAction($this->settings($key), ['name' => 'Neu', 'anchor' => null, 'hidden' => false])
|
||||||
|
->assertSet('data.seo_title', 'Offener Titel')
|
||||||
|
->assertSet("data.sections.{$key}.name", 'Neu');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_anchor_rules_have_one_wording_for_dialog_and_save(): void
|
||||||
|
{
|
||||||
|
$this->assertNull(PageSections::anchorProblem('kurse-2026', ['andere']));
|
||||||
|
$this->assertStringContainsString('Kleinbuchstaben', (string) PageSections::anchorProblem('Kurse', []));
|
||||||
|
$this->assertStringContainsString('Kleinbuchstaben', (string) PageSections::anchorProblem('a--b', []));
|
||||||
|
$this->assertStringContainsString('Seitengerüst', (string) PageSections::anchorProblem('main', []));
|
||||||
|
$this->assertStringContainsString('Seitengerüst', (string) PageSections::anchorProblem('bereich-abc', []));
|
||||||
|
$this->assertStringContainsString('schon', (string) PageSections::anchorProblem('kurse', ['kurse']));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
use App\Domain\Cms\WebsiteImageUsage;
|
use App\Domain\Cms\WebsiteImageUsage;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Media\WebsiteIntake;
|
use App\Domain\Media\WebsiteIntake;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use App\Domain\Media\WebsiteMediaAlias;
|
use App\Domain\Media\WebsiteMediaAlias;
|
||||||
use App\Domain\Media\WebsiteRelease;
|
use App\Domain\Media\WebsiteRelease;
|
||||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||||
@@ -47,7 +48,7 @@ protected function setUp(): void
|
|||||||
public function test_a_released_medium_is_shown_in_every_widget_through_the_website_route(): void
|
public function test_a_released_medium_is_shown_in_every_widget_through_the_website_route(): void
|
||||||
{
|
{
|
||||||
$medium = $this->releasedImage('Lara im Park', 'Lara sitzt auf einer Parkbank');
|
$medium = $this->releasedImage('Lara im Park', 'Lara sitzt auf einer Parkbank');
|
||||||
$url = route('website.media', $medium);
|
$url = app(WebsiteMedia::class)->present($medium)->url;
|
||||||
|
|
||||||
$revision = $this->publish('/medien-ueberall', [
|
$revision = $this->publish('/medien-ueberall', [
|
||||||
['layout' => 'u4', 'style' => ['background' => 'image', 'image' => $medium->id, 'overlay' => 'light'], 'slots' => [
|
['layout' => 'u4', 'style' => ['background' => 'image', 'image' => $medium->id, 'overlay' => 'light'], 'slots' => [
|
||||||
@@ -63,7 +64,8 @@ public function test_a_released_medium_is_shown_in_every_widget_through_the_webs
|
|||||||
$this->assertSame($medium->id, $revision->sections[0]['style']['image']);
|
$this->assertSame($medium->id, $revision->sections[0]['style']['image']);
|
||||||
|
|
||||||
$main = $this->main($this->get('/medien-ueberall')->assertOk()->getContent());
|
$main = $this->main($this->get('/medien-ueberall')->assertOk()->getContent());
|
||||||
$this->assertSame(4, substr_count($main, 'src="'.$url.'"'), 'Hintergrund, Einstieg, Bild und Text, Karte verwenden dasselbe Medium.');
|
$this->assertSame(3, substr_count($main, 'src="'.$url.'"'), 'Einstieg, Bild und Text, Karte verwenden dasselbe Medium.');
|
||||||
|
$this->assertSame(1, substr_count($main, 'src="'.$url.'&w=1920"'), 'Der Hintergrund nimmt dieselbe Datei in der Breite 1920.');
|
||||||
$this->assertStringContainsString('alt="Lara sitzt auf einer Parkbank"', $main, 'Alternativtext des Mediums.');
|
$this->assertStringContainsString('alt="Lara sitzt auf einer Parkbank"', $main, 'Alternativtext des Mediums.');
|
||||||
$this->assertStringContainsString('alt="Eigene Beschreibung"', $main, 'Abweichender Alternativtext im Widget.');
|
$this->assertStringContainsString('alt="Eigene Beschreibung"', $main, 'Abweichender Alternativtext im Widget.');
|
||||||
$this->assertStringNotContainsString('/redaktion/', $main);
|
$this->assertStringNotContainsString('/redaktion/', $main);
|
||||||
@@ -87,7 +89,7 @@ public function test_an_unreleased_medium_is_only_shown_in_the_preview_with_a_no
|
|||||||
$this->assertStringContainsString('lf-bt--without-image', $main);
|
$this->assertStringContainsString('lf-bt--without-image', $main);
|
||||||
|
|
||||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||||
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'element', 'subject' => $medium->id]).'"', $preview);
|
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'element', 'subject' => $medium->id, 'g' => 'mittel']).'&v=', $preview);
|
||||||
$this->assertStringContainsString('Das gewählte Bild „Noch nicht freigegeben“ erscheint öffentlich nicht: Nicht für die Website freigegeben.', $preview);
|
$this->assertStringContainsString('Das gewählte Bild „Noch nicht freigegeben“ erscheint öffentlich nicht: Nicht für die Website freigegeben.', $preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +106,7 @@ public function test_withdrawing_the_release_removes_the_image_from_pages_and_cl
|
|||||||
$this->assertNotNull($medium->website_released_at);
|
$this->assertNotNull($medium->website_released_at);
|
||||||
$this->refreshScoped();
|
$this->refreshScoped();
|
||||||
|
|
||||||
$this->get('/altbild')->assertSee('src="'.route('website.media', $medium).'"', false)->assertDontSee('/medien/cms/altbild', false);
|
$this->get('/altbild')->assertSee('src="'.app(WebsiteMedia::class)->present($medium)->url.'"', false)->assertDontSee('/medien/cms/altbild', false);
|
||||||
$this->get('/medien/cms/altbild-abc123.jpg')->assertOk();
|
$this->get('/medien/cms/altbild-abc123.jpg')->assertOk();
|
||||||
|
|
||||||
app(WebsiteRelease::class)->withdraw($medium);
|
app(WebsiteRelease::class)->withdraw($medium);
|
||||||
@@ -151,7 +153,7 @@ public function test_deleting_an_imported_medium_keeps_the_former_file_closed_an
|
|||||||
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
||||||
$medium = WebsiteMediaAlias::query()->firstOrFail()->element;
|
$medium = WebsiteMediaAlias::query()->firstOrFail()->element;
|
||||||
$this->refreshScoped();
|
$this->refreshScoped();
|
||||||
$this->get('/geloescht')->assertSee('src="'.route('website.media', $medium).'"', false);
|
$this->get('/geloescht')->assertSee('src="'.app(WebsiteMedia::class)->present($medium)->url.'"', false);
|
||||||
|
|
||||||
$medium->delete();
|
$medium->delete();
|
||||||
$this->refreshScoped();
|
$this->refreshScoped();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
use App\Domain\Media\FilmStill;
|
use App\Domain\Media\FilmStill;
|
||||||
use App\Domain\Media\FilmStillSource;
|
use App\Domain\Media\FilmStillSource;
|
||||||
use App\Domain\Media\ThumbnailDeriver;
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use App\Domain\Media\WebsiteRelease;
|
use App\Domain\Media\WebsiteRelease;
|
||||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -184,7 +185,7 @@ public function test_the_card_shows_the_stored_image_and_a_page_view_never_extra
|
|||||||
$html = $this->get('/filmkarte')->assertOk()->getContent();
|
$html = $this->get('/filmkarte')->assertOk()->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertStringContainsString('src="'.route('website.media', $still).'"', $html);
|
$this->assertStringContainsString('src="'.app(WebsiteMedia::class)->present($still)->url.'"', $html);
|
||||||
$this->assertStringContainsString('alt="Szene aus dem Film „Lara im Park“"', htmlspecialchars_decode($html));
|
$this->assertStringContainsString('alt="Szene aus dem Film „Lara im Park“"', htmlspecialchars_decode($html));
|
||||||
$this->assertStringNotContainsString('lf-pc__panel--film', $html, 'Mit freigegebenem Bild erscheint keine Filmtafel.');
|
$this->assertStringNotContainsString('lf-pc__panel--film', $html, 'Mit freigegebenem Bild erscheint keine Filmtafel.');
|
||||||
$this->assertStringNotContainsString('/redaktion/', $html);
|
$this->assertStringNotContainsString('/redaktion/', $html);
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public function test_a_medium_preview_fills_the_program_until_the_program_has_it
|
|||||||
$this->actingAs($member)
|
$this->actingAs($member)
|
||||||
->get(route('member.content', ['composition' => $released->composition->id, 'version' => $film->id]))
|
->get(route('member.content', ['composition' => $released->composition->id, 'version' => $film->id]))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertSee('poster="'.$elementUrl.'"', false);
|
->assertSee('poster="'.$elementUrl.'?g=mittel', false);
|
||||||
|
|
||||||
$this->actingAs($member)
|
$this->actingAs($member)
|
||||||
->get(route('member.library'))
|
->get(route('member.library'))
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
use App\Domain\Catalog\PresentationRole;
|
use App\Domain\Catalog\PresentationRole;
|
||||||
use App\Domain\Commerce\ShopCatalog;
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
use App\Domain\Commerce\ShopMarkers;
|
use App\Domain\Commerce\ShopMarkers;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use App\Filament\Pages\RedaktionelleStammdaten;
|
use App\Filament\Pages\RedaktionelleStammdaten;
|
||||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -135,10 +136,10 @@ public function test_a_released_cover_appears_on_the_tile_as_a_decorative_lazy_i
|
|||||||
$released = $this->image('Freigegebenes Titelbild', released: true);
|
$released = $this->image('Freigegebenes Titelbild', released: true);
|
||||||
$this->cover($this->konflikte(), $released);
|
$this->cover($this->konflikte(), $released);
|
||||||
|
|
||||||
$this->assertSame(route('website.media', $released), $this->card()['image']['url']);
|
$this->assertSame(app(WebsiteMedia::class)->present($released)->url, $this->card()['image']['url']);
|
||||||
$html = $this->get(route('shop'))->assertOk()->getContent();
|
$html = $this->get(route('shop'))->assertOk()->getContent();
|
||||||
$this->assertStringContainsString('src="'.route('website.media', $released).'"', $html);
|
$this->assertStringContainsString('src="'.app(WebsiteMedia::class)->present($released)->url.'"', $html);
|
||||||
$this->assertMatchesRegularExpression('#<img src="[^"]+website-medien/'.$released->id.'" alt="" loading="lazy"#', $html, 'Das Bild ist schmückend, der Titel ist der Link.');
|
$this->assertMatchesRegularExpression('#<img src="[^"]+website-medien/'.$released->id.'(\?v=\d+)?" alt="" loading="lazy"#', $html, 'Das Bild ist schmückend, der Titel ist der Link.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_an_unreleased_first_cover_is_skipped_for_the_next_released_one(): void
|
public function test_an_unreleased_first_cover_is_skipped_for_the_next_released_one(): void
|
||||||
@@ -147,7 +148,7 @@ public function test_an_unreleased_first_cover_is_skipped_for_the_next_released_
|
|||||||
$gallery = $this->image('Galeriebild freigegeben', released: true);
|
$gallery = $this->image('Galeriebild freigegeben', released: true);
|
||||||
$this->cover($this->konflikte(), $gallery, 'galerie', 2);
|
$this->cover($this->konflikte(), $gallery, 'galerie', 2);
|
||||||
|
|
||||||
$this->assertSame(route('website.media', $gallery), $this->card()['image']['url']);
|
$this->assertSame(app(WebsiteMedia::class)->present($gallery)->url, $this->card()['image']['url']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_a_film_is_not_used_as_a_cover(): void
|
public function test_a_film_is_not_used_as_a_cover(): void
|
||||||
|
|||||||
Reference in new issue
Block a user