Skip to content

Commit c22fd24

Browse files
committed
Make dashboard installable as Chrome desktop PWA
Signed-off-by: nhirokinet <nhirokinet@nhiroki.net>
1 parent 9979b6d commit c22fd24

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

apps/theming/lib/Controller/ThemingController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,11 @@ public function getManifest($app) {
376376
$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
377377
$responseJS = [
378378
'name' => $this->themingDefaults->getName(),
379-
'start_url' => $this->urlGenerator->getBaseUrl(),
379+
'start_url' => $this->urlGenerator->getBaseUrl() . '/',
380+
'short_name' => $this->themingDefaults->getName(),
381+
'description' => $this->themingDefaults->getName(),
382+
'theme_color' => $this->themingDefaults->getColorPrimary(),
383+
'background_color' => '#ffffff',
380384
'icons' =>
381385
[
382386
[

core/js/serviceworker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
self.addEventListener('install', function(e) {});
2+
3+
self.addEventListener('fetch',
4+
function(e) {
5+
e.respondWith(fetch(e.request).then(function(response){ return response; }));
6+
}
7+
);

core/js/serviceworker_loader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if ('serviceWorker' in navigator) {
2+
window.addEventListener('load', function() {
3+
navigator.serviceWorker.register(OC.getRootPath() + '/core/js/serviceworker.js', {scope: OC.getRootPath() + '/'});
4+
});
5+
}

lib/private/legacy/OC_Template.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public static function initTemplateEngine($renderAs) {
118118
OC_Util::addScript('merged-template-prepend', null, true);
119119
OC_Util::addScript('dist/files_client', null, true);
120120
OC_Util::addScript('dist/files_fileinfo', null, true);
121+
OC_Util::addScript('serviceworker_loader', null, true);
121122
}
122123
OC_Util::addScript('core', 'dist/main', true);
123124

0 commit comments

Comments
 (0)