diff --git a/app/Http/Middleware/InjectBootSplash.php b/app/Http/Middleware/InjectBootSplash.php new file mode 100644 index 0000000..af112ad --- /dev/null +++ b/app/Http/Middleware/InjectBootSplash.php @@ -0,0 +1,46 @@ +isMethod('GET') || ! Auth::check()) { + return $response; + } + + if (! str_contains((string) $response->headers->get('Content-Type', ''), 'text/html')) { + return $response; + } + + $content = $response->getContent(); + if (! is_string($content) + || stripos($content, 'render(); + $content = preg_replace_callback('/]*>/i', fn ($m) => $m[0].$splash, $content, 1); + + if (is_string($content)) { + $response->setContent($content); + } + + return $response; + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index ec178c3..652fded 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -24,6 +24,7 @@ return Application::configure(basePath: dirname(__DIR__)) 'platform.session' => \App\Http\Middleware\EnsurePlatformSession::class, ]); $middleware->web(append: [ + \App\Http\Middleware\InjectBootSplash::class, \App\Http\Middleware\SetActingAccount::class, ]); }) diff --git a/resources/views/partials/boot-splash.blade.php b/resources/views/partials/boot-splash.blade.php new file mode 100644 index 0000000..5d86769 --- /dev/null +++ b/resources/views/partials/boot-splash.blade.php @@ -0,0 +1,43 @@ +@php + // Branded boot splash (Ladill Mail style). Self-icon from this app's subdomain. + $sub = strtolower((string) ((explode('.', (string) (parse_url((string) config('app.url'), PHP_URL_HOST) ?: '')))[0] ?? '')); + $icon = $sub !== '' && is_file(public_path("images/launcher-icons/{$sub}.svg")) ? "images/launcher-icons/{$sub}.svg" : null; + $label = (string) config('app.name', 'Ladill'); +@endphp +
+
+ @if ($icon) + + @endif +
+
Loading {{ $label }}…
+
+
+ +