mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-25 21:49:20 +00:00
Merge 9740e5ee1209df17009c0012ca4959d90f0b1a58 into 9d5b8d99f7237df8668f553611d2e5e53359da4f
This commit is contained in:
commit
534f1b585c
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>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>yarr!</title>
|
<title>yarr!</title>
|
||||||
<link rel="stylesheet" href="./static/stylesheets/bootstrap.min.css">
|
<link rel="stylesheet" href="./static/stylesheets/bootstrap.min.css" crossorigin="use-credentials">
|
||||||
<link rel="stylesheet" href="./static/stylesheets/app.css">
|
<link rel="stylesheet" href="./static/stylesheets/app.css" crossorigin="use-credentials">
|
||||||
<link rel="icon" href="./static/graphicarts/favicon.svg" type="image/svg+xml">
|
<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">
|
<link rel="alternate icon" href="./static/graphicarts/favicon.png" type="image/png" crossorigin="use-credentials">
|
||||||
<link rel="manifest" href="./manifest.json" />
|
<link rel="manifest" href="./manifest.json" crossorigin="use-credentials"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<script>
|
<script>
|
||||||
window.app = window.app || {}
|
window.app = window.app || {}
|
||||||
window.app.settings = {% .settings %}
|
window.app.settings = {% .settings %}
|
||||||
window.app.authenticated = {% .authenticated %}
|
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>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body class="theme-{% .settings.theme_name %}">
|
<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()
|
||||||
|
})(),
|
||||||
|
)
|
||||||
|
})
|
@ -41,6 +41,7 @@ func (s *Server) handler() http.Handler {
|
|||||||
|
|
||||||
r.For("/", s.handleIndex)
|
r.For("/", s.handleIndex)
|
||||||
r.For("/manifest.json", s.handleManifest)
|
r.For("/manifest.json", s.handleManifest)
|
||||||
|
r.For("/sw.js", s.handleServiceWorker)
|
||||||
r.For("/static/*path", s.handleStatic)
|
r.For("/static/*path", s.handleStatic)
|
||||||
r.For("/api/status", s.handleStatus)
|
r.For("/api/status", s.handleStatus)
|
||||||
r.For("/api/folders", s.handleFolderList)
|
r.For("/api/folders", s.handleFolderList)
|
||||||
@ -93,10 +94,24 @@ func (s *Server) handleManifest(c *router.Context) {
|
|||||||
"sizes": "64x64",
|
"sizes": "64x64",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"src": s.BasePath + "/static/graphicarts/favicon-144.png",
|
||||||
|
"sizes": "144x144",
|
||||||
|
"type": "image/png",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": s.BasePath + "/static/graphicarts/favicon.svg",
|
||||||
|
"sizes": "any",
|
||||||
|
"type": "image/svg",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) handleServiceWorker(c *router.Context) {
|
||||||
|
http.ServeFile(c.Out, c.Req, "src/assets/javascripts/sw.js")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) handleStatus(c *router.Context) {
|
func (s *Server) handleStatus(c *router.Context) {
|
||||||
c.JSON(http.StatusOK, map[string]interface{}{
|
c.JSON(http.StatusOK, map[string]interface{}{
|
||||||
"running": s.worker.FeedsPending(),
|
"running": s.worker.FeedsPending(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user