mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-08-22 04:28:06 +02:00
* static url * add cors support for static resources * [assets] work on the migration to configurable url for assets Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [misc] fix whitespace Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [assets] fix the loading of the manifest.json It is generated dynamically, and as such can not be served by the cdn. Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * Revert "add cors support for static resources" This reverts commit42f964fd18
Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [docs] add the STATIC_URL_PREFIX option Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [docs] reverse-proxy: nginx: add two setups for STATIC_URL_PREFIX Signed-off-by: Jakob Ackermann <das7pad@outlook.com> * [assets] migrate the url of a new asset to the static url prefix REF:f2a3abc683
Signed-off-by: Jakob Ackermann <das7pad@outlook.com>
77 lines
3.2 KiB
Cheetah
77 lines
3.2 KiB
Cheetah
var STATIC_CACHE = 'static-cache-v1';
|
|
var urlsToCache = [
|
|
// js
|
|
'{{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',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/semantic/semantic.min.js',
|
|
'{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}',
|
|
'{{StaticUrlPrefix}}/js/draw.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/clipboard/clipboard.min.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/gitgraph/gitgraph.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/vue/vue.min.js',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/emojify/emojify.min.js',
|
|
'{{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',
|
|
|
|
// css
|
|
'{{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/gitgraph/gitgraph.css',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css',
|
|
'{{StaticUrlPrefix}}/vendor/plugins/semantic/semantic.min.css',
|
|
'{{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',
|
|
{{if .IsSigned }}
|
|
{{ if ne .SignedUser.Theme "gitea" }}
|
|
'{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css',
|
|
{{end}}
|
|
{{else if ne DefaultTheme "gitea"}}
|
|
'{{StaticUrlPrefix}}/css/theme-{{DefaultTheme}}.css',
|
|
{{end}}
|
|
|
|
// img
|
|
'{{StaticUrlPrefix}}/img/gitea-sm.png',
|
|
'{{StaticUrlPrefix}}/img/gitea-lg.png',
|
|
|
|
// fonts
|
|
'{{StaticUrlPrefix}}/vendor/plugins/semantic/themes/default/assets/fonts/icons.woff2',
|
|
'{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6',
|
|
'{{StaticUrlPrefix}}/vendor/assets/lato-fonts/lato-v14-latin-regular.woff2',
|
|
'{{StaticUrlPrefix}}/vendor/assets/lato-fonts/lato-v14-latin-700.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);
|
|
}
|
|
)
|
|
);
|
|
});
|