mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 10:34:05 +00:00
e76a64dda1
* AJAX SVG * Fix PWA * Remove unused PWA assets Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-Authored-by: silverwind <me@silverwind.io>
76 lines
3.1 KiB
Cheetah
76 lines
3.1 KiB
Cheetah
var STATIC_CACHE = 'static-cache-v1';
|
|
var urlsToCache = [
|
|
// js
|
|
'{{StaticUrlPrefix}}/fomantic/semantic.min.js?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/js/clipboard.js',
|
|
'{{StaticUrlPrefix}}/js/gitgraph.js',
|
|
'{{StaticUrlPrefix}}/js/highlight.js',
|
|
'{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/js/jquery.js?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/js/swagger.js?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/addon/mode/loadmode.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/emojify/emojify.custom.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/vue/vue.min.js',
|
|
|
|
// css
|
|
'{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/css/swagger.css?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/fomantic/semantic.min.css?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.css',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.css',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css',
|
|
{{if .IsSigned }}
|
|
{{ if ne .SignedUser.Theme "gitea" }}
|
|
'{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css?v={{MD5 AppVer}}',
|
|
{{end}}
|
|
{{else if ne DefaultTheme "gitea"}}
|
|
'{{StaticUrlPrefix}}/css/theme-{{DefaultTheme}}.css?v={{MD5 AppVer}}',
|
|
{{end}}
|
|
|
|
// img
|
|
'{{StaticUrlPrefix}}/img/gitea-sm.png',
|
|
'{{StaticUrlPrefix}}/img/gitea-lg.png',
|
|
|
|
// svg
|
|
'{{StaticUrlPrefix}}/img/svg/icons.svg',
|
|
|
|
// fonts
|
|
'{{StaticUrlPrefix}}/fomantic/themes/default/assets/fonts/icons.woff2',
|
|
'{{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',
|
|
'{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-700italic.woff2'
|
|
];
|
|
|
|
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);
|
|
}
|
|
)
|
|
);
|
|
});
|