2018-11-27 10:18:26 -05:00
|
|
|
var STATIC_CACHE = 'static-cache-v1';
|
|
|
|
var urlsToCache = [
|
|
|
|
// js
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.areyousure/jquery.are-you-sure.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery/jquery.min.js?v=3.4.1',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery-migrate/jquery-migrate.min.js?v=3.0.1',
|
2019-12-17 16:34:11 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/fomantic/semantic.min.js?v={{MD5 AppVer}}',
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}',
|
2020-01-14 13:02:08 -05:00
|
|
|
'{{StaticUrlPrefix}}/js/swagger.js?v={{MD5 AppVer}}',
|
2019-11-17 16:39:06 -05:00
|
|
|
'{{StaticUrlPrefix}}/js/gitgraph.js?v={{MD5 AppVer}}',
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/clipboard/clipboard.min.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/vue/vue.min.js',
|
2019-11-14 08:44:46 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/emojify/emojify.custom.js',
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/cssrelpreload/loadCSS.min.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/cssrelpreload/cssrelpreload.min.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/highlight/highlight.pack.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/addon/mode/loadmode.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.js',
|
2018-11-27 10:18:26 -05:00
|
|
|
|
|
|
|
// css
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.min.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css',
|
2019-12-17 16:34:11 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/fomantic/semantic.min.css?v={{MD5 AppVer}}',
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/highlight/github.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.css',
|
2019-01-09 12:22:57 -05:00
|
|
|
{{if .IsSigned }}
|
|
|
|
{{ if ne .SignedUser.Theme "gitea" }}
|
2019-12-18 22:35:03 -05:00
|
|
|
'{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css?v={{MD5 AppVer}}',
|
2019-01-09 12:22:57 -05:00
|
|
|
{{end}}
|
|
|
|
{{else if ne DefaultTheme "gitea"}}
|
2019-12-18 22:35:03 -05:00
|
|
|
'{{StaticUrlPrefix}}/css/theme-{{DefaultTheme}}.css?v={{MD5 AppVer}}',
|
2018-11-27 10:18:26 -05:00
|
|
|
{{end}}
|
2019-01-09 12:22:57 -05:00
|
|
|
|
2018-11-27 10:18:26 -05:00
|
|
|
// img
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/img/gitea-sm.png',
|
|
|
|
'{{StaticUrlPrefix}}/img/gitea-lg.png',
|
2018-11-27 10:18:26 -05:00
|
|
|
|
|
|
|
// fonts
|
2019-12-17 16:34:11 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/fomantic/themes/default/assets/fonts/icons.woff2',
|
2019-10-22 07:11:01 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6',
|
2019-12-25 23:11:39 -05:00
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/lato-fonts/lato-v16-latin-regular.woff2',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/lato-fonts/lato-v16-latin-700.woff2'
|
2018-11-27 10:18:26 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
self.addEventListener('install', function (event) {
|
|
|
|
// Perform install steps
|
|
|
|
event.waitUntil(
|
|
|
|
caches.open(STATIC_CACHE)
|
|
|
|
.then(function (cache) {
|
|
|
|
return cache.addAll(urlsToCache);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('fetch', function (event) {
|
|
|
|
event.respondWith(
|
|
|
|
caches.match(event.request)
|
|
|
|
.then(function (response) {
|
|
|
|
// Cache hit - return response
|
|
|
|
if (response) {
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
return fetch(event.request);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|