Skip to content

Commit 0758e02

Browse files
committed
improve webmanifest
Signed-off-by: szaimen <szaimen@e.mail.de>
1 parent 4f01018 commit 0758e02

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

apps/theming/lib/Controller/ThemingController.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,29 @@ public function getStylesheet() {
372372
*/
373373
public function getManifest($app) {
374374
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
375+
if ($app === 'core' || $app === 'settings') {
376+
$name = $this->themingDefaults->getName();
377+
$shortName = $this->themingDefaults->getName();
378+
$startUrl = $this->urlGenerator->getBaseUrl();
379+
$description = $this->themingDefaults->getSlogan();
380+
} else {
381+
$info = $this->appManager->getAppInfo($app);
382+
$name = $info['name'] . ' - ' . $this->themingDefaults->getName();
383+
$shortName = $info['name'];
384+
if (strpos($this->request->getRequestUri(), '/index.php/') !== false) {
385+
$startUrl = $this->urlGenerator->getBaseUrl() . '/index.php/apps/' . $app . '/';
386+
} else {
387+
$startUrl = $this->urlGenerator->getBaseUrl() . '/apps/' . $app . '/';
388+
}
389+
$description = $info['summary'];
390+
}
375391
$responseJS = [
376-
'name' => $this->themingDefaults->getName(),
377-
'start_url' => $this->urlGenerator->getBaseUrl(),
392+
'name' => $name,
393+
'short_name' => $shortName,
394+
'start_url' => $startUrl,
395+
'theme_color' => $this->themingDefaults->getColorPrimary(),
396+
'background_color' => $this->themingDefaults->getColorPrimary(),
397+
'description' => $description,
378398
'icons' =>
379399
[
380400
[

apps/theming/lib/ThemingDefaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public function replaceImagePath($app, $image) {
384384
}
385385
} catch (AppPathNotFoundException $e) {
386386
}
387-
$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest');
387+
$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest', ['app' => $app ]);
388388
}
389389
if (strpos($image, 'filetypes/') === 0 && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
390390
$route = $this->urlGenerator->linkToRoute('theming.Icon.getThemedIcon', ['app' => $app, 'image' => $image]);

apps/theming/tests/Controller/ThemingControllerTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,11 @@ public function testGetManifest() {
823823
'sizes' => '16x16'
824824
]
825825
],
826-
'display' => 'standalone'
826+
'display' => 'standalone',
827+
'short_name' => 'Nextcloud',
828+
'theme_color' => null,
829+
'background_color' => null,
830+
'description' => null
827831
]);
828832
$response->cacheFor(3600);
829833
$this->assertEquals($response, $this->themingController->getManifest('core'));

0 commit comments

Comments
 (0)