summaryrefslogtreecommitdiffstats
path: root/templates/pwa/serviceworker_js.tmpl
blob: f109d06300d4c49170712ba6f35fba813c95f326 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var STATIC_CACHE = 'static-cache-v1';
var urlsToCache = [
  // js
  '{{AppSubUrl}}/vendor/plugins/jquery.areyousure/jquery.are-you-sure.js',
  '{{AppSubUrl}}/vendor/plugins/jquery/jquery.min.js',
  '{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.js',
  '{{AppSubUrl}}/js/index.js?v={{MD5 AppVer}}',
  '{{AppSubUrl}}/js/draw.js',
  '{{AppSubUrl}}/vendor/plugins/clipboard/clipboard.min.js',
  '{{AppSubUrl}}/vendor/plugins/gitgraph/gitgraph.js',
  '{{AppSubUrl}}/vendor/plugins/vue/vue.min.js',
  '{{AppSubUrl}}/vendor/plugins/emojify/emojify.min.js',
  '{{AppSubUrl}}/vendor/plugins/cssrelpreload/loadCSS.min.js',
  '{{AppSubUrl}}/vendor/plugins/cssrelpreload/cssrelpreload.min.js',
  '{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.js',
  '{{AppSubUrl}}/vendor/plugins/highlight/highlight.pack.js',
  '{{AppSubUrl}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.js',
  '{{AppSubUrl}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js',
  '{{AppSubUrl}}/vendor/plugins/codemirror/addon/mode/loadmode.js',
  '{{AppSubUrl}}/vendor/plugins/codemirror/mode/meta.js',
  '{{AppSubUrl}}/vendor/plugins/simplemde/simplemde.min.js',

  // css
  '{{AppSubUrl}}/vendor/assets/font-awesome/css/font-awesome.min.css',
  '{{AppSubUrl}}/vendor/assets/octicons/octicons.min.css',
  '{{AppSubUrl}}/vendor/plugins/simplemde/simplemde.min.css',
  '{{AppSubUrl}}/vendor/plugins/gitgraph/gitgraph.css',
  '{{AppSubUrl}}/vendor/plugins/tribute/tribute.css',
  '{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.css',
  '{{AppSubUrl}}/css/index.css?v={{MD5 AppVer}}',
  '{{AppSubUrl}}/vendor/plugins/highlight/github.css',
  '{{AppSubUrl}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
  '{{AppSubUrl}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
  '{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.css',
{{if .IsSigned }}
	{{ if ne .SignedUser.Theme "gitea" }}
		'{{AppSubUrl}}/css/theme-{{.SignedUser.Theme}}.css'
	{{end}}
{{else if ne DefaultTheme "gitea"}}
	'{{AppSubUrl}}/css/theme-{{DefaultTheme}}.css'
{{end}}

  // img
  '{{AppSubUrl}}/img/gitea-sm.png',
  '{{AppSubUrl}}/img/gitea-lg.png',

  // fonts
  '{{AppSubUrl}}/vendor/plugins/semantic/themes/default/assets/fonts/icons.woff2',
  '{{AppSubUrl}}/vendor/assets/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6',
  '{{AppSubUrl}}/vendor/assets/lato-fonts/lato-v14-latin-regular.woff2',
  '{{AppSubUrl}}/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);
      }
      )
  );
});