From 2103708ab61df2be986ca7c36b90706668b8d133 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Thu, 25 Jun 2026 22:08:36 +0000 Subject: [PATCH] Add a branded boot splash (Ladill Mail style) to app pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InjectBootSplash middleware injects a full-screen loading splash — the app's launcher icon (pulsing), an animated progress bar, and "Loading …" — into authenticated HTML pages, then fades it out on load. Shows once per browser session (sessionStorage), so it masks the app's client-side boot without flashing on every navigation. Self-branding from the app's own subdomain icon, so the same partial/middleware drops into every Ladill app. Co-Authored-By: Claude Opus 4.8 --- app/Http/Middleware/InjectBootSplash.php | 46 +++++++++++++++++++ bootstrap/app.php | 1 + .../views/partials/boot-splash.blade.php | 43 +++++++++++++++++ tests/Feature/PosRegisterTest.php | 6 +++ 4 files changed, 96 insertions(+) create mode 100644 app/Http/Middleware/InjectBootSplash.php create mode 100644 resources/views/partials/boot-splash.blade.php 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 5955084..8e19c16 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -18,6 +18,7 @@ return Application::configure(basePath: dirname(__DIR__)) ])); $middleware->web(append: [ \App\Http\Middleware\SetActingAccount::class, + \App\Http\Middleware\InjectBootSplash::class, ]); $middleware->alias([ 'platform.session' => \App\Http\Middleware\EnsurePlatformSession::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 }}…
+
+
+ + diff --git a/tests/Feature/PosRegisterTest.php b/tests/Feature/PosRegisterTest.php index a3a3da0..5df858e 100644 --- a/tests/Feature/PosRegisterTest.php +++ b/tests/Feature/PosRegisterTest.php @@ -50,6 +50,12 @@ class PosRegisterTest extends TestCase ->assertSee('favicon.ico', false); } + public function test_boot_splash_injected_on_authenticated_pages(): void + { + $this->actingAs($this->user())->get(route('pos.dashboard')) + ->assertOk()->assertSee('id="ladill-boot"', false); + } + public function test_register_renders_local_products_in_restaurant_mode(): void { $user = $this->user();