Gib Website-Bilder aus dem Medienmanager frei, ohne sie zu lizenzieren.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
72130d66c5
commit
13530b8171
18 files changed
+940
-2
No files matched your search
@@ -17,6 +17,10 @@ class ContentElement extends Model
|
|||||||
'description',
|
'description',
|
||||||
'usage_note',
|
'usage_note',
|
||||||
'license_note',
|
'license_note',
|
||||||
|
'website_credit',
|
||||||
|
'website_alt',
|
||||||
|
'website_released_at',
|
||||||
|
'website_public_path',
|
||||||
'summary',
|
'summary',
|
||||||
'thumbnail_path',
|
'thumbnail_path',
|
||||||
'thumbnail_alt',
|
'thumbnail_alt',
|
||||||
@@ -30,6 +34,7 @@ protected function casts(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'archived_at' => 'datetime',
|
'archived_at' => 'datetime',
|
||||||
|
'website_released_at' => 'datetime',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,18 @@ public function forElementUpload(ContentElement $element, string $incoming): voi
|
|||||||
$this->rememberElement($element, 'eigen');
|
$this->rememberElement($element, 'eigen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function forWebsiteImage(ContentElement $element, string $incoming): void
|
||||||
|
{
|
||||||
|
if ($element->output_class !== 'bild' || ! $this->incomingIsSafe($incoming)) {
|
||||||
|
$this->fail($element, 'Das Bild für die Website wurde nicht übernommen.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->still($element, Storage::disk('cms_incoming'), $incoming, 'element-'.$element->id);
|
||||||
|
$this->rememberElement($element, 'eigen');
|
||||||
|
}
|
||||||
|
|
||||||
public function forElementFrame(ContentElement $element, ContentElementVersion $version, float $seconds): void
|
public function forElementFrame(ContentElement $element, ContentElementVersion $version, float $seconds): void
|
||||||
{
|
{
|
||||||
if ($version->content_element_id !== $element->id || $element->output_class !== 'film') {
|
if ($version->content_element_id !== $element->id || $element->output_class !== 'film') {
|
||||||
@@ -201,6 +213,14 @@ private function readableDerived(mixed $path, string $prefix): bool
|
|||||||
return Storage::disk('media_derived')->exists($path);
|
return Storage::disk('media_derived')->exists($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function incomingIsSafe(string $incoming): bool
|
||||||
|
{
|
||||||
|
return (str_starts_with($incoming, 'cms/') || str_starts_with($incoming, 'vorschau/'))
|
||||||
|
&& ! str_contains($incoming, '..')
|
||||||
|
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $incoming) === 1
|
||||||
|
&& Storage::disk('cms_incoming')->exists($incoming);
|
||||||
|
}
|
||||||
|
|
||||||
private function secondText(float $seconds): string
|
private function secondText(float $seconds): string
|
||||||
{
|
{
|
||||||
$seconds = max(0, min(7200, $seconds));
|
$seconds = max(0, min(7200, $seconds));
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\IdentityProfile;
|
||||||
|
use App\Jobs\AcceptWebsiteImage;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nimmt ein neues Website-Bild in den Medienmanager auf.
|
||||||
|
* Die Warteschlange erzeugt danach die Ableitung und gibt sie frei.
|
||||||
|
*/
|
||||||
|
class WebsiteIntake
|
||||||
|
{
|
||||||
|
public function acceptImage(
|
||||||
|
string $incomingPath,
|
||||||
|
string $title,
|
||||||
|
?string $credit = null,
|
||||||
|
?string $alt = null,
|
||||||
|
?User $actor = null,
|
||||||
|
): ContentElement {
|
||||||
|
$title = trim($title);
|
||||||
|
|
||||||
|
if ($title === '') {
|
||||||
|
throw new DomainRuleException('Der Titel fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->incomingIsReadable($incomingPath)) {
|
||||||
|
throw new DomainRuleException('Die Bilddatei liegt nicht im Eingang.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
|
||||||
|
app(IdentityProfile::class)->fill($element, [
|
||||||
|
'display_title' => $title,
|
||||||
|
'website_credit' => $credit,
|
||||||
|
'website_alt' => $alt,
|
||||||
|
], $actor);
|
||||||
|
AcceptWebsiteImage::dispatch($element->id, $incomingPath, $actor?->id);
|
||||||
|
|
||||||
|
return $element->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function incomingIsReadable(string $path): bool
|
||||||
|
{
|
||||||
|
return (str_starts_with($path, 'cms/') || str_starts_with($path, 'vorschau/'))
|
||||||
|
&& ! str_contains($path, '..')
|
||||||
|
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||||
|
&& Storage::disk('cms_incoming')->exists($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lesesicht für Hero, Teaser und Slideshow.
|
||||||
|
* Liefert nur eine freigegebene öffentliche Ableitung, sonst nichts.
|
||||||
|
*/
|
||||||
|
class WebsiteMedia
|
||||||
|
{
|
||||||
|
public function present(ContentElement|int $element): ?WebsitePresentation
|
||||||
|
{
|
||||||
|
$element = $element instanceof ContentElement
|
||||||
|
? $element
|
||||||
|
: ContentElement::query()->find($element);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || $element->website_released_at === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
$expected = '#^website/'.$element->id.'/datei\.[a-z0-9]+$#';
|
||||||
|
|
||||||
|
if (! is_string($path) || preg_match($expected, $path) !== 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! Storage::disk('media_public')->exists($path)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = trim((string) ($element->display_title ?: $element->working_title));
|
||||||
|
$alt = trim((string) ($element->website_alt ?? ''));
|
||||||
|
|
||||||
|
return new WebsitePresentation(
|
||||||
|
elementId: $element->id,
|
||||||
|
title: $title,
|
||||||
|
alt: $alt !== '' ? $alt : $title,
|
||||||
|
credit: filled($element->website_credit) ? trim((string) $element->website_credit) : null,
|
||||||
|
kind: $element->output_class === 'film' ? 'film' : 'bild',
|
||||||
|
url: route('website.media', $element),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
||||||
|
*
|
||||||
|
* @param list<int|string> $ids
|
||||||
|
* @return list<WebsitePresentation>
|
||||||
|
*/
|
||||||
|
public function presentMany(array $ids): array
|
||||||
|
{
|
||||||
|
$presentations = [];
|
||||||
|
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
if (! is_numeric($id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$presentation = $this->present((int) $id);
|
||||||
|
|
||||||
|
if ($presentation !== null) {
|
||||||
|
$presentations[] = $presentation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $presentations;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Öffentliche Ableitung eines für die Website freigegebenen Mediums.
|
||||||
|
* Enthält keine internen Vermerke und keine Adresse einer Bestandsdatei.
|
||||||
|
*/
|
||||||
|
final class WebsitePresentation
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public readonly int $elementId,
|
||||||
|
public readonly string $title,
|
||||||
|
public readonly string $alt,
|
||||||
|
public readonly ?string $credit,
|
||||||
|
public readonly string $kind,
|
||||||
|
public readonly string $url,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Jobs\PublishWebsiteMedia;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt eine Ableitung für die Website frei oder nimmt sie zurück.
|
||||||
|
* Legt keinen Lizenzartikel an und ruft DecideAccess nicht auf.
|
||||||
|
* Der Web-Prozess schreibt die öffentliche Datei nicht selbst; das tut die Warteschlange.
|
||||||
|
*/
|
||||||
|
class WebsiteRelease
|
||||||
|
{
|
||||||
|
public function release(ContentElement $element, ?User $actor = null): string
|
||||||
|
{
|
||||||
|
$refusal = $this->refusal($element);
|
||||||
|
|
||||||
|
if ($refusal !== null) {
|
||||||
|
return $refusal;
|
||||||
|
}
|
||||||
|
|
||||||
|
PublishWebsiteMedia::dispatch($element->id, 'release', $actor?->id);
|
||||||
|
|
||||||
|
return 'Für die Website freigegeben. Öffentliche Seiten lesen nur diese Ableitung.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withdraw(ContentElement $element, ?User $actor = null): string
|
||||||
|
{
|
||||||
|
PublishWebsiteMedia::dispatch($element->id, 'withdraw', $actor?->id);
|
||||||
|
|
||||||
|
return 'Die Website-Freigabe ist zurückgenommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refusal(ContentElement $element): ?string
|
||||||
|
{
|
||||||
|
if ($this->isConfidential($element)) {
|
||||||
|
return 'Traineranleitungen werden nicht für die Website freigegeben.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->derivedPath($element) === null) {
|
||||||
|
return 'Für die Website fehlt eine freigebbare Ableitung. Beim Bild ist das das Vorschaubild, beim Film eine Teaserfassung unter teaser/. Die Originaldatei bleibt geschützt.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function derivedPath(ContentElement $element): ?string
|
||||||
|
{
|
||||||
|
if ($this->isConfidential($element)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class === 'bild') {
|
||||||
|
return $this->allowedDerivedPath($element->thumbnail_path, 'vorschau/');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class !== 'film') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $element->versions()
|
||||||
|
->where('status', ContentVersionStatus::Bereit->value)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($version === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = MediaRendition::query()
|
||||||
|
->where('content_element_version_id', $version->id)
|
||||||
|
->where('role', 'preview')
|
||||||
|
->orderByDesc('id')
|
||||||
|
->value('path');
|
||||||
|
|
||||||
|
return $this->allowedDerivedPath($path, 'teaser/');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publicPath(ContentElement $element, string $derivedPath): string
|
||||||
|
{
|
||||||
|
$extension = strtolower(pathinfo($derivedPath, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
return 'website/'.$element->id.'/datei.'.$extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isConfidential(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
$slug = $element->editorialContentKind?->slug;
|
||||||
|
|
||||||
|
if ($slug === null && $element->editorial_content_kind_id !== null) {
|
||||||
|
$slug = EditorialContentKind::query()->whereKey($element->editorial_content_kind_id)->value('slug');
|
||||||
|
}
|
||||||
|
|
||||||
|
return in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function allowedDerivedPath(mixed $path, string $prefix): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($path) || ! str_starts_with($path, $prefix) || str_contains($path, '..')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
if (! in_array($extension, ['jpg', 'jpeg', 'png', 'webp', 'gif', 'mp4', 'webm'], true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! Storage::disk('media_derived')->exists($path)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Media\ThumbnailRef;
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Support\CatalogReading;
|
use App\Filament\Support\CatalogReading;
|
||||||
use App\Filament\Support\EditorialCatalog;
|
use App\Filament\Support\EditorialCatalog;
|
||||||
@@ -67,6 +69,12 @@ class ViewContentElement extends ViewRecord
|
|||||||
|
|
||||||
public string $licenseNote = '';
|
public string $licenseNote = '';
|
||||||
|
|
||||||
|
public string $websiteCredit = '';
|
||||||
|
|
||||||
|
public string $websiteAlt = '';
|
||||||
|
|
||||||
|
public string $websiteFeedback = '';
|
||||||
|
|
||||||
public int|string|null $kindId = null;
|
public int|string|null $kindId = null;
|
||||||
|
|
||||||
/** @var list<int|string> */
|
/** @var list<int|string> */
|
||||||
@@ -453,6 +461,8 @@ public function saveEditorial(): void
|
|||||||
'description' => $this->descriptionText,
|
'description' => $this->descriptionText,
|
||||||
'usage_note' => $this->usageNote,
|
'usage_note' => $this->usageNote,
|
||||||
'license_note' => $this->licenseNote,
|
'license_note' => $this->licenseNote,
|
||||||
|
'website_credit' => $this->websiteCredit,
|
||||||
|
'website_alt' => $this->websiteAlt,
|
||||||
'thumbnail_alt' => $this->thumbnailAlt,
|
'thumbnail_alt' => $this->thumbnailAlt,
|
||||||
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
|
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
|
||||||
], auth()->user());
|
], auth()->user());
|
||||||
@@ -476,6 +486,41 @@ public function saveEditorial(): void
|
|||||||
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
|
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function releaseForWebsite(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
app(IdentityProfile::class)->fill($element, [
|
||||||
|
'website_credit' => $this->websiteCredit,
|
||||||
|
'website_alt' => $this->websiteAlt,
|
||||||
|
], auth()->user());
|
||||||
|
$element->refresh();
|
||||||
|
$this->websiteFeedback = app(WebsiteRelease::class)->release($element, auth()->user());
|
||||||
|
$element->refresh();
|
||||||
|
$this->fillEditorial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withdrawWebsite(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$this->websiteFeedback = app(WebsiteRelease::class)->withdraw($element, auth()->user());
|
||||||
|
$element->refresh();
|
||||||
|
$this->fillEditorial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function websiteIsPublic(): bool
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
|
||||||
|
return app(WebsiteMedia::class)->present($element->fresh()) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
public function adoptLibraryImage(): void
|
public function adoptLibraryImage(): void
|
||||||
{
|
{
|
||||||
abort_unless(ContentElementResource::editor(), 403);
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
@@ -610,6 +655,9 @@ public function editorialHistory(): array
|
|||||||
'summary' => 'Kurzbeschreibung',
|
'summary' => 'Kurzbeschreibung',
|
||||||
'usage_note' => 'Einsatzhinweis',
|
'usage_note' => 'Einsatzhinweis',
|
||||||
'license_note' => 'Interner Lizenzvermerk',
|
'license_note' => 'Interner Lizenzvermerk',
|
||||||
|
'website_credit' => 'Quellenzeile',
|
||||||
|
'website_alt' => 'Alternativtext der Website',
|
||||||
|
'website_released_at' => 'Website-Freigabe',
|
||||||
'thumbnail_alt' => 'Alternativtext',
|
'thumbnail_alt' => 'Alternativtext',
|
||||||
'thumbnail_path' => 'Vorschaubild',
|
'thumbnail_path' => 'Vorschaubild',
|
||||||
'thumbnail_source' => 'Herkunft des Vorschaubilds',
|
'thumbnail_source' => 'Herkunft des Vorschaubilds',
|
||||||
@@ -651,6 +699,8 @@ private function fillEditorial(): void
|
|||||||
$this->descriptionText = (string) ($element->description ?? '');
|
$this->descriptionText = (string) ($element->description ?? '');
|
||||||
$this->usageNote = (string) ($element->usage_note ?? '');
|
$this->usageNote = (string) ($element->usage_note ?? '');
|
||||||
$this->licenseNote = (string) ($element->license_note ?? '');
|
$this->licenseNote = (string) ($element->license_note ?? '');
|
||||||
|
$this->websiteCredit = (string) ($element->website_credit ?? '');
|
||||||
|
$this->websiteAlt = (string) ($element->website_alt ?? '');
|
||||||
$this->kindId = $element->editorial_content_kind_id;
|
$this->kindId = $element->editorial_content_kind_id;
|
||||||
$this->pillarIds = $element->pillars()->pluck('pillars.id')->all();
|
$this->pillarIds = $element->pillars()->pluck('pillars.id')->all();
|
||||||
$this->dimensionIds = IdentityDimensionValue::query()
|
$this->dimensionIds = IdentityDimensionValue::query()
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
|
class WebsiteMediaController extends Controller
|
||||||
|
{
|
||||||
|
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||||
|
{
|
||||||
|
$presentation = $media->present($element);
|
||||||
|
abort_if($presentation === null, 404);
|
||||||
|
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
abort_if(! is_string($path), 404);
|
||||||
|
|
||||||
|
return Storage::disk('media_public')->response($path, null, [
|
||||||
|
'Content-Disposition' => 'inline',
|
||||||
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class AcceptWebsiteImage implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $elementId,
|
||||||
|
public string $incoming,
|
||||||
|
public ?int $actorId = null,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(ThumbnailDeriver $deriver, WebsiteRelease $release): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$deriver->forWebsiteImage($element, $this->incoming);
|
||||||
|
$element->refresh();
|
||||||
|
|
||||||
|
if ($release->derivedPath($element) === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->incomingIsDisposable()) {
|
||||||
|
Storage::disk('cms_incoming')->delete($this->incoming);
|
||||||
|
}
|
||||||
|
|
||||||
|
PublishWebsiteMedia::dispatch($element->id, 'release', $this->actorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function incomingIsDisposable(): bool
|
||||||
|
{
|
||||||
|
return (str_starts_with($this->incoming, 'cms/') || str_starts_with($this->incoming, 'vorschau/'))
|
||||||
|
&& ! str_contains($this->incoming, '..');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class PublishWebsiteMedia implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $elementId,
|
||||||
|
public string $action,
|
||||||
|
public ?int $actorId = null,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(WebsiteRelease $release): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || ! in_array($this->action, ['release', 'withdraw'], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->action === 'withdraw') {
|
||||||
|
$this->deletePublicFile($element);
|
||||||
|
$this->mark($element, $element->website_released_at?->toIso8601String(), null);
|
||||||
|
$element->forceFill([
|
||||||
|
'website_released_at' => null,
|
||||||
|
'website_public_path' => null,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$derived = $release->derivedPath($element);
|
||||||
|
|
||||||
|
if ($derived === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$target = $release->publicPath($element, $derived);
|
||||||
|
$previous = $element->website_public_path;
|
||||||
|
|
||||||
|
Storage::disk('media_public')->put($target, Storage::disk('media_derived')->get($derived));
|
||||||
|
|
||||||
|
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
||||||
|
Storage::disk('media_public')->delete($previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
||||||
|
$element->forceFill([
|
||||||
|
'website_released_at' => now(),
|
||||||
|
'website_public_path' => $target,
|
||||||
|
])->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deletePublicFile(ContentElement $element): void
|
||||||
|
{
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
|
||||||
|
if (! is_string($path) || ! str_starts_with($path, 'website/'.$element->id.'/') || str_contains($path, '..')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Storage::disk('media_public')->delete($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
||||||
|
{
|
||||||
|
if ($before === $after) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IdentityChange::query()->create([
|
||||||
|
'subject_type' => $element->getMorphClass(),
|
||||||
|
'subject_id' => $element->id,
|
||||||
|
'field' => 'website_released_at',
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'actor_id' => $this->actorId,
|
||||||
|
'occurred_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->text('website_credit')->nullable()->after('license_note');
|
||||||
|
$table->string('website_alt')->nullable()->after('website_credit');
|
||||||
|
$table->timestamp('website_released_at')->nullable()->after('website_alt');
|
||||||
|
$table->string('website_public_path')->nullable()->after('website_released_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->dropColumn([
|
||||||
|
'website_credit',
|
||||||
|
'website_alt',
|
||||||
|
'website_released_at',
|
||||||
|
'website_public_path',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -306,7 +306,7 @@ ## 13. Premium-Karten (Brand-UI-Kit v1.7, ADR-39)
|
|||||||
|
|
||||||
**Raster.** Eine Karte je Platz. Gemischte Raster entstehen über die Abschnittsraster, zum Beispiel 1 + 1 + 2 (`u1_1_2`), 2 + 2, 1 + 1 + 1 + 1. Gleiche Höhe: alle Karten einer Zeile auf „An die Zeile angleichen“ stellen; die Aktion steht dann am unteren Rand. Eine öffentlich nicht sichtbare Karte lässt ihren Platz entfallen; die übrigen Plätze teilen sich die Breite. Solche Karten daher in einen eigenen Abschnitt setzen oder mit einem Platz kombinieren, der allein gut aussieht.
|
**Raster.** Eine Karte je Platz. Gemischte Raster entstehen über die Abschnittsraster, zum Beispiel 1 + 1 + 2 (`u1_1_2`), 2 + 2, 1 + 1 + 1 + 1. Gleiche Höhe: alle Karten einer Zeile auf „An die Zeile angleichen“ stellen; die Aktion steht dann am unteren Rand. Eine öffentlich nicht sichtbare Karte lässt ihren Platz entfallen; die übrigen Plätze teilen sich die Breite. Solche Karten daher in einen eigenen Abschnitt setzen oder mit einem Platz kombinieren, der allein gut aussieht.
|
||||||
|
|
||||||
**Sicherheit.** Vorschaubilder der Bibliothek (Filmstandbilder, Modulvorschau) nur über `editorial.card` (Redaktionsanmeldung) und nur in der Redaktionsvorschau; öffentlich nie. Keine Adressen unter `/bereich/` oder `/redaktion/` auf öffentlichen Seiten, kein Abspielen, kein Download, kein Preis, keine Kaufaktion. Nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtexte, Traineranleitungen. Eine Karte begründet keine Berechtigung (Tests `CmsPremiumCardsTest`).
|
**Sicherheit.** Der einzuhaltende Weg steht in `medienzugriff-fuer-komponenten.md`. Vorschaubilder der Bibliothek (Filmstandbilder, Modulvorschau) nur über `editorial.card` (Redaktionsanmeldung) und nur in der Redaktionsvorschau; öffentlich nie. Keine Adressen unter `/bereich/` oder `/redaktion/` auf öffentlichen Seiten, kein Abspielen, kein Download, kein Preis, keine Kaufaktion. Nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtexte, Traineranleitungen. Eine Karte begründet keine Berechtigung (Tests `CmsPremiumCardsTest`).
|
||||||
|
|
||||||
**Erweiterungsbedarf für öffentliche Vorschaubilder und Filmvorschauen (nicht umgesetzt, minimal):**
|
**Erweiterungsbedarf für öffentliche Vorschaubilder und Filmvorschauen (nicht umgesetzt, minimal):**
|
||||||
1. *Vorschaubild für die Website freigeben:* je `ContentElement` und `Composition` ein Freigabevermerk (`thumbnail_public_at`, `thumbnail_public_by`, Bezug auf `thumbnail_source`), gesetzt nur durch eine ausdrückliche Aktion „Vorschaubild für die Website freigeben“ in der Medien- bzw. Modulbearbeitung. Die Hintergrundverarbeitung kopiert das freigegebene Standbild nach `media_public` (eigener Pfad, zum Beispiel `katalog/`), Zurücknehmen löscht die Kopie. Die Karte nimmt dieses Bild, wenn kein Kartenbild gewählt ist. Der Web-Prozess schreibt weiterhin nicht in den Medienbestand.
|
1. *Vorschaubild für die Website freigeben:* je `ContentElement` und `Composition` ein Freigabevermerk (`thumbnail_public_at`, `thumbnail_public_by`, Bezug auf `thumbnail_source`), gesetzt nur durch eine ausdrückliche Aktion „Vorschaubild für die Website freigeben“ in der Medien- bzw. Modulbearbeitung. Die Hintergrundverarbeitung kopiert das freigegebene Standbild nach `media_public` (eigener Pfad, zum Beispiel `katalog/`), Zurücknehmen löscht die Kopie. Die Karte nimmt dieses Bild, wenn kein Kartenbild gewählt ist. Der Web-Prozess schreibt weiterhin nicht in den Medienbestand.
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
# Medienzugriff für CMS-Komponenten
|
||||||
|
|
||||||
|
**Stand:** 18.11.2026. Beschreibt den vorhandenen Weg. Keine neue Freigabe, kein zweites Rechtesystem.
|
||||||
|
|
||||||
|
Eine CMS-Komponente, die im Medienmanager liegt, ist ein Inhaltselement (`ContentElement`). Sie entscheidet den Zugriff nicht selbst. Sie ruft eine der drei vorhandenen Stellen auf, je nachdem, was sie tut.
|
||||||
|
|
||||||
|
## Drei getrennte Stellen
|
||||||
|
|
||||||
|
| Was die Komponente tut | Stelle | Was sie nicht tut |
|
||||||
|
|---|---|---|
|
||||||
|
| Anzeigedaten auf der Website lesen | `PublicMaterialReader` | keine Datei, keine Ausgabeadresse |
|
||||||
|
| Datei an ein Mitglied ausliefern | `DecideAccess`, erneut bei jedem Abruf | keine eigene Erlaubnis, keine Vereinigung von Berechtigungen |
|
||||||
|
| Ein öffentliches Bild zeigen, das kein Bestandsmedium ist | `PublicMedia` | keinen Pfad aus `originals/` oder `derived/` |
|
||||||
|
|
||||||
|
Die Pflege im Medienmanager ist eine vierte, nur redaktionelle Tür: Ansehen dürfen Redaktion und Katalogverwaltung, Ändern nur die Redaktion (`ContentElementResource`). Diese Tür gibt nichts auf der Website und nichts im Mitgliederbereich frei.
|
||||||
|
|
||||||
|
## Anzeige auf der Website
|
||||||
|
|
||||||
|
`PublicMaterialReader` ist die einzige Lesesicht für ein Medium auf einer öffentlichen Seite. Die Medienkarte nutzt sie bereits.
|
||||||
|
|
||||||
|
Öffentlich genannt wird ein Medium nur, wenn alle Punkte zutreffen:
|
||||||
|
|
||||||
|
- es ist nicht archiviert und hat mindestens eine nicht gesperrte Fassung,
|
||||||
|
- es hat eine bereitgestellte Fassung,
|
||||||
|
- die Inhaltsart ist nicht `traineranleitung`,
|
||||||
|
- es gehört zur gezeigten Fassung eines öffentlich gezeigten Programms.
|
||||||
|
|
||||||
|
Solange öffentliche Profile (ADR-29) fehlen, ist das die Übergangsregel. Ein Medium hat keine eigene öffentliche Seite. Die Karte verweist dann auf die Programmseite.
|
||||||
|
|
||||||
|
Gelesen werden Anzeigename (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nicht gelesen und nicht ausgegeben werden Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtext und jede Datei.
|
||||||
|
|
||||||
|
Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau, über die Route `editorial.card`, und nur für angemeldete Redaktion. Auf einer öffentlichen Seite hat dieses Bild keine Adresse.
|
||||||
|
|
||||||
|
## Auslieferung an Mitglieder
|
||||||
|
|
||||||
|
`DecideAccess` ist die einzige Entscheidung über eine Datei. Sie prüft an genau einer Berechtigung: aktives Konto, passender Artikel-Stand, Fassung im fixierten Inhalt dieses Stands, Fassung nicht gesperrt, Aktion im Rechte-Schnappschuss für die Ausgabeart. Zwei Berechtigungen werden nicht zu einer zusammengefügt.
|
||||||
|
|
||||||
|
Die Bibliothek ruft dieselbe Prüfung beim Aufbau der Seite und erneut beim Abruf auf (`LibraryController::media`, signierte Adresse, Leser gebunden). Eine Signatur, eine Karte oder eine gespeicherte Komponente ersetzen diesen zweiten Aufruf nicht.
|
||||||
|
|
||||||
|
Komponenten liefern Dateien nicht selbst aus. Sie bauen keine Adresse auf `content.file`, `content.preview`, `content.rendition` oder `/bereich/`.
|
||||||
|
|
||||||
|
## Öffentliche Bilder außerhalb des Bestands
|
||||||
|
|
||||||
|
Heute liegen Bilder, die nur zur Website gehören, unter dem Präfix `cms/` und laufen über `PublicMedia` und die Route `media.public`. Der Controller liefert nur Pfade, die mit `cms/` beginnen, von den Platten `media_public` und `cms_incoming`.
|
||||||
|
|
||||||
|
Dieser Pfad ist kein Zugang zum Medienmanager. Ein Inhaltselement wird darüber nicht ausgeliefert. Umgekehrt wird eine geschützte Bestandsdatei nicht in `cms/` gelegt, um sie öffentlich zu machen.
|
||||||
|
|
||||||
|
## Website-Medien für Hero, Teaser und Slideshow
|
||||||
|
|
||||||
|
Hero-Grafiken, Teaserfilme und Slideshows liegen im Medienmanager. Sie werden nicht verkauft. Lizenzartikel, Angebot, Grant und `DecideAccess` bleiben dafür unbenutzt.
|
||||||
|
|
||||||
|
Die Website-Freigabe ist eine eigene Entscheidung am Inhaltselement. Sie hängt nicht daran, dass eine Fassung bereit ist, und nicht daran, dass das Medium in einem öffentlichen Programm liegt. `PublicMaterialReader` bleibt die Lesesicht der Programmkarte. Widgets für Hero, Bild und Slideshow lesen `WebsiteMedia`.
|
||||||
|
|
||||||
|
| Aufruf | Klasse | Ergebnis |
|
||||||
|
|---|---|---|
|
||||||
|
| Ein Medium | `WebsiteMedia::present($elementOderId)` | `WebsitePresentation` oder `null` |
|
||||||
|
| Slideshow, Reihenfolge bleibt | `WebsiteMedia::presentMany([$id, ...])` | nur freigegebene Einträge |
|
||||||
|
|
||||||
|
`WebsitePresentation` enthält `elementId`, `title`, `alt`, `credit`, `kind` (`bild` oder `film`) und `url`. `url` ist die einzige Dateiadresse, Route `website.media`. `credit` ist die öffentliche Quellenzeile. `license_note` steht dort nicht.
|
||||||
|
|
||||||
|
Ein Widget speichert die Kennung des Inhaltselements (`refs.element` oder bei einer Slideshow `refs.elements`), nicht einen kopierten Dateipfad. Ist `present` leer, gibt das Widget nichts aus. Vorhandene Bilder unter `cms/` bleiben gültig, bis das jeweilige Widget umgestellt ist.
|
||||||
|
|
||||||
|
### Neues Bild aus dem CMS
|
||||||
|
|
||||||
|
`WebsiteIntake::acceptImage($pfad, $titel, $quellenzeile, $alternativtext, $redakteur)` legt das Medium an und gibt seine Kennung sofort zurück. `$pfad` ist die bereits hochgeladene Datei auf `cms_incoming` und beginnt mit `cms/` oder `vorschau/`. Titel, Quellenzeile und Alternativtext werden am Medium gespeichert. Eine Inhaltsfassung entsteht dabei nicht.
|
||||||
|
|
||||||
|
Die Warteschlange liest die Datei, schreibt das JPEG nach `vorschau/element-{id}.jpg` und gibt danach genau diese Ableitung frei. `present` bleibt leer, bis das abgeschlossen ist. Eine unlesbare Datei bleibt im Eingang, das Medium trägt `thumbnail_error` und wird nicht freigegeben. Fehlt die Datei, liegt sie außerhalb des Eingangs oder fehlt der Titel, entsteht kein Medium.
|
||||||
|
|
||||||
|
Das CMS ruft dafür nicht `DeriveThumbnail` und nicht `WebsiteRelease` auf.
|
||||||
|
|
||||||
|
Freigeben und Zurücknehmen eines schon abgelegten Mediums stehen in der Medienansicht, Bereich Beschreibung (`WebsiteRelease`). Die Warteschlange kopiert die Ableitung nach `media_public` unter `website/{id}/datei.{endung}` und setzt `website_released_at`. Der Web-Prozess schreibt diese Datei nicht. Zurücknehmen löscht nur diese Kopie.
|
||||||
|
|
||||||
|
Was freigegeben werden kann:
|
||||||
|
|
||||||
|
- Bild: Vorschaubild unter `vorschau/` auf `media_derived`, Endung jpg, jpeg, png, webp oder gif.
|
||||||
|
- Film: an der höchsten bereitgestellten Fassung eine Ausgabe mit Rolle `preview` und Pfad unter `teaser/`, Endung mp4 oder webm.
|
||||||
|
|
||||||
|
Originaldatei, Master-Fassung und Traineranleitungen werden abgelehnt. Eine Quellenzeile (`website_credit`) und ein Alternativtext (`website_alt`) gehören zu den Anzeigedaten und erzeugen keine neue Fassung. Die Quellenzeile erscheint nur, solange die Freigabe besteht. Der interne Vermerk bleibt intern.
|
||||||
|
|
||||||
|
Ein neues Website-Bild nimmt `WebsiteIntake` auf. Eine Teaserfassung für einen Film erzeugt es nicht; die muss bereits unter `teaser/` liegen. Öffentliche Profile nach ADR-29 sind damit nicht umgesetzt.
|
||||||
|
|
||||||
|
## Was eine Komponente einhält
|
||||||
|
|
||||||
|
1. Identität und Anzeigedaten bleiben am Inhaltselement. Die Komponente speichert die Kennung, nicht eine Kopie von Titel, Text oder Datei.
|
||||||
|
2. Eine Programmkarte liest das Medium über `PublicMaterialReader`. Hero, Bild und Slideshow lesen `WebsiteMedia`. Ist dort nichts freigegeben, erscheint die Komponente öffentlich nicht.
|
||||||
|
3. Öffentliche Seiten enthalten keine Adresse unter `/redaktion/` oder `/bereich/` und kein Bibliotheksbild.
|
||||||
|
4. Die Mitgliedsdatei entsteht nur über den Mitgliederabruf, der `DecideAccess` erneut aufruft. Die Website-Ableitung läuft ausschließlich über `website.media`.
|
||||||
|
5. Der Web-Prozess schreibt nicht nach `originals/` und nicht nach `derived/` oder `public/`.
|
||||||
|
|
||||||
|
Eine Karte oder eine Komponente begründet keine Berechtigung.
|
||||||
@@ -36,6 +36,12 @@
|
|||||||
<label>Interner Lizenzvermerk
|
<label>Interner Lizenzvermerk
|
||||||
<textarea rows="4" wire:model="licenseNote" @disabled(! $editable)></textarea>
|
<textarea rows="4" wire:model="licenseNote" @disabled(! $editable)></textarea>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="is-wide">Quellenzeile für die Website
|
||||||
|
<textarea rows="2" wire:model="websiteCredit" @disabled(! $editable)></textarea>
|
||||||
|
</label>
|
||||||
|
<label>Alternativtext für die Website
|
||||||
|
<input type="text" wire:model="websiteAlt" @disabled(! $editable)>
|
||||||
|
</label>
|
||||||
<label>Inhaltsart
|
<label>Inhaltsart
|
||||||
<select wire:model.live="kindId" @disabled(! $editable)>
|
<select wire:model.live="kindId" @disabled(! $editable)>
|
||||||
<option value="">Keine</option>
|
<option value="">Keine</option>
|
||||||
@@ -65,7 +71,15 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
@endforeach
|
@endforeach
|
||||||
@if ($editable)
|
@if ($editable)
|
||||||
<p><button class="luf-editor-save" type="submit">Speichern</button></p>
|
<p>
|
||||||
|
<button class="luf-editor-save" type="submit">Speichern</button>
|
||||||
|
@if ($this->websiteIsPublic())
|
||||||
|
<button class="luf-editor-quiet" type="button" wire:click="withdrawWebsite">Website-Freigabe zurücknehmen</button>
|
||||||
|
@else
|
||||||
|
<button class="luf-editor-quiet" type="button" wire:click="releaseForWebsite">Für die Website freigeben</button>
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
<p class="luf-editor-lead">{{ $this->websiteFeedback !== '' ? $this->websiteFeedback : ($this->websiteIsPublic() ? 'Für die Website freigegeben. Öffentliche Seiten lesen nur diese Ableitung.' : 'Noch nicht für die Website freigegeben. Der interne Vermerk bleibt intern.') }}</p>
|
||||||
@endif
|
@endif
|
||||||
@php($history = $this->editorialHistory())
|
@php($history = $this->editorialHistory())
|
||||||
@if ($history !== [])
|
@if ($history !== [])
|
||||||
|
|||||||
@@ -81,6 +81,16 @@
|
|||||||
justify-content: start;
|
justify-content: start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
.luf-editor-quiet {
|
||||||
|
font: inherit;
|
||||||
|
font-weight: 650;
|
||||||
|
color: #1b2838;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #c5d2cb;
|
||||||
|
min-height: 2.75rem;
|
||||||
|
padding: 0.55rem 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
.luf-editor-save {
|
.luf-editor-save {
|
||||||
justify-self: start;
|
justify-self: start;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
use App\Http\Controllers\PublicCatalogController;
|
use App\Http\Controllers\PublicCatalogController;
|
||||||
use App\Http\Controllers\PublicMediaController;
|
use App\Http\Controllers\PublicMediaController;
|
||||||
use App\Http\Controllers\ThemeController;
|
use App\Http\Controllers\ThemeController;
|
||||||
|
use App\Http\Controllers\WebsiteMediaController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', [PageController::class, 'home'])->name('home');
|
Route::get('/', [PageController::class, 'home'])->name('home');
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
Route::get('/programme/{composition}', [PublicCatalogController::class, 'program'])->name('public.program');
|
Route::get('/programme/{composition}', [PublicCatalogController::class, 'program'])->name('public.program');
|
||||||
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
||||||
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
||||||
|
Route::get('/website-medien/{element}', [WebsiteMediaController::class, 'show'])->whereNumber('element')->name('website.media');
|
||||||
|
|
||||||
Route::middleware('guest')->group(function () {
|
Route::middleware('guest')->group(function () {
|
||||||
Route::get('/registrieren', [RegistrationController::class, 'create'])->name('register');
|
Route::get('/registrieren', [RegistrationController::class, 'create'])->name('register');
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Entitlement\Grant;
|
||||||
|
use App\Domain\Media\WebsiteIntake;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class WebsiteIntakeTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Storage::fake('cms_incoming');
|
||||||
|
Storage::fake('media_derived');
|
||||||
|
Storage::fake('media_public');
|
||||||
|
Storage::fake('media_originals');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_uploaded_image_becomes_a_released_medium(): void
|
||||||
|
{
|
||||||
|
Storage::disk('cms_incoming')->put('cms/hero.png', $this->pngBytes());
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
|
||||||
|
$element = app(WebsiteIntake::class)->acceptImage(
|
||||||
|
'cms/hero.png',
|
||||||
|
'Lara im Park',
|
||||||
|
'Foto: Lara und Felix',
|
||||||
|
'Lara sitzt auf einer Parkbank',
|
||||||
|
$editor,
|
||||||
|
);
|
||||||
|
|
||||||
|
$element->refresh();
|
||||||
|
$this->assertSame(0, $element->versions()->count());
|
||||||
|
$this->assertSame(0, Grant::query()->count());
|
||||||
|
$this->assertSame('Lara im Park', $element->display_title);
|
||||||
|
$this->assertSame('vorschau/element-'.$element->id.'.jpg', $element->thumbnail_path);
|
||||||
|
$this->assertSame('website/'.$element->id.'/datei.jpg', $element->website_public_path);
|
||||||
|
$this->assertNotNull($element->website_released_at);
|
||||||
|
Storage::disk('cms_incoming')->assertMissing('cms/hero.png');
|
||||||
|
Storage::disk('media_derived')->assertExists($element->thumbnail_path);
|
||||||
|
Storage::disk('media_originals')->assertMissing('cms/hero.png');
|
||||||
|
|
||||||
|
$presentation = app(WebsiteMedia::class)->present($element);
|
||||||
|
$this->assertNotNull($presentation);
|
||||||
|
$this->assertSame($element->id, $presentation->elementId);
|
||||||
|
$this->assertSame('Lara sitzt auf einer Parkbank', $presentation->alt);
|
||||||
|
$this->assertSame('Foto: Lara und Felix', $presentation->credit);
|
||||||
|
$this->assertSame('bild', $presentation->kind);
|
||||||
|
$this->assertStringStartsWith("\xFF\xD8", $this->get($presentation->url)->assertOk()->streamedContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_missing_or_misplaced_file_creates_no_medium(): void
|
||||||
|
{
|
||||||
|
$intake = app(WebsiteIntake::class);
|
||||||
|
Storage::disk('cms_incoming')->put('cms/hero.png', $this->pngBytes());
|
||||||
|
|
||||||
|
try {
|
||||||
|
$intake->acceptImage('cms/hero.png', ' ');
|
||||||
|
$this->fail('Der Titel hätte abgelehnt werden müssen.');
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->assertSame('Der Titel fehlt.', $exception->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (['cms/fehlt.png', 'originals/geheim.png', 'cms/../originals/geheim.png', ''] as $path) {
|
||||||
|
try {
|
||||||
|
$intake->acceptImage($path, 'Ohne Datei');
|
||||||
|
$this->fail('Die Datei hätte abgelehnt werden müssen.');
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->assertSame('Die Bilddatei liegt nicht im Eingang.', $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame(0, ContentElement::query()->count());
|
||||||
|
Storage::disk('media_public')->assertMissing('website/1/datei.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unreadable_file_is_kept_but_not_released(): void
|
||||||
|
{
|
||||||
|
Storage::disk('cms_incoming')->put('cms/kaputt.jpg', 'kein bild');
|
||||||
|
|
||||||
|
$element = app(WebsiteIntake::class)->acceptImage('cms/kaputt.jpg', 'Unlesbar', 'Quelle');
|
||||||
|
|
||||||
|
$this->assertNull($element->fresh()->website_released_at);
|
||||||
|
$this->assertNotNull($element->fresh()->thumbnail_error);
|
||||||
|
$this->assertNull(app(WebsiteMedia::class)->present($element));
|
||||||
|
Storage::disk('cms_incoming')->assertExists('cms/kaputt.jpg');
|
||||||
|
Storage::disk('media_public')->assertMissing('website/'.$element->id.'/datei.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function pngBytes(): string
|
||||||
|
{
|
||||||
|
$image = imagecreatetruecolor(8, 8);
|
||||||
|
ob_start();
|
||||||
|
imagepng($image);
|
||||||
|
$bytes = ob_get_clean();
|
||||||
|
imagedestroy($image);
|
||||||
|
|
||||||
|
return is_string($bytes) ? $bytes : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Entitlement\Grant;
|
||||||
|
use App\Domain\Media\MediaRendition;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class WebsiteReleaseTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||||
|
Storage::fake('media_derived');
|
||||||
|
Storage::fake('media_public');
|
||||||
|
Storage::fake('media_originals');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_preview_image_can_be_released_without_a_license_or_a_new_version(): void
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$element = $content->createElement('bild', 'bild', 'Hero Park');
|
||||||
|
$version = $content->publishElementVersion($element, null, ['file' => 'inhalte/hero.jpg']);
|
||||||
|
$element->forceFill([
|
||||||
|
'display_title' => 'Lara im Park',
|
||||||
|
'thumbnail_path' => 'vorschau/hero.jpg',
|
||||||
|
'license_note' => 'Interner Rechtevermerk',
|
||||||
|
])->save();
|
||||||
|
Storage::disk('media_derived')->put('vorschau/hero.jpg', 'hero-bytes');
|
||||||
|
Storage::disk('media_originals')->put('inhalte/hero.jpg', 'original-bytes');
|
||||||
|
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$this->actingAs($editor, 'staff');
|
||||||
|
|
||||||
|
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||||
|
->set('websiteCredit', 'Foto: Lara und Felix, eigene Aufnahme')
|
||||||
|
->set('websiteAlt', 'Lara sitzt auf einer Parkbank')
|
||||||
|
->call('releaseForWebsite')
|
||||||
|
->assertSee('Für die Website freigegeben');
|
||||||
|
|
||||||
|
$element->refresh();
|
||||||
|
$this->assertSame(1, $element->versions()->count());
|
||||||
|
$this->assertSame($version->id, $element->versions()->first()->id);
|
||||||
|
$this->assertSame(0, Grant::query()->count());
|
||||||
|
$this->assertNotNull($element->website_released_at);
|
||||||
|
$this->assertSame('website/'.$element->id.'/datei.jpg', $element->website_public_path);
|
||||||
|
$this->assertSame('Foto: Lara und Felix, eigene Aufnahme', $element->website_credit);
|
||||||
|
Storage::disk('media_public')->assertExists($element->website_public_path);
|
||||||
|
Storage::disk('media_derived')->assertExists('vorschau/hero.jpg');
|
||||||
|
Storage::disk('media_originals')->assertExists('inhalte/hero.jpg');
|
||||||
|
$this->assertFalse(app(PublicMaterialReader::class)->isPublic($element));
|
||||||
|
|
||||||
|
$presentation = app(WebsiteMedia::class)->present($element);
|
||||||
|
$this->assertNotNull($presentation);
|
||||||
|
$this->assertSame('Lara im Park', $presentation->title);
|
||||||
|
$this->assertSame('Lara sitzt auf einer Parkbank', $presentation->alt);
|
||||||
|
$this->assertSame('Foto: Lara und Felix, eigene Aufnahme', $presentation->credit);
|
||||||
|
$this->assertSame('bild', $presentation->kind);
|
||||||
|
|
||||||
|
$this->get($presentation->url)
|
||||||
|
->assertOk()
|
||||||
|
->assertStreamedContent('hero-bytes');
|
||||||
|
|
||||||
|
$this->get('/medien/'.$element->website_public_path)->assertNotFound();
|
||||||
|
$this->assertTrue(IdentityChange::query()->where('subject_id', $element->id)->where('field', 'website_credit')->exists());
|
||||||
|
$this->assertTrue(IdentityChange::query()->where('subject_id', $element->id)->where('field', 'website_released_at')->exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_film_releases_only_its_teaser_and_can_be_withdrawn(): void
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$element = $content->createElement('film', 'film', 'Teaser Park');
|
||||||
|
$version = $content->publishElementVersion($element, 'Teaser');
|
||||||
|
MediaRendition::query()->create([
|
||||||
|
'content_element_version_id' => $version->id,
|
||||||
|
'role' => 'master',
|
||||||
|
'label' => 'master',
|
||||||
|
'path' => 'filme/master.mp4',
|
||||||
|
]);
|
||||||
|
Storage::disk('media_derived')->put('filme/master.mp4', 'master-bytes');
|
||||||
|
|
||||||
|
$release = app(WebsiteRelease::class);
|
||||||
|
$this->assertNotNull($release->refusal($element));
|
||||||
|
$this->assertNull(app(WebsiteMedia::class)->present($element));
|
||||||
|
Storage::disk('media_public')->assertDirectoryEmpty('/');
|
||||||
|
|
||||||
|
MediaRendition::query()->create([
|
||||||
|
'content_element_version_id' => $version->id,
|
||||||
|
'role' => 'preview',
|
||||||
|
'label' => 'teaser',
|
||||||
|
'path' => 'teaser/kurz.mp4',
|
||||||
|
]);
|
||||||
|
Storage::disk('media_derived')->put('teaser/kurz.mp4', 'teaser-bytes');
|
||||||
|
$release->release($element);
|
||||||
|
|
||||||
|
$element->refresh();
|
||||||
|
$presentation = app(WebsiteMedia::class)->present($element);
|
||||||
|
$this->assertNotNull($presentation);
|
||||||
|
$this->assertSame('film', $presentation->kind);
|
||||||
|
$this->get($presentation->url)->assertOk()->assertStreamedContent('teaser-bytes');
|
||||||
|
Storage::disk('media_public')->assertMissing('website/'.$element->id.'/datei-master');
|
||||||
|
$this->assertStringNotContainsString('master', (string) $element->website_public_path);
|
||||||
|
|
||||||
|
$release->withdraw($element);
|
||||||
|
$element->refresh();
|
||||||
|
$this->assertNull($element->website_released_at);
|
||||||
|
$this->assertNull(app(WebsiteMedia::class)->present($element));
|
||||||
|
$this->get(route('website.media', $element))->assertNotFound();
|
||||||
|
Storage::disk('media_derived')->assertExists('filme/master.mp4');
|
||||||
|
Storage::disk('media_derived')->assertExists('teaser/kurz.mp4');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_trainer_guides_and_unready_files_stay_unpublished(): void
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$guide = $content->createElement('text', 'text', 'Abstand Trainer');
|
||||||
|
$guide->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'traineranleitung')->value('id');
|
||||||
|
$guide->thumbnail_path = 'vorschau/intern.jpg';
|
||||||
|
$guide->output_class = 'bild';
|
||||||
|
$guide->save();
|
||||||
|
Storage::disk('media_derived')->put('vorschau/intern.jpg', 'intern');
|
||||||
|
|
||||||
|
$this->assertNotNull(app(WebsiteRelease::class)->refusal($guide));
|
||||||
|
app(WebsiteRelease::class)->release($guide);
|
||||||
|
$this->assertNull($guide->fresh()->website_released_at);
|
||||||
|
|
||||||
|
$image = $content->createElement('bild', 'bild', 'Ohne Datei');
|
||||||
|
$image->thumbnail_path = 'vorschau/../originals/geheim.jpg';
|
||||||
|
$image->save();
|
||||||
|
app(WebsiteRelease::class)->release($image);
|
||||||
|
$this->assertNull($image->fresh()->website_public_path);
|
||||||
|
Storage::disk('media_public')->assertDirectoryEmpty('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_slideshow_keeps_only_released_media_in_order(): void
|
||||||
|
{
|
||||||
|
$released = $this->releasedImage('Erstes Bild');
|
||||||
|
$hidden = app(ContentService::class)->createElement('bild', 'bild', 'Zweites Bild');
|
||||||
|
$later = $this->releasedImage('Drittes Bild');
|
||||||
|
|
||||||
|
$presentations = app(WebsiteMedia::class)->presentMany([$released->id, $hidden->id, $later->id, 'kein-medium']);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
[$released->id, $later->id],
|
||||||
|
array_map(fn ($presentation) => $presentation->elementId, $presentations),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function releasedImage(string $title): ContentElement
|
||||||
|
{
|
||||||
|
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
|
||||||
|
app(ContentService::class)->publishElementVersion($element, null, ['file' => 'inhalte/'.$element->id.'.jpg']);
|
||||||
|
$element->thumbnail_path = 'vorschau/element-'.$element->id.'.jpg';
|
||||||
|
$element->save();
|
||||||
|
Storage::disk('media_derived')->put($element->thumbnail_path, 'bytes-'.$element->id);
|
||||||
|
app(WebsiteRelease::class)->release($element);
|
||||||
|
|
||||||
|
return $element->fresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user