mirror of
https://github.com/nkanaev/yarr.git
synced 2025-11-10 03:18:57 +00:00
Merge 9740e5ee12 into 9d5b8d99f7
This commit is contained in:
BIN
src/assets/graphicarts/favicon-144.png
Normal file
BIN
src/assets/graphicarts/favicon-144.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@@ -3,16 +3,22 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>yarr!</title>
|
||||
<link rel="stylesheet" href="./static/stylesheets/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="./static/stylesheets/app.css">
|
||||
<link rel="icon" href="./static/graphicarts/favicon.svg" type="image/svg+xml">
|
||||
<link rel="alternate icon" href="./static/graphicarts/favicon.png" type="image/png">
|
||||
<link rel="manifest" href="./manifest.json" />
|
||||
<link rel="stylesheet" href="./static/stylesheets/bootstrap.min.css" crossorigin="use-credentials">
|
||||
<link rel="stylesheet" href="./static/stylesheets/app.css" crossorigin="use-credentials">
|
||||
<link rel="icon" href="./static/graphicarts/favicon.svg" type="image/svg+xml" crossorigin="use-credentials">
|
||||
<link rel="alternate icon" href="./static/graphicarts/favicon.png" type="image/png" crossorigin="use-credentials">
|
||||
<link rel="manifest" href="./manifest.json" crossorigin="use-credentials"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<script>
|
||||
window.app = window.app || {}
|
||||
window.app.settings = {% .settings %}
|
||||
window.app.authenticated = {% .authenticated %}
|
||||
|
||||
if ("serviceWorker" in navigator) {
|
||||
// we use `./sw.js` instead of `./static/javascripts/sw.js` since the latter would not work with
|
||||
// `./manifest.json`, and it leads to uninstallable PWA
|
||||
navigator.serviceWorker.register("./sw.js")
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body class="theme-{% .settings.theme_name %}">
|
||||
|
||||
34
src/assets/javascripts/sw.js
Normal file
34
src/assets/javascripts/sw.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const VERSION = "v2.4"
|
||||
const APP_STATIC_RESOURCES = [
|
||||
"/",
|
||||
"/static/stylesheets/bootstrap.min.css",
|
||||
"/static/stylesheets/app.css",
|
||||
"/static/graphicarts/favicon.svg",
|
||||
"/static/graphicarts/favicon.png",
|
||||
]
|
||||
const CACHE_NAME = `yarr-${VERSION}`;
|
||||
|
||||
self.addEventListener("install", (e) => {
|
||||
e.waitUntil((async () => {
|
||||
const cache = await caches.open(CACHE_NAME)
|
||||
await cache.addAll(APP_STATIC_RESOURCES)
|
||||
})()
|
||||
)
|
||||
})
|
||||
|
||||
// delete old caches on activate
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const names = await caches.keys()
|
||||
await Promise.all(
|
||||
names.map((name) => {
|
||||
if (name !== CACHE_NAME) {
|
||||
return caches.delete(name)
|
||||
}
|
||||
}),
|
||||
)
|
||||
await clients.claim()
|
||||
})(),
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user