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

PWA: First implementation of offline mode

This commit is contained in:
Brieuc Dubois 2024-06-21 19:13:54 +02:00
parent 05f7a34d43
commit 925ea2c082
10 changed files with 1851 additions and 1076 deletions

View file

@ -31,7 +31,19 @@ func (h *handler) showJavascript(w http.ResponseWriter, r *http.Request) {
contents := static.JavascriptBundles[filename]
if filename == "service-worker" {
variables := fmt.Sprintf(`const OFFLINE_URL=%q;`, route.Path(h.router, "offline"))
user, err := h.store.UserByID(request.UserID(r))
if err != nil {
html.ServerError(w, r, err)
return
}
cacheForOffline := 0
if user.CacheForOffline {
cacheForOffline = 1
}
variables := fmt.Sprintf(`const OFFLINE_URL=%q;const USE_CACHE=%d;`, route.Path(h.router, "offline"), cacheForOffline)
contents = append([]byte(variables), contents...)
}