Merge pull request 'Zoom beim Bild' (#28) from develop into main
Reviewed-on: #28
No files matched your search
@@ -38,6 +38,15 @@ RUN composer dump-autoload --optimize --no-interaction
|
||||
ENV APP_ENV=testing
|
||||
CMD ["sh", "-ec", "if [ -x vendor/bin/pint ]; then vendor/bin/pint --test; fi; php artisan test --compact"]
|
||||
|
||||
# ---- JavaScript-Tests (CI): Vitest für resources/js. Nur das Gate baut dieses Ziel; die ausgelieferten Images
|
||||
# (app, web) enthalten weder Vitest noch die Tests, weil sie nur das Ergebnis von "assets" übernehmen.
|
||||
FROM node:22-alpine AS jstest
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json vitest.config.js ./
|
||||
RUN npm ci
|
||||
COPY resources/js ./resources/js
|
||||
CMD ["npm", "run", "test:js"]
|
||||
|
||||
# ---- App (php-fpm; derselbe Tag dient für Queue und Scheduler) -------------------------------
|
||||
FROM base AS app
|
||||
COPY --from=vendor /var/www/html /var/www/html
|
||||
|
||||
@@ -32,6 +32,9 @@ final class FormattedText
|
||||
/** Blockelemente, mit denen gespeichertes HTML beginnt. */
|
||||
private const BLOCKS = ['p', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'blockquote', 'table', 'img'];
|
||||
|
||||
/** Zusätzlich zu den Blöcken erkennt der Textanfang h1, h2 und div als HTML; die Bereinigung bildet sie auf h3 und p ab (mapLegacyTags). */
|
||||
private const START_TAGS = ['h1', 'h2', 'div'];
|
||||
|
||||
/** Angaben der Redaktion, die formatiert gespeichert werden. Suchbegriffe, Titel und Teaser bleiben Klartext. */
|
||||
public const FIELDS = ['summary', 'description'];
|
||||
|
||||
@@ -59,7 +62,7 @@ final class FormattedText
|
||||
/** Wird der Wert als HTML gelesen (sonst als Klartext des Altbestands)? */
|
||||
public static function isHtml(?string $value): bool
|
||||
{
|
||||
return preg_match('/^\s*<(?:'.implode('|', self::BLOCKS).')[\s>\/]/i', (string) $value) === 1;
|
||||
return preg_match('/^\s*<(?:'.implode('|', [...self::BLOCKS, ...self::START_TAGS]).')[\s>\/]/i', (string) $value) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Filament\Support\FramingSlider;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
/**
|
||||
* Bildausschnitt für Bilder und Videos in Widgets (ADR-70): Fokuspunkt (waagerecht, senkrecht, 0–100 %) und Zoom
|
||||
* (100–250 %). Gespeichert wird in data (`focus_x`, `focus_y`, `zoom`), weil settings nur Aufzählungswerte trägt.
|
||||
*
|
||||
* Der Zoom beginnt bei 100 %: Dann füllt das Bild den Rahmen (object-fit: cover), mehr Verkleinern gäbe es nur mit leeren
|
||||
* Rändern. Darüber wird um den Fokuspunkt vergrößert (`scale`, `transform-origin` = Fokuspunkt). Ein Bild, das mindestens
|
||||
* so groß ist wie der Rahmen und um einen Punkt im Rahmen vergrößert wird, lässt den Rahmen nie frei; es entstehen keine
|
||||
* Ränder. Die Rahmen schneiden ab (overflow: hidden), die Darstellung ist reines CSS, es gibt keine neue Bildfassung.
|
||||
*
|
||||
* Die Karten (CardsWidget) tragen den Ausschnitt je Karte, die übrigen Widgets je Widget (PremiumFields).
|
||||
*/
|
||||
final class ImageFraming
|
||||
{
|
||||
public const ZOOM_MIN = 100;
|
||||
|
||||
public const ZOOM_MAX = 250;
|
||||
|
||||
/** Vorgaben des Fokuspunkts bei Widgets, die ihn nicht selbst vorgeben (Karten: Bildmitte). */
|
||||
public const FOCUS_DEFAULT = 50;
|
||||
|
||||
/**
|
||||
* Die drei Regler. Ohne gespeicherten Wert zeigen sie die Vorgabe der Widget-Art, die auch die Darstellung verwendet.
|
||||
*
|
||||
* @return list<Slider>
|
||||
*/
|
||||
public static function sliders(int $defaultX = self::FOCUS_DEFAULT, int $defaultY = self::FOCUS_DEFAULT, ?\Closure $visible = null): array
|
||||
{
|
||||
$slider = function (string $name, string $label, int $min, int $max, int $default, ?string $help = null) use ($visible): FramingSlider {
|
||||
$field = FramingSlider::make($name)
|
||||
->label($label)
|
||||
->range($min, $max)
|
||||
->step(1)
|
||||
->required(false)
|
||||
->tooltips()
|
||||
->default($default)
|
||||
->afterStateHydrated(function (FramingSlider $component, mixed $state) use ($default, $min): void {
|
||||
// Ein Regler ohne Wert beginnt bei null; der Zoom darunter ist keine Eingabe, sondern „nicht gesetzt“.
|
||||
if (! is_numeric($state) || $state < $min) {
|
||||
$component->state($default);
|
||||
}
|
||||
})
|
||||
->live();
|
||||
|
||||
if ($help !== null) {
|
||||
$field->helperText($help);
|
||||
}
|
||||
|
||||
return $visible !== null ? $field->visible($visible) : $field;
|
||||
};
|
||||
|
||||
return [
|
||||
$slider('focus_x', 'Bildausschnitt waagerecht (0 = links, 100 = rechts)', 0, 100, $defaultX),
|
||||
$slider('focus_y', 'Bildausschnitt senkrecht (0 = oben, 100 = unten)', 0, 100, $defaultY),
|
||||
$slider('zoom', 'Zoom (in Prozent)', self::ZOOM_MIN, self::ZOOM_MAX, self::ZOOM_MIN, 'Bei 100 % füllt das Bild den Rahmen; weiter herauszoomen geht nicht, sonst entstünden leere Ränder. Darüber wird um den gewählten Ausschnitt vergrößert. Gilt auch für das Video auf dem Bild.'),
|
||||
];
|
||||
}
|
||||
|
||||
/** Sichtbar, sobald in der Karte ein Bild gewählt ist (Feld `image` desselben Eintrags). */
|
||||
public static function whenImageChosen(): \Closure
|
||||
{
|
||||
return fn (Get $get): bool => filled($get('image'));
|
||||
}
|
||||
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||
// Nach oben begrenzt; Werte darunter gelten als „kein Zoom“ (zoom() hebt sie auf 100 %).
|
||||
'zoom' => ['nullable', 'numeric', 'min:0', 'max:'.self::ZOOM_MAX],
|
||||
];
|
||||
}
|
||||
|
||||
/** Zoom in Prozent (100 bis 250); ungültig oder ohne Angabe 100. */
|
||||
public static function zoom(mixed $value): int
|
||||
{
|
||||
return is_numeric($value) ? (int) round(max(self::ZOOM_MIN, min(self::ZOOM_MAX, (float) $value))) : self::ZOOM_MIN;
|
||||
}
|
||||
|
||||
/** Fokuspunkt in Prozent, ohne Angabe der Vorgabe. */
|
||||
public static function percent(mixed $value, int $default = self::FOCUS_DEFAULT): int
|
||||
{
|
||||
return is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Speicherform: der Zoom nur, wenn er über 100 % liegt (Widgets ohne Zoom bleiben byteweise wie zuvor).
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function cleanZoom(array $data): array
|
||||
{
|
||||
$zoom = self::zoom($data['zoom'] ?? null);
|
||||
|
||||
if ($zoom > self::ZOOM_MIN) {
|
||||
$data['zoom'] = $zoom;
|
||||
} else {
|
||||
unset($data['zoom']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausschnitt einer Karte in der Speicherform: Schlüssel nur, wenn sie von der Vorgabe (Mitte, 100 %) abweichen.
|
||||
*
|
||||
* @param array<string, mixed> $item
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public static function cleanItem(array $item): array
|
||||
{
|
||||
$out = [];
|
||||
|
||||
foreach (['focus_x', 'focus_y'] as $key) {
|
||||
$value = self::percent($item[$key] ?? null);
|
||||
|
||||
if ($value !== self::FOCUS_DEFAULT) {
|
||||
$out[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$zoom = self::zoom($item['zoom'] ?? null);
|
||||
|
||||
if ($zoom > self::ZOOM_MIN) {
|
||||
$out['zoom'] = $zoom;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inline-Stil am Bild einer Karte, nur wenn etwas von der Vorgabe abweicht (sonst null: Ausgabe unverändert).
|
||||
*
|
||||
* @param array<string, mixed> $item
|
||||
*/
|
||||
public static function itemStyle(array $item): ?string
|
||||
{
|
||||
$x = self::percent($item['focus_x'] ?? null);
|
||||
$y = self::percent($item['focus_y'] ?? null);
|
||||
$zoom = self::zoom($item['zoom'] ?? null);
|
||||
|
||||
if ($x === self::FOCUS_DEFAULT && $y === self::FOCUS_DEFAULT && $zoom === self::ZOOM_MIN) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'object-position: '.$x.'% '.$y.'%'.($zoom > self::ZOOM_MIN ? '; transform-origin: '.$x.'% '.$y.'%; scale: '.round($zoom / 100, 2) : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* `sizes` für `srcset`: Bei Zoom wird ein Teil des Bilds auf die Rahmenbreite vergrößert, der Browser soll deshalb eine
|
||||
* größere Fassung holen.
|
||||
*/
|
||||
public static function sizes(string $sizes, int $zoom): string
|
||||
{
|
||||
if ($zoom <= self::ZOOM_MIN) {
|
||||
return $sizes;
|
||||
}
|
||||
|
||||
$factor = round($zoom / 100, 2);
|
||||
|
||||
return (string) preg_replace_callback('/(\d+(?:\.\d+)?)vw/', fn (array $m): string => 'calc('.$m[1].'vw * '.$factor.')', $sizes);
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,7 @@ public static function rules(): array
|
||||
'cta2_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta2_url'],
|
||||
'cta2_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta2_label'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||
];
|
||||
] + ImageFraming::rules();
|
||||
}
|
||||
|
||||
public static function eyebrowField(): TextInput
|
||||
@@ -67,29 +65,13 @@ public static function ctaFields(): Grid
|
||||
}
|
||||
|
||||
/**
|
||||
* Fokus waagerecht und senkrecht sowie Zoom (ImageFraming).
|
||||
*
|
||||
* @return list<Slider>
|
||||
*/
|
||||
public static function focusFields(int $defaultX = 50, int $defaultY = 50): array
|
||||
{
|
||||
// Ohne gespeicherten Wert zeigt der Regler die Vorgabe der Widget-Art, die auch die Darstellung verwendet.
|
||||
$slider = fn (string $name, string $label, int $default) => Slider::make($name)
|
||||
->label($label)
|
||||
->range(0, 100)
|
||||
->step(1)
|
||||
->required(false)
|
||||
->tooltips()
|
||||
->default($default)
|
||||
->afterStateHydrated(function (Slider $component, mixed $state) use ($default): void {
|
||||
if (! is_numeric($state)) {
|
||||
$component->state($default);
|
||||
}
|
||||
})
|
||||
->live();
|
||||
|
||||
return [
|
||||
$slider('focus_x', 'Bildausschnitt waagerecht (0 = links, 100 = rechts)', $defaultX),
|
||||
$slider('focus_y', 'Bildausschnitt senkrecht (0 = oben, 100 = unten)', $defaultY),
|
||||
];
|
||||
return ImageFraming::sliders($defaultX, $defaultY);
|
||||
}
|
||||
|
||||
public static function altField(): TextInput
|
||||
@@ -124,7 +106,7 @@ public static function clean(array $data, WidgetErrors $errors, bool $hasImage):
|
||||
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
return ImageFraming::cleanZoom($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,6 +141,12 @@ public static function focus(array $data, int $defaultX = 50, int $defaultY = 50
|
||||
return ['x' => $clamp($data['focus_x'] ?? null, $defaultX), 'y' => $clamp($data['focus_y'] ?? null, $defaultY)];
|
||||
}
|
||||
|
||||
/** Zoom in Prozent (100 bis 250); ohne Angabe 100. */
|
||||
public static function zoom(array $data): int
|
||||
{
|
||||
return ImageFraming::zoom($data['zoom'] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Übersetzt den früheren Fokuspunkt (Aufzählung wie beim Abschnittshintergrund) in Prozentwerte.
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
||||
use App\Domain\Cms\Widgets\Support\ImageFraming;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\LinkField;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
@@ -161,6 +162,9 @@ public function dataRules(): array
|
||||
'items.*.symbol' => ['nullable', 'string', Rule::in(array_keys(HeadingAccent::symbols()))],
|
||||
'items.*.image' => ['nullable'],
|
||||
'items.*._upload' => ['nullable'],
|
||||
'items.*.focus_x' => ImageFraming::rules()['focus_x'],
|
||||
'items.*.focus_y' => ImageFraming::rules()['focus_y'],
|
||||
'items.*.zoom' => ImageFraming::rules()['zoom'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -231,6 +235,7 @@ public function dataFields(): array
|
||||
$image,
|
||||
$upload,
|
||||
$status,
|
||||
...ImageFraming::sliders(visible: ImageFraming::whenImageChosen()),
|
||||
])
|
||||
->minItems(1)
|
||||
->maxItems(12)
|
||||
@@ -294,6 +299,8 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
...(filled($item['url'] ?? null) && filled($item['link_label'] ?? null) ? ['link_label' => trim((string) $item['link_label'])] : []),
|
||||
...(filled($item['symbol'] ?? null) ? ['symbol' => $item['symbol']] : []),
|
||||
'image' => $itemRefs['image'],
|
||||
// Bildausschnitt (ADR-70) nur, wenn er von der Vorgabe (Mitte, 100 %) abweicht und ein Bild da ist.
|
||||
...($itemRefs['image'] !== null ? ImageFraming::cleanItem($item) : []),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -320,6 +327,8 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
||||
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
||||
'imageSrcset' => $images->srcset($item['image'] ?? null),
|
||||
'imageStyle' => ImageFraming::itemStyle($item),
|
||||
'imageSizes' => ImageFraming::sizes('(min-width: 900px) 40vw, 100vw', ImageFraming::zoom($item['zoom'] ?? null)),
|
||||
];
|
||||
|
||||
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
||||
|
||||
@@ -220,11 +220,11 @@ public function editorSchema(): array
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
[, , , , $alt, $focusX, $focusY, $zoom] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make($this->refFields())->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
Group::make([$alt, $focusX, $focusY, $zoom])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -262,6 +262,7 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'actions' => $actions,
|
||||
'action' => $actions[0] ?? null,
|
||||
'focus' => PremiumFields::focus($widget['data'], 68, 50),
|
||||
'zoom' => PremiumFields::zoom($widget['data']),
|
||||
'accent' => in_array($widget['settings']['accent'] ?? null, ['underline', 'rays', 'none'], true) ? $widget['settings']['accent'] : 'underline',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -272,11 +272,11 @@ public function editorSchema(): array
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
[, , , , $alt, $focusX, $focusY, $zoom] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make($this->refFields())->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
Group::make([$alt, $focusX, $focusY, $zoom])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -357,6 +357,7 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'body' => TextMarkers::decorate(RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : '')),
|
||||
'actions' => PremiumFields::actions($widget['data']),
|
||||
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
||||
'zoom' => PremiumFields::zoom($widget['data']),
|
||||
// Eine gewählte Farbe aus der Palette (ADR-68) hat Vorrang vor „Hintergrund des Widgets“.
|
||||
'surface' => WidgetAppearance::slot($this, $widget) !== null ? 'palette' : (in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream'),
|
||||
];
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||
use App\Domain\Cms\Widgets\Support\ImageFraming;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
@@ -228,9 +229,7 @@ public function dataRules(): array
|
||||
'heading' => ['nullable', 'string', 'max:200'],
|
||||
'summary' => ['nullable', 'string', 'max:500'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||
];
|
||||
] + ImageFraming::rules();
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
@@ -294,11 +293,11 @@ public function editorSchema(): array
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
[, , $alt, $focusX, $focusY, $zoom] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([...ImageRefFields::fields('Kartenbild', live: true), ...$this->imageSourceFields()])->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
Group::make([$alt, $focusX, $focusY, $zoom])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -324,7 +323,7 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
return [$data, $refs];
|
||||
return [ImageFraming::cleanZoom($data), $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
@@ -367,6 +366,7 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
||||
'focus' => PremiumFields::focus($data, 66, 45),
|
||||
'zoom' => PremiumFields::zoom($data),
|
||||
'format' => $option('format', 'landscape'),
|
||||
'fit' => $option('fit', 'cover'),
|
||||
'headingTag' => $option('heading_level', 'h3'),
|
||||
|
||||
@@ -37,6 +37,40 @@ public function write(
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schreibt nur dann, wenn zu diesem Anspruch und dieser Fassung innerhalb des Zeitfensters noch kein Nachweis der
|
||||
* Aktion steht. So zählt eine Wiedergabe einmal, auch wenn der Player nur Erneuerungen und Abschnitte abruft; ein
|
||||
* Abruf, der nie die Hauptliste holt, bleibt trotzdem nicht ohne Nachweis.
|
||||
*
|
||||
* @return bool true, wenn geschrieben wurde
|
||||
*/
|
||||
public function writeUnlessRecent(
|
||||
int $windowSeconds,
|
||||
Grant $grant,
|
||||
LicenseArticle $article,
|
||||
ArticleRelease $release,
|
||||
ContentElementVersion $version,
|
||||
string $action,
|
||||
string $format,
|
||||
string $marking,
|
||||
string|\Closure|null $checksum = null,
|
||||
): bool {
|
||||
$recent = MediaDelivery::query()
|
||||
->where('grant_id', $grant->id)
|
||||
->where('content_element_version_id', $version->id)
|
||||
->where('action', $action)
|
||||
->where('delivered_at', '>=', now()->subSeconds($windowSeconds))
|
||||
->exists();
|
||||
|
||||
if ($recent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->write($grant, $article, $release, $version, $action, $format, $checksum instanceof \Closure ? $checksum() : $checksum, $marking);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function newCopyId(): string
|
||||
{
|
||||
return 'LK-'.strtoupper(bin2hex(random_bytes(6)));
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* SHA-256 einer Datei der Medienablage für den Auslieferungsnachweis (08 §7), je Datei einmal berechnet.
|
||||
*
|
||||
* Die Dateien sind nach dem Speichern unveränderlich. Der gemerkte Wert gilt daher für Pfad, Größe und Änderungszeit;
|
||||
* ändert sich eine davon, wird neu gerechnet. Ist die Datei nicht lesbar, ist das Ergebnis null (der Nachweis nennt
|
||||
* dann keine Prüfsumme, statt die Auslieferung zu blockieren).
|
||||
*/
|
||||
class FileChecksum
|
||||
{
|
||||
public function of(string $diskName, string $path): ?string
|
||||
{
|
||||
$disk = Storage::disk($diskName);
|
||||
|
||||
try {
|
||||
if (! $disk->exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$key = 'media-checksum:'.hash('sha256', $diskName.'|'.$path.'|'.$disk->size($path).'|'.$disk->lastModified($path));
|
||||
|
||||
return Cache::rememberForever($key, function () use ($disk, $path): ?string {
|
||||
$stream = $disk->readStream($path);
|
||||
|
||||
if (! is_resource($stream)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$context = hash_init('sha256');
|
||||
hash_update_stream($context, $stream);
|
||||
|
||||
return hash_final($context);
|
||||
} finally {
|
||||
fclose($stream);
|
||||
}
|
||||
});
|
||||
} catch (\Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,52 @@ public function rewrite(string $playlist, string $playlistPath, callable $sign):
|
||||
continue;
|
||||
}
|
||||
|
||||
$target = str_starts_with($value, 'ableitungen/')
|
||||
? $value
|
||||
: ($directory === '.' ? $value : $directory.'/'.$value);
|
||||
$rewritten[] = $sign($target);
|
||||
$rewritten[] = $sign($this->target($value, $directory));
|
||||
}
|
||||
|
||||
return implode("\n", $rewritten)."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Pfad (auf der Ablage) des ersten Eintrags einer Liste, bei einer Hauptliste also der ersten Teilliste.
|
||||
*/
|
||||
public function firstTarget(string $playlist, string $playlistPath): ?string
|
||||
{
|
||||
$directory = str_replace('\\', '/', dirname($playlistPath));
|
||||
|
||||
foreach (preg_split("/\r\n|\n|\r/", $playlist) ?: [] as $line) {
|
||||
$value = trim($line);
|
||||
|
||||
if ($value !== '' && ! str_starts_with($value, '#')) {
|
||||
return $this->target($value, $directory);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dauer einer Teilliste in Sekunden: Summe der #EXTINF-Werte. 0.0, wenn die Liste keine nennt (z. B. Hauptliste).
|
||||
*/
|
||||
public function duration(string $playlist): float
|
||||
{
|
||||
$seconds = 0.0;
|
||||
|
||||
foreach (preg_split("/\r\n|\n|\r/", $playlist) ?: [] as $line) {
|
||||
if (preg_match('/^#EXTINF:\s*([0-9]+(?:\.[0-9]+)?)/', trim($line), $match) === 1) {
|
||||
$seconds += (float) $match[1];
|
||||
}
|
||||
}
|
||||
|
||||
return $seconds;
|
||||
}
|
||||
|
||||
private function target(string $value, string $directory): string
|
||||
{
|
||||
if (str_starts_with($value, 'ableitungen/')) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $directory === '.' ? $value : $directory.'/'.$value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Laufzeit der Adressen für Teillisten und Abschnitte eines Films (config media.*): Filmlänge plus Reserve, höchstens
|
||||
* die Höchstdauer; ohne lesbare Filmlänge die Ersatzdauer.
|
||||
*/
|
||||
class StreamLifetime
|
||||
{
|
||||
public function __construct(private readonly HlsPlaylist $playlists) {}
|
||||
|
||||
public function seconds(int $versionId): int
|
||||
{
|
||||
$max = max(1, (int) config('media.stream_max_minutes')) * 60;
|
||||
$film = $this->filmSeconds($versionId);
|
||||
$wanted = $film > 0
|
||||
? (int) ceil($film) + max(0, (int) config('media.stream_reserve_minutes')) * 60
|
||||
: max(1, (int) config('media.stream_fallback_minutes')) * 60;
|
||||
|
||||
return min($wanted, $max);
|
||||
}
|
||||
|
||||
/** Zeitfenster in Sekunden, in dem Erneuerungen zur selben Wiedergabe zählen. */
|
||||
public function window(): int
|
||||
{
|
||||
return max(1, (int) config('media.stream_max_minutes')) * 60;
|
||||
}
|
||||
|
||||
private function filmSeconds(int $versionId): float
|
||||
{
|
||||
$disk = Storage::disk('media_derived');
|
||||
$master = MediaRendition::masterPath($versionId);
|
||||
|
||||
if ($master === null || ! $disk->exists($master)) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
$variant = $this->playlists->firstTarget((string) $disk->get($master), $master);
|
||||
|
||||
if ($variant === null || ! MediaRendition::owns($versionId, $variant) || ! $disk->exists($variant)) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return $this->playlists->duration((string) $disk->get($variant));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Schemas\Components\StateCasts\Contracts\StateCast;
|
||||
use Filament\Schemas\Components\StateCasts\SliderStateCast;
|
||||
|
||||
/**
|
||||
* Regler für Bildfokus und Zoom (ImageFraming). Filaments Regler macht beim Laden aus „kein Wert“ eine 0; der Dialog
|
||||
* zeigte dann bei jedem Widget ohne gespeicherten Ausschnitt „0“ statt der Vorgabe, mit der die Seite tatsächlich
|
||||
* dargestellt wird (Mitte, 100 %). Ohne diese Umwandlung setzt der Regler beim Laden die Vorgabe selbst.
|
||||
*/
|
||||
class FramingSlider extends Slider
|
||||
{
|
||||
/**
|
||||
* @return array<StateCast>
|
||||
*/
|
||||
public function getDefaultStateCasts(): array
|
||||
{
|
||||
return array_values(array_filter(
|
||||
parent::getDefaultStateCasts(),
|
||||
fn (object $cast): bool => ! $cast instanceof SliderStateCast,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
@@ -14,17 +15,29 @@ trait ServesByteRanges
|
||||
{
|
||||
private const CHUNK = 262144;
|
||||
|
||||
protected function respondWithRanges(Request $request, string $diskName, string $path, bool $ranged): StreamedResponse
|
||||
{
|
||||
/**
|
||||
* @param string|null $name Dateiname für Ansicht oder Download (ohne: Name der Datei)
|
||||
* @param string $disposition inline oder attachment
|
||||
* @param array<string, string> $extra weitere Kopfzeilen
|
||||
*/
|
||||
protected function respondWithRanges(
|
||||
Request $request,
|
||||
string $diskName,
|
||||
string $path,
|
||||
bool $ranged,
|
||||
?string $name = null,
|
||||
string $disposition = 'inline',
|
||||
array $extra = [],
|
||||
): StreamedResponse {
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
'Content-Disposition' => $name === null ? $disposition : $this->disposition($disposition, $name),
|
||||
'X-Content-Type-Options' => 'nosniff',
|
||||
'Accept-Ranges' => 'bytes',
|
||||
];
|
||||
] + $extra;
|
||||
$range = $request->header('Range');
|
||||
|
||||
if (! is_string($range) || ! $ranged) {
|
||||
return Storage::disk($diskName)->response($path, null, $headers);
|
||||
return Storage::disk($diskName)->response($path, $name, $headers, $disposition);
|
||||
}
|
||||
|
||||
$disk = Storage::disk($diskName);
|
||||
@@ -63,6 +76,13 @@ protected function respondWithRanges(Request $request, string $diskName, string
|
||||
]);
|
||||
}
|
||||
|
||||
private function disposition(string $type, string $name): string
|
||||
{
|
||||
$fallback = (string) preg_replace('/[^ -~]|["\\%]/', '_', $name);
|
||||
|
||||
return HeaderUtils::makeDisposition($type, $name, $fallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erster Bereich aus „bytes=a-b“, „bytes=a-“ oder „bytes=-n“; null, wenn er nicht erfüllbar ist.
|
||||
*
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Media\DeliveryLog;
|
||||
use App\Domain\Media\FileChecksum;
|
||||
use App\Domain\Media\FilmPlayback;
|
||||
use App\Domain\Media\HlsPlaylist;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use App\Domain\Media\StreamLifetime;
|
||||
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||
use App\Http\Controllers\Concerns\ServesImages;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\CourseOutline;
|
||||
@@ -27,6 +30,7 @@
|
||||
use App\Http\MemberLicenses;
|
||||
use App\Http\SignedLink;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
@@ -38,6 +42,7 @@
|
||||
|
||||
class LibraryController extends Controller
|
||||
{
|
||||
use ServesByteRanges;
|
||||
use ServesImages;
|
||||
|
||||
/** Inhaltsarten der Bibliothek (Schlüssel der Adresse und des Filters). */
|
||||
@@ -250,11 +255,11 @@ public function show(Request $request, LicenseArticle $article): View
|
||||
'action' => $action,
|
||||
'allowed' => $decision->allowed,
|
||||
'reason' => $decision->reason,
|
||||
'decision' => is_numeric($metadata['decision_seconds'] ?? null)
|
||||
? (int) $metadata['decision_seconds']
|
||||
: null,
|
||||
'playable' => $decision->allowed && is_string($file) && $file !== '' && ($class === 'film' || $class === 'audio'),
|
||||
'playback' => app(FilmPlayback::class)->mode($version->id),
|
||||
'renew_url' => $decision->allowed && $action === 'streamen' && app(FilmPlayback::class)->mode($version->id) === 'hls'
|
||||
? route('member.playback.renew', [$article->id, $release->id, $version->id])
|
||||
: null,
|
||||
'download_url' => $download->allowed
|
||||
? SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
@@ -331,7 +336,7 @@ public function media(
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->fileResponse($decision->grant, $article, $release, $version, $action, $file, 'bestand');
|
||||
return $this->fileResponse($request, $decision->grant, $article, $release, $version, $action, $file, 'bestand');
|
||||
}
|
||||
|
||||
public function rendition(
|
||||
@@ -365,6 +370,63 @@ public function rendition(
|
||||
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frische Adresse für den Player (Plan Videoplayer 0.1). Ohne "datei" die Hauptliste (deren Abruf ist die
|
||||
* Auslieferung und schreibt den Nachweis), mit "datei" ein Abschnitt oder eine Teilliste dieser Fassung. Geprüft
|
||||
* wird wie beim Abruf selbst: Anmeldung, Konto, Stand und Fassung, Berechtigung (DecideAccess). Die Erneuerung
|
||||
* schreibt keinen Nachweis, außer es gibt innerhalb des Zeitfensters noch keinen: Wer nie die Hauptliste holt, soll
|
||||
* nicht ohne Nachweis streamen.
|
||||
*/
|
||||
public function renew(
|
||||
Request $request,
|
||||
LicenseArticle $article,
|
||||
ArticleRelease $release,
|
||||
ContentElementVersion $version,
|
||||
): JsonResponse {
|
||||
$decision = app(DecideAccess::class)($request->user(), $article, $release, $version, 'streamen');
|
||||
abort_unless($decision->allowed && $decision->grant !== null, 403, $decision->reason);
|
||||
abort_if(MediaRendition::masterPath($version->id) === null, 404);
|
||||
|
||||
$file = $request->query('datei');
|
||||
|
||||
if ($file === null) {
|
||||
$url = SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
'action' => 'streamen',
|
||||
'reader' => $request->user()->id,
|
||||
]);
|
||||
$seconds = 600;
|
||||
} else {
|
||||
abort_unless(is_string($file) && $this->renditionBelongsTo($version->id, $file), 404);
|
||||
abort_unless(Storage::disk('media_derived')->exists($file), 404);
|
||||
$lifetime = app(StreamLifetime::class);
|
||||
app(DeliveryLog::class)->writeUnlessRecent(
|
||||
$lifetime->window(),
|
||||
$decision->grant,
|
||||
$article,
|
||||
$release,
|
||||
$version,
|
||||
'streamen',
|
||||
'hls',
|
||||
'k0',
|
||||
);
|
||||
$seconds = $lifetime->seconds($version->id);
|
||||
$url = SignedLink::temporary('member.rendition', now()->addSeconds($seconds), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
'datei' => $file,
|
||||
'reader' => $request->user()->id,
|
||||
]);
|
||||
}
|
||||
|
||||
return response()
|
||||
->json(['url' => $url, 'expires_in' => $seconds])
|
||||
->header('Cache-Control', 'no-store, private');
|
||||
}
|
||||
|
||||
public function thumbnail(Request $request, string $kind, int $subject): SymfonyResponse
|
||||
{
|
||||
abort_unless(in_array($kind, ['komposition', 'element'], true), 404);
|
||||
@@ -408,10 +470,11 @@ private function playlist(
|
||||
abort_unless($this->renditionBelongsTo($version->id, $path), 404);
|
||||
$disk = Storage::disk('media_derived');
|
||||
abort_unless($disk->exists($path), 404);
|
||||
$expires = now()->addSeconds(app(StreamLifetime::class)->seconds($version->id));
|
||||
$rewritten = app(HlsPlaylist::class)->rewrite(
|
||||
$disk->get($path),
|
||||
$path,
|
||||
fn (string $target): string => SignedLink::temporary('member.rendition', now()->addMinutes(10), [
|
||||
fn (string $target): string => SignedLink::temporary('member.rendition', $expires, [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
@@ -442,6 +505,7 @@ private function playlist(
|
||||
}
|
||||
|
||||
private function fileResponse(
|
||||
Request $request,
|
||||
Grant $grant,
|
||||
LicenseArticle $article,
|
||||
ArticleRelease $release,
|
||||
@@ -452,24 +516,27 @@ private function fileResponse(
|
||||
): StreamedResponse {
|
||||
$disk = Storage::disk('media_derived');
|
||||
abort_unless($disk->exists($file) && ! str_contains($file, '..'), 404);
|
||||
$delivery = app(DeliveryLog::class)->write(
|
||||
$grant,
|
||||
$article,
|
||||
$release,
|
||||
$version,
|
||||
$action,
|
||||
$format,
|
||||
hash_file('sha256', $disk->path($file)) ?: null,
|
||||
'k0',
|
||||
);
|
||||
$log = app(DeliveryLog::class);
|
||||
$checksum = fn (): ?string => app(FileChecksum::class)->of('media_derived', $file);
|
||||
|
||||
// Dateiname aus dem Anzeigetitel statt aus der Adresse („laden.mp4“); Laravel setzt Content-Disposition mit
|
||||
// ASCII-Rückfall und UTF-8-Name.
|
||||
return $disk->response(
|
||||
// Ein vollständiger Abruf ist eine Auslieferung. Teilabrufe (Springen, Fortsetzen) derselben Wiedergabe zählen
|
||||
// innerhalb der Laufzeit der Adresse nicht erneut; gibt es noch keinen Nachweis, entsteht genau einer.
|
||||
if (is_string($request->header('Range'))) {
|
||||
$log->writeUnlessRecent(600, $grant, $article, $release, $version, $action, $format, 'k0', $checksum);
|
||||
$copy = '';
|
||||
} else {
|
||||
$copy = $log->write($grant, $article, $release, $version, $action, $format, $checksum(), 'k0')->copy_id;
|
||||
}
|
||||
|
||||
// Dateiname aus dem Anzeigetitel statt aus der Adresse („laden.mp4“), mit ASCII-Rückfall und UTF-8-Name.
|
||||
return $this->respondWithRanges(
|
||||
$request,
|
||||
'media_derived',
|
||||
$file,
|
||||
true,
|
||||
$this->downloadName($version, $file),
|
||||
['X-License-Copy' => $delivery->copy_id],
|
||||
$action === 'laden' ? 'attachment' : 'inline',
|
||||
$copy === '' ? [] : ['X-License-Copy' => $copy],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -365,6 +365,7 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
||||
$view = null;
|
||||
$download = null;
|
||||
$playback = 'file';
|
||||
$renew = null;
|
||||
$poster = null;
|
||||
$element = $node->contentElementId === null ? null : $this->element($node->contentElementId);
|
||||
|
||||
@@ -376,6 +377,10 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
||||
$playback = app(FilmPlayback::class)->mode($node->contentElementVersionId);
|
||||
}
|
||||
|
||||
if ($view !== null && $playback === 'hls') {
|
||||
$renew = $this->renewal($user, $node->contentElementVersionId);
|
||||
}
|
||||
|
||||
if ($view !== null && $element !== null) {
|
||||
$poster = ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||
}
|
||||
@@ -399,6 +404,7 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
||||
'kind' => $node->editorialKindLabel ?? $this->outputLabel($node->technicalKindLabel) ?? $node->technicalKindLabel,
|
||||
'output_class' => $node->outputClass,
|
||||
'playback' => $playback,
|
||||
'renew_url' => $renew,
|
||||
'view_url' => $view ?? $documentUrl,
|
||||
'poster_url' => $poster,
|
||||
'download_url' => $download,
|
||||
@@ -574,6 +580,37 @@ private function viewAction(?string $outputClass): string
|
||||
}
|
||||
|
||||
private function open(User $user, int $versionId, string $action): ?string
|
||||
{
|
||||
$found = $this->grantedRelease($user, $versionId, $action);
|
||||
|
||||
if ($found === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $found->article->id,
|
||||
'release' => $found->id,
|
||||
'version' => $versionId,
|
||||
'action' => $action,
|
||||
'reader' => $user->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adresse, unter der der Player eine frische Wiedergabeadresse holt (Plan Videoplayer 0.1). Dieselbe Entscheidung
|
||||
* wie bei open(): derselbe Stand, der die Wiedergabe erlaubt.
|
||||
*/
|
||||
private function renewal(User $user, int $versionId): ?string
|
||||
{
|
||||
$found = $this->grantedRelease($user, $versionId, 'streamen');
|
||||
|
||||
return $found === null ? null : route('member.playback.renew', [$found->article->id, $found->id, $versionId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Der jüngste veröffentlichte Stand, in dem die Fassung steht und der die Aktion für dieses Konto erlaubt.
|
||||
*/
|
||||
private function grantedRelease(User $user, int $versionId, string $action): ?ArticleRelease
|
||||
{
|
||||
$version = ContentElementVersion::query()->with('element')->find($versionId);
|
||||
|
||||
@@ -589,19 +626,9 @@ private function open(User $user, int $versionId, string $action): ?string
|
||||
->get();
|
||||
|
||||
foreach ($releases as $release) {
|
||||
$decision = ($this->access)($user, $release->article, $release, $version, $action);
|
||||
|
||||
if (! $decision->allowed) {
|
||||
continue;
|
||||
if (($this->access)($user, $release->article, $release, $version, $action)->allowed) {
|
||||
return $release;
|
||||
}
|
||||
|
||||
return SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $release->article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
'action' => $action,
|
||||
'reader' => $user->id,
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Media\FileChecksum;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -82,6 +83,8 @@ public function handle(): void
|
||||
}
|
||||
|
||||
$version->save();
|
||||
// Prüfsumme für den Auslieferungsnachweis jetzt rechnen, damit die erste Wiedergabe nicht darauf wartet.
|
||||
app(FileChecksum::class)->of('media_derived', $target);
|
||||
DeriveThumbnail::dispatch('element', $version->content_element_id);
|
||||
DeriveFilmRenditions::dispatch($version->id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Wiedergabe über HLS im Mitgliederbereich.
|
||||
*
|
||||
* Die Adressen der Abschnitte und Teillisten gelten so lange wie der Film dauert plus Reserve (Plan
|
||||
* Videoplayer 0.1). Die Filmlänge ergibt sich aus der Summe der #EXTINF-Werte der Teilliste; ist sie nicht lesbar,
|
||||
* gilt die Ersatzdauer. Nach oben begrenzt die Höchstdauer.
|
||||
*
|
||||
* Eine längere Laufzeit verlängert nicht die Nachlaufzeit nach einem Entzug: Jeder Abruf prüft Anmeldung, Konto und
|
||||
* DecideAccess neu. Die Laufzeit begrenzt nur, wie lange eine einmal ausgestellte Adresse als Adresse taugt.
|
||||
* Dieselbe Höchstdauer ist das Zeitfenster, in dem Erneuerungen zur selben Wiedergabe zählen (ein Nachweis je
|
||||
* Wiedergabe, siehe PlaybackRenewal).
|
||||
*
|
||||
* Zum Prüfen auf der Test-Instanz in der Serverdatei kurz setzen, z. B. MEDIA_STREAM_RESERVE_MINUTES=1 und
|
||||
* MEDIA_STREAM_MAX_MINUTES=2.
|
||||
*/
|
||||
return [
|
||||
'stream_reserve_minutes' => (int) env('MEDIA_STREAM_RESERVE_MINUTES', 60),
|
||||
'stream_fallback_minutes' => (int) env('MEDIA_STREAM_FALLBACK_MINUTES', 240),
|
||||
'stream_max_minutes' => (int) env('MEDIA_STREAM_MAX_MINUTES', 720),
|
||||
];
|
||||
@@ -1,13 +1,17 @@
|
||||
# Umsetzungsplan: Zentraler Videoplayer (Website-Vollbild und Mitgliederbereich)
|
||||
|
||||
**Stand:** 30.11.2026, Branch `develop` (Commit `f11ff89`).
|
||||
**Status (30.11.2026):** Umsetzung begonnen auf `feature/videoplayer-grundlagen` (nicht gepusht, nicht committet). Lars hat „Dauerhaft laden“ ausgeschlossen und „Vorab laden (Sitzung)“ ausdrücklich eingeplant (Stufe 4; Antwort von Legal aus Entscheidung Nr. 6 steht aus).
|
||||
**Status (01.12.2026):** Stufe 0.7 und 1a/2 sind auf `develop` (Commit `e6957b7`, Deployment auf luf-test). Gerätetest von Lars (nur Aussage, keine Tabelle): iPhone und ein Android-Tablet, jeweils auf der normalen Webseite mit den Widgets, „alles klappt“.
|
||||
**Davor (30.11.2026):** Umsetzung begonnen auf `feature/videoplayer-grundlagen`. Lars hat „Dauerhaft laden“ ausgeschlossen und „Vorab laden (Sitzung)“ ausdrücklich eingeplant (Stufe 4; Antwort von Legal aus Entscheidung Nr. 6 steht aus).
|
||||
|
||||
| Stufe | Stand |
|
||||
|---|---|
|
||||
| 0.7 Rendition übernehmen | umgesetzt mit Tests: neue Fassung ohne neue Datei (`MediaRendition::carryOver`), spät fertige Verarbeitung (`carryForward`, Aufruf in `DeriveFilmRenditions`), `renditionBelongsTo` über `MediaRendition::owns`. Bereits betroffene Fassungen bleiben im Dateimodus; der Prüf- und Nachziehbefehl ist **nicht gebaut**. |
|
||||
| 1a/2 Website-Vollbild | umgesetzt: Einstellung `fullscreen` (Vorgabe „Aus“, Entscheidung Nr. 1 wie empfohlen angewendet, **nicht bestätigt**), `resources/js/player/fullscreen.js`, Anbindung in `card-clip.js`, Schaltfläche und CSS, ADR-43-Nachtrag, Registry. Desktop in Edge geprüft (19 Prüfungen, Wegwerf-Prüfstand außerhalb des Repositorys). **Nicht erledigt:** Kurzprobe 2.0 auf echten Geräten (iPhone-Weg nur als Logik nachgestellt), Abnahme auf luf-test (Screenshots, schmale Breite, Überlagerung mit der Art-Marke), Hero-Video, Entscheidung Nr. 11 (Neigerichtung folgt dem Gerät als Vorgabe). Es gibt noch keinen JS-Test im Repository (Entscheidung Nr. 9). |
|
||||
| 0.1–0.6, 0.8, 0.9, 1b, 3, 4 | nicht begonnen |
|
||||
| 1a/2 Website-Vollbild | umgesetzt: Einstellung `fullscreen` (Vorgabe „Aus“, Entscheidung Nr. 1 wie empfohlen angewendet, **nicht bestätigt**), `resources/js/player/fullscreen.js`, Anbindung in `card-clip.js`, Schaltfläche und CSS, ADR-43-Nachtrag, Registry. Desktop in Edge geprüft (19 Prüfungen, Wegwerf-Prüfstand außerhalb des Repositorys). **Gerätetest 01.12.2026:** iPhone und Android-Tablet bestanden laut Lars (iOS-/Android-Version, Browser und Einzelschritte wie Drehung und Zurück-Geste nicht notiert; **iPad, Windows-/macOS-Browser und Beamer ungeprüft**). **Nicht erledigt:** Abnahme auf luf-test (Screenshots, schmale Breite, Überlagerung mit der Art-Marke), Hero-Video, Entscheidung Nr. 11 (Neigerichtung folgt dem Gerät als Vorgabe). Es gibt noch keinen JS-Test im Repository (Entscheidung Nr. 9). |
|
||||
| 0.1 Signaturerneuerung | **umgesetzt auf `feature/videoplayer-grundlagen` (01.12.2026), noch nicht auf `develop`.** Server: `config/media.php` (Reserve 60 min, Höchstdauer 720 min, Ersatzdauer 240 min; Env `MEDIA_STREAM_RESERVE_MINUTES`, `MEDIA_STREAM_MAX_MINUTES`, `MEDIA_STREAM_FALLBACK_MINUTES`), `StreamLifetime` (Filmlänge = Summe der `#EXTINF`-Werte der ersten Teilliste, keine Migration), Endpunkt `member.playback.renew` mit `DecideAccess` und Tupelprüfung, Nachweis nur wenn im Zeitfenster noch keiner steht (`DeliveryLog::writeUnlessRecent`). Client: `player/renewal.js`, `player/source.js`, `data-hls-renew`; Vitest (24 Tests) im Gate (`jstest`). **Nicht abgedeckt:** Dateimodus (Filme ohne HLS) und Download bleiben bei 10 Minuten (0.2/0.3); die Hauptliste auf der Seite gilt weiter 10 Minuten und wird bei 403 über den Endpunkt erneuert. Der iPhone-Weg (nativ, Wiederaufnahme bei Fehler) ist nur als Logik getestet. Tatsache zum Entzug: Jeder Abruf prüft `DecideAccess`, die längere Laufzeit verlängert die Nachlaufzeit nach Entzug nicht (Test `test_an_expired_segment_link_is_refused_and_a_revoked_grant_stops_a_valid_one_at_once`); damit entfällt die offene Frage der Nachlaufzeit in Nr. 10. |
|
||||
| 0.2, 0.3 Dateimodus und Downloads | **umgesetzt (01.12.2026):** `fileResponse` nutzt `ServesByteRanges` (206/416, `Accept-Ranges`, Dateiname und `attachment` bleiben, Download lässt sich fortsetzen). Nachweis: ein vollständiger Abruf schreibt einen Eintrag, Teilabrufe innerhalb von 10 Minuten (Laufzeit der Adresse) nur, wenn noch keiner steht (`DeliveryLog::writeUnlessRecent`). Prüfsumme je Datei einmal (`FileChecksum`, gemerkt nach Pfad, Größe und Änderungszeit, beim Speichern vorgewärmt); ohne lesbare Datei `null`. **Abweichung vom Plan:** Der Wert liegt im Cache, nicht in `metadata['checksum']` (Fassungen sind unveränderlich, ein Nachtragen würde den Inhaltshash ändern); nach einem Cache-Verlust wird beim nächsten Abruf neu gerechnet. Sicht ungeprüft: Safari/iPhone im Dateimodus. |
|
||||
| 0.8 Entscheidungsmarke | **teilweise:** toter Handler (`data-course-decision`, `data-course-restart`, `data-decision`) aus `app.js` und der ungenutzte Schlüssel `decision` in `LibraryController::show` entfernt. Das Feld `decision_seconds` im Verwaltungsformular (`ElementRevision`) und seine Anzeige (`CatalogReading`) bleiben bis zum Marker-Editor (Stufe 3) als Altwert; `CoursePlayerTest` bleibt bis dahin unverändert. Der Vollbild-Knopf im Mitgliederbereich nutzt jetzt `player/fullscreen.js` (vorher nur `requestFullscreen`, auf dem iPhone ohne Wirkung); auf dem Gerät nicht geprüft. |
|
||||
| 0.4–0.6, 0.9, 1b, 3, 4 | nicht begonnen |
|
||||
|
||||
Ursprünglicher Stand: Vorschlag zur Freigabe; die Entscheidungen in Abschnitt 8 sind bis auf die genannten offen.
|
||||
**Grundlage:** `docs/architektur/08_Medien_Streaming_Kennzeichnung.md` (§3, §5), `docs/architektur/medienzugriff-fuer-komponenten.md`, ADR-43, `docs/analysen/medienauslieferung-performance-2026-11-30.md` (im Folgenden „Performance-Analyse“, Befunde W1…, M1…, Maßnahmen A1…, B1…).
|
||||
@@ -246,6 +250,19 @@ ## 8. Entscheidungen für Lars
|
||||
| 10 | Signaturdauer und Erneuerung (A5): Filmlänge plus Reserve plus Erneuerung per Endpunkt, oder nur kurze Prüfung beim Ausstellen? Wie lang darf die Nachlaufzeit nach Entzug sein? **Was zählt als „Auslieferung“ im Nachweis** (erster Abruf je Wiedergabesitzung statt jeder Abruf; Erneuerung und Nachladen schreiben nichts)? Zählweise auch mit dem Datenschutzbeauftragten abstimmen. | Erneuerung per Endpunkt mit `DecideAccess`, Dauer Filmlänge plus Reserve, Nachweis nur beim ersten Abruf. |
|
||||
| 11 | **Neigerichtung im Vollbild:** dem Gerät folgen (Vorgabe) oder Querformat-Clips nach Möglichkeit im Querformat öffnen (Sperre per Schnittstelle, nur wo verfügbar)? Entscheidung nach der Kurzprobe 2.0. | Dem Gerät folgen; Sperre nur, wenn die Probe zeigt, dass Hochkant-Haltung oder Systemsperre das Ergebnis unbrauchbar macht. |
|
||||
|
||||
**Entschieden von Lars am 01.12.2026** (die Empfehlungen oben gelten dort, wo nichts anderes steht):
|
||||
|
||||
| Nr. | Entscheidung |
|
||||
|---|---|
|
||||
| 1, 11 | Bestätigt: Vorgabe „Aus“, Vollbild folgt der Gerätelage, keine Ausrichtungssperre. Nr. 2 (Hero-Video) bleibt außerhalb dieser Lieferung. |
|
||||
| 3 | Eigener Player über `hls.js`. |
|
||||
| 4 | **Marken gehören zur Fassung, mit Arbeitsstand davor (Hybrid).** Lars will nicht für jede kleine Korrektur eine neue Fassung erzeugen; die Variante „Marken außerhalb der Fassung“ wurde erwogen und wegen der Bindung an die konkrete Datei verworfen. Verlangt ist stattdessen eine saubere **Vorabanzeige**, in der Marken explizit gesetzt und kontrolliert werden können, bevor eine Fassung entsteht. Umsetzung (Vorschlag, noch nicht gebaut): Arbeitsstand der Marken am Medium, bearbeitet im Marker-Editor mit Vorschau-Player (Sprung zur Marke, Stopp-Probelauf), analog zur Redaktion („nur Speichern schreibt“). Beim Erzeugen der Fassung wird der Arbeitsstand als `metadata['markers']` in die Fassung geschrieben. Bei neuer Datei wird der Stand der letzten Fassung als Vorschlag übernommen und als „prüfen“ gekennzeichnet. Korrekturen an einer **bereits freigegebenen** Fassung erzeugen weiterhin eine neue Fassung; das ist die akzeptierte Rückfalllösung. Noch zu klären: Berechtigung für den Marker-Editor, ob der Arbeitsstand protokolliert wird. |
|
||||
| 5 | Je Marke konfigurierbar plus Schalter „Automatische Stopps“ im Player, Vorgabe an. |
|
||||
| 8 | Bei 1080 p bleiben; Beamer-Auflösungen vorab erheben (Lars). |
|
||||
| 9 | Vitest als Entwicklungsabhängigkeit. Aufnahme ins Gate ändert `scripts/ci-test.sh`: gezielt, mit Begründung, nachgeführt in `docs/betrieb/DEPLOYMENT.md`. |
|
||||
| 10 | Erneuerung per Endpunkt mit `DecideAccess`, Signaturdauer Filmlänge plus Reserve, Nachweis nur beim ersten Abruf je Wiedergabe. Die Zählweise ist noch mit dem Datenschutzbeauftragten abzustimmen. Nachlaufzeit nach Entzug: keine, solange jeder Abschnittsabruf `DecideAccess` prüft (so umgesetzt und getestet). |
|
||||
| 6 | Weiterhin offen: Antwort von Legal zu „Vorab laden“ (Stufe 4). |
|
||||
|
||||
---
|
||||
|
||||
## 9. Nicht geprüft
|
||||
@@ -260,3 +277,5 @@ ## 10. Hinweise
|
||||
|
||||
- Das Dokument enthält Betriebsdetails aus der Projektdokumentation. Vor Weitergabe außerhalb des Teams prüfen und freigeben.
|
||||
- Rechtliche Fragen (Lizenztexte, Vorab laden, Download-Lizenz) gehören zu Legal und Compliance, Fragen zu Protokollierung und Aufbewahrung zum Datenschutzbeauftragten. Diese Planung gibt dazu keine Auskunft.
|
||||
|
||||
**Weitere Entscheidungen von Lars (01.12.2026):** Marker-Editor: gleiche Berechtigung wie zum Bearbeiten des Films. Der Arbeitsstand der Marken wird nicht gesondert protokolliert; das Protokoll liefert die Fassung. Reihenfolge: 0.2, 0.3, 0.8, danach Stufe 3.
|
||||
@@ -1056,3 +1056,18 @@ ## ADR-69 – CMS: Zeichen im Text (Symbol vor dem Absatz, Nummern im Kreis, Sym
|
||||
**Alternativen.** Einstellung je Widget („Listen in diesem Widget“; verworfen: gilt für alle Listen gleich und deckt das Symbol je Absatz nicht ab). Symbole als CSS-Bild über eine öffentliche Adresse (verworfen: die Bibliothek liegt nicht öffentlich, das eingebettete SVG nutzt den vorhandenen Weg).
|
||||
**Folgen.** Keine Migration. Rückfall: Ein älterer Stand entfernt die Attribute beim nächsten Speichern eines Textes (er kennt sie nicht), gespeicherte Seiten bleiben lesbar, zeigen aber ohne Zeichen; vor einem Rückfall die Stellen notieren.
|
||||
**Quelle.** Auftrag von Lars vom 30.11.2026.
|
||||
|
||||
## ADR-70 – CMS: Bildausschnitt und Zoom für Bilder und Videos in Widgets
|
||||
|
||||
**Status am 01.12.2026:** Umgesetzt auf `feature/bildausschnitt`; praktische Abnahme durch den Betreiber auf `luf-test` offen. Abnahme: `docs/ux/verwaltung/abnahme/bildausschnitt.md`.
|
||||
**Kontext.** Bilder in Widgets werden als Ausschnitt dargestellt (`object-fit: cover`) und häufig oben abgeschnitten, vor allem bei schmalen oder flachen Rahmen (Einstieg, Bild und Text, Themen-, Medien- und Programmkarten, Redaktionelle Karten). Einstieg, Bild und Text und die Premium-Karten hatten einen Fokuspunkt, die Redaktionellen Karten keinen Ausschnitt, und ein Zoom fehlte überall.
|
||||
**Entscheidung.**
|
||||
- **Ein Ausschnitt aus Fokuspunkt und Zoom** (`App\Domain\Cms\Widgets\Support\ImageFraming`): `focus_x`, `focus_y` (0–100 %, Vorgabe je Widget-Art) und `zoom` (100–250 %) in `data`, bei den Redaktionellen Karten je Karte in `data.items[]`. Gespeichert wird nur, was von der Vorgabe abweicht (kein `zoom` bei 100 %, bei Karten keine Mitte); ohne gesetzten Wert bleibt die Ausgabe byteweise wie zuvor.
|
||||
- **Zoom beginnt bei 100 %, nicht darunter.** Bei 100 % füllt das Bild den Rahmen (`cover`); weiter herauszoomen ließe leere Ränder, die gewünscht nicht entstehen dürfen. Darüber wird um den Fokuspunkt vergrößert (`scale`, `transform-origin` = Fokuspunkt). Ein Bild, das den Rahmen füllt und um einen Punkt im Rahmen mit mindestens 1 vergrößert wird, lässt den Rahmen nie frei. Der Regler „Zoom“ nennt das im Hilfetext.
|
||||
- **Darstellung nur mit CSS, keine neue Bildfassung.** Der Rahmen schneidet ab: bei den Karten `.card-media`, bei Premium-Karten `.lf-pc--zoom .lf-pc__visual`, beim Einstieg `.lf-hero__frame` und bei Bild und Text `.lf-bt__frame`, die beiden Letzten nur bei gesetztem Zoom (ohne Zoom entsteht der Rahmen nicht). Ecken, Schatten und die senkrechte Füllung neben dem Text bleiben erhalten. Video und Clip (Einstieg, Premium-Karte, Bild und Text) liegen im selben Rahmen und erhalten denselben Ausschnitt, damit der Bildausschnitt beim Start des Clips nicht springt. `sizes` wird mit dem Zoomfaktor multipliziert (`ImageFraming::sizes`), der Browser holt bei Zoom eine größere Fassung (ADR-63).
|
||||
- **Karten:** Die Regler (Waagerecht, Senkrecht, Zoom) stehen in jeder Karte, sichtbar mit gewähltem Bild; Vorgabe Mitte und 100 %. Die Premium-Karten ignorieren den Zoom bei „Ganzes Bild“ (die Karte zeigt das Bild vollständig).
|
||||
- **Regler:** `FramingSlider` ersetzt Filaments Regler für diese Felder. Filaments Regler machte aus „kein Wert“ eine 0 (`SliderStateCast`), der Dialog zeigte deshalb bei jedem Widget ohne gespeicherten Fokus „0“ statt der Vorgabe der Darstellung (Einstieg 68/50). Der Regler setzt nun beim Laden die Vorgabe; ein gespeicherter Wert 0 bleibt 0.
|
||||
**Nicht Teil.** Zoom unter 100 % und „Ganzes Bild“ für Karten (wäre ein eigener Auftrag: ruhige Fläche statt leerer Ränder); ein anderes Seitenverhältnis des Bildrahmens (Einstellung „Bildformat“); getrennte Ausschnitte für Handy und Desktop; Katalog- und Shopkarten sowie der Abschnittshintergrund (das Bild kommt dort aus dem Katalog bzw. gehört dem Abschnitt, es gibt keinen Eintrag je Widget, an dem ein Ausschnitt hängen könnte).
|
||||
**Alternativen.** Serverseitig zuschneiden (verworfen: der Web-Prozess schreibt nicht in `derived/`, es bräuchte neue Hintergrundarbeit je Ausschnitt). Zoom unter 100 % mit unscharf aufgefülltem Hintergrund (verworfen: doppeltes Bild, bei Video doppelte Last). `transform` statt `scale` (verworfen: kollidiert mit Hover-Bewegungen).
|
||||
**Folgen.** Keine Migration. Rückfall: Ein älterer Stand weist `zoom` beim Speichern ab bzw. zeigt das Bild ohne Zoom (er kennt den Schlüssel nicht); gespeicherte Seiten bleiben darstellbar. Beim Öffnen und Speichern eines Einstiegs oder einer Premium-Karte werden die Vorgaben für den Fokus nun als Zahlen mitgespeichert (gleiche Darstellung).
|
||||
**Quelle.** Auftrag von Lars vom 01.12.2026.
|
||||
@@ -98,6 +98,7 @@ ## 4. Registrierte Widget-Arten
|
||||
| Schaltflächen | `data.cta_label/cta_url`, `data.cta2_label/cta2_url` | Linkziele über `SafeUrl` |
|
||||
| Bild, Alternativtext | `refs.image`, `data.alt` | öffentlicher Bereich `cms/`; Alternativtext Pflicht bei Bild |
|
||||
| Bildfokus | `data.focus_x`, `data.focus_y` | ganze Zahlen 0–100; Vorgabe Einstieg 68/50, Bild und Text 64/43 |
|
||||
| Zoom des Bildausschnitts | `data.zoom` (nur über 100 %) | ganze Zahl 100–250; Einstieg, Bild und Text, Premium-Karten; bei den Redaktionellen Karten je Karte `data.items[].focus_x/focus_y/zoom` (nur abweichend von Mitte/100 %), ADR-70 |
|
||||
| Überschriftenebene | `settings.heading_level` | `auto` (Vorgabe), `h2`, `h3`; das erste Widget der Seite ist immer H1 |
|
||||
| Akzent (Einstieg) | `settings.accent` | `underline` (Vorgabe), `rays`, `none` |
|
||||
| Fläche (Bild und Text) | `settings.surface` | `cream` (Vorgabe), `clear` (übernimmt den Abschnitt), `navy` |
|
||||
|
||||
@@ -7,11 +7,12 @@ ## Ablauf
|
||||
|
||||
| Auslöser | Workflow | Schritte |
|
||||
|---|---|---|
|
||||
| Push auf `feature/**` | `ci-feature.yml` | Commit klonen, Test-Image bauen, Pint und `php artisan test` im Wegwerf-Container |
|
||||
| Push auf `feature/**` | `ci-feature.yml` | Commit klonen, Test-Image bauen, Pint und `php artisan test` im Wegwerf-Container, JavaScript-Tests (Vitest) im Ziel `jstest`, Migrationen gegen Wegwerf-Postgres |
|
||||
| Push auf `develop` | `deploy-test.yml` | Tests, dann Deploy Test (`luf-test`, Port 3011) |
|
||||
| Push auf `main` | `deploy-prod.yml` | Tests auf genau diesem Commit, dann Deploy Prod (`luf-prod`, Port 3010) |
|
||||
|
||||
- Der Deploy-Job hat `needs: test`. Sind die Tests rot, läuft kein Deploy.
|
||||
- **JavaScript-Tests (seit 01.12.2026, Plan Videoplayer):** `scripts/ci-test.sh` baut zusätzlich das Docker-Ziel `jstest` (`node:22-alpine`, `npm ci`, `npm run test:js`, Vitest nur als Entwicklungsabhängigkeit) und führt es im Wegwerf-Container aus. Das Ziel gehört nicht zu `app` und `web`; die ausgelieferten Images enthalten weder Vitest noch die Tests. Ein roter JS-Test blockiert wie ein roter PHP-Test jedes Deployment. Lokal: `npm run test:js` (unter Windows aus PowerShell, nicht aus Git-Bash: dort wird der Pfad doppelt aufgelöst und Vitest meldet "Cannot read properties of undefined (reading 'config')").
|
||||
- Deployt wird der getestete Commit (`github.sha`), nicht der jeweils neueste Stand des Branches.
|
||||
- `scripts/deploy.sh`: Konfigurationsprüfung, Portkonflikt-Prüfung, Build, DB starten, `migrate --force`, Start, Health (`/up` und Datenbankzugriff). Bei Fehler Rollback auf den letzten erfolgreichen Image-Tag (`.last_good_tag`). Der Deploy legt keinen Demokatalog an. `DemoCatalogSeeder` bleibt für die Testsuite; der Bestand der Testinstanz wird in der Verwaltung gepflegt.
|
||||
- Ein Deploy gleichzeitig pro Host (`flock`), alte Images werden bis auf die letzten Tags entfernt.
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
# Abnahme: Bildausschnitt und Zoom für Bilder und Videos in Widgets
|
||||
|
||||
Stand: 01.12.2026. Entscheidung: ADR-70. Screenshots: `abnahme/bildausschnitt/`. Geprüft durch Claude im Browser (Playwright, Chromium) gegen eine lokale Kopie auf `feature/bildausschnitt` mit einem Testbild (Raster, Beschriftung der Ecken, Gesicht oben); die praktische Abnahme durch den Betreiber auf `luf-test` steht aus. Ein Ergebnis gilt hier nur als geprüft, wenn die Ansicht tatsächlich betrachtet wurde.
|
||||
|
||||
## Bestand und Neues
|
||||
|
||||
| Bereits vorhanden und wiederverwendet | Neu |
|
||||
|---|---|
|
||||
| Fokuspunkt `data.focus_x/focus_y` bei Einstieg, Bild und Text und Premium-Karten (Kit v1.6/1.7), Regler im Reiter „Medien“ | Zoom `data.zoom` (100–250 %) bei denselben drei Widget-Arten |
|
||||
| Rahmen `.card-media` (Redaktionelle Karten, schneidet ab) | Ausschnitt (Waagerecht, Senkrecht, Zoom) je Karte in `data.items[]` |
|
||||
| `srcset` und `sizes` der Bildfassungen (ADR-63) | `sizes` wächst mit dem Zoomfaktor |
|
||||
| Clip und Video über dem Bild (`CardClip`, `HeroVideo`) | Dasselbe Ausschnitt-Verhalten für Video und Clip |
|
||||
|
||||
## Prüfungen
|
||||
|
||||
| | Ergebnis | Beleg |
|
||||
|---|---|---|
|
||||
| Karten: Ohne Ausschnitt, Zoom 200 % auf den Kopf, Zoom 250 % unten rechts | Der Ausschnitt folgt dem Fokuspunkt, das Bild füllt den Rahmen, keine leeren Ränder, Ecken bleiben rund | 02, 07 |
|
||||
| Karten in kompakter Liste | Zoom wirkt im kleinen Bild | 03 |
|
||||
| Einstieg mit Zoom 180 % | Foto füllt die Fläche, abgerundete Ecken, Text lesbar; bei 390 px oben als Bild im Format 16:9 | 01, 06 |
|
||||
| Bild und Text mit Zoom 200 % | Bild im Rahmen mit Ecken und Schatten, füllt die Fläche neben dem Text, die grüne Zierfläche bleibt dahinter | 04, 08 |
|
||||
| Themenkarten: Zoom, ohne Zoom, „Ganzes Bild“ | Zoom nur beim Ausschnitt; „Ganzes Bild“ bleibt vollständig | 05 |
|
||||
| Waagerechter Bildlauf | Kein Überlauf bei 1440 und 390 px | – |
|
||||
| Dialog Einstieg | Regler Waagerecht, Senkrecht, Zoom; gespeicherter Zoom 180 % wird angezeigt, die Änderung wirkt in der Live-Vorschau | 09 |
|
||||
| Dialog Karten | Je Karte drei Regler mit der Vorgabe 50/50/100; vor der Korrektur zeigten sie 0/0 | 10 |
|
||||
| Bestehende Seiten | Ohne gesetzte Werte unverändert: kein Stil am Kartenbild, kein Rahmen, keine neue Klasse (Tests) | Test |
|
||||
| Regression | Volle Testsuite grün (1466 Tests), `CmsSectionLegacyRenderTest` unverändert | – |
|
||||
|
||||
## Grenzen und offen
|
||||
|
||||
- **Zoom nur nach innen.** Bei 100 % füllt das Bild den Rahmen; weiter herauszoomen würde leere Ränder erzeugen. Wer mehr vom Bild zeigen will, braucht einen anderen Rahmen (Bildformat) oder „Ganzes Bild“ auf ruhiger Fläche; beides ist nicht umgesetzt (ADR-70, „Nicht Teil“).
|
||||
- **Video nicht am Gerät gesehen.** Clip und Video erhalten dieselbe Regel (Prüfung der Stylesheet-Regeln im Test), ein echter Clip lief in dieser Abnahme nicht. Auf `luf-test` mit einem Einstieg oder einer Premium-Karte mit Trailer prüfen.
|
||||
- **Nicht umgesetzt:** Katalog- und Shopkarten sowie der Abschnittshintergrund (kein Eintrag je Widget); getrennte Ausschnitte für Handy und Desktop.
|
||||
- **Unschärfe:** Bei Zoom wird ein Teil des Bilds vergrößert. `sizes` fordert eine größere Fassung an; bei kleinen Quelldateien bleibt das Bild trotzdem weicher.
|
||||
- **Nebenwirkung:** Die Regler im Dialog des Einstiegs, von Bild und Text und der Premium-Karten zeigen jetzt die Vorgabe statt 0. Wer einen solchen Dialog öffnet und speichert, speichert den Fokus (68/50, 64/43, 66/45) als Zahl mit; die Darstellung bleibt gleich.
|
||||
|
||||
## Belege
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
After Width: | Height: | Size: 252 KiB |
|
After Width: | Height: | Size: 186 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 126 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 143 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 117 KiB |
@@ -0,0 +1,11 @@
|
||||
# Abnahme: Fließtext, der mit einer Überschrift der Stufe 2 beginnt
|
||||
|
||||
Stand: 01.12.2026. Fehler: Ein Fließtext, dessen gespeichertes HTML mit `<h2>` (oder `<h1>`, `<div>`) beginnt, erschien auf der Website und in der Vorschau mit sichtbaren Tags. Ursache: `FormattedText::isHtml` erkannte nur Absatz, H3 bis H6, Listen, Zitat, Tabelle und Bild am Textanfang als HTML; alles andere galt als Klartext des Altbestands und wurde maskiert. Die Bereinigung bildet H1 und H2 auf H3 ab (`mapLegacyTags`), kam aber nie zum Zug.
|
||||
|
||||
Behoben in `FormattedText::isHtml` (zusätzlich `h1`, `h2`, `div`). Wirkt auf bereits gespeicherte Texte ohne Datenänderung, weil die Erkennung beim Ausgeben geschieht. H1 und H2 gehören der Seite und dem Kapitel; im Fließtext erscheinen sie als Zwischenüberschrift H3.
|
||||
|
||||
Geprüft lokal im Browser (Chromium) mit einem Beispieltext aus H2, H3, Absätzen, fettem Zwischentitel und Aufzählung: keine sichtbaren Tags, kein waagerechter Bildlauf. Tests: `FormattedTextTest`, `CmsProseFormattingTest`. Die Abnahme auf `luf-test` steht aus.
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 57 KiB |
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "app",
|
||||
"name": "luf",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
@@ -12,7 +12,8 @@
|
||||
"concurrently": "^10.0.3",
|
||||
"laravel-vite-plugin": "^3.1",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^8.0.0"
|
||||
"vite": "^8.0.0",
|
||||
"vitest": "^5.1.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@laravel/multiplex": "^0.4.1"
|
||||
@@ -816,6 +817,69 @@
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/chai": {
|
||||
"version": "5.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
|
||||
"integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/deep-eql": "*",
|
||||
"assertion-error": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/deep-eql": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
|
||||
"integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.11.tgz",
|
||||
"integrity": "sha512-YBdNe5JcjYR0sPhJW1QIeRCmI11YhYvaRuGCs9+WCeTTb+Yhb2BE2XMe5/wAqF10FK5g3+q1PDhQABfT7aX0gg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@vitest/mocker": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.2.tgz",
|
||||
"integrity": "sha512-UGc97wUIy0Ji2+9GxzHEJiOhiwkaukgE7VYcUNnjpX3sWnwQ8XogmNXX4WyOukxYgKb8Nh2XFa7KId0ZjpmVhQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/trace-mapping": "0.3.31",
|
||||
"@vitest/spy": "5.1.2",
|
||||
"estree-walker": "^3.0.3",
|
||||
"magic-string": "^1.4.5"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"msw": "^2.4.9 || ^3.0.0",
|
||||
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"msw": {
|
||||
"optional": true
|
||||
},
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@vitest/spy": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.2.tgz",
|
||||
"integrity": "sha512-PQl0/3+p9GaY71+MHywN6oyHfLhVDD5kcbm7oNRldA2F0ExMU3S8RQdnpteJ9gFAdK5P6KCgE6LqCpUgy57KzA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-escapes": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.3.0.tgz",
|
||||
@@ -858,6 +922,16 @@
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/assertion-error": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
||||
"integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/auto-bind": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-5.0.1.tgz",
|
||||
@@ -871,6 +945,16 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/chai": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz",
|
||||
"integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "5.6.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz",
|
||||
@@ -1113,6 +1197,13 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/es-module-lexer": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz",
|
||||
"integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/es-toolkit": {
|
||||
"version": "1.53.2",
|
||||
"resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.53.2.tgz",
|
||||
@@ -1146,6 +1237,26 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
|
||||
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/expect-type": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",
|
||||
"integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fdir": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
||||
@@ -1660,6 +1771,20 @@
|
||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/obug": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz",
|
||||
"integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
"https://github.com/sponsors/sxzz",
|
||||
"https://opencollective.com/debug"
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/onetime": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
|
||||
@@ -1903,6 +2028,13 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/std-env": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz",
|
||||
"integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "8.3.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz",
|
||||
@@ -1996,6 +2128,26 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/tinybench": {
|
||||
"version": "6.2.5",
|
||||
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.5.tgz",
|
||||
"integrity": "sha512-b/8GRMdnY4cqkfCLyaFpTGIv1qwfi3oT0mWaepwT++6Z/ZrYehNfZZ2JDKVLKGhNoEkS3IIB1ELtCT0XS5DtOA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyexec": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.4.0.tgz",
|
||||
"integrity": "sha512-PV6lIcJQh57aFeJDwx16JNHmgFRh5xguzallrDW1qe8nAghYgr5MKz2K5k7wEyV/ygZhdnIAP8+HZSarHPBCsg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/tinyglobby": {
|
||||
"version": "0.2.17",
|
||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
||||
@@ -2148,6 +2300,102 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/vitest": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.2.tgz",
|
||||
"integrity": "sha512-VIa2wXV208WraXUbzH+dQUrGcFpPuaiRA8HlhXS8R6/sy9cynw6OMqGj8fmAlH1hot7huTCtWUE14+FdXU3eLw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/chai": "^5.2.2",
|
||||
"@vitest/mocker": "5.1.2",
|
||||
"chai": "^6.3.0",
|
||||
"es-module-lexer": "^2.3.2",
|
||||
"expect-type": "^1.4.0",
|
||||
"magic-string": "^1.4.5",
|
||||
"obug": "^3.0.0",
|
||||
"picomatch": "^4.0.7",
|
||||
"std-env": "^4.3.0",
|
||||
"tinybench": "^6.2.3",
|
||||
"tinyexec": "^1.3.1",
|
||||
"tinyglobby": "^0.2.17",
|
||||
"why-is-node-running": "3.2.1"
|
||||
},
|
||||
"bin": {
|
||||
"vitest": "vitest.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^22.12.0 || ^24.0.0 || >=26.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/vitest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@edge-runtime/vm": "*",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
"@types/node": "^22.0.0 || >=24.0.0",
|
||||
"@vitest/browser-playwright": "5.1.2",
|
||||
"@vitest/browser-preview": "5.1.2",
|
||||
"@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0",
|
||||
"@vitest/coverage-istanbul": "5.1.2",
|
||||
"@vitest/coverage-v8": "5.1.2",
|
||||
"@vitest/ui": "5.1.2",
|
||||
"happy-dom": "*",
|
||||
"jsdom": "*",
|
||||
"vite": "^6.4.0 || ^7.0.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@edge-runtime/vm": {
|
||||
"optional": true
|
||||
},
|
||||
"@opentelemetry/api": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/browser-playwright": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/browser-preview": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/browser-webdriverio": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/coverage-istanbul": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/coverage-v8": {
|
||||
"optional": true
|
||||
},
|
||||
"@vitest/ui": {
|
||||
"optional": true
|
||||
},
|
||||
"happy-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"jsdom": {
|
||||
"optional": true
|
||||
},
|
||||
"vite": {
|
||||
"optional": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/why-is-node-running": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz",
|
||||
"integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"why-is-node-running": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.11"
|
||||
}
|
||||
},
|
||||
"node_modules/widest-line": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/widest-line/-/widest-line-6.0.0.tgz",
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
"dev": "vite",
|
||||
"test:js": "vitest run"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"concurrently": "^10.0.3",
|
||||
"laravel-vite-plugin": "^3.1",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^8.0.0"
|
||||
"vite": "^8.0.0",
|
||||
"vitest": "^5.1.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@laravel/multiplex": "^0.4.1"
|
||||
|
||||
@@ -276,3 +276,30 @@ @media (prefers-reduced-motion: reduce) {
|
||||
.lf-bt__button { transition: none; }
|
||||
.lf-bt__button:hover { transform: none; }
|
||||
}
|
||||
|
||||
/*
|
||||
* Zoom (ADR-70): Bild und Video liegen in einem Rahmen mit den Ecken und dem Schatten des Bilds und werden um den
|
||||
* Fokuspunkt vergrößert; ab 100 % füllt das Bild den Rahmen, es entstehen keine Ränder. Ohne Zoom gibt es den Rahmen nicht.
|
||||
*/
|
||||
.lf-bt__frame {
|
||||
position: relative;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
border-radius: clamp(0.78rem, 1.8cqi, 1.3rem);
|
||||
box-shadow: 0 10px 28px rgb(3 37 81 / 11%);
|
||||
}
|
||||
|
||||
.lf-bt__frame > .lf-bt__image,
|
||||
.lf-bt__frame > .lf-pc__clip {
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
object-position: var(--bt-focus-x) var(--bt-focus-y);
|
||||
transform-origin: var(--bt-focus-x) var(--bt-focus-y);
|
||||
scale: var(--bt-zoom, 1);
|
||||
}
|
||||
|
||||
/* Zweispaltig füllt das Bild die Fläche neben dem Text (siehe oben); dann füllt der Rahmen sie. Ohne Text bestimmt das Bild seine Höhe selbst. */
|
||||
@container lf-bt (min-width: 900px) {
|
||||
.lf-bt__frame { position: absolute; inset: 0; }
|
||||
.lf-bt--without-text .lf-bt__frame { position: relative; inset: auto; }
|
||||
}
|
||||
@@ -294,3 +294,29 @@ @media (prefers-reduced-motion: reduce) {
|
||||
.lf-hero__button { transition: none; }
|
||||
.lf-hero__button:hover { transform: none; }
|
||||
}
|
||||
|
||||
/*
|
||||
* Zoom (ADR-70): Foto und Video liegen in einem Rahmen, der den vergrößerten Ausschnitt abschneidet. Vergrößert wird um den
|
||||
* Fokuspunkt, ab 100 % füllt das Bild den Rahmen, es entstehen keine Ränder. Ohne Zoom gibt es den Rahmen nicht.
|
||||
*/
|
||||
.lf-hero__frame {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: -2;
|
||||
overflow: hidden;
|
||||
border-radius: inherit;
|
||||
}
|
||||
|
||||
.lf-hero__frame > .lf-hero__photo,
|
||||
.lf-hero__frame > .lf-hero__video {
|
||||
z-index: auto;
|
||||
border-radius: 0;
|
||||
transform-origin: var(--lf-hero-focus-x) var(--lf-hero-focus-y);
|
||||
scale: var(--lf-hero-zoom, 1);
|
||||
}
|
||||
|
||||
@container lf-hero (max-width: 859.99px) {
|
||||
.lf-hero__frame { position: relative; inset: auto; display: block; aspect-ratio: 16 / 9; }
|
||||
.lf-hero__frame > .lf-hero__photo,
|
||||
.lf-hero__frame > .lf-hero__video { position: absolute; inset: 0; block-size: 100%; aspect-ratio: auto; }
|
||||
}
|
||||
@@ -555,3 +555,17 @@ @media (prefers-reduced-motion: reduce) {
|
||||
.lf-pc__clip-toggle:hover { transform: translate(-50%, -50%); }
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Zoom (ADR-70): Bild und Clip werden um den Fokuspunkt vergrößert, der Bildbereich schneidet ab. Ab 100 % füllt das Bild
|
||||
* den Rahmen, es entstehen keine Ränder. Die Klasse steht nur bei Zoom und nie bei „Ganzes Bild“.
|
||||
*/
|
||||
.lf-pc--zoom .lf-pc__visual {
|
||||
overflow: hidden;
|
||||
border-radius: var(--radius-card);
|
||||
}
|
||||
|
||||
.lf-pc--zoom :is(.lf-pc__image, .lf-pc__clip) {
|
||||
transform-origin: var(--pc-focus-x, 66%) var(--pc-focus-y, 45%);
|
||||
scale: var(--pc-zoom, 1);
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import './hero-video.js';
|
||||
import './inquiry-form.js';
|
||||
import './inquiry-widget.js';
|
||||
import './member-nav.js';
|
||||
import { canFullscreen, enterFullscreen } from './player/fullscreen.js';
|
||||
import { attachSource } from './player/source.js';
|
||||
|
||||
function attachPlayback(video) {
|
||||
if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') {
|
||||
@@ -20,18 +22,7 @@ function attachPlayback(video) {
|
||||
}
|
||||
|
||||
video.dataset.playbackReady = '1';
|
||||
|
||||
if (Hls.isSupported()) {
|
||||
const playback = new Hls();
|
||||
playback.loadSource(source);
|
||||
playback.attachMedia(video);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = source;
|
||||
}
|
||||
attachSource(video, { Hls, source, renewUrl: video.dataset.hlsRenew || null });
|
||||
}
|
||||
|
||||
function scanPlayback(root) {
|
||||
@@ -61,44 +52,15 @@ new MutationObserver((records) => {
|
||||
document.addEventListener('click', (event) => {
|
||||
const fullscreen = event.target.closest('[data-fullscreen]');
|
||||
|
||||
if (fullscreen) {
|
||||
if (!fullscreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Der Vollbild-Knopf steht im Player oder, im Mitgliederbereich, neben ihm in derselben Spalte bzw. Zeile.
|
||||
// Ein Weg für Desktop, Android, iPad und iPhone (player/fullscreen.js); wo das Gerät kein Vollbild kann, tut er nichts.
|
||||
const media = fullscreen.closest('.player, .mb-content-main, .mb-outline-item')?.querySelector('video, audio');
|
||||
|
||||
if (media?.requestFullscreen) {
|
||||
media.requestFullscreen();
|
||||
if (media && canFullscreen(media)) {
|
||||
enterFullscreen(media);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const decision = event.target.closest('[data-course-decision]');
|
||||
const restart = event.target.closest('[data-course-restart]');
|
||||
const button = decision || restart;
|
||||
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
|
||||
const video = button.closest('li')?.querySelector('video');
|
||||
|
||||
if (!video) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (restart) {
|
||||
video.currentTime = 0;
|
||||
video.play();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const at = Number(video.dataset.decision);
|
||||
|
||||
if (Number.isNaN(at)) {
|
||||
return;
|
||||
}
|
||||
|
||||
video.currentTime = at;
|
||||
video.pause();
|
||||
});
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Erneuerung der Wiedergabeadressen (Plan Videoplayer 0.1).
|
||||
*
|
||||
* Teillisten und Abschnitte sind mit einer Signatur versehen, die Filmlänge plus Reserve gilt. Läuft sie trotzdem ab
|
||||
* (lange Pause, Seite lange offen, Hauptliste erst spät gestartet), antwortet der Server mit 403. Der Lader unten holt
|
||||
* dann beim Server eine frische Adresse für genau diese Datei und wiederholt den Abruf einmal. Der Server prüft dabei
|
||||
* wie bei jedem Abruf Anmeldung, Konto und Berechtigung; nach einem Entzug gibt es keine neue Adresse.
|
||||
*
|
||||
* Es gibt keine Schleife: je Abruf eine Wiederholung, je Wiedergabe höchstens MAX_RENEWALS Erneuerungen, und nach der
|
||||
* ersten abgelehnten Erneuerung keine weitere.
|
||||
*/
|
||||
|
||||
const MAX_RENEWALS = 20;
|
||||
const SECTION_PATH = /\/abschnitt\/\d+\/\d+\/\d+\/(.+)$/;
|
||||
|
||||
/**
|
||||
* Adresse der Erneuerung für eine abgelaufene Adresse: bei einer Datei unter /abschnitt/… mit dieser Datei, sonst
|
||||
* (Hauptliste) ohne Datei.
|
||||
*/
|
||||
export function renewalRequestUrl(renewUrl, failedUrl) {
|
||||
let pathname = '';
|
||||
|
||||
try {
|
||||
pathname = new URL(failedUrl, 'http://lokal.invalid').pathname;
|
||||
} catch (error) {
|
||||
return renewUrl;
|
||||
}
|
||||
|
||||
const match = SECTION_PATH.exec(pathname);
|
||||
|
||||
if (match === null) {
|
||||
return renewUrl;
|
||||
}
|
||||
|
||||
let file = match[1];
|
||||
|
||||
try {
|
||||
file = decodeURIComponent(file);
|
||||
} catch (error) {
|
||||
// Unlesbare Kodierung: den Pfad unverändert senden, der Server lehnt Unbekanntes ab.
|
||||
}
|
||||
|
||||
return renewUrl + (renewUrl.includes('?') ? '&' : '?') + 'datei=' + encodeURIComponent(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert eine Funktion (failedUrl) => Promise<string|null> mit der frischen Adresse oder null. Lehnt der Server ab
|
||||
* (Entzug, Anmeldung abgelaufen, unbrauchbare Antwort), wird onRefused einmal gerufen: Weiter warten hilft dann nicht.
|
||||
* Ein Netzwerkfehler gilt nicht als Ablehnung; der nächste Abruf versucht es wieder.
|
||||
*/
|
||||
export function createRenewer(renewUrl, fetchFn = (...args) => window.fetch(...args), onRefused = () => undefined) {
|
||||
let renewals = 0;
|
||||
let refused = false;
|
||||
const refuse = () => {
|
||||
refused = true;
|
||||
onRefused();
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
return async function renew(failedUrl) {
|
||||
if (refused || renewals >= MAX_RENEWALS) {
|
||||
return null;
|
||||
}
|
||||
|
||||
renewals += 1;
|
||||
|
||||
try {
|
||||
const response = await fetchFn(renewalRequestUrl(renewUrl, failedUrl), {
|
||||
credentials: 'same-origin',
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return refuse();
|
||||
}
|
||||
|
||||
const body = await response.json();
|
||||
|
||||
if (typeof body.url !== 'string' || body.url === '') {
|
||||
return refuse();
|
||||
}
|
||||
|
||||
return body.url;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut aus dem Standardlader von hls.js einen Lader, der bei 403 genau einmal mit erneuerter Adresse wiederholt.
|
||||
* Jeder Versuch nutzt einen neuen Lader, denn ein hls.js-Lader ist nur einmal verwendbar.
|
||||
*/
|
||||
export function createRenewingLoader(BaseLoader, renew) {
|
||||
return class RenewingLoader {
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.inner = new BaseLoader(config);
|
||||
this.aborted = false;
|
||||
}
|
||||
|
||||
get stats() {
|
||||
return this.inner.stats;
|
||||
}
|
||||
|
||||
get context() {
|
||||
return this.inner.context;
|
||||
}
|
||||
|
||||
load(context, loaderConfig, callbacks) {
|
||||
const failed = (error, failedContext, details, stats) => {
|
||||
if (this.aborted || error === undefined || error.code !== 403) {
|
||||
callbacks.onError(error, failedContext, details, stats);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
renew(context.url).then((url) => {
|
||||
if (this.aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (url === null) {
|
||||
callbacks.onError(error, failedContext, details, stats);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.inner.destroy();
|
||||
this.inner = new BaseLoader(this.config);
|
||||
context.url = url;
|
||||
this.inner.load(context, loaderConfig, callbacks);
|
||||
});
|
||||
};
|
||||
|
||||
this.inner.load(context, loaderConfig, { ...callbacks, onError: failed });
|
||||
}
|
||||
|
||||
abort() {
|
||||
this.aborted = true;
|
||||
this.inner.abort();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.aborted = true;
|
||||
this.inner.destroy();
|
||||
}
|
||||
|
||||
getCacheAge() {
|
||||
return typeof this.inner.getCacheAge === 'function' ? this.inner.getCacheAge() : null;
|
||||
}
|
||||
|
||||
getResponseHeader(name) {
|
||||
return typeof this.inner.getResponseHeader === 'function' ? this.inner.getResponseHeader(name) : null;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { createRenewer, createRenewingLoader, renewalRequestUrl } from './renewal.js';
|
||||
|
||||
const RENEW = 'https://luf.test/bereich/wiedergabe/1/2/3/erneuern';
|
||||
|
||||
function response(ok, body) {
|
||||
return { ok, json: async () => body };
|
||||
}
|
||||
|
||||
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
describe('renewalRequestUrl', () => {
|
||||
it('fragt für einen Abschnitt nach genau dieser Datei', () => {
|
||||
const failed = 'https://luf.test/bereich/abschnitt/1/2/3/ableitungen/3/480/segment-001.ts?expires=1&signature=x';
|
||||
|
||||
expect(renewalRequestUrl(RENEW, failed)).toBe(RENEW + '?datei=ableitungen%2F3%2F480%2Fsegment-001.ts');
|
||||
});
|
||||
|
||||
it('fragt für die Hauptliste ohne Datei', () => {
|
||||
expect(renewalRequestUrl(RENEW, 'https://luf.test/bereich/ausgabe/1/2/3/streamen?expires=1&signature=x')).toBe(RENEW);
|
||||
});
|
||||
|
||||
it('hängt die Datei an eine Adresse mit Abfrage an und entschlüsselt den Pfad', () => {
|
||||
const failed = 'https://luf.test/bereich/abschnitt/1/2/3/ableitungen/3/H%C3%B6fe/a.ts';
|
||||
|
||||
expect(renewalRequestUrl(RENEW + '?x=1', failed)).toBe(RENEW + '?x=1&datei=ableitungen%2F3%2FH%C3%B6fe%2Fa.ts');
|
||||
});
|
||||
|
||||
it('fällt bei einer unlesbaren Adresse auf die Hauptliste zurück', () => {
|
||||
expect(renewalRequestUrl(RENEW, 'http://[kaputt')).toBe(RENEW);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createRenewer', () => {
|
||||
it('liefert die frische Adresse', async () => {
|
||||
const fetchFn = vi.fn(async () => response(true, { url: 'https://luf.test/neu' }));
|
||||
|
||||
expect(await createRenewer(RENEW, fetchFn)('https://luf.test/bereich/ausgabe/1/2/3/streamen')).toBe('https://luf.test/neu');
|
||||
expect(fetchFn).toHaveBeenCalledWith(RENEW, expect.objectContaining({ credentials: 'same-origin' }));
|
||||
});
|
||||
|
||||
it('gibt nach der ersten Ablehnung nie wieder eine Anfrage heraus', async () => {
|
||||
const fetchFn = vi.fn(async () => response(false, {}));
|
||||
const renew = createRenewer(RENEW, fetchFn);
|
||||
|
||||
expect(await renew('https://luf.test/a')).toBeNull();
|
||||
expect(await renew('https://luf.test/b')).toBeNull();
|
||||
expect(fetchFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('behandelt eine Antwort ohne Adresse wie eine Ablehnung', async () => {
|
||||
const fetchFn = vi.fn(async () => response(true, { url: '' }));
|
||||
const renew = createRenewer(RENEW, fetchFn);
|
||||
|
||||
expect(await renew('https://luf.test/a')).toBeNull();
|
||||
expect(await renew('https://luf.test/b')).toBeNull();
|
||||
expect(fetchFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('fängt Netzwerkfehler ab und versucht es beim nächsten Abruf wieder', async () => {
|
||||
const fetchFn = vi.fn()
|
||||
.mockRejectedValueOnce(new Error('offline'))
|
||||
.mockResolvedValueOnce(response(true, { url: 'https://luf.test/neu' }));
|
||||
const renew = createRenewer(RENEW, fetchFn);
|
||||
|
||||
expect(await renew('https://luf.test/a')).toBeNull();
|
||||
expect(await renew('https://luf.test/a')).toBe('https://luf.test/neu');
|
||||
});
|
||||
|
||||
it('meldet eine Ablehnung des Servers genau einmal, einen Netzwerkfehler nie', async () => {
|
||||
const refused = vi.fn();
|
||||
const denied = createRenewer(RENEW, vi.fn(async () => response(false, {})), refused);
|
||||
|
||||
await denied('https://luf.test/a');
|
||||
await denied('https://luf.test/b');
|
||||
expect(refused).toHaveBeenCalledTimes(1);
|
||||
|
||||
const unusable = vi.fn();
|
||||
await createRenewer(RENEW, vi.fn(async () => response(true, {})), unusable)('https://luf.test/a');
|
||||
expect(unusable).toHaveBeenCalledTimes(1);
|
||||
|
||||
const offline = vi.fn();
|
||||
await createRenewer(RENEW, vi.fn().mockRejectedValue(new Error('offline')), offline)('https://luf.test/a');
|
||||
expect(offline).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('begrenzt die Zahl der Erneuerungen je Wiedergabe', async () => {
|
||||
const fetchFn = vi.fn(async () => response(true, { url: 'https://luf.test/neu' }));
|
||||
const renew = createRenewer(RENEW, fetchFn);
|
||||
let granted = 0;
|
||||
|
||||
for (let index = 0; index < 50; index += 1) {
|
||||
if (await renew('https://luf.test/a') !== null) {
|
||||
granted += 1;
|
||||
}
|
||||
}
|
||||
|
||||
expect(granted).toBe(20);
|
||||
expect(fetchFn).toHaveBeenCalledTimes(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createRenewingLoader', () => {
|
||||
function fakeBase() {
|
||||
const instances = [];
|
||||
|
||||
class Base {
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.stats = { loaded: 0 };
|
||||
this.destroyed = false;
|
||||
this.aborted = false;
|
||||
instances.push(this);
|
||||
}
|
||||
|
||||
load(context, loaderConfig, callbacks) {
|
||||
this.context = context;
|
||||
this.callbacks = callbacks;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.destroyed = true;
|
||||
}
|
||||
|
||||
abort() {
|
||||
this.aborted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return { Base, instances };
|
||||
}
|
||||
|
||||
function start(renew) {
|
||||
const { Base, instances } = fakeBase();
|
||||
const Loader = createRenewingLoader(Base, renew);
|
||||
const callbacks = { onSuccess: vi.fn(), onError: vi.fn(), onTimeout: vi.fn(), onAbort: vi.fn() };
|
||||
const context = { url: 'https://luf.test/bereich/abschnitt/1/2/3/ableitungen/3/480/s.ts', type: 'fragment' };
|
||||
const loader = new Loader({ id: 'konfiguration' });
|
||||
loader.load(context, { timeout: 1 }, callbacks);
|
||||
|
||||
return { loader, instances, callbacks, context };
|
||||
}
|
||||
|
||||
const forbidden = { code: 403, text: 'Forbidden' };
|
||||
|
||||
it('reicht Erfolg und fremde Fehler unverändert durch, ohne zu erneuern', async () => {
|
||||
const renew = vi.fn();
|
||||
const { instances, callbacks, context } = start(renew);
|
||||
|
||||
instances[0].callbacks.onSuccess({ url: context.url }, {}, context, null);
|
||||
instances[0].callbacks.onError({ code: 404, text: 'Not Found' }, context, null, {});
|
||||
await flush();
|
||||
|
||||
expect(callbacks.onSuccess).toHaveBeenCalledTimes(1);
|
||||
expect(callbacks.onError).toHaveBeenCalledWith({ code: 404, text: 'Not Found' }, context, null, {});
|
||||
expect(renew).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('wiederholt bei 403 mit der erneuerten Adresse in einem neuen Lader', async () => {
|
||||
const renew = vi.fn(async () => 'https://luf.test/frisch');
|
||||
const { instances, callbacks, context } = start(renew);
|
||||
|
||||
instances[0].callbacks.onError(forbidden, context, null, {});
|
||||
await flush();
|
||||
|
||||
expect(renew).toHaveBeenCalledWith('https://luf.test/bereich/abschnitt/1/2/3/ableitungen/3/480/s.ts');
|
||||
expect(instances).toHaveLength(2);
|
||||
expect(instances[0].destroyed).toBe(true);
|
||||
expect(instances[1].config).toEqual({ id: 'konfiguration' });
|
||||
expect(instances[1].context.url).toBe('https://luf.test/frisch');
|
||||
expect(callbacks.onError).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('wiederholt nur einmal: ein zweites 403 geht an hls.js weiter', async () => {
|
||||
const renew = vi.fn(async () => 'https://luf.test/frisch');
|
||||
const { instances, callbacks, context } = start(renew);
|
||||
|
||||
instances[0].callbacks.onError(forbidden, context, null, {});
|
||||
await flush();
|
||||
instances[1].callbacks.onError(forbidden, context, null, {});
|
||||
await flush();
|
||||
|
||||
expect(renew).toHaveBeenCalledTimes(1);
|
||||
expect(instances).toHaveLength(2);
|
||||
expect(callbacks.onError).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('meldet den ursprünglichen Fehler, wenn der Server keine Adresse gibt', async () => {
|
||||
const { instances, callbacks, context } = start(vi.fn(async () => null));
|
||||
|
||||
instances[0].callbacks.onError(forbidden, context, null, {});
|
||||
await flush();
|
||||
|
||||
expect(instances).toHaveLength(1);
|
||||
expect(callbacks.onError).toHaveBeenCalledWith(forbidden, context, null, {});
|
||||
});
|
||||
|
||||
it('tut nach einem Abbruch während der Erneuerung nichts mehr', async () => {
|
||||
let release;
|
||||
const renew = vi.fn(() => new Promise((resolve) => { release = resolve; }));
|
||||
const { loader, instances, callbacks, context } = start(renew);
|
||||
|
||||
instances[0].callbacks.onError(forbidden, context, null, {});
|
||||
loader.abort();
|
||||
release('https://luf.test/frisch');
|
||||
await flush();
|
||||
|
||||
expect(instances).toHaveLength(1);
|
||||
expect(callbacks.onError).not.toHaveBeenCalled();
|
||||
expect(instances[0].aborted).toBe(true);
|
||||
});
|
||||
|
||||
it('zeigt Statistik und Kontext des gerade laufenden Laders', async () => {
|
||||
const { loader, instances, context } = start(vi.fn(async () => 'https://luf.test/frisch'));
|
||||
|
||||
expect(loader.stats).toBe(instances[0].stats);
|
||||
instances[0].callbacks.onError(forbidden, context, null, {});
|
||||
await flush();
|
||||
|
||||
expect(loader.stats).toBe(instances[1].stats);
|
||||
expect(loader.context).toBe(instances[1].context);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Quelle eines Films an ein <video> binden: hls.js, wo es geht, sonst nativ (Safari, iPhone).
|
||||
*
|
||||
* Ohne Erneuerungsadresse (Redaktionsvorschau, Auswahl, Website) bleibt es beim bisherigen Verhalten. Mit
|
||||
* Erneuerungsadresse (Mitgliederbereich) holt der Player abgelaufene Adressen neu (renewal.js) und meldet einen
|
||||
* endgültigen Fehler sichtbar.
|
||||
*
|
||||
* iPhone: Safari lädt nativ, hls.js ist dort nicht im Spiel, es gibt keinen Fehlerhaken je Abschnitt. Der Rückfall
|
||||
* unten lädt bei einem Fehler einmal die Hauptliste neu und setzt an der Stelle fort. Ob das auf dem Gerät so
|
||||
* funktioniert, zeigt nur ein Gerätetest.
|
||||
*/
|
||||
import { createRenewer, createRenewingLoader } from './renewal.js';
|
||||
|
||||
const MESSAGE = 'Die Wiedergabe wurde unterbrochen. Bitte lade die Seite neu.';
|
||||
|
||||
export function attachSource(video, { Hls, source, renewUrl = null }) {
|
||||
if (Hls.isSupported()) {
|
||||
let hls = null;
|
||||
const renew = renewUrl
|
||||
? createRenewer(renewUrl, undefined, () => {
|
||||
hls?.destroy();
|
||||
showFailure(video);
|
||||
})
|
||||
: null;
|
||||
hls = new Hls(renew ? { loader: createRenewingLoader(Hls.DefaultConfig.loader, renew) } : {});
|
||||
|
||||
if (renew) {
|
||||
watchFatal(video, hls, Hls);
|
||||
}
|
||||
|
||||
hls.loadSource(source);
|
||||
hls.attachMedia(video);
|
||||
|
||||
return hls;
|
||||
}
|
||||
|
||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = source;
|
||||
|
||||
if (renewUrl) {
|
||||
recoverNative(video, createRenewer(renewUrl, undefined, () => showFailure(video)), source);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function watchFatal(video, hls, Hls) {
|
||||
let mediaRecovered = false;
|
||||
|
||||
hls.on(Hls.Events.ERROR, (event, data) => {
|
||||
if (!data.fatal) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.type === Hls.ErrorTypes.MEDIA_ERROR && !mediaRecovered) {
|
||||
mediaRecovered = true;
|
||||
hls.recoverMediaError();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
hls.destroy();
|
||||
showFailure(video);
|
||||
});
|
||||
}
|
||||
|
||||
function recoverNative(video, renew, source) {
|
||||
let retried = false;
|
||||
|
||||
video.addEventListener('error', async () => {
|
||||
if (retried) {
|
||||
showFailure(video);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
retried = true;
|
||||
|
||||
const position = video.currentTime;
|
||||
const wasPlaying = !video.paused;
|
||||
const url = await renew(source);
|
||||
|
||||
if (url === null) {
|
||||
showFailure(video);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
video.src = url;
|
||||
video.addEventListener('loadedmetadata', () => {
|
||||
if (position > 0) {
|
||||
video.currentTime = position;
|
||||
}
|
||||
|
||||
if (wasPlaying) {
|
||||
video.play().catch(() => undefined);
|
||||
}
|
||||
}, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
export function showFailure(video) {
|
||||
if (video.dataset.playbackFailed === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
video.dataset.playbackFailed = '1';
|
||||
|
||||
const message = document.createElement('p');
|
||||
message.className = 'mb-hint';
|
||||
message.setAttribute('role', 'alert');
|
||||
message.textContent = MESSAGE;
|
||||
(video.closest('.mb-player') ?? video).insertAdjacentElement('afterend', message);
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { attachSource } from './source.js';
|
||||
|
||||
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
|
||||
function fakeHls({ supported = true } = {}) {
|
||||
const instances = [];
|
||||
|
||||
class Hls {
|
||||
static isSupported() {
|
||||
return supported;
|
||||
}
|
||||
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.handlers = {};
|
||||
this.calls = [];
|
||||
instances.push(this);
|
||||
}
|
||||
|
||||
on(name, handler) {
|
||||
this.handlers[name] = handler;
|
||||
}
|
||||
|
||||
loadSource(url) {
|
||||
this.calls.push(['loadSource', url]);
|
||||
}
|
||||
|
||||
attachMedia(video) {
|
||||
this.calls.push(['attachMedia', video]);
|
||||
}
|
||||
|
||||
recoverMediaError() {
|
||||
this.calls.push(['recoverMediaError']);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.calls.push(['destroy']);
|
||||
}
|
||||
}
|
||||
|
||||
Hls.Events = { ERROR: 'hlsError' };
|
||||
Hls.ErrorTypes = { MEDIA_ERROR: 'mediaError', NETWORK_ERROR: 'networkError' };
|
||||
Hls.DefaultConfig = { loader: class DefaultLoader {} };
|
||||
|
||||
return { Hls, instances };
|
||||
}
|
||||
|
||||
function fakeVideo({ native = false } = {}) {
|
||||
const listeners = {};
|
||||
const inserted = [];
|
||||
|
||||
return {
|
||||
dataset: {},
|
||||
paused: true,
|
||||
currentTime: 0,
|
||||
src: '',
|
||||
inserted,
|
||||
listeners,
|
||||
canPlayType: () => (native ? 'maybe' : ''),
|
||||
addEventListener(name, handler) {
|
||||
listeners[name] = handler;
|
||||
},
|
||||
play: vi.fn(async () => undefined),
|
||||
closest: () => ({ insertAdjacentElement: (where, element) => inserted.push([where, element]) }),
|
||||
};
|
||||
}
|
||||
|
||||
describe('attachSource ohne Erneuerungsadresse (Vorschau, Auswahl)', () => {
|
||||
it('bindet hls.js wie bisher, ohne eigenen Lader und ohne Fehlerhaken', () => {
|
||||
const { Hls, instances } = fakeHls();
|
||||
const video = fakeVideo();
|
||||
|
||||
attachSource(video, { Hls, source: 'https://luf.test/m.m3u8' });
|
||||
|
||||
expect(instances[0].config).toEqual({});
|
||||
expect(instances[0].handlers).toEqual({});
|
||||
expect(instances[0].calls).toEqual([['loadSource', 'https://luf.test/m.m3u8'], ['attachMedia', video]]);
|
||||
});
|
||||
|
||||
it('setzt in Safari die Quelle direkt und hängt nichts an', () => {
|
||||
const { Hls } = fakeHls({ supported: false });
|
||||
const video = fakeVideo({ native: true });
|
||||
|
||||
attachSource(video, { Hls, source: 'https://luf.test/m.m3u8' });
|
||||
|
||||
expect(video.src).toBe('https://luf.test/m.m3u8');
|
||||
expect(video.listeners.error).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('attachSource mit Erneuerungsadresse (Mitgliederbereich)', () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('document', {
|
||||
createElement: () => ({
|
||||
className: '',
|
||||
textContent: '',
|
||||
attributes: {},
|
||||
setAttribute(name, value) {
|
||||
this.attributes[name] = value;
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it('nutzt den erneuernden Lader', () => {
|
||||
const { Hls, instances } = fakeHls();
|
||||
|
||||
attachSource(fakeVideo(), { Hls, source: 'https://luf.test/m.m3u8', renewUrl: 'https://luf.test/erneuern' });
|
||||
|
||||
expect(typeof instances[0].config.loader).toBe('function');
|
||||
expect(instances[0].handlers.hlsError).toBeTypeOf('function');
|
||||
});
|
||||
|
||||
it('versucht bei einem Medienfehler einmal die Wiederherstellung, danach Meldung und Abbau', () => {
|
||||
const { Hls, instances } = fakeHls();
|
||||
const video = fakeVideo();
|
||||
|
||||
attachSource(video, { Hls, source: 'https://luf.test/m.m3u8', renewUrl: 'https://luf.test/erneuern' });
|
||||
const onError = instances[0].handlers.hlsError;
|
||||
|
||||
onError('hlsError', { fatal: false, type: 'networkError' });
|
||||
expect(video.inserted).toHaveLength(0);
|
||||
|
||||
onError('hlsError', { fatal: true, type: 'mediaError' });
|
||||
expect(instances[0].calls).toContainEqual(['recoverMediaError']);
|
||||
expect(video.inserted).toHaveLength(0);
|
||||
|
||||
onError('hlsError', { fatal: true, type: 'mediaError' });
|
||||
expect(instances[0].calls).toContainEqual(['destroy']);
|
||||
expect(video.inserted).toHaveLength(1);
|
||||
expect(video.inserted[0][1].attributes.role).toBe('alert');
|
||||
|
||||
onError('hlsError', { fatal: true, type: 'networkError' });
|
||||
expect(video.inserted).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('meldet einen endgültigen Netzwerkfehler sofort', () => {
|
||||
const { Hls, instances } = fakeHls();
|
||||
const video = fakeVideo();
|
||||
|
||||
attachSource(video, { Hls, source: 'https://luf.test/m.m3u8', renewUrl: 'https://luf.test/erneuern' });
|
||||
instances[0].handlers.hlsError('hlsError', { fatal: true, type: 'networkError' });
|
||||
|
||||
expect(video.inserted).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('lädt in Safari bei einem Fehler die Hauptliste neu und setzt an der Stelle fort', async () => {
|
||||
vi.stubGlobal('window', {
|
||||
fetch: vi.fn(async () => ({ ok: true, json: async () => ({ url: 'https://luf.test/frisch.m3u8' }) })),
|
||||
});
|
||||
const { Hls } = fakeHls({ supported: false });
|
||||
const video = fakeVideo({ native: true });
|
||||
video.currentTime = 95;
|
||||
video.paused = false;
|
||||
|
||||
attachSource(video, { Hls, source: 'https://luf.test/m.m3u8', renewUrl: 'https://luf.test/erneuern' });
|
||||
await video.listeners.error();
|
||||
expect(video.src).toBe('https://luf.test/frisch.m3u8');
|
||||
|
||||
video.listeners.loadedmetadata();
|
||||
expect(video.currentTime).toBe(95);
|
||||
expect(video.play).toHaveBeenCalledTimes(1);
|
||||
expect(video.inserted).toHaveLength(0);
|
||||
|
||||
await video.listeners.error();
|
||||
expect(video.inserted).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('zeigt die Meldung sofort und baut hls.js ab, wenn der Server die Erneuerung ablehnt', async () => {
|
||||
vi.stubGlobal('window', { fetch: vi.fn(async () => ({ ok: false, json: async () => ({}) })) });
|
||||
const { Hls, instances } = fakeHls();
|
||||
const bases = [];
|
||||
|
||||
Hls.DefaultConfig.loader = class {
|
||||
constructor() {
|
||||
this.stats = {};
|
||||
bases.push(this);
|
||||
}
|
||||
|
||||
load(context, loaderConfig, callbacks) {
|
||||
this.callbacks = callbacks;
|
||||
}
|
||||
|
||||
destroy() {}
|
||||
|
||||
abort() {}
|
||||
};
|
||||
const video = fakeVideo();
|
||||
const callbacks = { onSuccess: vi.fn(), onError: vi.fn(), onTimeout: vi.fn() };
|
||||
const context = { url: 'https://luf.test/bereich/abschnitt/1/2/3/ableitungen/3/480/s.ts' };
|
||||
|
||||
attachSource(video, { Hls, source: 'https://luf.test/m.m3u8', renewUrl: 'https://luf.test/erneuern' });
|
||||
new instances[0].config.loader({}).load(context, {}, callbacks);
|
||||
bases[0].callbacks.onError({ code: 403, text: 'Forbidden' }, context, null, {});
|
||||
await flush();
|
||||
|
||||
expect(video.inserted).toHaveLength(1);
|
||||
expect(instances[0].calls).toContainEqual(['destroy']);
|
||||
expect(callbacks.onError).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('meldet in Safari, wenn der Server keine neue Adresse gibt', async () => {
|
||||
vi.stubGlobal('window', { fetch: vi.fn(async () => ({ ok: false, json: async () => ({}) })) });
|
||||
const { Hls } = fakeHls({ supported: false });
|
||||
const video = fakeVideo({ native: true });
|
||||
|
||||
attachSource(video, { Hls, source: 'https://luf.test/m.m3u8', renewUrl: 'https://luf.test/erneuern' });
|
||||
await video.listeners.error();
|
||||
await flush();
|
||||
|
||||
expect(video.src).toBe('https://luf.test/m.m3u8');
|
||||
expect(video.inserted).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -3,4 +3,4 @@
|
||||
@if (filled($poster ?? null)) poster="{{ $poster }}" @endif
|
||||
@if (filled($class ?? null)) class="{{ $class }}" @endif
|
||||
@if (filled($style ?? null)) style="{{ $style }}" @endif
|
||||
@if (($playback['mode'] ?? 'file') === 'hls') data-hls="{{ $playback['url'] }}" @else src="{{ $playback['url'] }}" @endif></video>
|
||||
@if (($playback['mode'] ?? 'file') === 'hls') data-hls="{{ $playback['url'] }}" @if (filled($playback['renew'] ?? null)) data-hls-renew="{{ $playback['renew'] }}" @endif @else src="{{ $playback['url'] }}" @endif></video>
|
||||
@@ -33,7 +33,7 @@
|
||||
@if ($entry['playable'])
|
||||
<div class="mb-player player">
|
||||
@include('content.video', [
|
||||
'playback' => ['mode' => $entry['playback'] ?? 'file', 'url' => $entry['url']],
|
||||
'playback' => ['mode' => $entry['playback'] ?? 'file', 'url' => $entry['url'], 'renew' => $entry['renew_url'] ?? null],
|
||||
'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>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<audio controls preload="metadata" src="{{ $node['view_url'] }}"></audio>
|
||||
@else
|
||||
@include('content.video', [
|
||||
'playback' => ['mode' => $node['playback'] ?? 'file', 'url' => $node['view_url']],
|
||||
'playback' => ['mode' => $node['playback'] ?? 'file', 'url' => $node['view_url'], 'renew' => $node['renew_url'] ?? null],
|
||||
'poster' => $node['poster_url'] ?? null,
|
||||
])
|
||||
@endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
])>
|
||||
@if ($item['imageUrl'])
|
||||
<div class="card-media">
|
||||
<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">
|
||||
<img class="card-image" src="{{ $item['imageUrl'] }}" @if (! empty($item['imageSrcset'])) srcset="{{ $item['imageSrcset'] }}" sizes="{{ $item['imageSizes'] }}" @endif{!! $item['imageStyle'] !== null ? ' style="'.e($item['imageStyle']).'"' : '' !!} alt="" loading="lazy" decoding="async">
|
||||
</div>
|
||||
@endif
|
||||
<div class="card-body">
|
||||
|
||||
@@ -15,16 +15,23 @@
|
||||
$loading = ! empty($first) ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
|
||||
$videoUrl = $layout === 'photo-split' ? ($video['url'] ?? null) : null;
|
||||
$videoTitle = $video['title'] ?? '';
|
||||
// Zoom (ADR-70): Foto und Video liegen dann in einem Rahmen, der den vergrößerten Ausschnitt abschneidet.
|
||||
$zoomPercent = (int) ($zoom ?? 100);
|
||||
$zoomed = $zoomPercent > 100 && $layout === 'photo-split' && ($imageUrl || $videoUrl !== null);
|
||||
@endphp
|
||||
<div class="lf-hero-host">
|
||||
<div class="lf-hero lf-hero--{{ $layout }} lf-hero--height-{{ $heightClass }} lf-hero--accent-{{ $accent }}"
|
||||
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 ($zoomed); --lf-hero-zoom: {{ $zoomPercent / 100 }}@endif"
|
||||
@if ($videoUrl !== null) data-hero-video data-clip-src="{{ $videoUrl }}" data-clip-title="{{ $videoTitle }}" @endif>
|
||||
@if ($zoomed)<div class="lf-hero__frame">@endif
|
||||
@if ($layout === 'photo-split' && $imageUrl)
|
||||
<img class="lf-hero__photo" src="{{ $imageUrl }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="100vw"@endif alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
||||
<img class="lf-hero__photo" src="{{ $imageUrl }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="{{ \App\Domain\Cms\Widgets\Support\ImageFraming::sizes('100vw', $zoomPercent) }}"@endif alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
||||
@endif
|
||||
@if ($videoUrl !== null)
|
||||
<video class="lf-hero__video" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
||||
@endif
|
||||
@if ($zoomed)</div>@endif
|
||||
@if ($videoUrl !== null)
|
||||
<button type="button" class="lf-hero__video-toggle" aria-pressed="false" data-hero-toggle aria-label="Video abspielen: {{ $videoTitle }}" hidden>
|
||||
<svg class="lf-hero__video-icon" viewBox="0 0 24 24" focusable="false" aria-hidden="true"><path class="lf-hero__video-play" d="M8 5.5v13l11-6.5z" fill="currentColor"/><path class="lf-hero__video-pause" d="M7 5h4v14H7zM13 5h4v14h-4z" fill="currentColor"/></svg>
|
||||
<span class="lf-hero__video-label" aria-hidden="true">Video</span>
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
$tag = \App\Domain\Cms\Widgets\Support\PremiumFields::headingTag($settings, ! empty($first));
|
||||
$hasCopy = $hasCopy ?? true;
|
||||
$imageShare = $imageShare ?? null;
|
||||
// Zoom (ADR-70): Bild und Video liegen dann in einem Rahmen, der den vergrößerten Ausschnitt abschneidet.
|
||||
$zoomPercent = (int) ($zoom ?? 100);
|
||||
$zoomed = $zoomPercent > 100;
|
||||
$clipUrl = $imageUrl ? ($video['url'] ?? null) : null;
|
||||
$clipTitle = (string) ($video['title'] ?? '');
|
||||
@endphp
|
||||
@@ -27,7 +30,7 @@
|
||||
'lf-bt--without-text' => ! $hasCopy,
|
||||
'lf-bt--shared' => $imageShare !== null && $imageUrl && $hasCopy,
|
||||
'lf-bt--share-'.$imageShare => $imageShare !== null && $imageUrl && $hasCopy,
|
||||
]) style="--bt-focus-x: {{ $focus['x'] }}%; --bt-focus-y: {{ $focus['y'] }}%">
|
||||
]) style="--bt-focus-x: {{ $focus['x'] }}%; --bt-focus-y: {{ $focus['y'] }}%@if ($zoomed); --bt-zoom: {{ $zoomPercent / 100 }}@endif">
|
||||
@if ($hasCopy)
|
||||
<div class="lf-bt__copy">
|
||||
@php($lead = \App\Domain\Cms\Widgets\Support\HeadingAccent::lead($settings))
|
||||
@@ -56,8 +59,10 @@
|
||||
@endif
|
||||
@if ($imageUrl)
|
||||
<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 }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="100vw" @endif alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
||||
@if ($zoomed)<div class="lf-bt__frame">@endif
|
||||
<img class="lf-bt__image" src="{{ $imageUrl }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="{{ \App\Domain\Cms\Widgets\Support\ImageFraming::sizes('100vw', $zoomPercent) }}" @endif alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
||||
@include('widgets.partials.card-clip', ['clipFullscreen' => $clipUrl !== null && ! empty($videoFullscreen)])
|
||||
@if ($zoomed)</div>@endif
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
@elseif ($subject->public || $context->preview)
|
||||
@php
|
||||
$libraryImage = $imageUrl === null && $context->preview ? $subject->previewImage : null;
|
||||
// Zoom (ADR-70) wirkt nur auf den Ausschnitt; „Ganzes Bild“ zeigt das Bild vollständig und wird nicht vergrößert.
|
||||
$zoomPercent = ($fit ?? 'cover') === 'contain' ? 100 : (int) ($zoom ?? 100);
|
||||
$zoomed = $zoomPercent > 100;
|
||||
$panel = $imageUrl === null && $libraryImage === null ? $subject->visual : null;
|
||||
$action = $show['action'] && $subject->url !== null ? ['url' => $subject->url, 'label' => $actionLabel] : null;
|
||||
$meta = $show['meta'] ? $subject->meta : [];
|
||||
@@ -49,10 +52,11 @@
|
||||
'lf-pc--bare' => ! empty($bare),
|
||||
'lf-pc--without-visual' => $imageUrl === null && $libraryImage === null && $panel === null,
|
||||
'lf-pc--internal' => ! $subject->public,
|
||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
||||
'lf-pc--zoom' => $zoomed,
|
||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%@if ($zoomed); --pc-zoom: {{ $zoomPercent / 100 }}@endif">
|
||||
@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>
|
||||
<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">
|
||||
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" @if ($imageUrl !== null && ! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="{{ \App\Domain\Cms\Widgets\Support\ImageFraming::sizes('(min-width: 900px) 50vw, 100vw', $zoomPercent) }}" @endif alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
||||
@include('widgets.partials.card-clip')
|
||||
@if ($show['kind'] && $subject->badge !== null && empty($bare))
|
||||
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
||||
|
||||
@@ -219,6 +219,10 @@
|
||||
Route::get('/stand/{article}/{release}/bild/{text}/{version}', StandImageController::class)
|
||||
->whereNumber(['text', 'version'])
|
||||
->name('stand.image');
|
||||
Route::get('/wiedergabe/{article}/{release}/{version}/erneuern', [LibraryController::class, 'renew'])
|
||||
->whereNumber(['article', 'release', 'version'])
|
||||
->middleware('throttle:120,1')
|
||||
->name('playback.renew');
|
||||
Route::get('/abschnitt/{article}/{release}/{version}/{datei}', [LibraryController::class, 'rendition'])
|
||||
->where('datei', '.*')
|
||||
->middleware('signed:relative')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Qualitätsprüfung eines Commits: baut das Test-Image und führt Pint und die Testsuite im Wegwerf-Container aus.
|
||||
# Qualitätsprüfung eines Commits: baut das Test-Image und führt Pint und die Testsuite im Wegwerf-Container aus,
|
||||
# danach die JavaScript-Tests (Vitest, eigenes Docker-Ziel "jstest").
|
||||
# Die fachlichen Tests nutzen SQLite im Speicher (phpunit.xml). Die Migrationen laufen zusätzlich gegen eine
|
||||
# Wegwerf-Postgres, nicht gegen luf-test oder luf-prod.
|
||||
# Aufruf im ausgecheckten Repo: bash scripts/ci-test.sh
|
||||
@@ -7,6 +8,7 @@ set -euo pipefail
|
||||
|
||||
SHA="$(git rev-parse --short=12 HEAD)"
|
||||
IMG="luf-ci-test:$SHA"
|
||||
JSIMG="luf-ci-js:$SHA"
|
||||
NET="luf-ci-$SHA"
|
||||
PG="luf-ci-pg-$SHA"
|
||||
|
||||
@@ -14,6 +16,7 @@ cleanup() {
|
||||
docker rm -f "$PG" >/dev/null 2>&1 || true
|
||||
docker network rm "$NET" >/dev/null 2>&1 || true
|
||||
docker rmi -f "$IMG" >/dev/null 2>&1 || true
|
||||
docker rmi -f "$JSIMG" >/dev/null 2>&1 || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
@@ -26,6 +29,10 @@ docker run --rm \
|
||||
-e APP_KEY="base64:$(head -c 32 /dev/urandom | base64)" \
|
||||
"$IMG"
|
||||
|
||||
echo "=== JavaScript-Tests (Vitest) ==="
|
||||
docker build --target jstest -t "$JSIMG" .
|
||||
docker run --rm "$JSIMG"
|
||||
|
||||
echo "=== Migrationen gegen Wegwerf-Postgres ==="
|
||||
docker network create "$NET"
|
||||
docker run -d --name "$PG" --network "$NET" \
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\Support\ImageFraming;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Livewire\Component;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Bildausschnitt und Zoom (ADR-70): Karten tragen ihn je Karte, Einstieg, Bild und Text und die Premium-Karten je Widget.
|
||||
* Ohne gesetzten Wert bleibt die Ausgabe unverändert.
|
||||
*/
|
||||
class CmsImageFramingTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('media_public');
|
||||
Storage::disk('media_public')->put('cms/bild.jpg', 'bild');
|
||||
}
|
||||
|
||||
public function test_a_card_with_framing_gets_position_origin_scale_and_a_larger_source_size(): void
|
||||
{
|
||||
$html = $this->publish('/karten', [$this->cards([
|
||||
['title' => 'Eng', 'image' => 'cms/bild.jpg', 'focus_x' => 30, 'focus_y' => 0, 'zoom' => 180],
|
||||
['title' => 'Normal', 'image' => 'cms/bild.jpg'],
|
||||
])]);
|
||||
|
||||
$this->assertStringContainsString('style="object-position: 30% 0%; transform-origin: 30% 0%; scale: 1.8"', $html);
|
||||
$this->assertSame(1, substr_count($html, 'style="object-position'), 'Die Karte ohne Ausschnitt trägt keinen Stil.');
|
||||
$this->assertStringContainsString('class="card-image" src=', $html);
|
||||
}
|
||||
|
||||
public function test_cards_without_framing_render_exactly_as_before(): void
|
||||
{
|
||||
$html = $this->publish('/karten-alt', [$this->cards([['title' => 'Alt', 'image' => 'cms/bild.jpg']])]);
|
||||
|
||||
$this->assertDoesNotMatchRegularExpression('/<img class="card-image"[^>]* style=/', $html);
|
||||
$this->assertStringNotContainsString('transform-origin', $html);
|
||||
}
|
||||
|
||||
public function test_the_framing_of_a_card_is_saved_only_when_it_differs_and_only_with_an_image(): void
|
||||
{
|
||||
$page = Page::query()->create(['path' => '/karten-speichern']);
|
||||
$service = app(PageService::class);
|
||||
$revision = $service->saveRevision($page, [$this->cards([
|
||||
['title' => 'Ausschnitt', 'image' => 'cms/bild.jpg', 'focus_x' => 20, 'focus_y' => 50, 'zoom' => 150],
|
||||
['title' => 'Vorgabe', 'image' => 'cms/bild.jpg', 'focus_x' => 50, 'focus_y' => 50, 'zoom' => 100],
|
||||
['title' => 'Ohne Bild', 'focus_x' => 10, 'zoom' => 200],
|
||||
])], null, null, null);
|
||||
|
||||
$items = $revision->sections[0]['slots'][0]['data']['items'];
|
||||
|
||||
$this->assertSame(20, $items[0]['focus_x']);
|
||||
$this->assertSame(150, $items[0]['zoom']);
|
||||
$this->assertArrayNotHasKey('focus_y', $items[0], 'Die Mitte ist die Vorgabe und wird nicht gespeichert.');
|
||||
$this->assertArrayNotHasKey('focus_x', $items[1]);
|
||||
$this->assertArrayNotHasKey('zoom', $items[1]);
|
||||
$this->assertArrayNotHasKey('zoom', $items[2]);
|
||||
}
|
||||
|
||||
public function test_a_zoom_above_the_cap_is_rejected(): void
|
||||
{
|
||||
$page = Page::query()->create(['path' => '/karten-zu-gross']);
|
||||
|
||||
$this->expectException(ValidationException::class);
|
||||
|
||||
app(PageService::class)->saveRevision($page, [$this->cards([['title' => 'X', 'image' => 'cms/bild.jpg', 'zoom' => 400]])], null, null, null);
|
||||
}
|
||||
|
||||
public function test_the_hero_puts_photo_and_video_into_a_clipping_frame_only_with_zoom(): void
|
||||
{
|
||||
$zoomed = $this->publish('/einstieg-zoom', [$this->widget('hero', 'photo_split', ['heading' => 'Stark', 'focus_x' => 40, 'focus_y' => 10, 'zoom' => 160], ['image' => 'cms/bild.jpg'])]);
|
||||
|
||||
$this->assertStringContainsString('--lf-hero-focus-x: 40%; --lf-hero-focus-y: 10%; --lf-hero-zoom: 1.6', $zoomed);
|
||||
$this->assertMatchesRegularExpression('#<div class="lf-hero__frame">\s*<img class="lf-hero__photo"#', $zoomed);
|
||||
|
||||
$plain = $this->publish('/einstieg-ohne', [$this->widget('hero', 'photo_split', ['heading' => 'Stark'], ['image' => 'cms/bild.jpg'])]);
|
||||
|
||||
$this->assertStringNotContainsString('lf-hero__frame', $plain);
|
||||
$this->assertStringNotContainsString('--lf-hero-zoom', $plain);
|
||||
}
|
||||
|
||||
public function test_image_and_text_wraps_the_image_in_a_frame_only_with_zoom(): void
|
||||
{
|
||||
$zoomed = $this->publish('/bt-zoom', [$this->widget('image_text', 'image_left', ['title' => 'Bild', 'body' => '<p>Text</p>', 'zoom' => 200], ['image' => 'cms/bild.jpg'])]);
|
||||
|
||||
$this->assertStringContainsString('--bt-zoom: 2', $zoomed);
|
||||
$this->assertMatchesRegularExpression('#<div class="lf-bt__frame">\s*<img class="lf-bt__image"#', $zoomed);
|
||||
|
||||
$plain = $this->publish('/bt-ohne', [$this->widget('image_text', 'image_left', ['title' => 'Bild', 'body' => '<p>Text</p>'], ['image' => 'cms/bild.jpg'])]);
|
||||
|
||||
$this->assertStringNotContainsString('lf-bt__frame', $plain);
|
||||
$this->assertStringNotContainsString('--bt-zoom', $plain);
|
||||
}
|
||||
|
||||
public function test_the_premium_card_zooms_the_cut_out_but_never_the_whole_image(): void
|
||||
{
|
||||
$pillars = app(PillarService::class);
|
||||
$pillar = $pillars->create('Hilfe holen');
|
||||
$pillars->present($pillar, 'Hilfe holen', 'hilfe-holen', 'Kurztext', true, 10);
|
||||
|
||||
$cover = $this->publish('/pc-zoom', [$this->widget('topic_card', 'adaptive', ['alt' => 'Park', 'zoom' => 150], ['pillar' => $pillar->id, 'image' => 'cms/bild.jpg'])]);
|
||||
$this->assertStringContainsString('lf-pc--zoom', $cover);
|
||||
$this->assertStringContainsString('--pc-zoom: 1.5', $cover);
|
||||
|
||||
$contain = $this->publish('/pc-ganz', [$this->widget('topic_card', 'adaptive', ['alt' => 'Park', 'zoom' => 150], ['pillar' => $pillar->id, 'image' => 'cms/bild.jpg'], ['fit' => 'contain'])]);
|
||||
$this->assertStringNotContainsString('lf-pc--zoom', $contain);
|
||||
$this->assertStringNotContainsString('--pc-zoom', $contain);
|
||||
}
|
||||
|
||||
public function test_every_zooming_stylesheet_keeps_the_frame_filled_and_clipped(): void
|
||||
{
|
||||
$hero = (string) file_get_contents(resource_path('css/components/lf-hero.css'));
|
||||
$text = (string) file_get_contents(resource_path('css/components/lf-bild-text.css'));
|
||||
$card = (string) file_get_contents(resource_path('css/components/lf-premium-card.css'));
|
||||
|
||||
$this->assertMatchesRegularExpression('/\.lf-hero__frame\s*\{[^}]*overflow: hidden/', $hero);
|
||||
$this->assertMatchesRegularExpression('/\.lf-bt__frame\s*\{[^}]*overflow: hidden/', $text);
|
||||
$this->assertMatchesRegularExpression('/\.lf-pc--zoom \.lf-pc__visual\s*\{[^}]*overflow: hidden/', $card);
|
||||
$this->assertStringContainsString('scale: var(--lf-hero-zoom, 1)', $hero);
|
||||
$this->assertStringContainsString('scale: var(--bt-zoom, 1)', $text);
|
||||
$this->assertStringContainsString('scale: var(--pc-zoom, 1)', $card);
|
||||
}
|
||||
|
||||
public function test_the_dialogs_offer_a_zoom_slider_next_to_the_focus(): void
|
||||
{
|
||||
$hero = app(WidgetRegistry::class)->get('hero');
|
||||
$fields = collect($hero->mediaSchema())->flatMap(fn ($group) => $group->getDefaultChildComponents())->keyBy(fn ($field) => method_exists($field, 'getName') ? $field->getName() : spl_object_id($field));
|
||||
|
||||
$this->assertInstanceOf(Slider::class, $fields['zoom']);
|
||||
$this->assertInstanceOf(Slider::class, $fields['focus_x']);
|
||||
}
|
||||
|
||||
public function test_the_sliders_show_the_default_of_the_widget_when_nothing_is_saved_and_keep_saved_values(): void
|
||||
{
|
||||
$livewire = new class extends Component implements HasSchemas
|
||||
{
|
||||
use InteractsWithSchemas;
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
// Filaments Regler machte aus „kein Wert“ eine 0 und zeigte sie statt der Vorgabe der Darstellung.
|
||||
Schema::make($livewire)->statePath('data')
|
||||
->components(ImageFraming::sliders(68, 50))
|
||||
->fill(['focus_y' => 0, 'zoom' => 150]);
|
||||
|
||||
$this->assertSame(68, $livewire->data['focus_x']);
|
||||
$this->assertSame(0, (int) $livewire->data['focus_y'], 'Ein gespeicherter Wert 0 bleibt 0.');
|
||||
$this->assertSame(150, (int) $livewire->data['zoom']);
|
||||
|
||||
Schema::make($livewire)->statePath('data')
|
||||
->components(ImageFraming::sliders())
|
||||
->fill([]);
|
||||
|
||||
$this->assertSame([50, 50, 100], [$livewire->data['focus_x'], $livewire->data['focus_y'], $livewire->data['zoom']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $items
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function cards(array $items): array
|
||||
{
|
||||
return ['type' => 'cards', 'v' => 2, 'settings' => [], 'data' => ['items' => $items]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
* @param array<string, mixed> $refs
|
||||
* @param array<string, mixed> $settings
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function widget(string $type, string $variant, array $data, array $refs = [], array $settings = []): array
|
||||
{
|
||||
return ['type' => $type, 'v' => $type === 'hero' ? 2 : ($type === 'image_text' ? 3 : 1), 'variant' => $variant, 'settings' => $settings, 'data' => $data, 'refs' => $refs];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $widgets
|
||||
*/
|
||||
private function publish(string $path, array $widgets): string
|
||||
{
|
||||
$page = Page::query()->create(['path' => $path]);
|
||||
$service = app(PageService::class);
|
||||
$service->publish($page, $service->saveRevision($page, [['layout' => 'u4', 'style' => [], 'slots' => $widgets]], null, null, null));
|
||||
|
||||
return $this->get($path)->assertOk()->getContent();
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,22 @@ public function test_the_page_shows_classes_instead_of_inline_styles(): void
|
||||
$this->assertSame('<p class="ta-center">x</p>', ProseWidget::render('<p style="text-align: center">x</p>'));
|
||||
}
|
||||
|
||||
public function test_a_text_that_starts_with_a_level_two_heading_is_shown_formatted_and_not_as_markup(): void
|
||||
{
|
||||
// Zugeliefert (Import, Einfügen aus einem anderen Text): beginnt mit h2, nicht mit einem Absatz.
|
||||
$body = '<h2>Was Kinder üben</h2><p>Text mit <strong>fett</strong>.</p><h3>Nein sagen</h3><ul><li><p>Eigene Ideen</p></li><li><p>Pause nutzen</p></li></ul>';
|
||||
$page = Page::query()->create(['path' => '/ueberschrift-zwei']);
|
||||
$service = app(PageService::class);
|
||||
$service->publish($page, $service->saveRevision($page, [['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'prose', 'v' => 2, 'settings' => [], 'data' => ['body' => $body]]]]], null, null, null));
|
||||
|
||||
$html = $this->get('/ueberschrift-zwei')->assertOk()->getContent();
|
||||
|
||||
$this->assertStringContainsString('<h3>Was Kinder üben</h3><p>Text mit <strong>fett</strong>.</p><h3>Nein sagen</h3><ul><li><p>Eigene Ideen</p></li><li><p>Pause nutzen</p></li></ul>', $html);
|
||||
$this->assertStringNotContainsString('<h2>', $html);
|
||||
$this->assertStringNotContainsString('<p>', $html);
|
||||
$this->assertStringContainsString('<h3>Was Kinder üben</h3>', ProseWidget::render($body));
|
||||
}
|
||||
|
||||
public function test_the_stylesheet_knows_every_size_and_color(): void
|
||||
{
|
||||
$css = (string) file_get_contents(resource_path('css/widgets.css'));
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Media\FilmPlayback;
|
||||
use App\Domain\Media\FilmTranscoder;
|
||||
@@ -16,6 +12,7 @@
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\Support\BuildsFilmFixtures;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -25,6 +22,7 @@
|
||||
*/
|
||||
class FilmRenditionCarryOverTest extends TestCase
|
||||
{
|
||||
use BuildsFilmFixtures;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_a_new_film_version_without_a_new_file_keeps_streaming_over_hls(): void
|
||||
@@ -157,38 +155,4 @@ public function test_the_editorial_preview_streams_the_carried_over_renditions()
|
||||
->get(route('content.rendition', ['version' => $second, 'datei' => 'ableitungen/999999/480/segment.ts']))
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: ContentElementVersion, 1: ContentElement}
|
||||
*/
|
||||
private function filmWithRenditions(string $title, string $file): array
|
||||
{
|
||||
Storage::disk('media_derived')->put($file, 'filmbytes');
|
||||
$content = app(ContentService::class);
|
||||
$element = $content->createElement('film', 'film', $title);
|
||||
$version = $content->publishElementVersion($element, null, ['file' => $file]);
|
||||
$base = 'ableitungen/'.$version->id;
|
||||
Storage::disk('media_derived')->put($base.'/480/index.m3u8', "#EXTM3U\n#EXTINF:6.0,\nsegment.ts\n");
|
||||
Storage::disk('media_derived')->put($base.'/480/segment.ts', 'segment-bytes');
|
||||
Storage::disk('media_derived')->put($base.'/master.m3u8', "#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=800000\n480/index.m3u8\n");
|
||||
MediaRendition::query()->create(['content_element_version_id' => $version->id, 'role' => 'variant', 'label' => '480', 'path' => $base.'/480/index.m3u8']);
|
||||
MediaRendition::query()->create(['content_element_version_id' => $version->id, 'role' => 'master', 'label' => 'master', 'path' => $base.'/master.m3u8']);
|
||||
|
||||
return [$version, $element];
|
||||
}
|
||||
|
||||
private function offerFor($version, array $capabilities): array
|
||||
{
|
||||
$articles = app(ArticleService::class);
|
||||
$offers = app(OfferService::class);
|
||||
$article = $articles->create('ausgabe-'.str()->random(6));
|
||||
$release = $articles->publishRelease($article, $version, 'Stand.');
|
||||
$rights = $offers->createRightsProfile('Rechte '.str()->random(4), 'ehrenamtlich', $capabilities);
|
||||
$offer = $offers->create('Angebot '.str()->random(4));
|
||||
$offers->activate($offer, [
|
||||
['target' => $article->fresh(), 'rights' => $rights],
|
||||
], ['grant_kind' => 'auf_abruf']);
|
||||
|
||||
return [$article->fresh(), $offer, $release];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Entitlement\MediaDelivery;
|
||||
use App\Domain\Media\FileChecksum;
|
||||
use App\Http\SignedLink;
|
||||
use App\Jobs\StoreContentFile;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\Support\BuildsFilmFixtures;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Filme ohne HLS-Stufen (Dateimodus) und Downloads im Mitgliederbereich: Bereichsabrufe (206/416) wie bei der
|
||||
* Website, damit Safari und iOS abspielen und Springen möglich ist. Der Auslieferungsnachweis zählt eine Auslieferung,
|
||||
* nicht jeden Teilabruf; die Prüfsumme wird je Datei einmal berechnet.
|
||||
*/
|
||||
class MemberFileRangesTest extends TestCase
|
||||
{
|
||||
use BuildsFilmFixtures;
|
||||
use RefreshDatabase;
|
||||
|
||||
private const BODY = '0123456789abcdefghij';
|
||||
|
||||
public function test_a_ranged_request_gets_only_the_requested_bytes(): void
|
||||
{
|
||||
[$member, $url] = $this->fileFilm('streamen');
|
||||
|
||||
$response = $this->actingAs($member)->get($url, ['Range' => 'bytes=2-5']);
|
||||
|
||||
$response->assertStatus(206);
|
||||
$response->assertHeader('Content-Range', 'bytes 2-5/'.strlen(self::BODY));
|
||||
$response->assertHeader('Accept-Ranges', 'bytes');
|
||||
$this->assertSame('2345', $response->streamedContent());
|
||||
|
||||
$open = $this->actingAs($member)->get($url, ['Range' => 'bytes=15-']);
|
||||
$open->assertStatus(206);
|
||||
$this->assertSame('fghij', $open->streamedContent());
|
||||
|
||||
$suffix = $this->actingAs($member)->get($url, ['Range' => 'bytes=-3']);
|
||||
$this->assertSame('hij', $suffix->streamedContent());
|
||||
}
|
||||
|
||||
public function test_an_unsatisfiable_range_gets_416_and_a_plain_request_gets_everything(): void
|
||||
{
|
||||
[$member, $url] = $this->fileFilm('streamen');
|
||||
|
||||
$this->actingAs($member)->get($url, ['Range' => 'bytes=500-600'])
|
||||
->assertStatus(416)
|
||||
->assertHeader('Content-Range', 'bytes */'.strlen(self::BODY));
|
||||
|
||||
$plain = $this->actingAs($member)->get($url);
|
||||
$plain->assertOk();
|
||||
$plain->assertHeader('Accept-Ranges', 'bytes');
|
||||
$this->assertSame(self::BODY, $plain->streamedContent());
|
||||
}
|
||||
|
||||
public function test_a_download_keeps_its_file_name_and_supports_resuming(): void
|
||||
{
|
||||
[$member, $url] = $this->fileFilm('laden');
|
||||
|
||||
$whole = $this->actingAs($member)->get($url);
|
||||
$whole->assertOk();
|
||||
$this->assertStringContainsString('attachment', (string) $whole->headers->get('Content-Disposition'));
|
||||
$this->assertStringContainsString('Hofszene.mp4', rawurldecode((string) $whole->headers->get('Content-Disposition')));
|
||||
|
||||
$part = $this->actingAs($member)->get($url, ['Range' => 'bytes=10-']);
|
||||
$part->assertStatus(206);
|
||||
$this->assertStringContainsString('attachment', (string) $part->headers->get('Content-Disposition'));
|
||||
$this->assertStringContainsString('Hofszene.mp4', rawurldecode((string) $part->headers->get('Content-Disposition')));
|
||||
$this->assertSame('abcdefghij', $part->streamedContent());
|
||||
}
|
||||
|
||||
public function test_partial_requests_count_as_one_delivery_and_a_new_plain_request_counts_again(): void
|
||||
{
|
||||
[$member, $url] = $this->fileFilm('streamen');
|
||||
|
||||
$this->actingAs($member)->get($url, ['Range' => 'bytes=0-1'])->assertStatus(206);
|
||||
$this->actingAs($member)->get($url, ['Range' => 'bytes=2-9'])->assertStatus(206);
|
||||
$this->actingAs($member)->get($url, ['Range' => 'bytes=10-'])->assertStatus(206);
|
||||
|
||||
$this->assertSame(1, MediaDelivery::query()->count(), 'Teilabrufe derselben Wiedergabe zählen einmal.');
|
||||
$row = MediaDelivery::query()->firstOrFail();
|
||||
$this->assertSame('streamen', $row->action);
|
||||
$this->assertSame(hash('sha256', self::BODY), $row->checksum);
|
||||
|
||||
$this->actingAs($member)->get($url)->assertOk();
|
||||
$this->assertSame(2, MediaDelivery::query()->count(), 'Ein vollständiger Abruf ist eine eigene Auslieferung.');
|
||||
}
|
||||
|
||||
public function test_a_resumed_range_without_any_earlier_record_still_leaves_a_record(): void
|
||||
{
|
||||
[$member, $url] = $this->fileFilm('streamen');
|
||||
|
||||
$this->actingAs($member)->get($url, ['Range' => 'bytes=10-'])->assertStatus(206);
|
||||
|
||||
$this->assertSame(1, MediaDelivery::query()->count());
|
||||
}
|
||||
|
||||
public function test_the_checksum_is_computed_once_per_file(): void
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
Cache::flush();
|
||||
Storage::disk('media_derived')->put('inhalte/a.mp4', 'inhalt eins');
|
||||
$checksum = app(FileChecksum::class);
|
||||
|
||||
$first = $checksum->of('media_derived', 'inhalte/a.mp4');
|
||||
$this->assertSame(hash('sha256', 'inhalt eins'), $first);
|
||||
|
||||
// Gleiche Größe und gleicher Zeitstempel: der gemerkte Wert gilt, die Datei wird nicht erneut gelesen.
|
||||
$path = Storage::disk('media_derived')->path('inhalte/a.mp4');
|
||||
$time = filemtime($path);
|
||||
file_put_contents($path, 'INHALT EINS');
|
||||
touch($path, $time);
|
||||
clearstatcache();
|
||||
$this->assertSame($first, $checksum->of('media_derived', 'inhalte/a.mp4'));
|
||||
|
||||
// Andere Größe: neu berechnen.
|
||||
file_put_contents($path, 'ganz anderer inhalt');
|
||||
clearstatcache();
|
||||
$this->assertSame(hash('sha256', 'ganz anderer inhalt'), $checksum->of('media_derived', 'inhalte/a.mp4'));
|
||||
|
||||
$this->assertNull($checksum->of('media_derived', 'inhalte/gibtesnicht.mp4'));
|
||||
}
|
||||
|
||||
public function test_storing_a_new_file_warms_the_checksum(): void
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('cms_incoming');
|
||||
Cache::flush();
|
||||
Storage::disk('cms_incoming')->put('inhalte/neu.mp4', 'frischer film');
|
||||
$element = app(ContentService::class)->createElement('film', 'film', 'Neu');
|
||||
$version = $element->versions()->create([
|
||||
'number' => 1,
|
||||
'status' => ContentVersionStatus::Entwurf,
|
||||
'content_hash' => hash('sha256', 'x'),
|
||||
'metadata' => ['incoming' => 'inhalte/neu.mp4'],
|
||||
]);
|
||||
|
||||
app(StoreContentFile::class, ['versionId' => $version->id, 'source' => 'inhalte/neu.mp4'])->handle();
|
||||
|
||||
$stored = $version->fresh()->metadata['file'];
|
||||
$path = Storage::disk('media_derived')->path($stored);
|
||||
$time = filemtime($path);
|
||||
file_put_contents($path, 'FRISCHER FILM');
|
||||
touch($path, $time);
|
||||
clearstatcache();
|
||||
|
||||
$this->assertSame(hash('sha256', 'frischer film'), app(FileChecksum::class)->of('media_derived', $stored), 'Der Wert wurde schon beim Speichern gemerkt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: User, 1: string}
|
||||
*/
|
||||
private function fileFilm(string $action): array
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
Cache::flush();
|
||||
Storage::disk('media_derived')->put('inhalte/hof.mp4', self::BODY);
|
||||
$content = app(ContentService::class);
|
||||
$element = $content->createElement('film', 'film', 'Hofszene');
|
||||
$version = $content->publishElementVersion($element, null, ['file' => 'inhalte/hof.mp4']);
|
||||
[$article, $offer, $release] = $this->offerFor($version, ['film' => ['streamen', 'laden']]);
|
||||
$member = User::factory()->create();
|
||||
app(GrantIssuer::class)->claim($member, $offer);
|
||||
|
||||
return [$member, SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
'action' => $action,
|
||||
'reader' => $member->id,
|
||||
])];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Entitlement\MediaDelivery;
|
||||
use App\Http\SignedLink;
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\Support\BuildsFilmFixtures;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Wiedergabe über HLS im Mitgliederbereich: Laufzeit der Abschnittsadressen und Erneuerung ohne neue Auslieferung.
|
||||
* Die Adressen gelten Filmlänge plus Reserve (config media.*). Jeder Abruf prüft ohnehin Anmeldung und DecideAccess;
|
||||
* eine längere Laufzeit verlängert deshalb nicht die Nachlaufzeit nach einem Entzug.
|
||||
*/
|
||||
class PlaybackRenewalTest extends TestCase
|
||||
{
|
||||
use BuildsFilmFixtures;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
CarbonImmutable::setTestNow('2026-12-01 10:00:00');
|
||||
config(['media.stream_reserve_minutes' => 60, 'media.stream_max_minutes' => 720, 'media.stream_fallback_minutes' => 240]);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
CarbonImmutable::setTestNow();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_segment_links_live_for_the_film_length_plus_a_reserve(): void
|
||||
{
|
||||
[$member, $article, $release, $version] = $this->member();
|
||||
|
||||
$master = $this->actingAs($member)->get($this->mediaUrl($member, $article, $release, $version))->assertOk()->getContent();
|
||||
$variantUrl = $this->firstUrl($master);
|
||||
$this->assertEqualsWithDelta(now()->addSeconds(6)->addMinutes(60)->getTimestamp(), $this->expiry($variantUrl), 2);
|
||||
|
||||
$variant = $this->actingAs($member)->get($variantUrl)->assertOk()->getContent();
|
||||
$this->assertEqualsWithDelta(now()->addSeconds(6)->addMinutes(60)->getTimestamp(), $this->expiry($this->firstUrl($variant)), 2);
|
||||
}
|
||||
|
||||
public function test_the_lifetime_is_capped(): void
|
||||
{
|
||||
config(['media.stream_max_minutes' => 30]);
|
||||
[$member, $article, $release, $version] = $this->member();
|
||||
|
||||
$master = $this->actingAs($member)->get($this->mediaUrl($member, $article, $release, $version))->getContent();
|
||||
|
||||
$this->assertEqualsWithDelta(now()->addMinutes(30)->getTimestamp(), $this->expiry($this->firstUrl($master)), 2);
|
||||
}
|
||||
|
||||
public function test_an_expired_segment_link_is_refused_and_a_revoked_grant_stops_a_valid_one_at_once(): void
|
||||
{
|
||||
[$member, $article, $release, $version, $base] = $this->member();
|
||||
$segment = $this->renditionUrl($member, $article, $release, $version, $base.'/480/segment.ts', 60);
|
||||
|
||||
$this->actingAs($member)->get($segment)->assertOk();
|
||||
|
||||
// Entzug: Die Signatur ist noch lange gültig, der Abruf prüft DecideAccess aber bei jeder Anfrage.
|
||||
Grant::query()->update(['status' => GrantStatus::Widerrufen]);
|
||||
$this->actingAs($member)->get($segment)->assertForbidden();
|
||||
|
||||
Grant::query()->update(['status' => GrantStatus::Aktiv]);
|
||||
$this->actingAs($member)->get($segment)->assertOk();
|
||||
|
||||
$this->travel(61)->minutes();
|
||||
$this->actingAs($member)->get($segment)->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_renewal_gives_a_fresh_master_link_and_writes_nothing(): void
|
||||
{
|
||||
[$member, $article, $release, $version] = $this->member();
|
||||
$this->actingAs($member)->get($this->mediaUrl($member, $article, $release, $version))->assertOk();
|
||||
$this->assertSame(1, MediaDelivery::query()->count());
|
||||
|
||||
$this->travel(30)->minutes();
|
||||
$response = $this->actingAs($member)->getJson(route('member.playback.renew', [$article, $release, $version]))
|
||||
->assertOk()
|
||||
->assertHeader('cache-control', 'no-store, private');
|
||||
$url = $response->json('url');
|
||||
|
||||
$this->assertIsString($url);
|
||||
$this->assertSame(1, MediaDelivery::query()->count(), 'Die Erneuerung selbst schreibt keinen Nachweis.');
|
||||
$this->assertGreaterThan(now()->addMinutes(5)->getTimestamp(), $this->expiry($url));
|
||||
$this->actingAs($member)->get($url)->assertOk()->assertHeader('content-type', 'application/vnd.apple.mpegurl');
|
||||
$this->assertSame(2, MediaDelivery::query()->count(), 'Der Abruf der Hauptliste ist die Auslieferung.');
|
||||
}
|
||||
|
||||
public function test_renewal_of_a_rendition_file_is_signed_for_that_file_and_not_counted_again(): void
|
||||
{
|
||||
[$member, $article, $release, $version, $base] = $this->member();
|
||||
$this->actingAs($member)->get($this->mediaUrl($member, $article, $release, $version))->assertOk();
|
||||
$this->actingAs($member)->get($this->renditionUrl($member, $article, $release, $version, $base.'/480/index.m3u8', 60))->assertOk();
|
||||
$this->travel(90)->minutes();
|
||||
|
||||
$url = $this->actingAs($member)->getJson(route('member.playback.renew', [$article, $release, $version, 'datei' => $base.'/480/segment.ts']))
|
||||
->assertOk()
|
||||
->json('url');
|
||||
|
||||
$this->assertStringContainsString('/abschnitt/'.$article->id.'/'.$release->id.'/'.$version->id.'/'.$base.'/480/segment.ts', $url);
|
||||
$this->assertGreaterThan(now()->addMinutes(30)->getTimestamp(), $this->expiry($url));
|
||||
$this->actingAs($member)->get($url)->assertOk()->assertStreamedContent('segment-bytes');
|
||||
$this->assertSame(1, MediaDelivery::query()->count(), 'Abschnitte und Erneuerung schreiben nichts; die Hauptliste schrieb einmal.');
|
||||
}
|
||||
|
||||
public function test_renewal_cannot_be_used_to_stream_without_ever_being_logged(): void
|
||||
{
|
||||
[$member, $article, $release, $version, $base] = $this->member();
|
||||
|
||||
$this->actingAs($member)->getJson(route('member.playback.renew', [$article, $release, $version, 'datei' => $base.'/480/segment.ts']))->assertOk();
|
||||
$this->assertSame(1, MediaDelivery::query()->count(), 'Ohne früheren Nachweis schreibt die Erneuerung genau einen.');
|
||||
$row = MediaDelivery::query()->firstOrFail();
|
||||
$this->assertSame('streamen', $row->action);
|
||||
$this->assertSame($version->id, $row->content_element_version_id);
|
||||
|
||||
$this->actingAs($member)->getJson(route('member.playback.renew', [$article, $release, $version, 'datei' => $base.'/480/segment.ts']))->assertOk();
|
||||
$this->assertSame(1, MediaDelivery::query()->count(), 'Danach zählt nichts mehr innerhalb der Laufzeit.');
|
||||
}
|
||||
|
||||
public function test_a_new_playback_after_the_lifetime_is_counted_again(): void
|
||||
{
|
||||
[$member, $article, $release, $version, $base] = $this->member();
|
||||
$this->actingAs($member)->get($this->mediaUrl($member, $article, $release, $version))->assertOk();
|
||||
|
||||
$this->travel(13)->hours();
|
||||
$this->actingAs($member)->getJson(route('member.playback.renew', [$article, $release, $version, 'datei' => $base.'/480/segment.ts']))->assertOk();
|
||||
|
||||
$this->assertSame(2, MediaDelivery::query()->count());
|
||||
}
|
||||
|
||||
public function test_renewal_is_refused_for_strangers_revoked_grants_and_mismatched_tuples(): void
|
||||
{
|
||||
[$member, $article, $release, $version, $base] = $this->member();
|
||||
[$foreignVersion] = $this->filmWithRenditions('Fremdfilm', 'inhalte/fremd.mp4');
|
||||
[$otherArticle, , $otherRelease] = $this->offerFor($foreignVersion, ['film' => ['streamen']]);
|
||||
$stranger = User::factory()->create();
|
||||
$renew = fn ($article, $release, $version, ?string $file = null) => route('member.playback.renew', [$article, $release, $version] + ($file === null ? [] : ['datei' => $file]));
|
||||
|
||||
// Ohne Anmeldung.
|
||||
$this->getJson($renew($article, $release, $version))->assertUnauthorized();
|
||||
// Ohne Berechtigung.
|
||||
$this->actingAs($stranger)->getJson($renew($article, $release, $version))->assertForbidden();
|
||||
// Fassung gehört nicht zum Stand, Stand nicht zum Artikel.
|
||||
$this->actingAs($member)->getJson($renew($article, $release, $foreignVersion))->assertForbidden();
|
||||
$this->actingAs($member)->getJson($renew($article, $otherRelease, $version))->assertForbidden();
|
||||
$this->actingAs($member)->getJson($renew($otherArticle, $release, $version))->assertForbidden();
|
||||
// Datei einer anderen Fassung, Pfadtricks, fehlende Datei.
|
||||
$this->actingAs($member)->getJson($renew($article, $release, $version, 'ableitungen/'.$foreignVersion->id.'/480/segment.ts'))->assertNotFound();
|
||||
$this->actingAs($member)->getJson($renew($article, $release, $version, $base.'/../x'))->assertNotFound();
|
||||
$this->actingAs($member)->getJson($renew($article, $release, $version, $base.'/480/gibtesnicht.ts'))->assertNotFound();
|
||||
// Entzug.
|
||||
Grant::query()->update(['status' => GrantStatus::Widerrufen]);
|
||||
$this->actingAs($member)->getJson($renew($article, $release, $version))->assertForbidden();
|
||||
$this->assertSame(0, MediaDelivery::query()->count());
|
||||
}
|
||||
|
||||
public function test_the_member_page_offers_the_renewal_address_to_the_player(): void
|
||||
{
|
||||
[$member, $article, $release, $version] = $this->member();
|
||||
|
||||
$this->actingAs($member)->get(route('member.article', $article))
|
||||
->assertOk()
|
||||
->assertSee('data-hls-renew="'.route('member.playback.renew', [$article, $release, $version]).'"', false);
|
||||
}
|
||||
|
||||
public function test_the_film_page_inside_a_program_offers_the_renewal_address_of_the_releasing_article(): void
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
[$film] = $this->filmWithRenditions('Hofszene', 'inhalte/hof.mp4');
|
||||
$content = app(ContentService::class);
|
||||
$programm = EditorialContentKind::query()->where('slug', 'programm')->firstOrFail();
|
||||
$released = $content->publishComposition(
|
||||
tap($content->createComposition('Sicher auf dem Schulweg'), function ($item) use ($programm): void {
|
||||
$item->editorial_content_kind_id = $programm->id;
|
||||
$item->save();
|
||||
}),
|
||||
[['role' => 'Film', 'target' => $film]],
|
||||
);
|
||||
$articles = app(ArticleService::class);
|
||||
$article = $articles->create('programm-wiedergabe');
|
||||
$release = $articles->publishRelease($article, $released, 'Programmartikel.');
|
||||
$offers = app(OfferService::class);
|
||||
$rights = $offers->createRightsProfile('Film', 'ehrenamtlich', ['film' => ['streamen']]);
|
||||
$offer = $offers->create('Programmzugang');
|
||||
$offers->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
|
||||
$member = User::factory()->create();
|
||||
app(GrantIssuer::class)->claim($member, $offer);
|
||||
app(CompositionDisplayRelease::class)->release($released, $member);
|
||||
|
||||
$this->actingAs($member)
|
||||
->get(route('member.content', ['composition' => $released->composition->id, 'version' => $film->id]))
|
||||
->assertOk()
|
||||
->assertSee('data-hls-renew="'.route('member.playback.renew', [$article->id, $release->id, $film->id]).'"', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: User, 1: LicenseArticle, 2: ArticleRelease, 3: ContentElementVersion, 4: string}
|
||||
*/
|
||||
private function member(): array
|
||||
{
|
||||
Storage::fake('media_derived');
|
||||
[$version] = $this->filmWithRenditions('Hofszene', 'inhalte/hof.mp4');
|
||||
[$article, $offer, $release] = $this->offerFor($version, ['film' => ['streamen']]);
|
||||
$member = User::factory()->create();
|
||||
app(GrantIssuer::class)->claim($member, $offer);
|
||||
|
||||
return [$member, $article, $release, $version, 'ableitungen/'.$version->id];
|
||||
}
|
||||
|
||||
private function mediaUrl(User $member, $article, $release, $version): string
|
||||
{
|
||||
return SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
'action' => 'streamen',
|
||||
'reader' => $member->id,
|
||||
]);
|
||||
}
|
||||
|
||||
private function renditionUrl(User $member, $article, $release, $version, string $path, int $minutes): string
|
||||
{
|
||||
return SignedLink::temporary('member.rendition', now()->addMinutes($minutes), [
|
||||
'article' => $article->id,
|
||||
'release' => $release->id,
|
||||
'version' => $version->id,
|
||||
'datei' => $path,
|
||||
'reader' => $member->id,
|
||||
]);
|
||||
}
|
||||
|
||||
private function firstUrl(string $playlist): string
|
||||
{
|
||||
foreach (preg_split('/\R/', $playlist) as $line) {
|
||||
if ($line !== '' && ! str_starts_with($line, '#')) {
|
||||
return $line;
|
||||
}
|
||||
}
|
||||
|
||||
$this->fail('Die Liste enthält keine Adresse.');
|
||||
}
|
||||
|
||||
private function expiry(string $url): int
|
||||
{
|
||||
parse_str((string) parse_url($url, PHP_URL_QUERY), $query);
|
||||
|
||||
return (int) ($query['expires'] ?? 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Gemeinsame Ausstattung der Tests zur Filmauslieferung: ein Film mit HLS-Stufen auf der Ablage "media_derived" und
|
||||
* ein Angebot mit Rechteprofil. Der Aufrufer ruft vorher Storage::fake('media_derived') auf.
|
||||
*/
|
||||
trait BuildsFilmFixtures
|
||||
{
|
||||
/**
|
||||
* @return array{0: ContentElementVersion, 1: ContentElement}
|
||||
*/
|
||||
private function filmWithRenditions(string $title, string $file): array
|
||||
{
|
||||
Storage::disk('media_derived')->put($file, 'filmbytes');
|
||||
$content = app(ContentService::class);
|
||||
$element = $content->createElement('film', 'film', $title);
|
||||
$version = $content->publishElementVersion($element, null, ['file' => $file]);
|
||||
$base = 'ableitungen/'.$version->id;
|
||||
Storage::disk('media_derived')->put($base.'/480/index.m3u8', "#EXTM3U\n#EXTINF:6.0,\nsegment.ts\n");
|
||||
Storage::disk('media_derived')->put($base.'/480/segment.ts', 'segment-bytes');
|
||||
Storage::disk('media_derived')->put($base.'/master.m3u8', "#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=800000\n480/index.m3u8\n");
|
||||
MediaRendition::query()->create(['content_element_version_id' => $version->id, 'role' => 'variant', 'label' => '480', 'path' => $base.'/480/index.m3u8']);
|
||||
MediaRendition::query()->create(['content_element_version_id' => $version->id, 'role' => 'master', 'label' => 'master', 'path' => $base.'/master.m3u8']);
|
||||
|
||||
return [$version, $element];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, list<string>> $capabilities
|
||||
* @return array{0: LicenseArticle, 1: mixed, 2: ArticleRelease}
|
||||
*/
|
||||
private function offerFor(ContentElementVersion $version, array $capabilities): array
|
||||
{
|
||||
$articles = app(ArticleService::class);
|
||||
$offers = app(OfferService::class);
|
||||
$article = $articles->create('ausgabe-'.str()->random(6));
|
||||
$release = $articles->publishRelease($article, $version, 'Stand.');
|
||||
$rights = $offers->createRightsProfile('Rechte '.str()->random(4), 'ehrenamtlich', $capabilities);
|
||||
$offer = $offers->create('Angebot '.str()->random(4));
|
||||
$offers->activate($offer, [
|
||||
['target' => $article->fresh(), 'rights' => $rights],
|
||||
], ['grant_kind' => 'auf_abruf']);
|
||||
|
||||
return [$article->fresh(), $offer, $release];
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,24 @@ public function test_plain_text_that_only_looks_like_markup_stays_plain(): void
|
||||
$this->assertFalse(FormattedText::isHtml('Preis < 5 und > 3'));
|
||||
}
|
||||
|
||||
public function test_html_that_starts_with_h1_h2_or_div_is_html_and_not_masked_as_plain_text(): void
|
||||
{
|
||||
$html = '<h2>Was Kinder üben</h2><p>Text mit <strong>fett</strong>.</p><h3>Unterpunkt</h3><ul><li><p>Eins</p></li></ul>';
|
||||
|
||||
$this->assertTrue(FormattedText::isHtml($html));
|
||||
$this->assertTrue(FormattedText::isHtml('
|
||||
<h1>Titel</h1>'));
|
||||
$this->assertTrue(FormattedText::isHtml('<div>Lose Zeile</div>'));
|
||||
|
||||
// h1 und h2 gehören der Seite und dem Kapitel; im Text werden sie zur Zwischenüberschrift h3.
|
||||
$this->assertSame(
|
||||
'<h3>Was Kinder üben</h3><p>Text mit <strong>fett</strong>.</p><h3>Unterpunkt</h3><ul><li><p>Eins</p></li></ul>',
|
||||
FormattedText::canonical($html, true),
|
||||
);
|
||||
$this->assertStringNotContainsString('<', FormattedText::html($html, null, true));
|
||||
$this->assertSame('<p>Lose Zeile</p>', FormattedText::canonical('<div>Lose Zeile</div>'));
|
||||
}
|
||||
|
||||
public function test_plain_text_and_excerpt_drop_markup_but_keep_structure(): void
|
||||
{
|
||||
$html = '<p>Erster <strong>Absatz</strong><br>mit Umbruch</p><ul><li><p>Eins</p></li><li><p>Zwei</p></li></ul><ol><li><p>A</p></li><li><p>B</p></li></ol>';
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Domain\Media\HlsPlaylist;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HlsPlaylistTest extends TestCase
|
||||
{
|
||||
public function test_the_duration_is_the_sum_of_the_segment_lengths(): void
|
||||
{
|
||||
$playlist = "#EXTM3U\n#EXT-X-TARGETDURATION:6\n#EXTINF:6.0,\na.ts\n#EXTINF:6.006,\nb.ts\r\n#EXTINF:2.5,title\nc.ts\n#EXT-X-ENDLIST\n";
|
||||
|
||||
$this->assertEqualsWithDelta(14.506, (new HlsPlaylist)->duration($playlist), 0.0001);
|
||||
}
|
||||
|
||||
public function test_a_master_list_has_no_duration(): void
|
||||
{
|
||||
$this->assertSame(0.0, (new HlsPlaylist)->duration("#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=800000\n480/index.m3u8\n"));
|
||||
}
|
||||
|
||||
public function test_the_first_target_is_resolved_against_the_directory_of_the_list(): void
|
||||
{
|
||||
$master = "#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=800000\n480/index.m3u8\n#EXT-X-STREAM-INF:BANDWIDTH=2000000\n720/index.m3u8\n";
|
||||
$lists = new HlsPlaylist;
|
||||
|
||||
$this->assertSame('ableitungen/7/480/index.m3u8', $lists->firstTarget($master, 'ableitungen/7/master.m3u8'));
|
||||
$this->assertSame('ableitungen/7/x/index.m3u8', $lists->firstTarget("#EXTM3U\nableitungen/7/x/index.m3u8\n", 'ableitungen/7/master.m3u8'));
|
||||
$this->assertNull($lists->firstTarget("#EXTM3U\n#EXT-X-ENDLIST\n", 'ableitungen/7/master.m3u8'));
|
||||
}
|
||||
|
||||
public function test_rewriting_signs_only_the_entries(): void
|
||||
{
|
||||
$out = (new HlsPlaylist)->rewrite("#EXTM3U\n#EXTINF:6.0,\nsegment.ts\n", 'ableitungen/7/480/index.m3u8', fn (string $path): string => 'signiert:'.$path);
|
||||
|
||||
$this->assertSame("#EXTM3U\n#EXTINF:6.0,\nsigniert:ableitungen/7/480/segment.ts", rtrim($out));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\ImageFraming;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ImageFramingTest extends TestCase
|
||||
{
|
||||
public function test_zoom_stays_between_fill_and_the_cap_and_never_below_one_hundred(): void
|
||||
{
|
||||
$this->assertSame(100, ImageFraming::zoom(null));
|
||||
$this->assertSame(100, ImageFraming::zoom(''));
|
||||
$this->assertSame(100, ImageFraming::zoom('abc'));
|
||||
$this->assertSame(100, ImageFraming::zoom(0), 'Ein Regler ohne Wert gilt als „kein Zoom“.');
|
||||
$this->assertSame(100, ImageFraming::zoom(60), 'Weiter herauszoomen würde Ränder lassen.');
|
||||
$this->assertSame(180, ImageFraming::zoom('180'));
|
||||
$this->assertSame(250, ImageFraming::zoom(900));
|
||||
}
|
||||
|
||||
public function test_a_card_stores_the_framing_only_when_it_differs_from_the_default(): void
|
||||
{
|
||||
$this->assertSame([], ImageFraming::cleanItem([]));
|
||||
$this->assertSame([], ImageFraming::cleanItem(['focus_x' => 50, 'focus_y' => '50', 'zoom' => 100]));
|
||||
$this->assertSame(['focus_y' => 0], ImageFraming::cleanItem(['focus_x' => 50, 'focus_y' => 0]));
|
||||
$this->assertSame(['focus_x' => 30, 'focus_y' => 70, 'zoom' => 180], ImageFraming::cleanItem(['focus_x' => 30, 'focus_y' => 70, 'zoom' => 180]));
|
||||
$this->assertSame(['focus_x' => 100, 'zoom' => 250], ImageFraming::cleanItem(['focus_x' => 400, 'zoom' => 999]));
|
||||
}
|
||||
|
||||
public function test_widget_data_keeps_the_zoom_key_only_above_one_hundred(): void
|
||||
{
|
||||
$this->assertSame(['alt' => 'x'], ImageFraming::cleanZoom(['alt' => 'x', 'zoom' => 100]));
|
||||
$this->assertSame(['alt' => 'x'], ImageFraming::cleanZoom(['alt' => 'x', 'zoom' => 0]));
|
||||
$this->assertSame(['alt' => 'x', 'zoom' => 140], ImageFraming::cleanZoom(['alt' => 'x', 'zoom' => '140']));
|
||||
}
|
||||
|
||||
public function test_the_image_of_a_card_gets_a_style_only_when_something_differs(): void
|
||||
{
|
||||
$this->assertNull(ImageFraming::itemStyle([]));
|
||||
$this->assertNull(ImageFraming::itemStyle(['focus_x' => 50, 'focus_y' => 50, 'zoom' => 100]));
|
||||
$this->assertSame('object-position: 50% 0%', ImageFraming::itemStyle(['focus_y' => 0]));
|
||||
$this->assertSame('object-position: 30% 70%; transform-origin: 30% 70%; scale: 1.8', ImageFraming::itemStyle(['focus_x' => 30, 'focus_y' => 70, 'zoom' => 180]));
|
||||
}
|
||||
|
||||
public function test_a_zoomed_image_asks_the_browser_for_a_larger_version(): void
|
||||
{
|
||||
$this->assertSame('(min-width: 900px) 40vw, 100vw', ImageFraming::sizes('(min-width: 900px) 40vw, 100vw', 100));
|
||||
$this->assertSame('(min-width: 900px) calc(40vw * 2), calc(100vw * 2)', ImageFraming::sizes('(min-width: 900px) 40vw, 100vw', 200));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
// Tests der reinen Logik in resources/js (Erneuerung der Wiedergabeadressen, später Marken). Kein Browser: Alles, was
|
||||
// das DOM braucht, wird in den Tests mit kleinen Attrappen ersetzt. Browserverhalten prüft die Abnahme auf luf-test.
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'node',
|
||||
include: ['resources/js/**/*.test.js'],
|
||||
},
|
||||
});
|
||||