Erlaube Seiten unter mehrteiligen Adressen und reserviere die Pfade fester Routen
- Auffangroute und Pfadprüfung nehmen beliebig tiefe Adressen (/kurse/kinder) an; die Elternseite muss nicht existieren. - ReservedPaths sperrt jeden ersten Pfadteil fester Routen und des Ordners public/ (zur Laufzeit aus dem Router); frei bleiben nur /, /shop und /angebote. Eine bestehende Seite mit unverändertem Pfad bleibt speicherbar. - Menü: Eintrag im aktiven Pfad, wenn die aktuelle Seite unter seinem Ziel liegt. - Verwaltung: Hilfetext und Hinweis am Adressfeld, Sortierung nach Pfadteilen in Webpräsenz und Seitenauswahlen, Chip "Unterseite von ...". - ShopSwitchTest: Ein POST auf die entfernte Kaufadresse ergibt nun 405 statt 404, weil die Auffangroute die mehrteilige Adresse trifft (bei einteiligen Adressen schon bisher so). Keine Bestellung entsteht weiterhin; Begründung in ADR-72. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb9b203ecf
commit
6fcd3e39e9
11 files changed
+612
-30
No files matched your search
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Cms\LinkTargets;
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page as CmsPage;
|
||||
use App\Domain\Cms\PagePath;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
@@ -169,8 +170,9 @@ public function bestand(): array
|
||||
$seiten = CmsPage::query()->with('latestRevision')->get();
|
||||
$seiten = match ($this->sortierung) {
|
||||
'bearbeitet_alt' => $seiten->sortBy([['updated_at', 'asc'], ['id', 'asc']]),
|
||||
'adresse' => $seiten->sortBy('path', SORT_NATURAL),
|
||||
'adresse_ab' => $seiten->sortByDesc('path', SORT_NATURAL),
|
||||
// Nach Pfadteilen, damit Unterseiten unmittelbar hinter ihrer übergeordneten Adresse stehen.
|
||||
'adresse' => $seiten->sort(fn (CmsPage $a, CmsPage $b): int => PagePath::compare($a->path, $b->path)),
|
||||
'adresse_ab' => $seiten->sort(fn (CmsPage $a, CmsPage $b): int => PagePath::compare($b->path, $a->path)),
|
||||
default => $seiten->sortBy([['updated_at', 'desc'], ['id', 'desc']]),
|
||||
};
|
||||
|
||||
@@ -241,6 +243,10 @@ private function seitenZeile(CmsPage $seite, Collection $menues): array
|
||||
}
|
||||
}
|
||||
|
||||
if (PagePath::depth($seite->path) > 1) {
|
||||
$chips[] = ['label' => 'Unterseite von '.PagePath::parent($seite->path), 'ton' => 'leise'];
|
||||
}
|
||||
|
||||
$eintraege = $menues->filter(fn (NavigationItem $item): bool => $item->page_id === $seite->id
|
||||
|| ($item->page_id === null && $item->targetPath() === $seite->path));
|
||||
$sichtbarImKopf = false;
|
||||
@@ -297,8 +303,9 @@ public function duplicateAction(): Action
|
||||
TextInput::make('path')
|
||||
->label('Pfad der neuen Seite')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText('Zum Beispiel /neue-landingpage'),
|
||||
->maxLength(PagePath::MAX_LENGTH)
|
||||
->live(onBlur: true)
|
||||
->helperText(fn (?string $state): string => PageResource::pathHelp($state)),
|
||||
])
|
||||
->modalSubmitActionLabel('Duplizieren')
|
||||
->action(function (array $arguments, array $data, PageService $service): void {
|
||||
@@ -772,7 +779,8 @@ public function zielSeiten(): array
|
||||
{
|
||||
$needle = mb_strtolower(trim($this->zielSuche));
|
||||
|
||||
return CmsPage::query()->with('latestRevision')->orderBy('path')->get()
|
||||
return CmsPage::query()->with('latestRevision')->get()
|
||||
->sort(fn (CmsPage $a, CmsPage $b): int => PagePath::compare($a->path, $b->path))
|
||||
->map(fn (CmsPage $seite): array => [
|
||||
'id' => $seite->id,
|
||||
'titel' => $seite->latestRevision?->contentTitle() ?: $seite->path,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PagePath;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Filament\Resources\NavigationItems\Pages\ManageNavigationItems;
|
||||
use Closure;
|
||||
@@ -70,7 +71,7 @@ public static function form(Schema $schema): Schema
|
||||
}),
|
||||
Select::make('page_id')
|
||||
->label('Interne Seite')
|
||||
->options(fn (): array => Page::query()->orderBy('path')->pluck('path', 'id')->all())
|
||||
->options(fn (): array => Page::query()->get()->sort(fn (Page $a, Page $b): int => PagePath::compare($a->path, $b->path))->pluck('path', 'id')->all())
|
||||
->searchable()
|
||||
->helperText('Bevorzugt: eine CMS-Seite wählen. Dann folgt der Link automatisch einer Pfadänderung.'),
|
||||
TextInput::make('url')
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PagePath;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\Pages\CreatePage;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
@@ -36,6 +37,28 @@ class PageResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'path';
|
||||
|
||||
/**
|
||||
* Hilfetext am Adressfeld: Form der Adresse und, falls die übergeordnete Stufe keine Seite ist, ein Hinweis.
|
||||
*/
|
||||
public static function pathHelp(?string $state): string
|
||||
{
|
||||
$help = 'Zum Beispiel /praevention oder /kurse/kinder. Beliebig viele Ebenen, nur Kleinbuchstaben, Ziffern und Bindestriche.';
|
||||
|
||||
if (! is_string($state) || trim($state) === '') {
|
||||
return $help;
|
||||
}
|
||||
|
||||
$service = app(PageService::class);
|
||||
|
||||
try {
|
||||
$parent = $service->missingParent($service->normalizePath($state));
|
||||
} catch (ValidationException) {
|
||||
return $help;
|
||||
}
|
||||
|
||||
return $parent === null ? $help : $help.' Hinweis: '.$parent.' ist keine Seite; diese Adresse ergibt 404, bis dort eine Seite liegt.';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
@@ -48,8 +71,9 @@ public static function form(Schema $schema): Schema
|
||||
TextInput::make('path')
|
||||
->label('Pfad')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText('Zum Beispiel / oder /praevention'),
|
||||
->maxLength(PagePath::MAX_LENGTH)
|
||||
->live(onBlur: true)
|
||||
->helperText(fn (?string $state): string => self::pathHelp($state)),
|
||||
TextInput::make('seo_title')
|
||||
->label('SEO-Titel')
|
||||
->maxLength(255),
|
||||
@@ -115,8 +139,9 @@ public static function table(Table $table): Table
|
||||
TextInput::make('path')
|
||||
->label('Pfad der neuen Seite')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText('Zum Beispiel /neue-landingpage'),
|
||||
->maxLength(PagePath::MAX_LENGTH)
|
||||
->live(onBlur: true)
|
||||
->helperText(fn (?string $state): string => self::pathHelp($state)),
|
||||
])
|
||||
->modalSubmitActionLabel('Duplizieren')
|
||||
->action(function (Page $record, array $data, PageService $service) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PagePath;
|
||||
use App\Domain\Cms\SectionTransfer;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -82,8 +83,8 @@ private static function pageOptions(mixed $livewire): array
|
||||
return Page::query()
|
||||
->with(['latestRevision', 'publishedRevision'])
|
||||
->when($current !== null, fn ($query) => $query->whereKeyNot($current))
|
||||
->orderBy('path')
|
||||
->get()
|
||||
->sort(fn (Page $a, Page $b): int => PagePath::compare($a->path, $b->path))
|
||||
->filter(fn (Page $page): bool => $user?->can('update', $page) ?? false)
|
||||
->mapWithKeys(function (Page $page): array {
|
||||
$title = ($page->latestRevision ?? $page->publishedRevision)?->contentTitle();
|
||||
|
||||
Reference in new issue
Block a user