2018-02-05 10:42:09 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace dokuwiki;
|
|
|
|
|
2018-06-15 17:35:53 +02:00
|
|
|
use dokuwiki\Extension\Event;
|
|
|
|
|
2018-02-05 10:42:09 +01:00
|
|
|
class Manifest
|
|
|
|
{
|
|
|
|
public function sendManifest()
|
|
|
|
{
|
|
|
|
$manifest = retrieveConfig('manifest', 'jsonToArray');
|
|
|
|
|
|
|
|
global $conf;
|
|
|
|
|
|
|
|
$manifest['scope'] = DOKU_REL;
|
|
|
|
|
|
|
|
if (empty($manifest['name'])) {
|
|
|
|
$manifest['name'] = $conf['title'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($manifest['short_name'])) {
|
|
|
|
$manifest['short_name'] = $conf['title'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($manifest['description'])) {
|
|
|
|
$manifest['description'] = $conf['tagline'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($manifest['start_url'])) {
|
|
|
|
$manifest['start_url'] = DOKU_REL;
|
|
|
|
}
|
|
|
|
|
2023-08-29 19:42:15 +02:00
|
|
|
$styleUtil = new StyleUtils();
|
2019-02-28 13:45:19 +01:00
|
|
|
$styleIni = $styleUtil->cssStyleini();
|
2018-02-05 10:42:09 +01:00
|
|
|
$replacements = $styleIni['replacements'];
|
|
|
|
|
|
|
|
if (empty($manifest['background_color'])) {
|
|
|
|
$manifest['background_color'] = $replacements['__background__'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($manifest['theme_color'])) {
|
2023-08-29 19:42:15 +02:00
|
|
|
$manifest['theme_color'] = empty($replacements['__theme_color__'])
|
|
|
|
? $replacements['__background_alt__']
|
|
|
|
: $replacements['__theme_color__'];
|
2018-02-05 10:42:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($manifest['icons'])) {
|
|
|
|
$manifest['icons'] = [];
|
2018-03-07 11:24:44 +01:00
|
|
|
if (file_exists(mediaFN(':wiki:favicon.ico'))) {
|
|
|
|
$url = ml(':wiki:favicon.ico', '', true, '', true);
|
|
|
|
$manifest['icons'][] = [
|
|
|
|
'src' => $url,
|
|
|
|
'sizes' => '16x16',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-02-05 10:42:09 +01:00
|
|
|
$look = [
|
2018-03-07 11:24:44 +01:00
|
|
|
':wiki:logo.svg',
|
|
|
|
':logo.svg',
|
|
|
|
':wiki:dokuwiki.svg'
|
2018-02-05 10:42:09 +01:00
|
|
|
];
|
|
|
|
|
2018-03-07 11:24:44 +01:00
|
|
|
foreach ($look as $svgLogo) {
|
|
|
|
$svgLogoFN = mediaFN($svgLogo);
|
|
|
|
|
|
|
|
if (file_exists($svgLogoFN)) {
|
|
|
|
$url = ml($svgLogo, '', true, '', true);
|
2018-02-05 10:42:09 +01:00
|
|
|
$manifest['icons'][] = [
|
|
|
|
'src' => $url,
|
2018-03-07 11:24:44 +01:00
|
|
|
'sizes' => '17x17 512x512',
|
|
|
|
'type' => 'image/svg+xml',
|
2018-02-05 10:42:09 +01:00
|
|
|
];
|
2018-03-07 11:24:44 +01:00
|
|
|
break;
|
2018-02-05 10:42:09 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-15 17:35:53 +02:00
|
|
|
Event::createAndTrigger('MANIFEST_SEND', $manifest);
|
2018-02-05 10:42:09 +01:00
|
|
|
|
|
|
|
header('Content-Type: application/manifest+json');
|
2023-08-29 19:42:15 +02:00
|
|
|
echo json_encode($manifest, JSON_THROW_ON_ERROR);
|
2018-02-05 10:42:09 +01:00
|
|
|
}
|
|
|
|
}
|