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