Skip to content

Commit e8cbb67

Browse files
committed
improve webmanifest
Signed-off-by: szaimen <[email protected]>
1 parent 4f01018 commit e8cbb67

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

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') {
376+
$name = $this->themingDefaults->getName();
377+
$short_name = $this->themingDefaults->getName();
378+
$start_url = $this->urlGenerator->getBaseUrl();
379+
$description = $this->themingDefaults->getSlogan();
380+
} else {
381+
$info = $this->appManager->getAppInfo($app);
382+
$name = $info['name'] . ' - ' . $this->themingDefaults->getName();
383+
$short_name = $info['name'];
384+
if (strpos($this->request->getRequestUri(), '/index.php/') !== false) {
385+
$start_url = $this->urlGenerator->getBaseUrl() . '/index.php' . $this->urlGenerator->linkTo($app, '');
386+
} else {
387+
$start_url = $this->urlGenerator->getBaseUrl() . $this->urlGenerator->linkTo($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' => $short_name,
394+
'start_url' => $start_url,
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,10 @@ public function testGetManifest() {
823823
'sizes' => '16x16'
824824
]
825825
],
826-
'display' => 'standalone'
826+
'display' => 'standalone',
827+
'short_name' => 'Nextcloud',
828+
'background_color' => null,
829+
'description' => null
827830
]);
828831
$response->cacheFor(3600);
829832
$this->assertEquals($response, $this->themingController->getManifest('core'));

0 commit comments

Comments
 (0)