You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

serviceworker_js.tmpl 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var STATIC_CACHE = 'static-cache-v1';
  2. var urlsToCache = [
  3. // js
  4. '{{StaticUrlPrefix}}/vendor/plugins/jquery.areyousure/jquery.are-you-sure.js',
  5. '{{StaticUrlPrefix}}/vendor/plugins/jquery/jquery.min.js?v=3.4.1',
  6. '{{StaticUrlPrefix}}/vendor/plugins/jquery-migrate/jquery-migrate.min.js?v=3.0.1',
  7. '{{StaticUrlPrefix}}/fomantic/semantic.min.js?v={{MD5 AppVer}}',
  8. '{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}',
  9. '{{StaticUrlPrefix}}/js/swagger.js?v={{MD5 AppVer}}',
  10. '{{StaticUrlPrefix}}/js/gitgraph.js?v={{MD5 AppVer}}',
  11. '{{StaticUrlPrefix}}/vendor/plugins/clipboard/clipboard.min.js',
  12. '{{StaticUrlPrefix}}/vendor/plugins/vue/vue.min.js',
  13. '{{StaticUrlPrefix}}/vendor/plugins/emojify/emojify.custom.js',
  14. '{{StaticUrlPrefix}}/vendor/plugins/cssrelpreload/loadCSS.min.js',
  15. '{{StaticUrlPrefix}}/vendor/plugins/cssrelpreload/cssrelpreload.min.js',
  16. '{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.js',
  17. '{{StaticUrlPrefix}}/vendor/plugins/highlight/highlight.pack.js',
  18. '{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js',
  19. '{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
  20. '{{StaticUrlPrefix}}/vendor/plugins/codemirror/addon/mode/loadmode.js',
  21. '{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js',
  22. '{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.js',
  23. // css
  24. '{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css',
  25. '{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.min.css',
  26. '{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.css',
  27. '{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css',
  28. '{{StaticUrlPrefix}}/fomantic/semantic.min.css?v={{MD5 AppVer}}',
  29. '{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}',
  30. '{{StaticUrlPrefix}}/vendor/plugins/highlight/github.css',
  31. '{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
  32. '{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
  33. '{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.css',
  34. {{if .IsSigned }}
  35. {{ if ne .SignedUser.Theme "gitea" }}
  36. '{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css?v={{MD5 AppVer}}',
  37. {{end}}
  38. {{else if ne DefaultTheme "gitea"}}
  39. '{{StaticUrlPrefix}}/css/theme-{{DefaultTheme}}.css?v={{MD5 AppVer}}',
  40. {{end}}
  41. // img
  42. '{{StaticUrlPrefix}}/img/gitea-sm.png',
  43. '{{StaticUrlPrefix}}/img/gitea-lg.png',
  44. // fonts
  45. '{{StaticUrlPrefix}}/vendor/plugins/fomantic/themes/default/assets/fonts/icons.woff2',
  46. '{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6',
  47. '{{StaticUrlPrefix}}/vendor/assets/lato-fonts/lato-v16-latin-regular.woff2',
  48. '{{StaticUrlPrefix}}/vendor/assets/lato-fonts/lato-v16-latin-700.woff2'
  49. ];
  50. self.addEventListener('install', function (event) {
  51. // Perform install steps
  52. event.waitUntil(
  53. caches.open(STATIC_CACHE)
  54. .then(function (cache) {
  55. return cache.addAll(urlsToCache);
  56. })
  57. );
  58. });
  59. self.addEventListener('fetch', function (event) {
  60. event.respondWith(
  61. caches.match(event.request)
  62. .then(function (response) {
  63. // Cache hit - return response
  64. if (response) {
  65. return response;
  66. }
  67. return fetch(event.request);
  68. }
  69. )
  70. );
  71. });