Merge pull request #28459 from nextcloud/enh/noid/improve-webmanifest-2

Allow to open any app in a standalone window
This commit is contained in:
szaimen 2021-08-25 12:21:12 +02:00 committed by GitHub
commit 48b3a6bcdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 4 deletions

View file

@ -372,9 +372,29 @@ class ThemingController extends Controller {
*/
public function getManifest($app) {
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
if ($app === 'core' || $app === 'settings') {
$name = $this->themingDefaults->getName();
$shortName = $this->themingDefaults->getName();
$startUrl = $this->urlGenerator->getBaseUrl();
$description = $this->themingDefaults->getSlogan();
} else {
$info = $this->appManager->getAppInfo($app);
$name = $info['name'] . ' - ' . $this->themingDefaults->getName();
$shortName = $info['name'];
if (strpos($this->request->getRequestUri(), '/index.php/') !== false) {
$startUrl = $this->urlGenerator->getBaseUrl() . '/index.php/apps/' . $app . '/';
} else {
$startUrl = $this->urlGenerator->getBaseUrl() . '/apps/' . $app . '/';
}
$description = $info['summary'];
}
$responseJS = [
'name' => $this->themingDefaults->getName(),
'start_url' => $this->urlGenerator->getBaseUrl(),
'name' => $name,
'short_name' => $shortName,
'start_url' => $startUrl,
'theme_color' => $this->themingDefaults->getColorPrimary(),
'background_color' => $this->themingDefaults->getColorPrimary(),
'description' => $description,
'icons' =>
[
[

View file

@ -384,7 +384,7 @@ class ThemingDefaults extends \OC_Defaults {
}
} catch (AppPathNotFoundException $e) {
}
$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest');
$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest', ['app' => $app ]);
}
if (strpos($image, 'filetypes/') === 0 && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
$route = $this->urlGenerator->linkToRoute('theming.Icon.getThemedIcon', ['app' => $app, 'image' => $image]);

View file

@ -823,7 +823,11 @@ class ThemingControllerTest extends TestCase {
'sizes' => '16x16'
]
],
'display' => 'standalone'
'display' => 'standalone',
'short_name' => 'Nextcloud',
'theme_color' => null,
'background_color' => null,
'description' => null
]);
$response->cacheFor(3600);
$this->assertEquals($response, $this->themingController->getManifest('core'));