1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Add basic PWA offline page

- Remove feed_icons cache because it's causing more problems that it solve.
- Add basic offline mode when using the service worker.
- Starting in Chrome 93, offline mode is going to be a requirement to install the PWA.

https://developer.chrome.com/blog/improved-pwa-offline-detection/#enforcement-starting-chrome-93-august-2021
This commit is contained in:
Frédéric Guillot 2021-03-07 15:25:34 -08:00 committed by fguillot
parent ae13b4e420
commit 8a812cd8ec
20 changed files with 141 additions and 14 deletions

View file

@ -5,12 +5,14 @@
package ui // import "miniflux.app/ui"
import (
"fmt"
"net/http"
"time"
"miniflux.app/http/request"
"miniflux.app/http/response"
"miniflux.app/http/response/html"
"miniflux.app/http/route"
"miniflux.app/ui/static"
)
@ -23,8 +25,15 @@ func (h *handler) showJavascript(w http.ResponseWriter, r *http.Request) {
}
response.New(w, r).WithCaching(etag, 48*time.Hour, func(b *response.Builder) {
contents := static.JavascriptBundles[filename]
if filename == "service-worker" {
variables := fmt.Sprintf(`const OFFLINE_URL="%s";`, route.Path(h.router, "offline"))
contents = append([]byte(variables)[:], contents[:]...)
}
b.WithHeader("Content-Type", "text/javascript; charset=utf-8")
b.WithBody(static.JavascriptBundles[filename])
b.WithBody(contents)
b.Write()
})
}