Plugin-System; Neuigkeiten und Termine als mitgelieferte Plugins
- Plugins nach WordPress-Prinzip: plugin.json-Manifest mit Versions- und Abhängigkeitsprüfung, eigenes PSR-4-Autoloading, register()/boot(), activate()/deactivate()/uninstall(), Migrationen, Routen und Views je Plugin - plugins-core/ (mitgeliefert, aktiv bis zur Deaktivierung) und plugins/ (Kunden-Plugins, geschützt vor Updates, inaktiv bis zur Aktivierung) - Zustand in storage/app/plugins.json – Laden ohne Datenbankabfrage - Wiederherstellungsmodus: Ausnahmen und Fatal Errors beim Laden deaktivieren das Plugin, das Portal bleibt erreichbar - Hooks (Actions/Filter mit Prioritäten) und Registries für Navigation, Startseiten-Kacheln, Rechte und Admin-Seiten (Filament-Discovery) - Admin-Seite „Plugins“: aktivieren, deaktivieren, per ZIP installieren (ZIP-Slip-Schutz), löschen mit oder ohne Daten; abschaltbar per INHAUS_DISALLOW_FILE_MODS - Startseite komplett aus Kacheln; Plugin-Seiten als „slug::Seite“ - Version 0.3.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cc0020458f
commit
28ef1e4a20
155 changed files with 2762 additions and 573 deletions
|
|
@ -4,6 +4,11 @@ Neueste Version oben. Jeder Abschnitt beginnt mit `## MAJOR.MINOR.PATCH` und
|
|||
enthält kurze Stichpunkte für Anwenderinnen und Anwender – keine Commit-Texte.
|
||||
Der Self-Updater zeigt diese Abschnitte bei neuen Versionen an.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Plugins: Funktionen lassen sich einzeln aktivieren und deaktivieren, eigene Plugins per ZIP installieren
|
||||
- Neuigkeiten und Termine sind jetzt mitgelieferte Plugins
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Aktualisierung per Klick im Admin-Bereich – ohne Serverzugang, mit Wartungsseite und Fortschrittsanzeige
|
||||
|
|
|
|||
47
app/Dashboard/CoreWidgets.php
Normal file
47
app/Dashboard/CoreWidgets.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard;
|
||||
|
||||
use App\Http\Resources\PersonResource;
|
||||
use App\Models\User;
|
||||
use App\Support\QuickLinks;
|
||||
|
||||
/**
|
||||
* Kacheln des Kerns. Plugins ergänzen weitere über App\Dashboard\Widgets.
|
||||
*/
|
||||
class CoreWidgets
|
||||
{
|
||||
public static function register(Widgets $widgets): void
|
||||
{
|
||||
$widgets->add('core.greeting', 'core::Greeting', 'aside', sort: 0, props: fn (User $user) => [
|
||||
'profile' => [
|
||||
'job_title' => $user->job_title,
|
||||
'department' => $user->department,
|
||||
'location' => $user->location,
|
||||
'avatar_url' => $user->avatarUrl(256),
|
||||
],
|
||||
], mobileSort: 0);
|
||||
|
||||
$widgets->add('core.quick-links', 'core::QuickLinks', 'main', sort: 10, props: fn () => [
|
||||
'links' => app(QuickLinks::class)->all(),
|
||||
], mobileSort: 40);
|
||||
|
||||
$widgets->add('core.new-colleagues', 'core::NewColleagues', 'main', sort: 90, props: function (User $user) {
|
||||
$people = User::query()
|
||||
->active()
|
||||
->whereKeyNot($user->getKey())
|
||||
->where('created_at', '>=', now()->subDays(90))
|
||||
->latest()
|
||||
->limit(6)
|
||||
->get();
|
||||
|
||||
return $people->isEmpty() ? null : ['people' => PersonResource::collection($people)->resolve()];
|
||||
}, mobileSort: 60);
|
||||
|
||||
$widgets->add('core.profile-incomplete', 'core::ProfileIncomplete', 'aside', sort: 50, props: fn (User $user) => $user->avatar_path && $user->job_title ? null : [], mobileSort: 70);
|
||||
|
||||
$widgets->add('core.people-search', 'core::PeopleSearch', 'aside', sort: 60, props: fn () => [
|
||||
'count' => User::query()->active()->count(),
|
||||
], mobileSort: 80);
|
||||
}
|
||||
}
|
||||
72
app/Dashboard/Widgets.php
Normal file
72
app/Dashboard/Widgets.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Kacheln der Startseite als Registry.
|
||||
*
|
||||
* Bereiche (siehe resources/js/pages/Dashboard.vue):
|
||||
* hero – groß links oben (z. B. Slider) feed – neben hero
|
||||
* main – volle Breite der linken Spalte aside – rechte Spalte
|
||||
*
|
||||
* Die Props-Funktion liefert die Daten der Kachel oder null, wenn sie für
|
||||
* diese Person nichts anzuzeigen hat.
|
||||
*/
|
||||
class Widgets
|
||||
{
|
||||
public const AREAS = ['hero', 'feed', 'main', 'aside'];
|
||||
|
||||
/** @var array<string, array{component: string, area: string, sort: int, mobileSort: int, props: callable}> */
|
||||
private array $widgets = [];
|
||||
|
||||
/**
|
||||
* @param string $component Vue-Komponente, z. B. „core::QuickLinks“ oder „news::Hero“
|
||||
* @param callable(User, Request): (array<string, mixed>|null) $props
|
||||
* @param int|null $mobileSort Reihenfolge in der einspaltigen Mobilansicht (Standard: nach Bereich)
|
||||
*/
|
||||
public function add(string $key, string $component, string $area, int $sort, callable $props, ?int $mobileSort = null): void
|
||||
{
|
||||
if (! in_array($area, self::AREAS, true)) {
|
||||
throw new \InvalidArgumentException("Unbekannter Bereich „{$area}“ für Kachel {$key}.");
|
||||
}
|
||||
|
||||
$mobileSort ??= ['hero' => 10, 'feed' => 20, 'aside' => 30, 'main' => 50][$area] + $sort;
|
||||
|
||||
$this->widgets[$key] = compact('component', 'area', 'sort', 'mobileSort', 'props');
|
||||
}
|
||||
|
||||
public function remove(string $key): void
|
||||
{
|
||||
unset($this->widgets[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{key: string, component: string, area: string, mobileSort: int, props: array<string, mixed>}>
|
||||
*/
|
||||
public function resolve(User $user, Request $request): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach (collect($this->widgets)->sortBy('sort') as $key => $widget) {
|
||||
try {
|
||||
$props = ($widget['props'])($user, $request);
|
||||
} catch (Throwable $e) {
|
||||
// Eine fehlerhafte Kachel darf die Startseite nicht lahmlegen.
|
||||
Log::error("Startseiten-Kachel {$key} fehlgeschlagen: ".$e->getMessage(), ['exception' => $e]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($props !== null) {
|
||||
$result[] = ['key' => $key, 'component' => $widget['component'], 'area' => $widget['area'], 'mobileSort' => $widget['mobileSort'], 'props' => $props];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
102
app/Filament/Pages/Plugins.php
Normal file
102
app/Filament/Pages/Plugins.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Plugins\PluginInstaller;
|
||||
use App\Plugins\PluginManager;
|
||||
use App\Plugins\PluginManifest;
|
||||
use BackedEnum;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Livewire\WithFileUploads;
|
||||
use Throwable;
|
||||
use UnitEnum;
|
||||
|
||||
class Plugins extends Page
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
protected string $view = 'filament.pages.plugins';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPuzzlePiece;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'System';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
protected static ?string $title = 'Plugins';
|
||||
|
||||
protected static ?string $slug = 'plugins';
|
||||
|
||||
/** @var TemporaryUploadedFile|null */
|
||||
public $archive = null;
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('plugins.manage') ?? false;
|
||||
}
|
||||
|
||||
public function activate(string $slug, PluginManager $plugins): void
|
||||
{
|
||||
$this->run(fn () => $plugins->activate($slug), 'Plugin aktiviert', 'Die Änderungen sind ab dem nächsten Seitenaufruf sichtbar.');
|
||||
}
|
||||
|
||||
public function deactivate(string $slug, PluginManager $plugins): void
|
||||
{
|
||||
$this->run(fn () => $plugins->deactivate($slug), 'Plugin deaktiviert', 'Die Daten bleiben erhalten und stehen nach erneuter Aktivierung wieder zur Verfügung.');
|
||||
}
|
||||
|
||||
public function delete(string $slug, bool $removeData, PluginManager $plugins): void
|
||||
{
|
||||
$this->run(fn () => $plugins->delete($slug, $removeData), 'Plugin gelöscht', $removeData ? 'Das Plugin und seine Daten wurden entfernt.' : 'Die Daten des Plugins sind noch in der Datenbank.');
|
||||
}
|
||||
|
||||
public function upload(PluginInstaller $installer): void
|
||||
{
|
||||
$this->validate(['archive' => ['required', 'file', 'mimes:zip', 'max:51200']], attributes: ['archive' => 'ZIP-Archiv']);
|
||||
|
||||
try {
|
||||
$manifest = $installer->install($this->archive->getRealPath());
|
||||
$this->archive = null;
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title("„{$manifest->name}“ {$manifest->version} installiert")
|
||||
->body('Das Plugin kann jetzt aktiviert werden.')
|
||||
->send();
|
||||
} catch (Throwable $e) {
|
||||
$this->addError('archive', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function run(callable $action, string $title, string $body): void
|
||||
{
|
||||
try {
|
||||
$action();
|
||||
Notification::make()->success()->title($title)->body($body)->send();
|
||||
$this->redirect(static::getUrl());
|
||||
} catch (Throwable $e) {
|
||||
Notification::make()->danger()->title('Nicht möglich')->body($e->getMessage())->send();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getViewData(): array
|
||||
{
|
||||
$plugins = app(PluginManager::class);
|
||||
|
||||
return [
|
||||
'plugins' => collect($plugins->all())->map(fn (PluginManifest $m) => [
|
||||
'manifest' => $m,
|
||||
'enabled' => $plugins->isEnabled($m->slug),
|
||||
'problem' => $plugins->problem($m->slug) ?? (($issues = $m->incompatibilities()) ? implode(', ', $issues) : null),
|
||||
'dependents' => $plugins->dependents($m->slug),
|
||||
])->sortBy(fn (array $p) => [$p['manifest']->core ? 0 : 1, $p['manifest']->name])->values(),
|
||||
'uploadsAllowed' => PluginInstaller::uploadsAllowed(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,59 +2,17 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\EventResource;
|
||||
use App\Http\Resources\NewsPostResource;
|
||||
use App\Http\Resources\PersonResource;
|
||||
use App\Models\Event;
|
||||
use App\Models\NewsPost;
|
||||
use App\Models\User;
|
||||
use App\Support\QuickLinks;
|
||||
use App\Dashboard\Widgets;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, QuickLinks $quickLinks): Response
|
||||
public function __invoke(Request $request, Widgets $widgets): Response
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
// Hervorgehobene Beiträge für den Slider; ohne Hervorhebung die neuesten mit Bild.
|
||||
$featured = NewsPost::query()->published()->with('category')
|
||||
->where('is_featured', true)->whereNotNull('cover_path')
|
||||
->latest('published_at')->limit(5)->get();
|
||||
|
||||
if ($featured->isEmpty()) {
|
||||
$featured = NewsPost::query()->published()->with('category')
|
||||
->whereNotNull('cover_path')->latest('published_at')->limit(3)->get();
|
||||
}
|
||||
|
||||
$recent = NewsPost::query()->published()->with('category')
|
||||
->whereKeyNot($featured->modelKeys())
|
||||
->latest('published_at')->limit(8)->get();
|
||||
|
||||
return Inertia::render('Dashboard', [
|
||||
'profile' => [
|
||||
'job_title' => $user->job_title,
|
||||
'department' => $user->department,
|
||||
'location' => $user->location,
|
||||
'avatar_url' => $user->avatarUrl(256),
|
||||
],
|
||||
'quickLinks' => $quickLinks->all(),
|
||||
'featuredNews' => NewsPostResource::collection($featured),
|
||||
'latestNews' => NewsPostResource::collection($recent->take(4)->values()),
|
||||
'moreNews' => NewsPostResource::collection($recent->slice(4)->values()),
|
||||
'upcomingEvents' => EventResource::collection(Event::query()->upcoming()->limit(4)->get()),
|
||||
'newColleagues' => PersonResource::collection(
|
||||
User::query()
|
||||
->active()
|
||||
->whereKeyNot($user->getKey())
|
||||
->where('created_at', '>=', now()->subDays(90))
|
||||
->latest()
|
||||
->limit(6)
|
||||
->get()
|
||||
),
|
||||
'peopleCount' => User::query()->active()->count(),
|
||||
'widgets' => $widgets->resolve($request->user(), $request),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
67
app/Plugins/Hooks.php
Normal file
67
app/Plugins/Hooks.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Plugins;
|
||||
|
||||
/**
|
||||
* Actions und Filter nach WordPress-Vorbild.
|
||||
*
|
||||
* Hooks::on('post.published', fn (NewsPost $post) => …); // Action
|
||||
* Hooks::do('post.published', $post);
|
||||
*
|
||||
* Hooks::filter('navigation.items', fn (array $items) => [...]); // Filter
|
||||
* $items = Hooks::apply('navigation.items', $items);
|
||||
*
|
||||
* Niedrigere Priorität läuft zuerst (Standard 10).
|
||||
*/
|
||||
class Hooks
|
||||
{
|
||||
/** @var array<string, array<int, list<callable>>> */
|
||||
private array $actions = [];
|
||||
|
||||
/** @var array<string, array<int, list<callable>>> */
|
||||
private array $filters = [];
|
||||
|
||||
public static function on(string $name, callable $callback, int $priority = 10): void
|
||||
{
|
||||
app(self::class)->actions[$name][$priority][] = $callback;
|
||||
}
|
||||
|
||||
public static function do(string $name, mixed ...$arguments): void
|
||||
{
|
||||
foreach (app(self::class)->sorted(app(self::class)->actions[$name] ?? []) as $callback) {
|
||||
$callback(...$arguments);
|
||||
}
|
||||
}
|
||||
|
||||
public static function filter(string $name, callable $callback, int $priority = 10): void
|
||||
{
|
||||
app(self::class)->filters[$name][$priority][] = $callback;
|
||||
}
|
||||
|
||||
public static function apply(string $name, mixed $value, mixed ...$arguments): mixed
|
||||
{
|
||||
foreach (app(self::class)->sorted(app(self::class)->filters[$name] ?? []) as $callback) {
|
||||
$value = $callback($value, ...$arguments);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public static function has(string $name): bool
|
||||
{
|
||||
$hooks = app(self::class);
|
||||
|
||||
return ! empty($hooks->actions[$name]) || ! empty($hooks->filters[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, list<callable>> $byPriority
|
||||
* @return list<callable>
|
||||
*/
|
||||
private function sorted(array $byPriority): array
|
||||
{
|
||||
ksort($byPriority);
|
||||
|
||||
return array_merge(...array_values($byPriority) ?: [[]]);
|
||||
}
|
||||
}
|
||||
39
app/Plugins/Plugin.php
Normal file
39
app/Plugins/Plugin.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Plugins;
|
||||
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
|
||||
/**
|
||||
* Basisklasse für Plugins – mitgelieferte wie vom Kunden installierte.
|
||||
*
|
||||
* register(): Dienste binden, Navigation/Kacheln/Rechte registrieren (früh, vor boot).
|
||||
* boot(): Hooks, Routen, Views – alles, was andere Dienste braucht.
|
||||
* activate()/deactivate()/uninstall(): Lebenszyklus, vom Admin ausgelöst.
|
||||
*/
|
||||
abstract class Plugin
|
||||
{
|
||||
public function __construct(
|
||||
protected readonly Application $app,
|
||||
public readonly PluginManifest $manifest,
|
||||
) {}
|
||||
|
||||
public function register(): void {}
|
||||
|
||||
public function boot(): void {}
|
||||
|
||||
public function activate(): void {}
|
||||
|
||||
public function deactivate(): void {}
|
||||
|
||||
/**
|
||||
* Beim Löschen mit „Daten entfernen“. Die Tabellen aus den Migrationen des
|
||||
* Plugins entfernt der Kern selbst.
|
||||
*/
|
||||
public function uninstall(): void {}
|
||||
|
||||
protected function path(string $path = ''): string
|
||||
{
|
||||
return $this->manifest->path.($path !== '' ? '/'.ltrim($path, '/') : '');
|
||||
}
|
||||
}
|
||||
75
app/Plugins/PluginInstaller.php
Normal file
75
app/Plugins/PluginInstaller.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Plugins;
|
||||
|
||||
use App\Support\Audit;
|
||||
use App\Support\Update\Filesystem;
|
||||
use App\Support\Update\ZipExtractor;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Installiert Kunden-Plugins aus einem ZIP-Archiv nach plugins/<slug>.
|
||||
* Nutzt denselben ZIP-Slip-Schutz wie der Self-Updater. Ein vorhandenes Plugin
|
||||
* mit gleichem Kürzel wird ersetzt (Update), seine Daten bleiben erhalten.
|
||||
*/
|
||||
class PluginInstaller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PluginManager $plugins,
|
||||
private readonly ZipExtractor $extractor,
|
||||
) {}
|
||||
|
||||
public static function uploadsAllowed(): bool
|
||||
{
|
||||
return ! filter_var(config('inhaus.disallow_file_mods'), FILTER_VALIDATE_BOOL);
|
||||
}
|
||||
|
||||
public function install(string $zipFile): PluginManifest
|
||||
{
|
||||
if (! self::uploadsAllowed()) {
|
||||
throw new RuntimeException('Das Installieren von Plugins ist in dieser Installation abgeschaltet.');
|
||||
}
|
||||
|
||||
$staging = storage_path('framework/plugin-upload-'.bin2hex(random_bytes(4)));
|
||||
|
||||
try {
|
||||
$this->extractor->extract($zipFile, $staging);
|
||||
|
||||
try {
|
||||
$manifest = PluginManifest::fromDirectory($staging, core: false);
|
||||
} catch (Throwable $e) {
|
||||
throw new RuntimeException('Das Archiv enthält kein gültiges Plugin: '.$e->getMessage());
|
||||
}
|
||||
|
||||
$existing = $this->plugins->find($manifest->slug);
|
||||
|
||||
if ($existing?->core) {
|
||||
throw new RuntimeException("Das Kürzel „{$manifest->slug}“ gehört zu einem mitgelieferten Plugin.");
|
||||
}
|
||||
|
||||
if (! is_file($staging.'/src/'.str_replace('\\', '/', substr($manifest->class, strlen($manifest->namespace))).'.php')) {
|
||||
throw new RuntimeException("Die Plugin-Klasse {$manifest->class} fehlt im Archiv (erwartet unter src/).");
|
||||
}
|
||||
|
||||
$target = $this->plugins->customerPath().'/'.$manifest->slug;
|
||||
|
||||
if (! is_dir(dirname($target)) && ! @mkdir(dirname($target), 0775, true)) {
|
||||
throw new RuntimeException('Das Verzeichnis plugins/ ist nicht beschreibbar.');
|
||||
}
|
||||
|
||||
Filesystem::deleteDirectory($target);
|
||||
|
||||
if (! Filesystem::moveDirectory($staging, $target)) {
|
||||
throw new RuntimeException('Das Plugin konnte nicht nach plugins/ verschoben werden. Bitte Schreibrechte prüfen.');
|
||||
}
|
||||
|
||||
$this->plugins->forgetDiscovered();
|
||||
Audit::log($existing ? 'plugin.updated' : 'plugin.installed', ['plugin' => $manifest->slug, 'version' => $manifest->version]);
|
||||
|
||||
return PluginManifest::fromDirectory($target, core: false);
|
||||
} finally {
|
||||
Filesystem::deleteDirectory($staging);
|
||||
}
|
||||
}
|
||||
}
|
||||
411
app/Plugins/PluginManager.php
Normal file
411
app/Plugins/PluginManager.php
Normal file
|
|
@ -0,0 +1,411 @@
|
|||
<?php
|
||||
|
||||
namespace App\Plugins;
|
||||
|
||||
use App\Support\Audit;
|
||||
use App\Support\Update\Filesystem;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Findet, lädt und verwaltet Plugins.
|
||||
*
|
||||
* plugins-core/<slug>/ mitgeliefert (Teil jedes Updates)
|
||||
* plugins/<slug>/ vom Kunden installiert (geschützt, Updates lassen sie in Ruhe)
|
||||
*
|
||||
* Wiederherstellungsmodus: Vor dem Laden eines Plugins wird eine Markierung
|
||||
* geschrieben und danach entfernt. Bleibt sie liegen, ist der Prozess beim
|
||||
* Laden abgestürzt (Fatal Error) – das Plugin wird beim nächsten Aufruf
|
||||
* deaktiviert, das Portal bleibt erreichbar. Ausnahmen führen sofort dazu.
|
||||
*/
|
||||
class PluginManager
|
||||
{
|
||||
/** Ab diesem Alter gilt eine liegengebliebene Lade-Markierung als Absturz. */
|
||||
private const CRASH_AFTER_SECONDS = 30;
|
||||
|
||||
/** @var array<string, PluginManifest>|null */
|
||||
private ?array $manifests = null;
|
||||
|
||||
/** @var array<string, Plugin> */
|
||||
private array $loaded = [];
|
||||
|
||||
/** @var array<string, string> Slug => Grund */
|
||||
private array $problems = [];
|
||||
|
||||
/** @var array<string, bool> */
|
||||
private array $autoloaded = [];
|
||||
|
||||
public function __construct(
|
||||
private readonly Application $app,
|
||||
private readonly PluginState $state,
|
||||
private readonly ?string $corePath = null,
|
||||
private readonly ?string $customerPath = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return array<string, PluginManifest>
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
if ($this->manifests !== null) {
|
||||
return $this->manifests;
|
||||
}
|
||||
|
||||
$this->manifests = [];
|
||||
|
||||
foreach ([[$this->corePath(), true], [$this->customerPath(), false]] as [$directory, $core]) {
|
||||
foreach (glob($directory.'/*/plugin.json') ?: [] as $file) {
|
||||
try {
|
||||
$manifest = PluginManifest::fromDirectory(dirname($file), $core);
|
||||
} catch (Throwable $e) {
|
||||
$this->problems[basename(dirname($file))] = $e->getMessage();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($this->manifests[$manifest->slug])) {
|
||||
$this->problems[$manifest->slug] = 'Ein Plugin mit diesem Kürzel ist bereits vorhanden.';
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->manifests[$manifest->slug] = $manifest;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($this->manifests);
|
||||
|
||||
return $this->manifests;
|
||||
}
|
||||
|
||||
public function find(string $slug): ?PluginManifest
|
||||
{
|
||||
return $this->all()[$slug] ?? null;
|
||||
}
|
||||
|
||||
public function isEnabled(string $slug): bool
|
||||
{
|
||||
$manifest = $this->find($slug);
|
||||
|
||||
return $manifest !== null && $this->state->isEnabled($manifest);
|
||||
}
|
||||
|
||||
public function isLoaded(string $slug): bool
|
||||
{
|
||||
return isset($this->loaded[$slug]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Plugin>
|
||||
*/
|
||||
public function loaded(): array
|
||||
{
|
||||
return $this->loaded;
|
||||
}
|
||||
|
||||
public function problem(string $slug): ?string
|
||||
{
|
||||
return $this->problems[$slug] ?? $this->state->disabledReason($slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktive, lauffähige Plugins in Abhängigkeitsreihenfolge.
|
||||
*
|
||||
* @return list<PluginManifest>
|
||||
*/
|
||||
public function bootOrder(): array
|
||||
{
|
||||
$candidates = array_filter($this->all(), fn (PluginManifest $m) => $this->state->isEnabled($m));
|
||||
$ordered = [];
|
||||
$visiting = [];
|
||||
|
||||
$visit = function (PluginManifest $manifest) use (&$visit, &$ordered, &$visiting, $candidates): bool {
|
||||
if (isset($ordered[$manifest->slug])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset($visiting[$manifest->slug]) || $manifest->incompatibilities() !== []) {
|
||||
$this->problems[$manifest->slug] ??= implode(', ', $manifest->incompatibilities()) ?: 'Zirkuläre Abhängigkeit.';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$visiting[$manifest->slug] = true;
|
||||
|
||||
foreach ($manifest->requiredPlugins() as $dependency) {
|
||||
if (! isset($candidates[$dependency]) || ! $visit($candidates[$dependency])) {
|
||||
$this->problems[$manifest->slug] ??= "benötigt das Plugin „{$dependency}“";
|
||||
unset($visiting[$manifest->slug]);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unset($visiting[$manifest->slug]);
|
||||
$ordered[$manifest->slug] = $manifest;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
foreach ($candidates as $manifest) {
|
||||
$visit($manifest);
|
||||
}
|
||||
|
||||
return array_values($ordered);
|
||||
}
|
||||
|
||||
/**
|
||||
* Phase 1: Autoload und register() aller aktiven Plugins.
|
||||
*/
|
||||
public function registerAll(): void
|
||||
{
|
||||
$this->recoverFromCrash();
|
||||
|
||||
foreach ($this->bootOrder() as $manifest) {
|
||||
$this->guard($manifest, function () use ($manifest) {
|
||||
$this->registerAutoload($manifest);
|
||||
$plugin = $this->instantiate($manifest);
|
||||
$plugin->register();
|
||||
$this->loaded[$manifest->slug] = $plugin;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Phase 2: Migrationen, Views, Routen und boot().
|
||||
*/
|
||||
public function bootAll(): void
|
||||
{
|
||||
foreach ($this->loaded as $slug => $plugin) {
|
||||
$manifest = $plugin->manifest;
|
||||
|
||||
$this->guard($manifest, function () use ($plugin, $manifest) {
|
||||
if (is_dir($manifest->migrationsPath())) {
|
||||
$this->app['migrator']->path($manifest->migrationsPath());
|
||||
}
|
||||
|
||||
if (is_dir($manifest->path.'/resources/views')) {
|
||||
$this->app['view']->addNamespace($manifest->slug, $manifest->path.'/resources/views');
|
||||
}
|
||||
|
||||
if (is_file($manifest->path.'/routes/web.php') && ! $this->app->routesAreCached()) {
|
||||
Route::middleware('web')->group($manifest->path.'/routes/web.php');
|
||||
}
|
||||
|
||||
$plugin->boot();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function activate(string $slug): void
|
||||
{
|
||||
$manifest = $this->find($slug) ?? throw new RuntimeException('Plugin nicht gefunden.');
|
||||
|
||||
if ($problems = $manifest->incompatibilities()) {
|
||||
throw new RuntimeException('Das Plugin kann nicht aktiviert werden: '.implode(', ', $problems).'.');
|
||||
}
|
||||
|
||||
foreach ($manifest->requiredPlugins() as $dependency) {
|
||||
if (! $this->isEnabled($dependency)) {
|
||||
throw new RuntimeException("Bitte zuerst das Plugin „{$dependency}“ aktivieren.");
|
||||
}
|
||||
}
|
||||
|
||||
$this->registerAutoload($manifest);
|
||||
|
||||
if (is_dir($manifest->migrationsPath())) {
|
||||
Artisan::call('migrate', ['--path' => $manifest->migrationsPath(), '--realpath' => true, '--force' => true]);
|
||||
}
|
||||
|
||||
$this->instantiate($manifest)->activate();
|
||||
$this->state->setEnabled($slug, true);
|
||||
Audit::log('plugin.activated', ['plugin' => $slug, 'version' => $manifest->version]);
|
||||
}
|
||||
|
||||
public function deactivate(string $slug, ?string $reason = null): void
|
||||
{
|
||||
$manifest = $this->find($slug) ?? throw new RuntimeException('Plugin nicht gefunden.');
|
||||
|
||||
if ($reason === null && ($dependents = $this->dependents($slug)) !== []) {
|
||||
throw new RuntimeException('Wird noch benötigt von: '.implode(', ', $dependents).'.');
|
||||
}
|
||||
|
||||
if ($reason === null && isset($this->loaded[$slug])) {
|
||||
$this->loaded[$slug]->deactivate();
|
||||
}
|
||||
|
||||
$this->state->setEnabled($slug, false, $reason);
|
||||
Audit::log('plugin.deactivated', ['plugin' => $slug, 'reason' => $reason]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kunden-Plugin löschen, optional samt Daten (Tabellen aus den Migrationen).
|
||||
*/
|
||||
public function delete(string $slug, bool $removeData): void
|
||||
{
|
||||
$manifest = $this->find($slug) ?? throw new RuntimeException('Plugin nicht gefunden.');
|
||||
|
||||
if ($manifest->core) {
|
||||
throw new RuntimeException('Mitgelieferte Plugins können nur deaktiviert werden.');
|
||||
}
|
||||
|
||||
if ($this->isEnabled($slug)) {
|
||||
$this->deactivate($slug);
|
||||
}
|
||||
|
||||
if ($removeData) {
|
||||
$this->registerAutoload($manifest);
|
||||
$this->instantiate($manifest)->uninstall();
|
||||
|
||||
if (is_dir($manifest->migrationsPath())) {
|
||||
Artisan::call('migrate:reset', ['--path' => $manifest->migrationsPath(), '--realpath' => true, '--force' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
Filesystem::deleteDirectory($manifest->path);
|
||||
$this->state->forget($slug);
|
||||
$this->manifests = null;
|
||||
Audit::log('plugin.deleted', ['plugin' => $slug, 'data_removed' => $removeData]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function dependents(string $slug): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
fn (PluginManifest $m) => $m->name,
|
||||
array_filter($this->all(), fn (PluginManifest $m) => $this->isEnabled($m->slug) && in_array($slug, $m->requiredPlugins(), true)),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verzeichnisse für Filament (Ressourcen, Seiten, Widgets) der geladenen Plugins.
|
||||
*
|
||||
* @return list<array{type: string, path: string, namespace: string}>
|
||||
*/
|
||||
public function filamentDiscovery(): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($this->loaded as $plugin) {
|
||||
foreach (['Resources', 'Pages', 'Widgets'] as $type) {
|
||||
$path = $plugin->manifest->path."/src/Filament/{$type}";
|
||||
|
||||
if (is_dir($path)) {
|
||||
$result[] = ['type' => $type, 'path' => $path, 'namespace' => $plugin->manifest->namespace."Filament\\{$type}"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function corePath(): string
|
||||
{
|
||||
return $this->corePath ?? base_path('plugins-core');
|
||||
}
|
||||
|
||||
public function customerPath(): string
|
||||
{
|
||||
return $this->customerPath ?? base_path('plugins');
|
||||
}
|
||||
|
||||
public function forgetDiscovered(): void
|
||||
{
|
||||
$this->manifests = null;
|
||||
}
|
||||
|
||||
private function instantiate(PluginManifest $manifest): Plugin
|
||||
{
|
||||
if (! class_exists($manifest->class)) {
|
||||
throw new RuntimeException("Plugin-Klasse {$manifest->class} nicht gefunden.");
|
||||
}
|
||||
|
||||
$plugin = new ($manifest->class)($this->app, $manifest);
|
||||
|
||||
if (! $plugin instanceof Plugin) {
|
||||
throw new RuntimeException("{$manifest->class} muss von ".Plugin::class.' erben.');
|
||||
}
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
private function registerAutoload(PluginManifest $manifest): void
|
||||
{
|
||||
if (isset($this->autoloaded[$manifest->slug])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$prefix = $manifest->namespace;
|
||||
$base = $manifest->path.'/src/';
|
||||
|
||||
spl_autoload_register(function (string $class) use ($prefix, $base) {
|
||||
if (str_starts_with($class, $prefix)) {
|
||||
$file = $base.str_replace('\\', '/', substr($class, strlen($prefix))).'.php';
|
||||
|
||||
if (is_file($file)) {
|
||||
require $file;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Eigene Abhängigkeiten eines Plugins (gescoped, siehe docs/PLAN.md 4.2).
|
||||
if (is_file($manifest->path.'/vendor/autoload.php')) {
|
||||
require_once $manifest->path.'/vendor/autoload.php';
|
||||
}
|
||||
|
||||
$this->autoloaded[$manifest->slug] = true;
|
||||
}
|
||||
|
||||
private function guard(PluginManifest $manifest, callable $callback): void
|
||||
{
|
||||
$marker = $this->markerPath($manifest->slug);
|
||||
@file_put_contents($marker, (string) time());
|
||||
|
||||
try {
|
||||
$callback();
|
||||
} catch (Throwable $e) {
|
||||
unset($this->loaded[$manifest->slug]);
|
||||
$this->problems[$manifest->slug] = $e->getMessage();
|
||||
Log::error("Plugin {$manifest->slug} wurde wegen eines Fehlers deaktiviert: ".$e->getMessage(), ['exception' => $e]);
|
||||
|
||||
try {
|
||||
$this->deactivate($manifest->slug, 'Fehler beim Laden: '.$e->getMessage());
|
||||
} catch (Throwable) {
|
||||
$this->state->setEnabled($manifest->slug, false, 'Fehler beim Laden: '.$e->getMessage());
|
||||
}
|
||||
} finally {
|
||||
@unlink($marker);
|
||||
}
|
||||
}
|
||||
|
||||
private function recoverFromCrash(): void
|
||||
{
|
||||
foreach (glob($this->markerPath('*')) ?: [] as $marker) {
|
||||
if (time() - (int) @filemtime($marker) < self::CRASH_AFTER_SECONDS) {
|
||||
continue; // Lädt vermutlich gerade in einer parallelen Anfrage.
|
||||
}
|
||||
|
||||
$slug = substr(basename($marker), strlen('booting-'));
|
||||
Log::critical("Plugin {$slug} hat beim Laden einen schweren Fehler verursacht und wurde deaktiviert.");
|
||||
$this->state->setEnabled($slug, false, 'Schwerer Fehler beim Laden (das Portal wurde dadurch unterbrochen).');
|
||||
@unlink($marker);
|
||||
}
|
||||
}
|
||||
|
||||
private function markerPath(string $slug): string
|
||||
{
|
||||
$dir = storage_path('framework/plugins');
|
||||
|
||||
if (! is_dir($dir)) {
|
||||
@mkdir($dir, 0775, true);
|
||||
}
|
||||
|
||||
return $dir.'/booting-'.$slug;
|
||||
}
|
||||
}
|
||||
128
app/Plugins/PluginManifest.php
Normal file
128
app/Plugins/PluginManifest.php
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
namespace App\Plugins;
|
||||
|
||||
use App\Version;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Inhalt einer plugin.json.
|
||||
*
|
||||
* {
|
||||
* "slug": "mav-kalender",
|
||||
* "name": "MAV-Kalender",
|
||||
* "version": "1.0.0",
|
||||
* "description": "…",
|
||||
* "author": "…",
|
||||
* "namespace": "Acme\\MavKalender\\",
|
||||
* "class": "Acme\\MavKalender\\Plugin",
|
||||
* "requires": { "core": ">=0.3.0", "php": ">=8.3", "plugins": ["news"] },
|
||||
* "update_url": "https://…"
|
||||
* }
|
||||
*/
|
||||
final class PluginManifest
|
||||
{
|
||||
public const SLUG_PATTERN = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/';
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
private function __construct(
|
||||
public readonly string $slug,
|
||||
public readonly string $name,
|
||||
public readonly string $version,
|
||||
public readonly string $description,
|
||||
public readonly string $author,
|
||||
public readonly string $namespace,
|
||||
public readonly string $class,
|
||||
public readonly string $path,
|
||||
public readonly bool $core,
|
||||
public readonly array $requires,
|
||||
public readonly ?string $updateUrl,
|
||||
) {}
|
||||
|
||||
public static function fromDirectory(string $path, bool $core): self
|
||||
{
|
||||
$file = rtrim($path, '/').'/plugin.json';
|
||||
$data = json_decode((string) @file_get_contents($file), true);
|
||||
|
||||
if (! is_array($data)) {
|
||||
throw new InvalidArgumentException('plugin.json fehlt oder ist kein gültiges JSON.');
|
||||
}
|
||||
|
||||
return self::fromArray($data, $path, $core);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public static function fromArray(array $data, string $path, bool $core): self
|
||||
{
|
||||
foreach (['slug', 'name', 'version', 'namespace', 'class'] as $field) {
|
||||
if (! is_string($data[$field] ?? null) || trim($data[$field]) === '') {
|
||||
throw new InvalidArgumentException("plugin.json: Feld „{$field}“ fehlt.");
|
||||
}
|
||||
}
|
||||
|
||||
if (! preg_match(self::SLUG_PATTERN, $data['slug'])) {
|
||||
throw new InvalidArgumentException('plugin.json: „slug“ darf nur Kleinbuchstaben, Ziffern und Bindestriche enthalten.');
|
||||
}
|
||||
|
||||
$namespace = rtrim($data['namespace'], '\\').'\\';
|
||||
|
||||
if (! str_starts_with(ltrim($data['class'], '\\'), $namespace)) {
|
||||
throw new InvalidArgumentException('plugin.json: „class“ muss im angegebenen Namespace liegen.');
|
||||
}
|
||||
|
||||
if (str_starts_with($namespace, 'App\\') || str_starts_with($namespace, 'Illuminate\\')) {
|
||||
throw new InvalidArgumentException('plugin.json: Der Namespace „App\\“ ist dem Kern vorbehalten.');
|
||||
}
|
||||
|
||||
return new self(
|
||||
slug: $data['slug'],
|
||||
name: $data['name'],
|
||||
version: $data['version'],
|
||||
description: (string) ($data['description'] ?? ''),
|
||||
author: (string) ($data['author'] ?? ''),
|
||||
namespace: $namespace,
|
||||
class: ltrim($data['class'], '\\'),
|
||||
path: rtrim($path, '/'),
|
||||
core: $core,
|
||||
requires: is_array($data['requires'] ?? null) ? $data['requires'] : [],
|
||||
updateUrl: is_string($data['update_url'] ?? null) ? $data['update_url'] : null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function requiredPlugins(): array
|
||||
{
|
||||
return array_values(array_filter((array) ($this->requires['plugins'] ?? []), 'is_string'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gründe, warum das Plugin in dieser Umgebung nicht laufen kann.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function incompatibilities(): array
|
||||
{
|
||||
$problems = [];
|
||||
|
||||
if (! VersionConstraint::satisfies(Version::VERSION, $this->requires['core'] ?? null)) {
|
||||
$problems[] = 'benötigt Inhaus '.$this->requires['core'];
|
||||
}
|
||||
|
||||
if (! VersionConstraint::satisfies(PHP_VERSION, $this->requires['php'] ?? null)) {
|
||||
$problems[] = 'benötigt PHP '.$this->requires['php'];
|
||||
}
|
||||
|
||||
return $problems;
|
||||
}
|
||||
|
||||
public function migrationsPath(): string
|
||||
{
|
||||
return $this->path.'/database/migrations';
|
||||
}
|
||||
}
|
||||
80
app/Plugins/PluginState.php
Normal file
80
app/Plugins/PluginState.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Plugins;
|
||||
|
||||
use App\Support\Update\AtomicFile;
|
||||
|
||||
/**
|
||||
* Aktivierungszustand der Plugins in storage/app/plugins.json – als Datei, damit
|
||||
* das Laden der Plugins keine Datenbankabfrage kostet und auch ohne DB klappt.
|
||||
* Mitgelieferte Plugins sind aktiv, solange nichts anderes vermerkt ist.
|
||||
*/
|
||||
class PluginState
|
||||
{
|
||||
/** @var array<string, array<string, mixed>>|null */
|
||||
private ?array $data = null;
|
||||
|
||||
public function __construct(private readonly ?string $file = null) {}
|
||||
|
||||
public function isEnabled(PluginManifest $manifest): bool
|
||||
{
|
||||
$entry = $this->all()[$manifest->slug] ?? null;
|
||||
|
||||
return is_array($entry) ? (bool) ($entry['enabled'] ?? false) : $manifest->core;
|
||||
}
|
||||
|
||||
public function setEnabled(string $slug, bool $enabled, ?string $reason = null): void
|
||||
{
|
||||
$this->update($slug, ['enabled' => $enabled, 'disabled_reason' => $enabled ? null : $reason]);
|
||||
}
|
||||
|
||||
public function disabledReason(string $slug): ?string
|
||||
{
|
||||
return $this->all()[$slug]['disabled_reason'] ?? null;
|
||||
}
|
||||
|
||||
public function forget(string $slug): void
|
||||
{
|
||||
$data = $this->all();
|
||||
unset($data[$slug]);
|
||||
$this->write($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
if ($this->data === null) {
|
||||
$decoded = json_decode((string) @file_get_contents($this->path()), true);
|
||||
$this->data = is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $values
|
||||
*/
|
||||
private function update(string $slug, array $values): void
|
||||
{
|
||||
$this->data = null;
|
||||
$data = $this->all();
|
||||
$data[$slug] = array_merge($data[$slug] ?? [], $values);
|
||||
$this->write($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, array<string, mixed>> $data
|
||||
*/
|
||||
private function write(array $data): void
|
||||
{
|
||||
AtomicFile::write($this->path(), json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
private function path(): string
|
||||
{
|
||||
return $this->file ?? storage_path('app/plugins.json');
|
||||
}
|
||||
}
|
||||
58
app/Plugins/VersionConstraint.php
Normal file
58
app/Plugins/VersionConstraint.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace App\Plugins;
|
||||
|
||||
/**
|
||||
* Einfache Versionsbedingungen für Plugin-Manifeste: „>=1.2“, „<2.0“, „^1.4“,
|
||||
* „~1.4“, „1.2.3“, „*“ – mehrere mit Leerzeichen oder Komma verknüpft (UND).
|
||||
*/
|
||||
final class VersionConstraint
|
||||
{
|
||||
public static function satisfies(string $version, ?string $constraint): bool
|
||||
{
|
||||
$constraint = trim((string) $constraint);
|
||||
|
||||
if ($constraint === '' || $constraint === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (preg_split('/[\s,]+/', $constraint) ?: [] as $part) {
|
||||
if (! self::check(self::normalize($version), $part)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function check(string $version, string $part): bool
|
||||
{
|
||||
if (str_starts_with($part, '^')) {
|
||||
$min = self::normalize(substr($part, 1));
|
||||
[$major, $minor] = array_map('intval', explode('.', $min));
|
||||
$max = $major > 0 ? ($major + 1).'.0.0' : '0.'.($minor + 1).'.0';
|
||||
|
||||
return version_compare($version, $min, '>=') && version_compare($version, $max, '<');
|
||||
}
|
||||
|
||||
if (str_starts_with($part, '~')) {
|
||||
$min = self::normalize(substr($part, 1));
|
||||
[$major, $minor] = array_map('intval', explode('.', $min));
|
||||
|
||||
return version_compare($version, $min, '>=') && version_compare($version, $major.'.'.($minor + 1).'.0', '<');
|
||||
}
|
||||
|
||||
if (preg_match('/^(>=|<=|>|<|==|=|!=)(.+)$/', $part, $m)) {
|
||||
return version_compare($version, self::normalize($m[2]), $m[1] === '=' ? '==' : $m[1]);
|
||||
}
|
||||
|
||||
return version_compare($version, self::normalize($part), '==');
|
||||
}
|
||||
|
||||
private static function normalize(string $version): string
|
||||
{
|
||||
$parts = explode('.', preg_replace('/[^0-9.].*$/', '', ltrim(trim($version), 'vV')));
|
||||
|
||||
return implode('.', array_slice(array_pad(array_map('intval', $parts), 3, 0), 0, 3));
|
||||
}
|
||||
}
|
||||
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Dashboard\CoreWidgets;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Support\Avatars;
|
||||
use App\Support\BackgroundTasks;
|
||||
use App\Support\Branding;
|
||||
use App\Support\Installation;
|
||||
use App\Support\License\LicenseStore;
|
||||
use App\Support\Navigation;
|
||||
use App\Support\QuickLinks;
|
||||
use App\Support\Settings;
|
||||
use App\Support\Update\InstalledVersion;
|
||||
|
|
@ -36,7 +37,6 @@ class AppServiceProvider extends ServiceProvider
|
|||
$this->app->singleton(Settings::class);
|
||||
$this->app->singleton(Branding::class);
|
||||
$this->app->singleton(Avatars::class);
|
||||
$this->app->singleton(Navigation::class);
|
||||
$this->app->singleton(QuickLinks::class);
|
||||
$this->app->singleton(LicenseStore::class);
|
||||
$this->app->singleton(BackgroundTasks::class);
|
||||
|
|
@ -47,11 +47,14 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
public function boot(): void
|
||||
{
|
||||
CoreWidgets::register($this->app->make(Widgets::class));
|
||||
|
||||
// N+1-Abfragen in Entwicklung und Tests sofort sichtbar machen (docs/PLAN.md, Performance).
|
||||
Model::preventLazyLoading(! $this->app->isProduction());
|
||||
|
||||
// Vorläufig: Administratoren über is_admin – wird in Phase 2 durch Rollen ersetzt.
|
||||
Gate::define('admin', fn (User $user) => $user->is_admin && $user->is_active);
|
||||
Gate::before(fn (User $user) => $user->is_admin && $user->is_active ? true : null);
|
||||
|
||||
Password::defaults(fn () => Password::min(10)->letters()->numbers());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Providers\Filament;
|
|||
|
||||
use App\Filament\AvatarProviders\InitialsAvatarProvider;
|
||||
use App\Filament\Pages\Feedback;
|
||||
use App\Plugins\PluginManager;
|
||||
use App\Support\Branding;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
|
|
@ -29,7 +30,7 @@ class AdminPanelProvider extends PanelProvider
|
|||
{
|
||||
// Keine eigene Filament-Anmeldung: das Admin-Backend nutzt den Portal-Login
|
||||
// (und damit später auch Entra ID). Nicht angemeldete Personen landen auf /login.
|
||||
return $panel
|
||||
$panel = $panel
|
||||
->default()
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
|
|
@ -76,5 +77,16 @@ class AdminPanelProvider extends PanelProvider
|
|||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
|
||||
// Admin-Seiten der aktiven Plugins (src/Filament/{Resources,Pages,Widgets}).
|
||||
foreach (app(PluginManager::class)->filamentDiscovery() as $discovery) {
|
||||
match ($discovery['type']) {
|
||||
'Resources' => $panel->discoverResources(in: $discovery['path'], for: $discovery['namespace']),
|
||||
'Pages' => $panel->discoverPages(in: $discovery['path'], for: $discovery['namespace']),
|
||||
'Widgets' => $panel->discoverWidgets(in: $discovery['path'], for: $discovery['namespace']),
|
||||
};
|
||||
}
|
||||
|
||||
return $panel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
app/Providers/PluginServiceProvider.php
Normal file
35
app/Providers/PluginServiceProvider.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Plugins\Hooks;
|
||||
use App\Plugins\PluginManager;
|
||||
use App\Plugins\PluginState;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Navigation;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Lädt die Plugins. Muss vor den Panel-Providern registriert sein, damit
|
||||
* Plugins ihre Admin-Seiten beitragen können.
|
||||
*/
|
||||
class PluginServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton(Hooks::class);
|
||||
$this->app->singleton(PluginState::class);
|
||||
$this->app->singleton(PluginManager::class);
|
||||
$this->app->singleton(Navigation::class);
|
||||
$this->app->singleton(Widgets::class);
|
||||
$this->app->singleton(Abilities::class);
|
||||
|
||||
$this->app->make(PluginManager::class)->registerAll();
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$this->app->make(PluginManager::class)->bootAll();
|
||||
}
|
||||
}
|
||||
87
app/Support/Abilities.php
Normal file
87
app/Support/Abilities.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
/**
|
||||
* Registry der Rechte (Abilities). Kern und Plugins melden hier an, welche
|
||||
* Rechte es gibt – das Rollen-Formular und der Rechte-Prüfer bauen darauf auf.
|
||||
*
|
||||
* Globale Rechte gelten überall („Benutzer verwalten“). Objekt-Rechte gelten für
|
||||
* einzelne Objekte eines Typs („Beiträge schreiben in Kategorie MAV-Info“).
|
||||
*/
|
||||
class Abilities
|
||||
{
|
||||
/** @var array<string, array{label: string, group: string, resource: string|null}> */
|
||||
private array $abilities = [];
|
||||
|
||||
/** @var array<string, array{label: string, options: callable}> */
|
||||
private array $resourceTypes = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->define('admin.access', 'Administrationsbereich öffnen', 'System');
|
||||
$this->define('users.manage', 'Benutzer verwalten', 'System');
|
||||
$this->define('roles.manage', 'Rollen und Rechte verwalten', 'System');
|
||||
$this->define('plugins.manage', 'Plugins verwalten und installieren', 'System');
|
||||
$this->define('appearance.manage', 'Erscheinungsbild und Schnellzugriffe', 'System');
|
||||
$this->define('updates.manage', 'Aktualisierungen, Lizenz und Systemzustand', 'System');
|
||||
$this->define('feedback.send', 'Rückmeldungen an den Hersteller senden', 'System');
|
||||
}
|
||||
|
||||
public function define(string $ability, string $label, string $group, ?string $resource = null): void
|
||||
{
|
||||
$this->abilities[$ability] = ['label' => $label, 'group' => $group, 'resource' => $resource];
|
||||
}
|
||||
|
||||
/**
|
||||
* Objekttyp, auf den sich Rechte beziehen können (z. B. „news_category“).
|
||||
*
|
||||
* @param callable(): array<int|string, string> $options ID => Bezeichnung
|
||||
*/
|
||||
public function resourceType(string $type, string $label, callable $options): void
|
||||
{
|
||||
$this->resourceTypes[$type] = ['label' => $label, 'options' => $options];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{label: string, group: string, resource: string|null}>
|
||||
*/
|
||||
public function all(): array
|
||||
{
|
||||
return $this->abilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{label: string, group: string, resource: string|null}>
|
||||
*/
|
||||
public function global(): array
|
||||
{
|
||||
return array_filter($this->abilities, fn (array $a) => $a['resource'] === null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{label: string, group: string, resource: string|null}>
|
||||
*/
|
||||
public function forResource(string $type): array
|
||||
{
|
||||
return array_filter($this->abilities, fn (array $a) => $a['resource'] === $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{label: string, options: callable}>
|
||||
*/
|
||||
public function resourceTypes(): array
|
||||
{
|
||||
return $this->resourceTypes;
|
||||
}
|
||||
|
||||
public function exists(string $ability): bool
|
||||
{
|
||||
return isset($this->abilities[$ability]);
|
||||
}
|
||||
|
||||
public function label(string $ability): string
|
||||
{
|
||||
return $this->abilities[$ability]['label'] ?? $ability;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,24 +2,56 @@
|
|||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Plugins\Hooks;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Hauptnavigation des Portals. Wird ab Phase 2 zu einer Registry, in die
|
||||
* Plugins eigene Einträge eintragen.
|
||||
* Hauptnavigation des Portals als Registry: Kern und Plugins tragen Einträge ein.
|
||||
*
|
||||
* app(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: 'news.*', sort: 20);
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
/**
|
||||
* @return list<array{label: string, href: string, active: bool}>
|
||||
*/
|
||||
public function items(Request $request): array
|
||||
/** @var array<string, array{label: string, href: string, active: list<string>, sort: int, ability: string|null}> */
|
||||
private array $items = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
return [
|
||||
['label' => 'Startseite', 'href' => '/', 'active' => $request->routeIs('dashboard')],
|
||||
['label' => 'Neuigkeiten', 'href' => '/neuigkeiten', 'active' => $request->routeIs('news.*')],
|
||||
['label' => 'Termine', 'href' => '/termine', 'active' => $request->routeIs('events.*')],
|
||||
['label' => 'Personen', 'href' => '/personen', 'active' => $request->routeIs('people.*')],
|
||||
];
|
||||
$this->add('home', 'Startseite', '/', active: 'dashboard', sort: 0);
|
||||
$this->add('people', 'Personen', '/personen', active: 'people.*', sort: 90);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|list<string> $active Routennamen (mit *), bei denen der Eintrag aktiv ist
|
||||
*/
|
||||
public function add(string $key, string $label, string $href, string|array $active = [], int $sort = 50, ?string $ability = null): void
|
||||
{
|
||||
$this->items[$key] = ['label' => $label, 'href' => $href, 'active' => (array) $active, 'sort' => $sort, 'ability' => $ability];
|
||||
}
|
||||
|
||||
public function remove(string $key): void
|
||||
{
|
||||
unset($this->items[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{key: string, label: string, href: string, active: bool}>
|
||||
*/
|
||||
public function items(Request $request, ?User $user = null): array
|
||||
{
|
||||
$items = collect($this->items)
|
||||
->filter(fn (array $item) => $item['ability'] === null || ($user?->can($item['ability']) ?? false))
|
||||
->sortBy('sort')
|
||||
->map(fn (array $item, string $key) => [
|
||||
'key' => $key,
|
||||
'label' => $item['label'],
|
||||
'href' => $item['href'],
|
||||
'active' => $item['active'] !== [] && $request->routeIs(...$item['active']),
|
||||
])
|
||||
->values()
|
||||
->all();
|
||||
|
||||
return Hooks::apply('navigation.items', $items, $request, $user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,52 @@ use RecursiveIteratorIterator;
|
|||
|
||||
final class Filesystem
|
||||
{
|
||||
/**
|
||||
* Verzeichnis verschieben – per rename(), bei Dateisystemgrenzen per Kopie.
|
||||
*/
|
||||
public static function moveDirectory(string $from, string $to): bool
|
||||
{
|
||||
if (@rename($from, $to)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! self::copyDirectory($from, $to)) {
|
||||
self::deleteDirectory($to);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
self::deleteDirectory($from);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function copyDirectory(string $from, string $to): bool
|
||||
{
|
||||
if (! is_dir($to) && ! @mkdir($to, 0775, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$items = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($from, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::SELF_FIRST,
|
||||
);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$target = $to.'/'.substr($item->getPathname(), strlen(rtrim($from, '/')) + 1);
|
||||
|
||||
if ($item->isDir()) {
|
||||
if (! is_dir($target) && ! @mkdir($target, 0775, true)) {
|
||||
return false;
|
||||
}
|
||||
} elseif (! @copy($item->getPathname(), $target)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteDirectory(string $dir): void
|
||||
{
|
||||
if (! is_dir($dir)) {
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ namespace App;
|
|||
*/
|
||||
final class Version
|
||||
{
|
||||
public const VERSION = '0.2.0';
|
||||
public const VERSION = '0.3.0';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
use App\Providers\AppServiceProvider;
|
||||
use App\Providers\Filament\AdminPanelProvider;
|
||||
use App\Providers\FortifyServiceProvider;
|
||||
use App\Providers\PluginServiceProvider;
|
||||
|
||||
return [
|
||||
AppServiceProvider::class,
|
||||
PluginServiceProvider::class,
|
||||
AdminPanelProvider::class,
|
||||
FortifyServiceProvider::class,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ return [
|
|||
|
||||
'testing' => [
|
||||
|
||||
'ensure_pages_exist' => true,
|
||||
// Plugin-Seiten („news::Index“) liegen außerhalb von resources/js/pages.
|
||||
'ensure_pages_exist' => false,
|
||||
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -6,4 +6,8 @@ return [
|
|||
// eingerichtet, wenn storage/.installed existiert oder APP_ENV=local ist.
|
||||
'installed' => env('INHAUS_INSTALLED'),
|
||||
|
||||
// Wie DISALLOW_FILE_MODS bei WordPress: verbietet das Hochladen und Löschen von
|
||||
// Plugins über den Admin-Bereich (z. B. bei strengen IT-Richtlinien).
|
||||
'disallow_file_mods' => env('INHAUS_DISALLOW_FILE_MODS', false),
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\NewsCategory;
|
||||
use App\Models\NewsPost;
|
||||
use App\Models\User;
|
||||
use App\Support\Branding;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
|
|
|
|||
13
plugins-core/events/plugin.json
Normal file
13
plugins-core/events/plugin.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"slug": "events",
|
||||
"name": "Termine",
|
||||
"version": "1.0.0",
|
||||
"description": "Veranstaltungen und Fortbildungen mit Kalender-Export.",
|
||||
"author": "Inhaus",
|
||||
"namespace": "Inhaus\\Plugins\\Events\\",
|
||||
"class": "Inhaus\\Plugins\\Events\\EventsPlugin",
|
||||
"requires": {
|
||||
"core": ">=0.3.0",
|
||||
"php": ">=8.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import EventDateBlock from '@/components/EventDateBlock.vue';
|
||||
import EventDateBlock from './EventDateBlock.vue';
|
||||
import { formatEventRange } from '@/lib/format';
|
||||
|
||||
defineProps({
|
||||
|
|
@ -3,7 +3,7 @@ import { computed } from 'vue';
|
|||
import { Link } from '@inertiajs/vue3';
|
||||
import { CalendarDays, MapPin, Video } from '@lucide/vue';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import EventDateBlock from '@/components/EventDateBlock.vue';
|
||||
import EventDateBlock from '../components/EventDateBlock.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import { formatEventRange, formatMonthYear } from '@/lib/format';
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
import { Link } from '@inertiajs/vue3';
|
||||
import { ArrowLeft, CalendarPlus, Clock, MapPin, Video } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import EventDateBlock from '@/components/EventDateBlock.vue';
|
||||
import EventDateBlock from '../components/EventDateBlock.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import { formatEventRange } from '@/lib/format';
|
||||
19
plugins-core/events/resources/js/widgets/Upcoming.vue
Normal file
19
plugins-core/events/resources/js/widgets/Upcoming.vue
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<script setup>
|
||||
import { CalendarDays } from '@lucide/vue';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import EventListItem from '../components/EventListItem.vue';
|
||||
|
||||
defineProps({
|
||||
events: { type: Array, required: true },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Termine" action-label="Alle Termine" action-href="/termine">
|
||||
<div v-if="events.length" class="-my-3 divide-y">
|
||||
<EventListItem v-for="event in events" :key="event.id" :event="event" />
|
||||
</div>
|
||||
<EmptyState v-else :icon="CalendarDays" title="Keine anstehenden Termine" class="py-6" />
|
||||
</Panel>
|
||||
</template>
|
||||
10
plugins-core/events/routes/web.php
Normal file
10
plugins-core/events/routes/web.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Inhaus\Plugins\Events\Http\Controllers\EventController;
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/termine', [EventController::class, 'index'])->name('events.index');
|
||||
Route::get('/termine/{event}', [EventController::class, 'show'])->name('events.show');
|
||||
Route::get('/termine/{event}/kalender.ics', [EventController::class, 'ics'])->name('events.ics');
|
||||
});
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
namespace Inhaus\Plugins\Events;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Support\Str;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
|
||||
/**
|
||||
* iCalendar-Export (RFC 5545) für einzelne Termine – zum Übernehmen in Outlook & Co.
|
||||
|
|
@ -1,15 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
namespace Inhaus\Plugins\Events\Database\Factories;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
|
||||
/**
|
||||
* @extends Factory<Event>
|
||||
*/
|
||||
class EventFactory extends Factory
|
||||
{
|
||||
protected $model = Event::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$start = now()->addDays(fake()->numberBetween(1, 30))->setTime(10, 0);
|
||||
24
plugins-core/events/src/EventsPlugin.php
Normal file
24
plugins-core/events/src/EventsPlugin.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\Events;
|
||||
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Plugins\Plugin;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Navigation;
|
||||
use Inhaus\Plugins\Events\Http\Resources\EventResource;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
|
||||
class EventsPlugin extends Plugin
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Navigation::class)->add('events', 'Termine', '/termine', active: 'events.*', sort: 30);
|
||||
$this->app->make(Abilities::class)->define('events.manage', 'Termine verwalten', 'Termine');
|
||||
|
||||
$this->app->make(Widgets::class)->add('events.upcoming', 'events::Upcoming', 'aside', sort: 20, props: fn (User $user) => [
|
||||
'events' => EventResource::collection(Event::query()->upcoming()->visibleTo($user)->limit(4)->get())->resolve(),
|
||||
], mobileSort: 30);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Events;
|
||||
namespace Inhaus\Plugins\Events\Filament\Resources\Events;
|
||||
|
||||
use App\Filament\Resources\Events\Pages\CreateEvent;
|
||||
use App\Filament\Resources\Events\Pages\EditEvent;
|
||||
use App\Filament\Resources\Events\Pages\ListEvents;
|
||||
use App\Models\Event;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
|
|
@ -24,6 +20,10 @@ use Filament\Tables\Columns\TextColumn;
|
|||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Inhaus\Plugins\Events\Filament\Resources\Events\Pages\CreateEvent;
|
||||
use Inhaus\Plugins\Events\Filament\Resources\Events\Pages\EditEvent;
|
||||
use Inhaus\Plugins\Events\Filament\Resources\Events\Pages\ListEvents;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
use UnitEnum;
|
||||
|
||||
class EventResource extends Resource
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Events\Pages;
|
||||
namespace Inhaus\Plugins\Events\Filament\Resources\Events\Pages;
|
||||
|
||||
use App\Filament\Resources\Events\EventResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Inhaus\Plugins\Events\Filament\Resources\Events\EventResource;
|
||||
|
||||
class CreateEvent extends CreateRecord
|
||||
{
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Events\Pages;
|
||||
namespace Inhaus\Plugins\Events\Filament\Resources\Events\Pages;
|
||||
|
||||
use App\Filament\Resources\Events\EventResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Inhaus\Plugins\Events\Filament\Resources\Events\EventResource;
|
||||
|
||||
class EditEvent extends EditRecord
|
||||
{
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Events\Pages;
|
||||
namespace Inhaus\Plugins\Events\Filament\Resources\Events\Pages;
|
||||
|
||||
use App\Filament\Resources\Events\EventResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Inhaus\Plugins\Events\Filament\Resources\Events\EventResource;
|
||||
|
||||
class ListEvents extends ListRecords
|
||||
{
|
||||
|
|
@ -1,20 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace Inhaus\Plugins\Events\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\EventResource;
|
||||
use App\Models\Event;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Support\Branding;
|
||||
use App\Support\Calendar;
|
||||
use Illuminate\Http\Response as HttpResponse;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Inhaus\Plugins\Events\Calendar;
|
||||
use Inhaus\Plugins\Events\Http\Resources\EventResource;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
|
||||
class EventController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
return Inertia::render('Events/Index', [
|
||||
return Inertia::render('events::Index', [
|
||||
'events' => EventResource::collection(
|
||||
Event::query()->upcoming()->limit(200)->get()
|
||||
),
|
||||
|
|
@ -25,7 +26,7 @@ class EventController extends Controller
|
|||
{
|
||||
abort_unless($event->is_published, 404);
|
||||
|
||||
return Inertia::render('Events/Show', [
|
||||
return Inertia::render('events::Show', [
|
||||
'event' => [
|
||||
...(new EventResource($event))->resolve(),
|
||||
'description_html' => $event->description_html,
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
namespace Inhaus\Plugins\Events\Http\Resources;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
|
||||
/**
|
||||
* @mixin Event
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace Inhaus\Plugins\Events\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Support\Images;
|
||||
use App\Support\RichText;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
|
|
@ -9,6 +10,7 @@ use Illuminate\Database\Eloquent\Builder;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Inhaus\Plugins\Events\Database\Factories\EventFactory;
|
||||
|
||||
#[Fillable([
|
||||
'author_id', 'title', 'description', 'location', 'online_url',
|
||||
|
|
@ -18,6 +20,11 @@ class Event extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory(): EventFactory
|
||||
{
|
||||
return EventFactory::new();
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (Event $event): void {
|
||||
|
|
@ -82,4 +89,11 @@ class Event extends Model
|
|||
{
|
||||
return app(Images::class)->url($this->image_path, $variant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Nur Einträge, die diese Person sehen darf (Zielgruppen). Platzhalter bis Phase 2c.
|
||||
*
|
||||
* @param Builder<Event> $query
|
||||
*/
|
||||
public function scopeVisibleTo(Builder $query, ?User $user): void {}
|
||||
}
|
||||
13
plugins-core/news/plugin.json
Normal file
13
plugins-core/news/plugin.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"slug": "news",
|
||||
"name": "Neuigkeiten",
|
||||
"version": "1.0.0",
|
||||
"description": "Beiträge mit Kategorien, Titelbildern und Hervorhebung auf der Startseite.",
|
||||
"author": "Inhaus",
|
||||
"namespace": "Inhaus\\Plugins\\News\\",
|
||||
"class": "Inhaus\\Plugins\\News\\NewsPlugin",
|
||||
"requires": {
|
||||
"core": ">=0.3.0",
|
||||
"php": ">=8.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import CategoryLabel from '@/components/CategoryLabel.vue';
|
||||
import NewsImage from '@/components/NewsImage.vue';
|
||||
import CategoryLabel from './CategoryLabel.vue';
|
||||
import NewsImage from './NewsImage.vue';
|
||||
import { formatShortDate } from '@/lib/format';
|
||||
|
||||
defineProps({
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import CategoryLabel from '@/components/CategoryLabel.vue';
|
||||
import NewsImage from '@/components/NewsImage.vue';
|
||||
import CategoryLabel from './CategoryLabel.vue';
|
||||
import NewsImage from './NewsImage.vue';
|
||||
import { formatRelative } from '@/lib/format';
|
||||
|
||||
defineProps({
|
||||
|
|
@ -3,7 +3,7 @@ import { Link, router } from '@inertiajs/vue3';
|
|||
import { ChevronLeft, ChevronRight, Newspaper } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import NewsCard from '@/components/NewsCard.vue';
|
||||
import NewsCard from '../components/NewsCard.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
|
||||
defineProps({
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ArrowLeft, Clock } from '@lucide/vue';
|
||||
import CategoryLabel from '@/components/CategoryLabel.vue';
|
||||
import NewsCard from '@/components/NewsCard.vue';
|
||||
import CategoryLabel from '../components/CategoryLabel.vue';
|
||||
import NewsCard from '../components/NewsCard.vue';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import { formatDate } from '@/lib/format';
|
||||
17
plugins-core/news/resources/js/widgets/Areas.vue
Normal file
17
plugins-core/news/resources/js/widgets/Areas.vue
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<script setup>
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import NewsCard from '../components/NewsCard.vue';
|
||||
|
||||
defineProps({
|
||||
posts: { type: Array, required: true },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Aktuelles aus den Bereichen" action-label="Alle" action-href="/neuigkeiten">
|
||||
<!-- Mobil wischbar, ab sm als Raster -->
|
||||
<div class="-mx-5 flex snap-x scroll-px-5 gap-4 overflow-x-auto px-5 pb-1 [scrollbar-width:none] sm:mx-0 sm:grid sm:grid-cols-2 sm:overflow-visible sm:px-0 sm:pb-0 xl:grid-cols-4 [&::-webkit-scrollbar]:hidden">
|
||||
<NewsCard v-for="post in posts" :key="post.id" :post="post" class="w-[78%] shrink-0 snap-start sm:w-auto" />
|
||||
</div>
|
||||
</Panel>
|
||||
</template>
|
||||
11
plugins-core/news/resources/js/widgets/Hero.vue
Normal file
11
plugins-core/news/resources/js/widgets/Hero.vue
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<script setup>
|
||||
import HeroSlider from '../components/HeroSlider.vue';
|
||||
|
||||
defineProps({
|
||||
posts: { type: Array, required: true },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<HeroSlider :posts="posts" class="h-full" />
|
||||
</template>
|
||||
23
plugins-core/news/resources/js/widgets/Latest.vue
Normal file
23
plugins-core/news/resources/js/widgets/Latest.vue
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<script setup>
|
||||
import { Newspaper } from '@lucide/vue';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import NewsListItem from '../components/NewsListItem.vue';
|
||||
|
||||
defineProps({
|
||||
posts: { type: Array, required: true },
|
||||
canWrite: { type: Boolean, default: false },
|
||||
wide: { type: Boolean, default: false },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Neuigkeiten" action-label="Alle anzeigen" action-href="/neuigkeiten">
|
||||
<div v-if="posts.length" class="-my-3 divide-y" :class="{ 'sm:grid sm:grid-cols-2 sm:gap-x-6 sm:divide-y-0': wide }">
|
||||
<NewsListItem v-for="post in posts" :key="post.id" :post="post" />
|
||||
</div>
|
||||
<EmptyState v-else :icon="Newspaper" title="Noch keine Neuigkeiten" text="Sobald Beiträge veröffentlicht sind, erscheinen sie hier.">
|
||||
<a v-if="canWrite" href="/admin/neuigkeiten/neu" class="mt-4 text-sm font-medium text-brand-text hover:underline">Ersten Beitrag schreiben</a>
|
||||
</EmptyState>
|
||||
</Panel>
|
||||
</template>
|
||||
9
plugins-core/news/routes/web.php
Normal file
9
plugins-core/news/routes/web.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Inhaus\Plugins\News\Http\Controllers\NewsController;
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::get('/neuigkeiten', [NewsController::class, 'index'])->name('news.index');
|
||||
Route::get('/neuigkeiten/{post:slug}', [NewsController::class, 'show'])->name('news.show');
|
||||
});
|
||||
|
|
@ -1,16 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
namespace Inhaus\Plugins\News\Database\Factories;
|
||||
|
||||
use App\Models\NewsCategory;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
|
||||
/**
|
||||
* @extends Factory<NewsCategory>
|
||||
*/
|
||||
class NewsCategoryFactory extends Factory
|
||||
{
|
||||
protected $model = NewsCategory::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->words(2, true);
|
||||
|
|
@ -1,15 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
namespace Inhaus\Plugins\News\Database\Factories;
|
||||
|
||||
use App\Models\NewsPost;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
|
||||
/**
|
||||
* @extends Factory<NewsPost>
|
||||
*/
|
||||
class NewsPostFactory extends Factory
|
||||
{
|
||||
protected $model = NewsPost::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NewsCategories;
|
||||
namespace Inhaus\Plugins\News\Filament\Resources\NewsCategories;
|
||||
|
||||
use App\Filament\Resources\NewsCategories\Pages\ManageNewsCategories;
|
||||
use App\Models\NewsCategory;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
|
|
@ -15,6 +13,8 @@ use Filament\Support\Icons\Heroicon;
|
|||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Str;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsCategories\Pages\ManageNewsCategories;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use UnitEnum;
|
||||
|
||||
class NewsCategoryResource extends Resource
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NewsCategories\Pages;
|
||||
namespace Inhaus\Plugins\News\Filament\Resources\NewsCategories\Pages;
|
||||
|
||||
use App\Filament\Resources\NewsCategories\NewsCategoryResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsCategories\NewsCategoryResource;
|
||||
|
||||
class ManageNewsCategories extends ManageRecords
|
||||
{
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NewsPosts;
|
||||
namespace Inhaus\Plugins\News\Filament\Resources\NewsPosts;
|
||||
|
||||
use App\Filament\Resources\NewsPosts\Pages\CreateNewsPost;
|
||||
use App\Filament\Resources\NewsPosts\Pages\EditNewsPost;
|
||||
use App\Filament\Resources\NewsPosts\Pages\ListNewsPosts;
|
||||
use App\Models\NewsPost;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
|
|
@ -26,6 +22,10 @@ use Filament\Tables\Columns\ImageColumn;
|
|||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages\CreateNewsPost;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages\EditNewsPost;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages\ListNewsPosts;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use UnitEnum;
|
||||
|
||||
class NewsPostResource extends Resource
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NewsPosts\Pages;
|
||||
namespace Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages;
|
||||
|
||||
use App\Filament\Resources\NewsPosts\NewsPostResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\NewsPostResource;
|
||||
|
||||
class CreateNewsPost extends CreateRecord
|
||||
{
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NewsPosts\Pages;
|
||||
namespace Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages;
|
||||
|
||||
use App\Filament\Resources\NewsPosts\NewsPostResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\NewsPostResource;
|
||||
|
||||
class EditNewsPost extends EditRecord
|
||||
{
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NewsPosts\Pages;
|
||||
namespace Inhaus\Plugins\News\Filament\Resources\NewsPosts\Pages;
|
||||
|
||||
use App\Filament\Resources\NewsPosts\NewsPostResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Inhaus\Plugins\News\Filament\Resources\NewsPosts\NewsPostResource;
|
||||
|
||||
class ListNewsPosts extends ListRecords
|
||||
{
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace Inhaus\Plugins\News\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\NewsPostResource;
|
||||
use App\Models\NewsCategory;
|
||||
use App\Models\NewsPost;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Inhaus\Plugins\News\Http\Resources\NewsPostResource;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
|
|
@ -24,7 +25,7 @@ class NewsController extends Controller
|
|||
->paginate(12)
|
||||
->withQueryString();
|
||||
|
||||
return Inertia::render('News/Index', [
|
||||
return Inertia::render('news::Index', [
|
||||
'posts' => NewsPostResource::collection($posts),
|
||||
'categories' => $categories->map(fn (NewsCategory $c) => ['name' => $c->name, 'slug' => $c->slug]),
|
||||
'activeCategory' => $category?->slug,
|
||||
|
|
@ -37,7 +38,7 @@ class NewsController extends Controller
|
|||
|
||||
$post->load(['category', 'author']);
|
||||
|
||||
return Inertia::render('News/Show', [
|
||||
return Inertia::render('news::Show', [
|
||||
'post' => [
|
||||
...(new NewsPostResource($post))->resolve(),
|
||||
'body_html' => $post->body_html,
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
namespace Inhaus\Plugins\News\Http\Resources;
|
||||
|
||||
use App\Models\NewsPost;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
|
||||
/**
|
||||
* @mixin NewsPost
|
||||
|
|
@ -1,17 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace Inhaus\Plugins\News\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Inhaus\Plugins\News\Database\Factories\NewsCategoryFactory;
|
||||
|
||||
#[Fillable(['name', 'slug', 'description', 'sort'])]
|
||||
class NewsCategory extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory(): NewsCategoryFactory
|
||||
{
|
||||
return NewsCategoryFactory::new();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<NewsPost, $this>
|
||||
*/
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
namespace Inhaus\Plugins\News\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Support\Images;
|
||||
use App\Support\RichText;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
|
|
@ -10,6 +11,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Str;
|
||||
use Inhaus\Plugins\News\Database\Factories\NewsPostFactory;
|
||||
|
||||
#[Fillable([
|
||||
'category_id', 'author_id', 'title', 'slug', 'teaser', 'body',
|
||||
|
|
@ -19,6 +21,11 @@ class NewsPost extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory(): NewsPostFactory
|
||||
{
|
||||
return NewsPostFactory::new();
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (NewsPost $post): void {
|
||||
|
|
@ -108,4 +115,11 @@ class NewsPost extends Model
|
|||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nur Einträge, die diese Person sehen darf (Zielgruppen). Platzhalter bis Phase 2c.
|
||||
*
|
||||
* @param Builder<NewsPost> $query
|
||||
*/
|
||||
public function scopeVisibleTo(Builder $query, ?User $user): void {}
|
||||
}
|
||||
76
plugins-core/news/src/NewsPlugin.php
Normal file
76
plugins-core/news/src/NewsPlugin.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Inhaus\Plugins\News;
|
||||
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Models\User;
|
||||
use App\Plugins\Plugin;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Navigation;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Inhaus\Plugins\News\Http\Resources\NewsPostResource;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
|
||||
class NewsPlugin extends Plugin
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->make(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: 'news.*', sort: 20);
|
||||
|
||||
$abilities = $this->app->make(Abilities::class);
|
||||
$abilities->define('news.manage', 'Neuigkeiten: alle Kategorien verwalten', 'Neuigkeiten');
|
||||
$abilities->define('news.post.create', 'Beiträge schreiben', 'Neuigkeiten', resource: 'news_category');
|
||||
$abilities->define('news.post.publish', 'Beiträge veröffentlichen', 'Neuigkeiten', resource: 'news_category');
|
||||
$abilities->resourceType('news_category', 'Kategorie', fn () => NewsCategory::query()->orderBy('sort')->pluck('name', 'id')->all());
|
||||
|
||||
$this->registerWidgets($this->app->make(Widgets::class));
|
||||
}
|
||||
|
||||
private function registerWidgets(Widgets $widgets): void
|
||||
{
|
||||
// Slider: hervorgehobene Beiträge mit Bild, sonst die neuesten mit Bild.
|
||||
$widgets->add('news.hero', 'news::Hero', 'hero', sort: 10, props: function (User $user) {
|
||||
$featured = $this->featured($user);
|
||||
|
||||
return $featured->isEmpty() ? null : ['posts' => NewsPostResource::collection($featured)->resolve()];
|
||||
}, mobileSort: 10);
|
||||
|
||||
$widgets->add('news.latest', 'news::Latest', 'feed', sort: 10, props: function (User $user, Request $request) {
|
||||
$posts = NewsPost::query()->published()->visibleTo($user)->with('category')
|
||||
->whereKeyNot($this->featured($user)->modelKeys())
|
||||
->latest('published_at')->limit(4)->get();
|
||||
|
||||
return [
|
||||
'posts' => NewsPostResource::collection($posts)->resolve(),
|
||||
'canWrite' => $user->can('news.manage'),
|
||||
];
|
||||
}, mobileSort: 20);
|
||||
|
||||
$widgets->add('news.areas', 'news::Areas', 'main', sort: 20, props: function (User $user) {
|
||||
$posts = NewsPost::query()->published()->visibleTo($user)->with('category')
|
||||
->whereKeyNot($this->featured($user)->modelKeys())
|
||||
->latest('published_at')->skip(4)->limit(4)->get();
|
||||
|
||||
return $posts->isEmpty() ? null : ['posts' => NewsPostResource::collection($posts)->resolve()];
|
||||
}, mobileSort: 50);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, NewsPost>
|
||||
*/
|
||||
private function featured(User $user)
|
||||
{
|
||||
static $cache = [];
|
||||
|
||||
return $cache[$user->id] ??= (function () use ($user) {
|
||||
$featured = NewsPost::query()->published()->visibleTo($user)->with('category')
|
||||
->where('is_featured', true)->whereNotNull('cover_path')
|
||||
->latest('published_at')->limit(5)->get();
|
||||
|
||||
return $featured->isNotEmpty() ? $featured : NewsPost::query()->published()->visibleTo($user)->with('category')
|
||||
->whereNotNull('cover_path')->latest('published_at')->limit(3)->get();
|
||||
})();
|
||||
}
|
||||
}
|
||||
2
plugins/.gitignore
vendored
Normal file
2
plugins/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
1
public/build/assets/AppLayout-1ldLchM-.js
Normal file
1
public/build/assets/AppLayout-1ldLchM-.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
public/build/assets/Areas-Dr9rKjp6.js
Normal file
1
public/build/assets/Areas-Dr9rKjp6.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,I as t,J as n,Wt as r,X as i,Xt as a,q as o}from"./app-DJnl8SxL.js";import{t as s}from"./Panel-D5zuY1_v.js";import{t as c}from"./NewsCard-B-l5uZ4h.js";var l={class:`-mx-5 flex snap-x scroll-px-5 gap-4 overflow-x-auto px-5 pb-1 [scrollbar-width:none] sm:mx-0 sm:grid sm:grid-cols-2 sm:overflow-visible sm:px-0 sm:pb-0 xl:grid-cols-4 [&::-webkit-scrollbar]:hidden`},u={__name:`Areas`,props:{posts:{type:Array,required:!0}},setup(u){return(d,f)=>(r(),n(s,{title:`Aktuelles aus den Bereichen`,"action-label":`Alle`,"action-href":`/neuigkeiten`},{default:e(()=>[o(`div`,l,[(r(!0),i(t,null,a(u.posts,e=>(r(),n(c,{key:e.id,post:e,class:`w-[78%] shrink-0 snap-start sm:w-auto`},null,8,[`post`]))),128))])]),_:1}))}};export{u as default};
|
||||
File diff suppressed because one or more lines are too long
1
public/build/assets/BrandLogo-B9oA1DG4.js
Normal file
1
public/build/assets/BrandLogo-B9oA1DG4.js
Normal file
File diff suppressed because one or more lines are too long
2
public/build/assets/Dashboard-CFDctOAW.js
Normal file
2
public/build/assets/Dashboard-CFDctOAW.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Greeting-BcYAXPh9.js","assets/app-DJnl8SxL.js","assets/app-yTLwYkM9.css","assets/AppLayout-1ldLchM-.js","assets/RovingFocusGroup-CqmMkMQP.js","assets/BrandLogo-B9oA1DG4.js","assets/NewColleagues-JGWMoXS3.js","assets/Panel-D5zuY1_v.js","assets/chevron-right-CAXGr-zo.js","assets/PeopleSearch-BcXAH_-c.js","assets/arrow-right-c2thy74C.js","assets/ProfileIncomplete-CWirgl8s.js","assets/QuickLinks-CiA26-F8.js","assets/building-complex-CCnkmD29.js","assets/calendar-days-Q7KBeYQV.js","assets/chevron-left-D2uxffyU.js","assets/clock-7Lzug1Ti.js","assets/phone-CUH1yCi5.js","assets/dist-CQsPCHOQ.js","assets/Upcoming-BETeUWER.js","assets/EmptyState-CFBmx8ne.js","assets/format-Dlm0nTI_.js","assets/EventDateBlock-CfSpm6m9.js","assets/Areas-Dr9rKjp6.js","assets/NewsCard-B-l5uZ4h.js","assets/NewsImage-DyRK4fmY.js","assets/Hero-oumSJF6b.js","assets/Latest-rEL3O0dw.js"])))=>i.map(i=>d[i]);
|
||||
import{At as e,Cn as t,I as n,J as r,K as i,Wt as a,X as o,Xt as s,Y as c,en as l,ir as u,it as d,o as f,q as p}from"./app-DJnl8SxL.js";import{t as m}from"./AppLayout-1ldLchM-.js";import{n as h}from"./dist-CQsPCHOQ.js";var g=Object.assign({"../widgets/Greeting.vue":()=>f(()=>import(`./Greeting-BcYAXPh9.js`),__vite__mapDeps([0,1,2,3,4,5])),"../widgets/NewColleagues.vue":()=>f(()=>import(`./NewColleagues-JGWMoXS3.js`),__vite__mapDeps([6,1,2,3,4,5,7,8])),"../widgets/PeopleSearch.vue":()=>f(()=>import(`./PeopleSearch-BcXAH_-c.js`),__vite__mapDeps([9,1,2,10,5,3,4,7,8])),"../widgets/ProfileIncomplete.vue":()=>f(()=>import(`./ProfileIncomplete-CWirgl8s.js`),__vite__mapDeps([11,1,2,3,4,5])),"../widgets/QuickLinks.vue":()=>f(()=>import(`./QuickLinks-CiA26-F8.js`),__vite__mapDeps([12,1,2,5,13,14,3,4,15,8,16,17,18]))}),_=Object.assign({"../../../plugins-core/events/resources/js/widgets/Upcoming.vue":()=>f(()=>import(`./Upcoming-BETeUWER.js`),__vite__mapDeps([19,1,2,14,5,20,21,22,7,8])),"../../../plugins-core/news/resources/js/widgets/Areas.vue":()=>f(()=>import(`./Areas-Dr9rKjp6.js`),__vite__mapDeps([23,1,2,7,8,5,24,25,21])),"../../../plugins-core/news/resources/js/widgets/Hero.vue":()=>f(()=>import(`./Hero-oumSJF6b.js`),__vite__mapDeps([26,1,2,5,10,15,8])),"../../../plugins-core/news/resources/js/widgets/Latest.vue":()=>f(()=>import(`./Latest-rEL3O0dw.js`),__vite__mapDeps([27,1,2,25,5,20,21,7,8]))}),v={};for(let[e,t]of Object.entries(g))v[`core::${e.split(`/`).pop().replace(`.vue`,``)}`]=d(t);for(let[e,t]of Object.entries(_)){let[,n]=e.match(/plugins-core\/([^/]+)\//);v[`${n}::${e.split(`/`).pop().replace(`.vue`,``)}`]=d(t)}function y(e){return v[e]??null}var b={key:0,class:`grid grid-cols-12 gap-6`},x={class:`col-span-8 grid min-w-0 grid-cols-1 content-start gap-6 xl:col-span-9 xl:grid-cols-3`},S={class:`col-span-4 grid min-w-0 grid-cols-1 content-start gap-6 xl:col-span-3`},C={key:1,class:`grid min-w-0 grid-cols-1 gap-6`},w={__name:`Dashboard`,props:{widgets:{type:Array,required:!0}},setup(d){let f=d,g=h(`(min-width: 1024px)`),_=i(()=>f.widgets.filter(e=>y(e.component))),v=e=>_.value.filter(t=>t.area===e),w=i(()=>v(`hero`)[0]??null),T=i(()=>[..._.value].sort((e,t)=>e.mobileSort-t.mobileSort));return(i,d)=>(a(),r(m,{title:`Startseite`},{default:t(()=>[u(g)?(a(),o(`div`,b,[p(`div`,x,[w.value?(a(),r(l(u(y)(w.value.component)),e({key:0},w.value.props,{class:`xl:col-span-2`}),null,16)):c(``,!0),(a(!0),o(n,null,s(v(`feed`),t=>(a(),r(l(u(y)(t.component)),e({key:t.key},{ref_for:!0},t.props,{wide:!w.value,class:w.value?`xl:col-span-1`:`xl:col-span-3`}),null,16,[`wide`,`class`]))),128)),(a(!0),o(n,null,s(v(`main`),t=>(a(),r(l(u(y)(t.component)),e({key:t.key},{ref_for:!0},t.props,{class:`xl:col-span-3`}),null,16))),128))]),p(`aside`,S,[(a(!0),o(n,null,s(v(`aside`),t=>(a(),r(l(u(y)(t.component)),e({key:t.key},{ref_for:!0},t.props),null,16))),128))])])):(a(),o(`div`,C,[(a(!0),o(n,null,s(T.value,t=>(a(),r(l(u(y)(t.component)),e({key:t.key},{ref_for:!0},t.props),null,16))),128))]))]),_:1}))}};export{w as default};
|
||||
File diff suppressed because one or more lines are too long
1
public/build/assets/Edit-DEVJjjGl.js
Normal file
1
public/build/assets/Edit-DEVJjjGl.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
public/build/assets/EmptyState-CFBmx8ne.js
Normal file
1
public/build/assets/EmptyState-CFBmx8ne.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{J as e,Wt as t,X as n,Y as r,Zt as i,en as a,q as o,ur as s}from"./app-DJnl8SxL.js";var c={class:`grid place-items-center px-6 py-10 text-center`},l={class:`mt-3 text-sm font-medium`},u={key:0,class:`mt-1 max-w-sm text-[13px] text-muted-foreground`},d={__name:`EmptyState`,props:{icon:{type:[Object,Function],required:!0},title:{type:String,required:!0},text:{type:String,default:``}},setup(d){return(f,p)=>(t(),n(`div`,c,[(t(),e(a(d.icon),{class:`size-8 text-muted-foreground`,"stroke-width":1.5})),o(`p`,l,s(d.title),1),d.text?(t(),n(`p`,u,s(d.text),1)):r(``,!0),i(f.$slots,`default`)]))}};export{d as t};
|
||||
|
|
@ -1 +0,0 @@
|
|||
import{$t as e,J as t,K as n,Ut as r,Xt as i,Y as a,lr as o,q as s}from"./app-D5-myltL.js";var c={class:`grid place-items-center px-6 py-10 text-center`},l={class:`mt-3 text-sm font-medium`},u={key:0,class:`mt-1 max-w-sm text-[13px] text-muted-foreground`},d={__name:`EmptyState`,props:{icon:{type:[Object,Function],required:!0},title:{type:String,required:!0},text:{type:String,default:``}},setup(d){return(f,p)=>(r(),a(`div`,c,[(r(),s(e(d.icon),{class:`size-8 text-muted-foreground`,"stroke-width":1.5})),n(`p`,l,o(d.title),1),d.text?(r(),a(`p`,u,o(d.text),1)):t(``,!0),i(f.$slots,`default`)]))}};export{d as t};
|
||||
|
|
@ -1 +1 @@
|
|||
import{G as e,K as t,Ut as n,Y as r,lr as i}from"./app-D5-myltL.js";import{t as a}from"./format-Dlm0nTI_.js";var o={class:`grid w-12 shrink-0 place-items-center rounded-md bg-muted py-1.5 leading-none`},s={class:`text-xl font-semibold`},c={class:`mt-1 text-[10px] font-semibold tracking-wide text-muted-foreground`},l={__name:`EventDateBlock`,props:{date:{type:String,required:!0}},setup(l){let u=l,d=e(()=>a(u.date));return(e,a)=>(n(),r(`div`,o,[t(`span`,s,i(d.value.day),1),t(`span`,c,i(d.value.month),1)]))}};export{l as t};
|
||||
import{K as e,Wt as t,X as n,q as r,ur as i}from"./app-DJnl8SxL.js";import{t as a}from"./format-Dlm0nTI_.js";var o={class:`grid w-12 shrink-0 place-items-center rounded-md bg-muted py-1.5 leading-none`},s={class:`text-xl font-semibold`},c={class:`mt-1 text-[10px] font-semibold tracking-wide text-muted-foreground`},l={__name:`EventDateBlock`,props:{date:{type:String,required:!0}},setup(l){let u=l,d=e(()=>a(u.date));return(e,a)=>(t(),n(`div`,o,[r(`span`,s,i(d.value.day),1),r(`span`,c,i(d.value.month),1)]))}};export{l as t};
|
||||
|
|
@ -1 +0,0 @@
|
|||
import{J as e,K as t,Sn as n,Ut as r,Y as i,k as a,lr as o,n as s,nt as c,q as l,r as u,rr as d,tt as f}from"./app-D5-myltL.js";import{k as p}from"./BrandLogo-6n9qq87f.js";import{t as m}from"./arrow-left-99a39ArM.js";import{t as h}from"./button-CK8gfgLI.js";import{r as g,t as _}from"./FormField-BxtniYWy.js";import{t as v}from"./GuestLayout-DXTg9GcL.js";var y={key:0,class:`mb-6 rounded-md border border-brand-200 bg-brand-soft px-4 py-3 text-sm text-brand-soft-foreground`},b={__name:`ForgotPassword`,props:{status:{type:String,default:null}},setup(b){let x=u({email:``});return(u,S)=>(r(),l(v,{title:`Passwort vergessen`,description:`Wir senden Ihnen einen Link, mit dem Sie ein neues Passwort festlegen können.`},{default:n(()=>[b.status?(r(),i(`div`,y,o(b.status),1)):e(``,!0),t(`form`,{class:`grid gap-5`,onSubmit:S[1]||=a(e=>d(x).post(`/forgot-password`),[`prevent`])},[c(_,{id:`email`,label:`E-Mail-Adresse`,error:d(x).errors.email},{default:n(()=>[c(d(g),{id:`email`,modelValue:d(x).email,"onUpdate:modelValue":S[0]||=e=>d(x).email=e,type:`email`,autocomplete:`username`,autofocus:``,class:`h-10`},null,8,[`modelValue`])]),_:1},8,[`error`]),c(d(h),{type:`submit`,size:`lg`,class:`h-10 w-full`,disabled:d(x).processing},{default:n(()=>[d(x).processing?(r(),l(d(p),{key:0,class:`animate-spin`})):e(``,!0),S[2]||=f(` Link senden `,-1)]),_:1},8,[`disabled`]),c(d(s),{href:`/login`,class:`inline-flex items-center justify-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground`},{default:n(()=>[c(d(m),{class:`size-4`}),S[3]||=f(` Zurück zur Anmeldung `,-1)]),_:1})],32)]),_:1}))}};export{b as default};
|
||||
1
public/build/assets/ForgotPassword-D94Q6-9V.js
Normal file
1
public/build/assets/ForgotPassword-D94Q6-9V.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{A as e,Cn as t,J as n,Wt as r,X as i,Y as a,ir as o,n as s,nt as c,q as l,r as u,rt as d,ur as f}from"./app-DJnl8SxL.js";import{j as p}from"./BrandLogo-B9oA1DG4.js";import{t as m}from"./arrow-left-CAaEosyK.js";import{r as h,t as g}from"./FormField-BmjgU2Yw.js";import{t as _}from"./button-9_XTGiWz.js";import{t as v}from"./GuestLayout-BQuErbaI.js";var y={key:0,class:`mb-6 rounded-md border border-brand-200 bg-brand-soft px-4 py-3 text-sm text-brand-soft-foreground`},b={__name:`ForgotPassword`,props:{status:{type:String,default:null}},setup(b){let x=u({email:``});return(u,S)=>(r(),n(v,{title:`Passwort vergessen`,description:`Wir senden Ihnen einen Link, mit dem Sie ein neues Passwort festlegen können.`},{default:t(()=>[b.status?(r(),i(`div`,y,f(b.status),1)):a(``,!0),l(`form`,{class:`grid gap-5`,onSubmit:S[1]||=e(e=>o(x).post(`/forgot-password`),[`prevent`])},[d(g,{id:`email`,label:`E-Mail-Adresse`,error:o(x).errors.email},{default:t(()=>[d(o(h),{id:`email`,modelValue:o(x).email,"onUpdate:modelValue":S[0]||=e=>o(x).email=e,type:`email`,autocomplete:`username`,autofocus:``,class:`h-10`},null,8,[`modelValue`])]),_:1},8,[`error`]),d(o(_),{type:`submit`,size:`lg`,class:`h-10 w-full`,disabled:o(x).processing},{default:t(()=>[o(x).processing?(r(),n(o(p),{key:0,class:`animate-spin`})):a(``,!0),S[2]||=c(` Link senden `,-1)]),_:1},8,[`disabled`]),d(o(s),{href:`/login`,class:`inline-flex items-center justify-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground`},{default:t(()=>[d(o(m),{class:`size-4`}),S[3]||=c(` Zurück zur Anmeldung `,-1)]),_:1})],32)]),_:1}))}};export{b as default};
|
||||
1
public/build/assets/FormField-BmjgU2Yw.js
Normal file
1
public/build/assets/FormField-BmjgU2Yw.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{At as e,Bn as t,Cn as n,D as r,J as i,Tn as a,Wt as o,X as s,Y as c,Zt as l,at as u,ir as d,nt as f,rt as p,sr as m,ur as h}from"./app-DJnl8SxL.js";import{g,l as _,m as v,n as y}from"./BrandLogo-B9oA1DG4.js";import{i as b}from"./dist-CQsPCHOQ.js";var x=u({__name:`Label`,props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`label`}},setup(t){let r=t;return g(),(t,a)=>(o(),i(d(v),e(r,{onMousedown:a[0]||=e=>{!e.defaultPrevented&&e.detail>1&&e.preventDefault()}}),{default:n(()=>[l(t.$slots,`default`)]),_:3},16))}}),S=u({__name:`Input`,props:{defaultValue:{},modelValue:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:n}){let i=e,c=b(i,`modelValue`,n,{passive:!0,defaultValue:i.defaultValue});return(e,n)=>a((o(),s(`input`,{"onUpdate:modelValue":n[0]||=e=>t(c)?c.value=e:null,"data-slot":`input`,class:m(d(y)(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,i.class))},null,2)),[[r,d(c)]])}}),C=u({__name:`Label`,props:{for:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(t){let r=t,a=_(r,`class`);return(t,s)=>(o(),i(d(x),e({"data-slot":`label`},d(a),{class:d(y)(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,r.class)}),{default:n(()=>[l(t.$slots,`default`)]),_:3},16,[`class`]))}}),w={class:`grid content-start gap-1.5`},T={key:0,class:`text-[13px] text-destructive`},E={key:1,class:`text-[13px] text-muted-foreground`},D={__name:`FormField`,props:{id:{type:String,required:!0},label:{type:String,required:!0},error:{type:String,default:``},hint:{type:String,default:``}},setup(e){return(t,r)=>(o(),s(`div`,w,[p(d(C),{for:e.id,class:`text-[13px] font-medium`},{default:n(()=>[f(h(e.label),1)]),_:1},8,[`for`]),l(t.$slots,`default`),e.error?(o(),s(`p`,T,h(e.error),1)):e.hint?(o(),s(`p`,E,h(e.hint),1)):c(``,!0)]))}};export{C as n,S as r,D as t};
|
||||
|
|
@ -1 +0,0 @@
|
|||
import{E as e,J as t,Sn as n,Ut as r,Xt as i,Y as a,it as o,kt as s,lr as c,nt as l,or as u,q as d,rr as f,tt as p,wn as m,zn as h}from"./app-D5-myltL.js";import{a as g,d as _,p as v,u as y}from"./BrandLogo-6n9qq87f.js";import{r as b}from"./dist-BaRwaKfU.js";var x=o({__name:`Label`,props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`label`}},setup(e){let t=e;return v(),(e,a)=>(r(),d(f(_),s(t,{onMousedown:a[0]||=e=>{!e.defaultPrevented&&e.detail>1&&e.preventDefault()}}),{default:n(()=>[i(e.$slots,`default`)]),_:3},16))}}),S=o({__name:`Input`,props:{defaultValue:{},modelValue:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,o=b(i,`modelValue`,n,{passive:!0,defaultValue:i.defaultValue});return(t,n)=>m((r(),a(`input`,{"onUpdate:modelValue":n[0]||=e=>h(o)?o.value=e:null,"data-slot":`input`,class:u(f(y)(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,i.class))},null,2)),[[e,f(o)]])}}),C=o({__name:`Label`,props:{for:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,a=g(t,`class`);return(e,o)=>(r(),d(f(x),s({"data-slot":`label`},f(a),{class:f(y)(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,t.class)}),{default:n(()=>[i(e.$slots,`default`)]),_:3},16,[`class`]))}}),w={class:`grid content-start gap-1.5`},T={key:0,class:`text-[13px] text-destructive`},E={key:1,class:`text-[13px] text-muted-foreground`},D={__name:`FormField`,props:{id:{type:String,required:!0},label:{type:String,required:!0},error:{type:String,default:``},hint:{type:String,default:``}},setup(e){return(o,s)=>(r(),a(`div`,w,[l(f(C),{for:e.id,class:`text-[13px] font-medium`},{default:n(()=>[p(c(e.label),1)]),_:1},8,[`for`]),i(o.$slots,`default`),e.error?(r(),a(`p`,T,c(e.error),1)):e.hint?(r(),a(`p`,E,c(e.hint),1)):t(``,!0)]))}};export{C as n,S as r,D as t};
|
||||
1
public/build/assets/Greeting-BcYAXPh9.js
Normal file
1
public/build/assets/Greeting-BcYAXPh9.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,J as t,K as n,Wt as r,X as i,i as a,ir as o,n as s,nt as c,q as l,rt as u,ur as d}from"./app-DJnl8SxL.js";import{a as f,i as p,l as m,n as h,o as g}from"./AppLayout-1ldLchM-.js";var _={class:`overflow-hidden rounded-lg border bg-card`},v={class:`flex items-center justify-between gap-4 bg-brand px-6 py-6 text-brand-foreground`},y={class:`min-w-0`},b={class:`text-sm opacity-85`},x={class:`mt-0.5 text-[22px] leading-tight font-semibold tracking-tight break-words`},S={class:`mt-1.5 line-clamp-2 text-[13px] opacity-85`},C={class:`grid grid-cols-3 divide-x`,"aria-label":`Mein Bereich`},w={key:0,href:`/admin`,class:`flex flex-col items-center gap-2 px-2 py-4 text-center text-xs font-medium text-foreground/80 hover:bg-accent hover:text-foreground`},T={__name:`GreetingCard`,props:{user:{type:Object,required:!0},profile:{type:Object,required:!0},greeting:{type:String,required:!0}},setup(n){return(a,T)=>(r(),i(`section`,_,[l(`div`,v,[l(`div`,y,[l(`div`,b,d(n.greeting)+`,`,1),l(`div`,x,d(n.user.name),1),l(`div`,S,d(n.profile.job_title||`Schön, dass Sie da sind!`),1)]),u(h,{person:n.user,class:`size-16 shrink-0 text-lg ring-4 ring-white/25 xl:size-20 xl:text-xl`},null,8,[`person`])]),l(`nav`,C,[u(o(s),{href:`/personen/${n.user.id}`,class:`flex flex-col items-center gap-2 px-2 py-4 text-center text-xs font-medium text-foreground/80 hover:bg-accent hover:text-foreground`},{default:e(()=>[u(o(p),{class:`size-5 text-brand-text`,"stroke-width":1.75}),T[0]||=c(` Mein Profil `,-1)]),_:1},8,[`href`]),u(o(s),{href:`/profil/bearbeiten`,class:`flex flex-col items-center gap-2 px-2 py-4 text-center text-xs font-medium text-foreground/80 hover:bg-accent hover:text-foreground`},{default:e(()=>[u(o(f),{class:`size-5 text-brand-text`,"stroke-width":1.75}),T[1]||=c(` Profil bearbeiten `,-1)]),_:1}),n.user.is_admin?(r(),i(`a`,w,[u(o(g),{class:`size-5 text-brand-text`,"stroke-width":1.75}),T[2]||=c(` Administration `,-1)])):(r(),t(o(s),{key:1,href:`/logout`,method:`post`,as:`button`,class:`flex flex-col items-center gap-2 px-2 py-4 text-center text-xs font-medium text-foreground/80 hover:bg-accent hover:text-foreground`},{default:e(()=>[u(o(m),{class:`size-5 text-brand-text`,"stroke-width":1.75}),T[3]||=c(` Abmelden `,-1)]),_:1}))])]))}},E={__name:`Greeting`,props:{profile:{type:Object,required:!0}},setup(e){let i=e,o=a(),s=n(()=>({...o.props.auth.user,avatar_url:i.profile.avatar_url})),c=n(()=>{let e=new Date().getHours();return e<11?`Guten Morgen`:e<18?`Guten Tag`:`Guten Abend`});return(n,i)=>(r(),t(T,{user:s.value,profile:e.profile,greeting:c.value},null,8,[`user`,`profile`,`greeting`]))}};export{E as default};
|
||||
|
|
@ -1 +1 @@
|
|||
import{F as e,G as t,J as n,K as r,Ut as i,Xt as a,Y as o,i as s,lr as c,nt as l,rr as u,t as d}from"./app-D5-myltL.js";import{t as f}from"./BrandLogo-6n9qq87f.js";var p={class:`grid min-h-screen lg:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`},m={class:`relative hidden overflow-hidden bg-brand text-brand-foreground lg:flex lg:flex-col lg:justify-between lg:p-12`},h={class:`relative max-w-md`},g={class:`mt-4 text-[15px] opacity-80`},_={class:`relative text-xs opacity-60`},v={class:`flex items-center justify-center bg-background px-4 py-12 sm:px-8`},y={class:`w-full max-w-[400px]`},b={class:`mb-10 lg:hidden`},x={class:`text-2xl font-semibold tracking-tight`},S={key:0,class:`mt-2 text-sm text-muted-foreground`},C={class:`mt-8`},w={__name:`GuestLayout`,props:{title:{type:String,default:``},description:{type:String,default:``}},setup(w){let T=w,E=t(()=>s().props.branding);return(t,s)=>(i(),o(e,null,[l(u(d),{title:T.title},null,8,[`title`]),r(`div`,p,[r(`aside`,m,[s[1]||=r(`div`,{class:`pointer-events-none absolute inset-0 opacity-[0.12]`,style:{"background-image":`radial-gradient(circle at 20% 20%, white 0, transparent 45%), radial-gradient(circle at 90% 80%, white 0, transparent 40%)`}},null,-1),l(f,{inverted:``,class:`relative`}),r(`div`,h,[s[0]||=r(`p`,{class:`text-3xl leading-tight font-semibold tracking-tight`},`Alles Wichtige für Ihren Arbeitsalltag – an einem Ort.`,-1),r(`p`,g,`Neuigkeiten, Ansprechpartner und Anwendungen von `+c(E.value.portal_name)+`.`,1)]),r(`p`,_,`© `+c(new Date().getFullYear())+` `+c(E.value.portal_name),1)]),r(`main`,v,[r(`div`,y,[r(`div`,b,[l(f)]),r(`h1`,x,c(T.title),1),T.description?(i(),o(`p`,S,c(T.description),1)):n(``,!0),r(`div`,C,[a(t.$slots,`default`)])])])])],64))}};export{w as t};
|
||||
import{I as e,K as t,Wt as n,X as r,Y as i,Zt as a,i as o,ir as s,q as c,rt as l,t as u,ur as d}from"./app-DJnl8SxL.js";import{t as f}from"./BrandLogo-B9oA1DG4.js";var p={class:`grid min-h-screen lg:grid-cols-[minmax(0,5fr)_minmax(0,6fr)]`},m={class:`relative hidden overflow-hidden bg-brand text-brand-foreground lg:flex lg:flex-col lg:justify-between lg:p-12`},h={class:`relative max-w-md`},g={class:`mt-4 text-[15px] opacity-80`},_={class:`relative text-xs opacity-60`},v={class:`flex items-center justify-center bg-background px-4 py-12 sm:px-8`},y={class:`w-full max-w-[400px]`},b={class:`mb-10 lg:hidden`},x={class:`text-2xl font-semibold tracking-tight`},S={key:0,class:`mt-2 text-sm text-muted-foreground`},C={class:`mt-8`},w={__name:`GuestLayout`,props:{title:{type:String,default:``},description:{type:String,default:``}},setup(w){let T=w,E=t(()=>o().props.branding);return(t,o)=>(n(),r(e,null,[l(s(u),{title:T.title},null,8,[`title`]),c(`div`,p,[c(`aside`,m,[o[1]||=c(`div`,{class:`pointer-events-none absolute inset-0 opacity-[0.12]`,style:{"background-image":`radial-gradient(circle at 20% 20%, white 0, transparent 45%), radial-gradient(circle at 90% 80%, white 0, transparent 40%)`}},null,-1),l(f,{inverted:``,class:`relative`}),c(`div`,h,[o[0]||=c(`p`,{class:`text-3xl leading-tight font-semibold tracking-tight`},`Alles Wichtige für Ihren Arbeitsalltag – an einem Ort.`,-1),c(`p`,g,`Neuigkeiten, Ansprechpartner und Anwendungen von `+d(E.value.portal_name)+`.`,1)]),c(`p`,_,`© `+d(new Date().getFullYear())+` `+d(E.value.portal_name),1)]),c(`main`,v,[c(`div`,y,[c(`div`,b,[l(f)]),c(`h1`,x,d(T.title),1),T.description?(n(),r(`p`,S,d(T.description),1)):i(``,!0),c(`div`,C,[a(t.$slots,`default`)])])])])],64))}};export{w as t};
|
||||
1
public/build/assets/Hero-oumSJF6b.js
Normal file
1
public/build/assets/Hero-oumSJF6b.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,I as t,J as n,Jn as r,K as i,O as a,Pt as o,Rt as s,Tn as c,Wt as l,X as u,Xt as d,Y as f,c as p,ir as m,n as h,nt as g,q as _,rt as v,sr as y,ur as b}from"./app-DJnl8SxL.js";import{M as x}from"./BrandLogo-B9oA1DG4.js";import{t as S}from"./arrow-right-c2thy74C.js";import{t as C}from"./chevron-left-D2uxffyU.js";import{t as w}from"./chevron-right-CAXGr-zo.js";var T=x({name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]}),E=x({name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]}),D=[`src`],O={class:`flex h-full flex-col justify-end p-6 sm:max-w-[65%] sm:justify-center sm:p-10`,"aria-live":`polite`},k={key:0,class:`mb-3 w-fit rounded-sm bg-brand px-2 py-0.5 text-[11px] font-semibold tracking-wide text-brand-foreground uppercase`},A={class:`text-2xl leading-tight font-semibold tracking-tight sm:text-[32px]`},j={key:1,class:`mt-3 line-clamp-3 hidden text-[15px] text-white/85 sm:block`},M={key:0,class:`absolute right-4 bottom-4 flex items-center gap-2 sm:right-6 sm:bottom-6`},N={class:`flex items-center gap-1.5 px-1`},P=[`aria-label`,`aria-current`,`onClick`],F=[`aria-label`],I={__name:`HeroSlider`,props:{posts:{type:Array,required:!0}},setup(x){let I=x,L=r(0),R=r(!1),z=i(()=>I.posts[L.value]),B=null;function V(e){L.value=(e+I.posts.length)%I.posts.length}function H(){U(),I.posts.length>1&&!R.value&&!window.matchMedia(`(prefers-reduced-motion: reduce)`).matches&&(B=setInterval(()=>V(L.value+1),7e3))}function U(){clearInterval(B)}function W(){R.value=!R.value,H()}return s(H),o(U),(r,i)=>(l(),u(`section`,{class:`relative isolate aspect-[16/10] overflow-hidden rounded-lg bg-brand-950 text-white sm:aspect-[16/9] lg:aspect-auto lg:h-full lg:min-h-[400px]`,"aria-roledescription":`Karussell`,"aria-label":`Hervorgehobene Neuigkeiten`,onMouseenter:U,onMouseleave:H,onFocusin:U,onFocusout:H},[v(p,{"enter-active-class":`transition-opacity duration-700`,"leave-active-class":`transition-opacity duration-700 absolute inset-0`,"enter-from-class":`opacity-0`,"leave-to-class":`opacity-0`},{default:e(()=>[(l(!0),u(t,null,d(x.posts,(e,t)=>c((l(),u(`img`,{key:e.id,src:e.cover_url,alt:``,class:`absolute inset-0 -z-10 size-full object-cover`},null,8,D)),[[a,t===L.value]])),128))]),_:1}),i[3]||=_(`div`,{class:`absolute inset-0 -z-10 bg-gradient-to-t from-black/80 via-black/35 to-black/5 sm:bg-gradient-to-r sm:from-black/75 sm:via-black/40 sm:to-transparent`},null,-1),_(`div`,O,[z.value.category?(l(),u(`span`,k,b(z.value.category.name),1)):f(``,!0),_(`h2`,A,b(z.value.title),1),z.value.teaser?(l(),u(`p`,j,b(z.value.teaser),1)):f(``,!0),v(m(h),{href:`/neuigkeiten/${z.value.slug}`,class:`mt-5 inline-flex w-fit items-center gap-2 rounded-md bg-brand px-4 py-2.5 text-sm font-medium text-brand-foreground transition-colors hover:bg-brand-700`},{default:e(()=>[i[2]||=g(` Mehr erfahren `,-1),v(m(S),{class:`size-4`})]),_:1},8,[`href`])]),x.posts.length>1?(l(),u(`div`,M,[_(`button`,{type:`button`,class:`grid size-9 place-items-center rounded-full bg-black/35 hover:bg-black/55`,"aria-label":`Vorheriger Beitrag`,onClick:i[0]||=e=>V(L.value-1)},[v(m(C),{class:`size-5`})]),_(`div`,N,[(l(!0),u(t,null,d(x.posts,(e,t)=>(l(),u(`button`,{key:e.id,type:`button`,class:y([`h-1.5 rounded-full transition-all`,t===L.value?`w-6 bg-white`:`w-1.5 bg-white/50 hover:bg-white/80`]),"aria-label":`Beitrag ${t+1} von ${x.posts.length}`,"aria-current":t===L.value,onClick:e=>V(t)},null,10,P))),128))]),_(`button`,{type:`button`,class:`grid size-9 place-items-center rounded-full bg-black/35 hover:bg-black/55`,"aria-label":`Nächster Beitrag`,onClick:i[1]||=e=>V(L.value+1)},[v(m(w),{class:`size-5`})]),_(`button`,{type:`button`,class:`grid size-9 place-items-center rounded-full bg-black/35 hover:bg-black/55`,"aria-label":R.value?`Automatisch weiterblättern`:`Anhalten`,onClick:W},[R.value?(l(),n(m(E),{key:0,class:`size-4`})):(l(),n(m(T),{key:1,class:`size-4`}))],8,F)])):f(``,!0)],32))}},L={__name:`Hero`,props:{posts:{type:Array,required:!0}},setup(e){return(t,r)=>(l(),n(I,{posts:e.posts,class:`h-full`},null,8,[`posts`]))}};export{L as default};
|
||||
File diff suppressed because one or more lines are too long
1
public/build/assets/Index-CinqnjLj.js
Normal file
1
public/build/assets/Index-CinqnjLj.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,I as t,J as n,Wt as r,X as i,Xt as a,Y as o,a as s,ir as c,n as l,nt as u,q as d,rt as f,sr as p,ur as m}from"./app-DJnl8SxL.js";import{t as h}from"./AppLayout-1ldLchM-.js";import{t as g}from"./chevron-left-D2uxffyU.js";import{t as _}from"./chevron-right-CAXGr-zo.js";import{r as v}from"./NewsImage-DyRK4fmY.js";import{t as y}from"./EmptyState-CFBmx8ne.js";import{t as b}from"./button-9_XTGiWz.js";import{t as x}from"./NewsCard-B-l5uZ4h.js";var S={key:0,class:`mb-6 flex flex-wrap gap-2`,"aria-label":`Kategorien`},C={key:1,class:`grid gap-5 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4`},w={key:2,class:`rounded-lg border border-dashed bg-card`},T={key:3,class:`mt-8 flex items-center justify-between`,"aria-label":`Seiten`},E={class:`text-sm text-muted-foreground`},D={class:`flex gap-2`},O={__name:`Index`,props:{posts:{type:Object,required:!0},categories:{type:Array,required:!0},activeCategory:{type:String,default:null}},setup(O){return(k,A)=>(r(),n(h,{title:`Neuigkeiten`},{default:e(()=>[A[5]||=d(`div`,{class:`mb-6`},[d(`h1`,{class:`text-2xl font-semibold tracking-tight`},`Neuigkeiten`),d(`p`,{class:`mt-1 text-sm text-muted-foreground`},`Aktuelles aus dem Unternehmen und den Bereichen.`)],-1),O.categories.length?(r(),i(`nav`,S,[f(c(l),{href:`/neuigkeiten`,class:p([`rounded-full border px-3.5 py-1.5 text-[13px] font-medium transition-colors`,O.activeCategory?`bg-card hover:bg-accent`:`border-brand bg-brand text-brand-foreground`]),"preserve-scroll":``},{default:e(()=>[...A[2]||=[u(` Alle `,-1)]]),_:1},8,[`class`]),(r(!0),i(t,null,a(O.categories,t=>(r(),n(c(l),{key:t.slug,href:`/neuigkeiten?kategorie=${t.slug}`,class:p([`rounded-full border px-3.5 py-1.5 text-[13px] font-medium transition-colors`,O.activeCategory===t.slug?`border-brand bg-brand text-brand-foreground`:`bg-card hover:bg-accent`]),"preserve-scroll":``},{default:e(()=>[u(m(t.name),1)]),_:2},1032,[`href`,`class`]))),128))])):o(``,!0),O.posts.data.length?(r(),i(`div`,C,[(r(!0),i(t,null,a(O.posts.data,e=>(r(),n(x,{key:e.id,post:e},null,8,[`post`]))),128))])):(r(),i(`div`,w,[f(y,{icon:c(v),title:`Keine Beiträge`,text:`In dieser Kategorie ist noch nichts veröffentlicht.`},null,8,[`icon`])])),O.posts.meta.last_page>1?(r(),i(`nav`,T,[d(`p`,E,`Seite `+m(O.posts.meta.current_page)+` von `+m(O.posts.meta.last_page),1),d(`div`,D,[f(c(b),{variant:`outline`,size:`sm`,disabled:!O.posts.links.prev,onClick:A[0]||=e=>c(s).get(O.posts.links.prev)},{default:e(()=>[f(c(g)),A[3]||=u(` Neuere`,-1)]),_:1},8,[`disabled`]),f(c(b),{variant:`outline`,size:`sm`,disabled:!O.posts.links.next,onClick:A[1]||=e=>c(s).get(O.posts.links.next)},{default:e(()=>[A[4]||=u(`Ältere `,-1),f(c(_))]),_:1},8,[`disabled`])])])):o(``,!0)]),_:1}))}};export{O as default};
|
||||
1
public/build/assets/Index-DeGPLaWM.js
Normal file
1
public/build/assets/Index-DeGPLaWM.js
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1 +0,0 @@
|
|||
import{F as e,G as t,J as n,K as r,Sn as i,Ut as a,Y as o,Yt as s,lr as c,n as l,nt as u,q as d,rr as f,tt as p}from"./app-D5-myltL.js";import{t as m}from"./calendar-days-idvOkJ3J.js";import{t as h}from"./AppLayout-DI-U1ko3.js";import{t as g}from"./map-pin-gOUT4ItV.js";import{t as _}from"./video-Bvsp0re8.js";import{t as v}from"./EmptyState-wvjgIxp3.js";import{i as y,r as b}from"./format-Dlm0nTI_.js";import{t as x}from"./EventDateBlock-BEMye_DY.js";var S={key:0,class:`grid max-w-4xl gap-8`},C={class:`mb-3 text-sm font-semibold text-muted-foreground`},w={class:`divide-y rounded-lg border bg-card`},T={class:`min-w-0 flex-1`},E={class:`text-[15px] font-semibold group-hover:underline`},D={class:`mt-0.5 text-[13px] text-muted-foreground`},O={key:0,class:`mt-0.5 flex items-center gap-1.5 text-[13px] text-muted-foreground`},k=[`src`],A={key:1,class:`max-w-4xl rounded-lg border border-dashed bg-card`},j={__name:`Index`,props:{events:{type:Object,required:!0}},setup(j){let M=j,N=t(()=>{let e=[];for(let t of M.events.data){let n=new Date(t.starts_at),r=y((n<new Date?new Date:n).toISOString()),i=e[e.length-1];i?.label===r?i.events.push(t):e.push({label:r,events:[t]})}return e});return(t,y)=>(a(),d(h,{title:`Termine`},{default:i(()=>[y[0]||=r(`div`,{class:`mb-6`},[r(`h1`,{class:`text-2xl font-semibold tracking-tight`},`Termine`),r(`p`,{class:`mt-1 text-sm text-muted-foreground`},`Veranstaltungen, Fortbildungen und Treffen.`)],-1),N.value.length?(a(),o(`div`,S,[(a(!0),o(e,null,s(N.value,t=>(a(),o(`section`,{key:t.label},[r(`h2`,C,c(t.label),1),r(`ul`,w,[(a(!0),o(e,null,s(t.events,e=>(a(),o(`li`,{key:e.id},[u(f(l),{href:`/termine/${e.id}`,class:`group flex items-center gap-4 p-4 transition-colors hover:bg-accent/60`},{default:i(()=>[u(x,{date:e.starts_at,class:`w-14`},null,8,[`date`]),r(`div`,T,[r(`h3`,E,c(e.title),1),r(`p`,D,c(f(b)(e)),1),e.location||e.online_url?(a(),o(`p`,O,[e.location?(a(),d(f(g),{key:0,class:`size-3.5`})):(a(),d(f(_),{key:1,class:`size-3.5`})),p(` `+c(e.location||`Online`),1)])):n(``,!0)]),e.thumb_url?(a(),o(`img`,{key:0,src:e.thumb_url,alt:``,loading:`lazy`,class:`hidden h-16 w-28 shrink-0 rounded-md object-cover sm:block`},null,8,k)):n(``,!0)]),_:2},1032,[`href`])]))),128))])]))),128))])):(a(),o(`div`,A,[u(v,{icon:f(m),title:`Keine anstehenden Termine`,text:`Neue Termine erscheinen hier, sobald sie eingetragen sind.`},null,8,[`icon`])]))]),_:1}))}};export{j as default};
|
||||
1
public/build/assets/Index-M1eUDNcS.js
Normal file
1
public/build/assets/Index-M1eUDNcS.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,I as t,J as n,K as r,Wt as i,X as a,Xt as o,Y as s,ir as c,n as l,nt as u,q as d,rt as f,ur as p}from"./app-DJnl8SxL.js";import{t as m}from"./calendar-days-Q7KBeYQV.js";import{t as h}from"./AppLayout-1ldLchM-.js";import{t as g}from"./map-pin-A7DprnXY.js";import{t as _}from"./video-RhaN0-fc.js";import{t as v}from"./EmptyState-CFBmx8ne.js";import{i as y,r as b}from"./format-Dlm0nTI_.js";import{t as x}from"./EventDateBlock-CfSpm6m9.js";var S={key:0,class:`grid max-w-4xl gap-8`},C={class:`mb-3 text-sm font-semibold text-muted-foreground`},w={class:`divide-y rounded-lg border bg-card`},T={class:`min-w-0 flex-1`},E={class:`text-[15px] font-semibold group-hover:underline`},D={class:`mt-0.5 text-[13px] text-muted-foreground`},O={key:0,class:`mt-0.5 flex items-center gap-1.5 text-[13px] text-muted-foreground`},k=[`src`],A={key:1,class:`max-w-4xl rounded-lg border border-dashed bg-card`},j={__name:`Index`,props:{events:{type:Object,required:!0}},setup(j){let M=j,N=r(()=>{let e=[];for(let t of M.events.data){let n=new Date(t.starts_at),r=y((n<new Date?new Date:n).toISOString()),i=e[e.length-1];i?.label===r?i.events.push(t):e.push({label:r,events:[t]})}return e});return(r,y)=>(i(),n(h,{title:`Termine`},{default:e(()=>[y[0]||=d(`div`,{class:`mb-6`},[d(`h1`,{class:`text-2xl font-semibold tracking-tight`},`Termine`),d(`p`,{class:`mt-1 text-sm text-muted-foreground`},`Veranstaltungen, Fortbildungen und Treffen.`)],-1),N.value.length?(i(),a(`div`,S,[(i(!0),a(t,null,o(N.value,r=>(i(),a(`section`,{key:r.label},[d(`h2`,C,p(r.label),1),d(`ul`,w,[(i(!0),a(t,null,o(r.events,t=>(i(),a(`li`,{key:t.id},[f(c(l),{href:`/termine/${t.id}`,class:`group flex items-center gap-4 p-4 transition-colors hover:bg-accent/60`},{default:e(()=>[f(x,{date:t.starts_at,class:`w-14`},null,8,[`date`]),d(`div`,T,[d(`h3`,E,p(t.title),1),d(`p`,D,p(c(b)(t)),1),t.location||t.online_url?(i(),a(`p`,O,[t.location?(i(),n(c(g),{key:0,class:`size-3.5`})):(i(),n(c(_),{key:1,class:`size-3.5`})),u(` `+p(t.location||`Online`),1)])):s(``,!0)]),t.thumb_url?(i(),a(`img`,{key:0,src:t.thumb_url,alt:``,loading:`lazy`,class:`hidden h-16 w-28 shrink-0 rounded-md object-cover sm:block`},null,8,k)):s(``,!0)]),_:2},1032,[`href`])]))),128))])]))),128))])):(i(),a(`div`,A,[f(v,{icon:c(m),title:`Keine anstehenden Termine`,text:`Neue Termine erscheinen hier, sobald sie eingetragen sind.`},null,8,[`icon`])]))]),_:1}))}};export{j as default};
|
||||
|
|
@ -1 +0,0 @@
|
|||
import{F as e,J as t,K as n,Sn as r,Ut as i,Y as a,Yt as o,a as s,lr as c,n as l,nt as u,or as d,q as f,rr as p,tt as m}from"./app-D5-myltL.js";import{t as h}from"./AppLayout-DI-U1ko3.js";import{t as g}from"./chevron-left-DJf03pzL.js";import{t as _}from"./chevron-right-3K_kIePF.js";import{i as v,t as y}from"./NewsCard-C3zrf7NQ.js";import{t as b}from"./button-CK8gfgLI.js";import{t as x}from"./EmptyState-wvjgIxp3.js";var S={key:0,class:`mb-6 flex flex-wrap gap-2`,"aria-label":`Kategorien`},C={key:1,class:`grid gap-5 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4`},w={key:2,class:`rounded-lg border border-dashed bg-card`},T={key:3,class:`mt-8 flex items-center justify-between`,"aria-label":`Seiten`},E={class:`text-sm text-muted-foreground`},D={class:`flex gap-2`},O={__name:`Index`,props:{posts:{type:Object,required:!0},categories:{type:Array,required:!0},activeCategory:{type:String,default:null}},setup(O){return(k,A)=>(i(),f(h,{title:`Neuigkeiten`},{default:r(()=>[A[5]||=n(`div`,{class:`mb-6`},[n(`h1`,{class:`text-2xl font-semibold tracking-tight`},`Neuigkeiten`),n(`p`,{class:`mt-1 text-sm text-muted-foreground`},`Aktuelles aus dem Unternehmen und den Bereichen.`)],-1),O.categories.length?(i(),a(`nav`,S,[u(p(l),{href:`/neuigkeiten`,class:d([`rounded-full border px-3.5 py-1.5 text-[13px] font-medium transition-colors`,O.activeCategory?`bg-card hover:bg-accent`:`border-brand bg-brand text-brand-foreground`]),"preserve-scroll":``},{default:r(()=>[...A[2]||=[m(` Alle `,-1)]]),_:1},8,[`class`]),(i(!0),a(e,null,o(O.categories,e=>(i(),f(p(l),{key:e.slug,href:`/neuigkeiten?kategorie=${e.slug}`,class:d([`rounded-full border px-3.5 py-1.5 text-[13px] font-medium transition-colors`,O.activeCategory===e.slug?`border-brand bg-brand text-brand-foreground`:`bg-card hover:bg-accent`]),"preserve-scroll":``},{default:r(()=>[m(c(e.name),1)]),_:2},1032,[`href`,`class`]))),128))])):t(``,!0),O.posts.data.length?(i(),a(`div`,C,[(i(!0),a(e,null,o(O.posts.data,e=>(i(),f(y,{key:e.id,post:e},null,8,[`post`]))),128))])):(i(),a(`div`,w,[u(x,{icon:p(v),title:`Keine Beiträge`,text:`In dieser Kategorie ist noch nichts veröffentlicht.`},null,8,[`icon`])])),O.posts.meta.last_page>1?(i(),a(`nav`,T,[n(`p`,E,`Seite `+c(O.posts.meta.current_page)+` von `+c(O.posts.meta.last_page),1),n(`div`,D,[u(p(b),{variant:`outline`,size:`sm`,disabled:!O.posts.links.prev,onClick:A[0]||=e=>p(s).get(O.posts.links.prev)},{default:r(()=>[u(p(g)),A[3]||=m(` Neuere`,-1)]),_:1},8,[`disabled`]),u(p(b),{variant:`outline`,size:`sm`,disabled:!O.posts.links.next,onClick:A[1]||=e=>p(s).get(O.posts.links.next)},{default:r(()=>[A[4]||=m(`Ältere `,-1),u(p(_))]),_:1},8,[`disabled`])])])):t(``,!0)]),_:1}))}};export{O as default};
|
||||
1
public/build/assets/Latest-rEL3O0dw.js
Normal file
1
public/build/assets/Latest-rEL3O0dw.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,I as t,J as n,Wt as r,X as i,Xt as a,Y as o,ir as s,n as c,q as l,rt as u,sr as d,ur as f}from"./app-DJnl8SxL.js";import{n as p,r as m,t as h}from"./NewsImage-DyRK4fmY.js";import{t as g}from"./EmptyState-CFBmx8ne.js";import{a as _}from"./format-Dlm0nTI_.js";import{t as v}from"./Panel-D5zuY1_v.js";var y={class:`min-w-0`},b={class:`mt-0.5 line-clamp-2 text-sm leading-snug font-semibold group-hover:underline`},x={class:`mt-1 text-xs text-muted-foreground`},S={__name:`NewsListItem`,props:{post:{type:Object,required:!0}},setup(t){return(i,a)=>(r(),n(s(c),{href:`/neuigkeiten/${t.post.slug}`,class:`group flex gap-4 py-3`},{default:e(()=>[u(h,{src:t.post.thumb_url,alt:t.post.title,class:`w-28 shrink-0 rounded-md sm:w-32`},null,8,[`src`,`alt`]),l(`div`,y,[u(p,{category:t.post.category},null,8,[`category`]),l(`h3`,b,f(t.post.title),1),l(`p`,x,f(s(_)(t.post.published_at)),1)])]),_:1},8,[`href`]))}},C={key:0,href:`/admin/neuigkeiten/neu`,class:`mt-4 text-sm font-medium text-brand-text hover:underline`},w={__name:`Latest`,props:{posts:{type:Array,required:!0},canWrite:{type:Boolean,default:!1},wide:{type:Boolean,default:!1}},setup(c){return(l,u)=>(r(),n(v,{title:`Neuigkeiten`,"action-label":`Alle anzeigen`,"action-href":`/neuigkeiten`},{default:e(()=>[c.posts.length?(r(),i(`div`,{key:0,class:d([`-my-3 divide-y`,{"sm:grid sm:grid-cols-2 sm:gap-x-6 sm:divide-y-0":c.wide}])},[(r(!0),i(t,null,a(c.posts,e=>(r(),n(S,{key:e.id,post:e},null,8,[`post`]))),128))],2)):(r(),n(g,{key:1,icon:s(m),title:`Noch keine Neuigkeiten`,text:`Sobald Beiträge veröffentlicht sind, erscheinen sie hier.`},{default:e(()=>[c.canWrite?(r(),i(`a`,C,`Ersten Beitrag schreiben`)):o(``,!0)]),_:1},8,[`icon`]))]),_:1}))}};export{w as default};
|
||||
File diff suppressed because one or more lines are too long
1
public/build/assets/Login-DmnB-AB2.js
Normal file
1
public/build/assets/Login-DmnB-AB2.js
Normal file
File diff suppressed because one or more lines are too long
1
public/build/assets/NewColleagues-JGWMoXS3.js
Normal file
1
public/build/assets/NewColleagues-JGWMoXS3.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,I as t,J as n,Wt as r,X as i,Xt as a,ir as o,n as s,q as c,rt as l,ur as u}from"./app-DJnl8SxL.js";import{n as d}from"./AppLayout-1ldLchM-.js";import{t as f}from"./Panel-D5zuY1_v.js";var p={class:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`},m={class:`min-w-0`},h={class:`truncate text-sm font-semibold`},g={class:`truncate text-[13px] text-muted-foreground`},_={__name:`NewColleagues`,props:{people:{type:Array,required:!0}},setup(_){return(v,y)=>(r(),n(f,{title:`Neu im Team`,"action-label":`Alle Personen`,"action-href":`/personen`},{default:e(()=>[c(`ul`,p,[(r(!0),i(t,null,a(_.people,t=>(r(),i(`li`,{key:t.id},[l(o(s),{href:`/personen/${t.id}`,class:`flex items-center gap-3 rounded-lg border p-3 transition-colors hover:bg-accent`},{default:e(()=>[l(d,{person:t,class:`size-11`},null,8,[`person`]),c(`div`,m,[c(`div`,h,u(t.name),1),c(`div`,g,u(t.job_title||t.department),1)])]),_:2},1032,[`href`])]))),128))])]),_:1}))}};export{_ as default};
|
||||
1
public/build/assets/NewsCard-B-l5uZ4h.js
Normal file
1
public/build/assets/NewsCard-B-l5uZ4h.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Cn as e,J as t,Wt as n,X as r,Y as i,ir as a,n as o,q as s,rt as c,ur as l}from"./app-DJnl8SxL.js";import{n as u,t as d}from"./NewsImage-DyRK4fmY.js";import{o as f}from"./format-Dlm0nTI_.js";var p={class:`flex flex-1 flex-col p-4`},m={class:`mt-1 line-clamp-2 text-[15px] leading-snug font-semibold group-hover:underline`},h={key:0,class:`mt-1.5 line-clamp-2 text-[13px] text-muted-foreground`},g={class:`mt-auto pt-3 text-xs text-muted-foreground`},_={__name:`NewsCard`,props:{post:{type:Object,required:!0}},setup(_){return(v,y)=>(n(),t(a(o),{href:`/neuigkeiten/${_.post.slug}`,class:`group flex h-full flex-col overflow-hidden rounded-lg border bg-card transition-shadow hover:shadow-md`},{default:e(()=>[c(d,{src:_.post.thumb_url,alt:_.post.title},null,8,[`src`,`alt`]),s(`div`,p,[c(u,{category:_.post.category},null,8,[`category`]),s(`h3`,m,l(_.post.title),1),_.post.teaser?(n(),r(`p`,h,l(_.post.teaser),1)):i(``,!0),s(`p`,g,l(a(f)(_.post.published_at))+` · `+l(_.post.reading_minutes)+` Min.`,1)])]),_:1},8,[`href`]))}};export{_ as t};
|
||||
|
|
@ -1 +0,0 @@
|
|||
import{J as e,K as t,Sn as n,Ut as r,Y as i,lr as a,n as o,nt as s,q as c,rr as l}from"./app-D5-myltL.js";import{A as u}from"./BrandLogo-6n9qq87f.js";import{o as d}from"./format-Dlm0nTI_.js";var f=u({name:`newspaper`,size:24,node:[[`path`,{d:`M15 18h-5`,key:`95g1m2`}],[`path`,{d:`M18 14h-8`,key:`sponae`}],[`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2`,key:`39pd36`}],[`rect`,{width:`8`,height:`4`,x:`10`,y:`6`,rx:`1`,key:`aywv1n`}]]}),p={key:0,class:`text-[11px] font-semibold tracking-wide text-brand-text uppercase`},m={__name:`CategoryLabel`,props:{category:{type:Object,default:null}},setup(t){return(n,o)=>t.category?(r(),i(`span`,p,a(t.category.name),1)):e(``,!0)}},h={class:`relative aspect-video overflow-hidden bg-muted`},g=[`src`,`alt`],_={key:1,class:`grid size-full place-items-center bg-brand-soft`},v={__name:`NewsImage`,props:{src:{type:String,default:null},alt:{type:String,default:``}},setup(e){return(t,n)=>(r(),i(`div`,h,[e.src?(r(),i(`img`,{key:0,src:e.src,alt:e.alt,loading:`lazy`,class:`size-full object-cover`},null,8,g)):(r(),i(`div`,_,[s(l(f),{class:`size-1/4 max-h-10 max-w-10 text-brand-text opacity-60`,"stroke-width":1.5})]))]))}},y={class:`flex flex-1 flex-col p-4`},b={class:`mt-1 line-clamp-2 text-[15px] leading-snug font-semibold group-hover:underline`},x={key:0,class:`mt-1.5 line-clamp-2 text-[13px] text-muted-foreground`},S={class:`mt-auto pt-3 text-xs text-muted-foreground`},C={__name:`NewsCard`,props:{post:{type:Object,required:!0}},setup(u){return(f,p)=>(r(),c(l(o),{href:`/neuigkeiten/${u.post.slug}`,class:`group flex h-full flex-col overflow-hidden rounded-lg border bg-card transition-shadow hover:shadow-md`},{default:n(()=>[s(v,{src:u.post.thumb_url,alt:u.post.title},null,8,[`src`,`alt`]),t(`div`,y,[s(m,{category:u.post.category},null,8,[`category`]),t(`h3`,b,a(u.post.title),1),u.post.teaser?(r(),i(`p`,x,a(u.post.teaser),1)):e(``,!0),t(`p`,S,a(l(d)(u.post.published_at))+` · `+a(u.post.reading_minutes)+` Min.`,1)])]),_:1},8,[`href`]))}};export{f as i,v as n,m as r,C as t};
|
||||
1
public/build/assets/NewsImage-DyRK4fmY.js
Normal file
1
public/build/assets/NewsImage-DyRK4fmY.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
import{Wt as e,X as t,Y as n,ir as r,rt as i,ur as a}from"./app-DJnl8SxL.js";import{M as o}from"./BrandLogo-B9oA1DG4.js";var s=o({name:`newspaper`,size:24,node:[[`path`,{d:`M15 18h-5`,key:`95g1m2`}],[`path`,{d:`M18 14h-8`,key:`sponae`}],[`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2`,key:`39pd36`}],[`rect`,{width:`8`,height:`4`,x:`10`,y:`6`,rx:`1`,key:`aywv1n`}]]}),c={key:0,class:`text-[11px] font-semibold tracking-wide text-brand-text uppercase`},l={__name:`CategoryLabel`,props:{category:{type:Object,default:null}},setup(r){return(i,o)=>r.category?(e(),t(`span`,c,a(r.category.name),1)):n(``,!0)}},u={class:`relative aspect-video overflow-hidden bg-muted`},d=[`src`,`alt`],f={key:1,class:`grid size-full place-items-center bg-brand-soft`},p={__name:`NewsImage`,props:{src:{type:String,default:null},alt:{type:String,default:``}},setup(n){return(a,o)=>(e(),t(`div`,u,[n.src?(e(),t(`img`,{key:0,src:n.src,alt:n.alt,loading:`lazy`,class:`size-full object-cover`},null,8,d)):(e(),t(`div`,f,[i(r(s),{class:`size-1/4 max-h-10 max-w-10 text-brand-text opacity-60`,"stroke-width":1.5})]))]))}};export{l as n,s as r,p as t};
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue