2018-11-27 08:18:26 -07:00
|
|
|
var STATIC_CACHE = 'static-cache-v1';
|
|
|
|
var urlsToCache = [
|
|
|
|
// js
|
2020-01-20 22:17:58 -07:00
|
|
|
'{{StaticUrlPrefix}}/fomantic/semantic.min.js?v={{MD5 AppVer}}',
|
2020-02-07 16:03:42 -07:00
|
|
|
'{{StaticUrlPrefix}}/js/clipboard.js',
|
2020-01-25 01:41:34 -07:00
|
|
|
'{{StaticUrlPrefix}}/js/gitgraph.js',
|
2020-01-28 14:57:20 -07:00
|
|
|
'{{StaticUrlPrefix}}/js/highlight.js',
|
2019-10-22 06:11:01 -06:00
|
|
|
'{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}',
|
2020-01-21 10:32:33 -07:00
|
|
|
'{{StaticUrlPrefix}}/js/jquery.js?v={{MD5 AppVer}}',
|
2020-01-25 01:41:34 -07:00
|
|
|
'{{StaticUrlPrefix}}/js/swagger.js?v={{MD5 AppVer}}',
|
2020-03-07 14:06:15 -07:00
|
|
|
'{{StaticUrlPrefix}}/js/dropzone.js',
|
2020-03-17 13:08:15 -06:00
|
|
|
'{{StaticUrlPrefix}}/js/datetimepicker.js',
|
2020-01-25 01:41:34 -07:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/addon/mode/loadmode.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js',
|
2019-10-22 06:11:01 -06:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.js',
|
2018-11-27 08:18:26 -07:00
|
|
|
|
|
|
|
// css
|
2020-01-25 01:41:34 -07:00
|
|
|
'{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}',
|
|
|
|
'{{StaticUrlPrefix}}/css/swagger.css?v={{MD5 AppVer}}',
|
2020-03-07 14:06:15 -07:00
|
|
|
'{{StaticUrlPrefix}}/css/dropzone.css',
|
2020-03-17 13:08:15 -06:00
|
|
|
'{{StaticUrlPrefix}}/css/datetimepicker.css',
|
2020-01-25 01:41:34 -07:00
|
|
|
'{{StaticUrlPrefix}}/fomantic/semantic.min.css?v={{MD5 AppVer}}',
|
2019-10-22 06:11:01 -06:00
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css',
|
2020-01-25 01:41:34 -07:00
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.css',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css',
|
2019-01-09 10:22:57 -07:00
|
|
|
{{if .IsSigned }}
|
|
|
|
{{ if ne .SignedUser.Theme "gitea" }}
|
2019-12-18 20:35:03 -07:00
|
|
|
'{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css?v={{MD5 AppVer}}',
|
2019-01-09 10:22:57 -07:00
|
|
|
{{end}}
|
|
|
|
{{else if ne DefaultTheme "gitea"}}
|
2019-12-18 20:35:03 -07:00
|
|
|
'{{StaticUrlPrefix}}/css/theme-{{DefaultTheme}}.css?v={{MD5 AppVer}}',
|
2018-11-27 08:18:26 -07:00
|
|
|
{{end}}
|
2019-01-09 10:22:57 -07:00
|
|
|
|
2018-11-27 08:18:26 -07:00
|
|
|
// img
|
2019-10-22 06:11:01 -06:00
|
|
|
'{{StaticUrlPrefix}}/img/gitea-sm.png',
|
|
|
|
'{{StaticUrlPrefix}}/img/gitea-lg.png',
|
2018-11-27 08:18:26 -07:00
|
|
|
|
2020-02-11 10:02:41 -07:00
|
|
|
// svg
|
2020-02-17 16:11:59 -07:00
|
|
|
'{{StaticUrlPrefix}}/img/svg/icons.svg',
|
2020-02-11 10:02:41 -07:00
|
|
|
|
2018-11-27 08:18:26 -07:00
|
|
|
// fonts
|
2020-01-21 11:07:34 -07:00
|
|
|
'{{StaticUrlPrefix}}/fomantic/themes/default/assets/fonts/icons.woff2',
|
2020-01-25 14:47:42 -07:00
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-regular.woff2',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-italic.woff2',
|
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-700.woff2',
|
2020-05-14 10:06:01 -06:00
|
|
|
'{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-700italic.woff2',
|
|
|
|
|
|
|
|
// monaco
|
|
|
|
'{{StaticUrlPrefix}}/css/monaco.css',
|
|
|
|
'{{StaticUrlPrefix}}/fonts/codicon.ttf',
|
|
|
|
'{{StaticUrlPrefix}}/js/monaco-css.worker.js',
|
|
|
|
'{{StaticUrlPrefix}}/js/monaco-editor.worker.js',
|
|
|
|
'{{StaticUrlPrefix}}/js/monaco-html.worker.js',
|
|
|
|
'{{StaticUrlPrefix}}/js/monaco-json.worker.js',
|
|
|
|
'{{StaticUrlPrefix}}/js/monaco.js',
|
|
|
|
'{{StaticUrlPrefix}}/js/monaco-ts.worker.js'
|
2018-11-27 08:18:26 -07: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);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|