]> BookStack Code Mirror - bookstack/commitdiff
Implementation of required changes
authorJonatanRek <redacted>
Fri, 22 Sep 2023 09:00:41 +0000 (11:00 +0200)
committerJonatanRek <redacted>
Fri, 22 Sep 2023 09:00:41 +0000 (11:00 +0200)
app/App/PwaManifestBuilder.php [new file with mode: 0644]
app/Config/manifest.php [deleted file]
routes/web.php

diff --git a/app/App/PwaManifestBuilder.php b/app/App/PwaManifestBuilder.php
new file mode 100644 (file)
index 0000000..4c51707
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+namespace BookStack\App;
+
+use BookStack\Activity\ActivityQueries;
+use BookStack\Entities\Models\Book;
+use BookStack\Entities\Models\Page;
+use BookStack\Entities\Queries\RecentlyViewed;
+use BookStack\Entities\Queries\TopFavourites;
+use BookStack\Entities\Repos\BookRepo;
+use BookStack\Entities\Repos\BookshelfRepo;
+use BookStack\Entities\Tools\PageContent;
+use BookStack\Http\Controller;
+use BookStack\Uploads\FaviconHandler;
+use BookStack\Util\SimpleListOptions;
+use Illuminate\Http\Request;
+
+class PwaManifestBuilder extends Controller
+{
+    private function GenerateManifest()
+    {
+        return [
+            "name" => config('app.name'),
+            "short_name" => config('app.name'),
+            "start_url" => "./",
+            "scope" => ".",
+            "display" => "standalone",
+            "background_color" => (setting()->getForCurrentUser('dark-mode-enabled') ? setting('app-color-dark') : setting('app-color')),
+            "description" => config('app.name'),
+            "theme_color" => setting('app-color'),
+            "launch_handler" => [
+                "client_mode" => "focus-existing"
+            ],
+            "orientation" => "portrait",
+            "icons" => [
+                [
+                    "src" => setting('app-icon-64') ?: url('/icon-64.png'),
+                    "sizes" => "64x64",
+                    "type" => "image/png"
+                ],
+                [
+                    "src" => setting('app-icon-32') ?: url('/icon-32.png'),
+                    "sizes" => "32x32",
+                    "type" => "image/png"
+                ],
+                [
+                    "src" => setting('app-icon-128') ?: url('/icon-128.png'),
+                    "sizes" => "128x128",
+                    "type" => "image/png"
+                ],
+                [
+                    "src" => setting('app-icon-180') ?: url('/icon-180.png'),
+                    "sizes" => "180x180",
+                    "type" => "image/png"
+                ],
+                [
+                    "src" => setting('app-icon') ?: url('/icon.png'),
+                    "sizes" => "256x256",
+                    "type" => "image/png"
+                ],
+                [
+                    "src" => "icon.ico",
+                    "sizes" => "48x48",
+                    "type" => "image/vnd.microsoft.icon"
+                ],
+                [
+                    "src" => "favicon.ico",
+                    "sizes" => "48x48",
+                    "type" => "image/vnd.microsoft.icon"
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Serve the application manifest.
+     * Ensures a 'manifest.json'
+     */
+    public function manifest()
+    {
+        return response()->json($this->GenerateManifest());
+    }
+}
diff --git a/app/Config/manifest.php b/app/Config/manifest.php
deleted file mode 100644 (file)
index 640ba70..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-return [
-    "name" => (env('APP_NAME' | 'BookStack') ??'BookStack' ), 
-    "short_name" => "bookstack", 
-    "start_url" => "./", 
-    "scope" => ".", 
-    "display" => "standalone", 
-    "background_color" => "#fff", 
-    "description" =>( env('APP_NAME' | 'BookStack') ??'BookStack'), 
-    "categories" => [
-        "productivity", 
-        "lifestyle" 
-    ], 
-    "launch_handler" => [
-        "client_mode" => "focus-existing" 
-    ], 
-    "orientation" => "portrait", 
-    "icons" => [
-        [
-            "src" => "/icon-64.png", 
-            "sizes" => "64x64", 
-            "type" => "image/png" 
-        ], 
-        [
-            "src" => "/icon-32.png", 
-            "sizes" => "32x32", 
-            "type" => "image/png" 
-        ], 
-        [
-            "src" => "/icon-128.png", 
-            "sizes" => "128x128", 
-            "type" => "image/png" 
-        ], 
-        [
-            "src" => "icon-180.png", 
-            "sizes" => "180x180", 
-            "type" => "image/png" 
-        ], 
-        [
-            "src" => "icon.png", 
-            "sizes" => "256x256", 
-            "type" => "image/png" 
-        ], 
-        [
-            "src" => "icon.ico", 
-            "sizes" => "48x48", 
-            "type" => "image/vnd.microsoft.icon" 
-        ], 
-        [
-            "src" => "favicon.ico", 
-            "sizes" => "48x48", 
-            "type" => "image/vnd.microsoft.icon" 
-        ],
-    ],
-];
\ No newline at end of file
index 8116cdaf8fb9c9b99b377c36b438f21a56a61dcf..6bc563480da37d03a2b6a304edb3cce925c0797c 100644 (file)
@@ -5,6 +5,7 @@ use BookStack\Activity\Controllers as ActivityControllers;
 use BookStack\Api\ApiDocsController;
 use BookStack\Api\UserApiTokenController;
 use BookStack\App\HomeController;
+use BookStack\App\PwaManifestBuilder;
 use BookStack\Entities\Controllers as EntityControllers;
 use BookStack\Http\Middleware\VerifyCsrfToken;
 use BookStack\Permissions\PermissionsController;
@@ -20,7 +21,7 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
 Route::get('/status', [SettingControllers\StatusController::class, 'show']);
 Route::get('/robots.txt', [HomeController::class, 'robots']);
 Route::get('/favicon.ico', [HomeController::class, 'favicon']);
-Route::get('/manifest.json', [HomeController::class, 'manifest']);
+Route::get('/manifest.json', [PwaManifestBuilder::class, 'manifest']);
 
 // Authenticated routes...
 Route::middleware('auth')->group(function () {
Morty Proxy This is a proxified and sanitized view of the page, visit original site.