]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Manifest.php
Merge pull request #10544 from annando/router-lock
[friendica.git] / src / Module / Manifest.php
index d40624cf80f43e333cb9bffa045d054a8cb1723e..0f9112d11f0efd799be7cc48c3e625236f0ae073 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -31,23 +31,63 @@ class Manifest extends BaseModule
        {
                $config = DI::config();
 
-               header('Content-type: application/manifest+json');
-
-               $touch_icon = $config->get('system', 'touch_icon') ?: 'images/friendica-128.png';
+               $touch_icon = $config->get('system', 'touch_icon') ?: 'images/friendica-192.png';
 
                $theme = DI::config()->get('system', 'theme');
 
-               $tpl = Core\Renderer::getMarkupTemplate('manifest.tpl');
-               $output = Core\Renderer::replaceMacros($tpl, [
-                       '$touch_icon'       => $touch_icon,
-                       '$title'            => $config->get('config', 'sitename', 'Friendica'),
-                       '$description'      => $config->get('config', 'info', DI::l10n()->t('A Decentralized Social Network')),
-                       '$background_color' => Core\Theme::getBackgroundColor($theme),
-                       '$theme_color'      => Core\Theme::getThemeColor($theme),
-               ]);
+               $manifest = [
+                       'name'          => $config->get('config', 'sitename', 'Friendica'),
+                       'start_url'     => DI::baseUrl()->get(),
+                       'display'       => 'standalone',
+                       'description'   => $config->get('config', 'info', DI::l10n()->t('A Decentralized Social Network')),
+                       'short_name'    => 'Friendica',
+                       'lang'          => $config->get('system', 'language'),
+                       'dir'           => 'auto',
+                       'categories'    => ['social network', 'internet'],
+                       'icons'         => [
+                               [
+                                       'src'   => DI::baseUrl()->get() . '/' . $touch_icon,
+                                       'sizes' => '192x192',
+                                       'type'  => 'image/png',
+                               ],
+                               [
+                                       'src'   => DI::baseUrl()->get() . '/' . $touch_icon,
+                                       'sizes' => '512x512',
+                                       'type'  => 'image/png',
+                               ],
+                       ],
+                       'shortcuts'     => [
+                               [
+                                       'name'  => 'Latest posts',
+                                       'url'   => '/network'
+                               ],
+                               [
+                                       'name'  => 'Messages',
+                                       'url'   => '/message'
+                               ],
+                               [
+                                       'name'  => 'Notifications',
+                                       'url'   => '/notifications/system'
+                               ],
+                               [
+                                       'name'  => 'Contacts',
+                                       'url'   => '/contact'
+                               ],
+                               [
+                                       'name'  => 'Events',
+                                       'url'   => '/events'
+                               ]
+                       ]
+               ];
+
+               if ($background_color = Core\Theme::getBackgroundColor($theme)) {
+                       $manifest['background_color'] = $background_color;
+               }
 
-               echo $output;
+               if ($theme_color = Core\Theme::getThemeColor($theme)) {
+                       $manifest['theme_color'] = $theme_color;
+               }
 
-               exit();
+               Core\System::jsonExit($manifest, 'application/manifest+json');
        }
 }