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.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. var STATIC_CACHE = 'static-cache-v1';
  2. var urlsToCache = [
  3. // js
  4. '{{StaticUrlPrefix}}/fomantic/semantic.min.js?v={{MD5 AppVer}}',
  5. '{{StaticUrlPrefix}}/js/clipboard.js',
  6. '{{StaticUrlPrefix}}/js/gitgraph.js',
  7. '{{StaticUrlPrefix}}/js/highlight.js',
  8. '{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}',
  9. '{{StaticUrlPrefix}}/js/jquery.js?v={{MD5 AppVer}}',
  10. '{{StaticUrlPrefix}}/js/swagger.js?v={{MD5 AppVer}}',
  11. '{{StaticUrlPrefix}}/vendor/plugins/codemirror/addon/mode/loadmode.js',
  12. '{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js',
  13. '{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.js',
  14. '{{StaticUrlPrefix}}/vendor/plugins/emojify/emojify.custom.js',
  15. '{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js',
  16. '{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
  17. '{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.js',
  18. '{{StaticUrlPrefix}}/vendor/plugins/vue/vue.min.js',
  19. // css
  20. '{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}',
  21. '{{StaticUrlPrefix}}/css/swagger.css?v={{MD5 AppVer}}',
  22. '{{StaticUrlPrefix}}/fomantic/semantic.min.css?v={{MD5 AppVer}}',
  23. '{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css',
  24. '{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.min.css',
  25. '{{StaticUrlPrefix}}/vendor/plugins/dropzone/dropzone.css',
  26. '{{StaticUrlPrefix}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
  27. '{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
  28. '{{StaticUrlPrefix}}/vendor/plugins/simplemde/simplemde.min.css',
  29. '{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css',
  30. {{if .IsSigned }}
  31. {{ if ne .SignedUser.Theme "gitea" }}
  32. '{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css?v={{MD5 AppVer}}',
  33. {{end}}
  34. {{else if ne DefaultTheme "gitea"}}
  35. '{{StaticUrlPrefix}}/css/theme-{{DefaultTheme}}.css?v={{MD5 AppVer}}',
  36. {{end}}
  37. // img
  38. '{{StaticUrlPrefix}}/img/gitea-sm.png',
  39. '{{StaticUrlPrefix}}/img/gitea-lg.png',
  40. // svg
  41. '{{StaticUrlPrefix}}/img/svg/icons.svg'
  42. // fonts
  43. '{{StaticUrlPrefix}}/fomantic/themes/default/assets/fonts/icons.woff2',
  44. '{{StaticUrlPrefix}}/vendor/assets/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6',
  45. '{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-regular.woff2',
  46. '{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-italic.woff2',
  47. '{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-700.woff2',
  48. '{{StaticUrlPrefix}}/vendor/assets/roboto-fonts/roboto-v20-latin-ext_cyrillic-ext_latin_greek_vietnamese_cyrillic_greek-ext-700italic.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. });