Update manifest output with config/theme info

This commit is contained in:
Hypolite Petovan 2020-02-19 10:29:13 -05:00
parent b9325251e8
commit 930d395d7b
2 changed files with 23 additions and 13 deletions

View file

@ -22,7 +22,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Renderer; use Friendica\Core;
use Friendica\DI; use Friendica\DI;
class Manifest extends BaseModule class Manifest extends BaseModule
@ -31,18 +31,19 @@ class Manifest extends BaseModule
{ {
$config = DI::config(); $config = DI::config();
$tpl = Renderer::getMarkupTemplate('manifest.tpl');
header('Content-type: application/manifest+json'); 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-128.png';
if ($touch_icon == '') {
$touch_icon = 'images/friendica-128.png';
}
$output = Renderer::replaceMacros($tpl, [ $theme = DI::config()->get('system', 'theme');
'$touch_icon' => $touch_icon,
'$title' => $config->get('config', 'sitename', 'Friendica'), $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),
]); ]);
echo $output; echo $output;

View file

@ -2,8 +2,17 @@
"name": "{{$title}}", "name": "{{$title}}",
"start_url": "{{$baseurl}}", "start_url": "{{$baseurl}}",
"display": "standalone", "display": "standalone",
"description": "A Decentralized Social Network", "description": "{{$description}}",
{{if $background_color}}
"theme_color": "{{$theme_color}}",
{{/if}}
{{if $background_color}}
"background_color": "{{$background_color}}",
{{/if}}
"short_name": "Friendica",
"icons": [{ "icons": [{
"src": "{{$baseurl}}/{{$touch_icon}}" "src": "{{$baseurl}}/{{$touch_icon}}",
"sizes": "128x128",
"type": "image/png"
}] }]
} }