]> BookStack Code Mirror - bookstack/blob - app/App/PwaManifestBuilder.php
Remove Dumps
[bookstack] / app / App / PwaManifestBuilder.php
1 <?php
2
3 namespace BookStack\App;
4
5 use BookStack\Http\Controller;
6
7 class PwaManifestBuilder extends Controller
8 {
9     private function GenerateManifest()
10     {
11         return [
12             "name" => setting('app-name'),
13             "short_name" => setting('app-name'),
14             "start_url" => "./",
15             "scope" => "/",
16             "display" => "standalone",
17             "background_color" => (setting()->getForCurrentUser('dark-mode-enabled') ? setting('app-color-dark') : setting('app-color')),
18             "description" => setting('app-name'),
19             "theme_color" => (setting()->getForCurrentUser('dark-mode-enabled') ? setting('app-color-dark') : setting('app-color')),
20             "launch_handler" => [
21                 "client_mode" => "focus-existing"
22             ],
23             "orientation" => "portrait",
24             "icons" => [
25                 [
26                     "src" => setting('app-icon-64') ?: url('/icon-64.png'),
27                     "sizes" => "64x64",
28                     "type" => "image/png"
29                 ],
30                 [
31                     "src" => setting('app-icon-32') ?: url('/icon-32.png'),
32                     "sizes" => "32x32",
33                     "type" => "image/png"
34                 ],
35                 [
36                     "src" => setting('app-icon-128') ?: url('/icon-128.png'),
37                     "sizes" => "128x128",
38                     "type" => "image/png"
39                 ],
40                 [
41                     "src" => setting('app-icon-180') ?: url('/icon-180.png'),
42                     "sizes" => "180x180",
43                     "type" => "image/png"
44                 ],
45                 [
46                     "src" => setting('app-icon') ?: url('/icon.png'),
47                     "sizes" => "256x256",
48                     "type" => "image/png"
49                 ],
50                 [
51                     "src" => public_path('icon.ico'),
52                     "sizes" => "48x48",
53                     "type" => "image/vnd.microsoft.icon"
54                 ],
55                 [
56                     "src" => public_path('favicon.ico'),
57                     "sizes" => "48x48",
58                     "type" => "image/vnd.microsoft.icon"
59                 ],
60             ],
61         ];
62     }
63
64     /**
65      * Serve the application manifest.
66      * Ensures a 'manifest.json'
67      */
68     public function manifest()
69     {
70         return response()->json($this->GenerateManifest());
71     }
72 }