]> git.mxchange.org Git - friendica.git/blob - src/Module/Manifest.php
Merge pull request #13599 from Raroun/Fix_for_Pull_Request_#13596_missing_a_hidden...
[friendica.git] / src / Module / Manifest.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Module;
23
24 use Friendica\BaseModule;
25 use Friendica\Core;
26 use Friendica\DI;
27
28 class Manifest extends BaseModule
29 {
30         protected function rawContent(array $request = [])
31         {
32                 $config = DI::config();
33
34                 $theme = DI::config()->get('system', 'theme');
35
36                 $manifest = [
37                         'name'          => $config->get('config', 'sitename', 'Friendica'),
38                         'start_url'     => DI::baseUrl(),
39                         'display'       => 'standalone',
40                         'description'   => $config->get('config', 'info', DI::l10n()->t('A Decentralized Social Network')),
41                         'short_name'    => 'Friendica',
42                         'lang'          => $config->get('system', 'language'),
43                         'dir'           => 'auto',
44                         'categories'    => ['social network', 'internet'],
45                         'shortcuts'     => [
46                                 [
47                                         'name'  => 'Latest posts',
48                                         'url'   => '/network'
49                                 ],
50                                 [
51                                         'name'  => 'Messages',
52                                         'url'   => '/message'
53                                 ],
54                                 [
55                                         'name'  => 'Notifications',
56                                         'url'   => '/notifications/system'
57                                 ],
58                                 [
59                                         'name'  => 'Contacts',
60                                         'url'   => '/contact'
61                                 ],
62                                 [
63                                         'name'  => 'Calendar',
64                                         'url'   => '/calendar'
65                                 ]
66                         ]
67                 ];
68
69                 /// @TODO If the admin provides their own touch icon, the manifest will regress
70                 /// to a smaller set of icons that do not follow the web app manifest spec.
71                 /// There should be a mechanism to allow the admin to provide all of the 6
72                 /// different images that are required for a fully valid web app manifest.
73                 $touch_icon = $config->get('system', 'touch_icon');
74                 if($touch_icon){
75                         $manifest['icons'] = [
76                                 [
77                                         'src'   => DI::baseUrl() . '/' . $touch_icon,
78                                         'sizes' => '192x192',
79                                         'type'  => 'image/png',
80                                 ],
81                                 [
82                                         'src'   => DI::baseUrl() . '/' . $touch_icon,
83                                         'sizes' => '512x512',
84                                         'type'  => 'image/png',
85                                 ],
86                         ];
87                 } else {
88                         $manifest['icons'] = [
89                                 [
90                                         'src'   => DI::baseUrl() . '/images/friendica.svg',
91                                         'sizes' => 'any',
92                                         'type'  => 'image/svg+xml',
93                                         'purpose' => 'any',
94                                 ],
95                                 [
96                                         'src'   => DI::baseUrl() . '/images/friendica-192.png',
97                                         'sizes' => '192x192',
98                                         'type'  => 'image/png',
99                                         'purpose' => 'any',
100                                 ],
101                                 [
102                                         'src'   => DI::baseUrl() . '/images/friendica-512.png',
103                                         'sizes' => '512x512',
104                                         'type'  => 'image/png',
105                                         'purpose' => 'any',
106                                 ],
107                                 [
108                                         'src'   => DI::baseUrl() . '/images/friendica-maskable.svg',
109                                         'sizes' => 'any',
110                                         'type'  => 'image/svg+xml',
111                                         'purpose' => 'maskable',
112                                 ],
113                                 [
114                                         'src'   => DI::baseUrl() . '/images/friendica-maskable-192.png',
115                                         'sizes' => '192x192',
116                                         'type'  => 'image/png',
117                                         'purpose' => 'maskable',
118                                 ],
119                                 [
120                                         'src'   => DI::baseUrl() . '/images/friendica-maskable-512.png',
121                                         'sizes' => '512x512',
122                                         'type'  => 'image/png',
123                                         'purpose' => 'maskable',
124                                 ],
125                         ];
126                 }
127
128                 if ($background_color = Core\Theme::getBackgroundColor($theme)) {
129                         $manifest['background_color'] = $background_color;
130                 }
131
132                 if ($theme_color = Core\Theme::getThemeColor($theme)) {
133                         $manifest['theme_color'] = $theme_color;
134                 }
135
136                 $this->jsonExit($manifest, 'application/manifest+json');
137         }
138 }