1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +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

@ -24,6 +24,9 @@ var commonTemplateFiles embed.FS
//go:embed templates/views/*.html
var viewTemplateFiles embed.FS
//go:embed templates/standalone/*.html
var standaloneTemplateFiles embed.FS
// Engine handles the templating system.
type Engine struct {
templates map[string]*template.Template
@ -75,6 +78,22 @@ func (e *Engine) ParseTemplates() error {
e.templates[templateName] = template.Must(template.New("main").Funcs(e.funcMap.Map()).Parse(templateContents.String()))
}
dirEntries, err = standaloneTemplateFiles.ReadDir("templates/standalone")
if err != nil {
return err
}
for _, dirEntry := range dirEntries {
templateName := dirEntry.Name()
fileData, err := standaloneTemplateFiles.ReadFile("templates/standalone/" + dirEntry.Name())
if err != nil {
return err
}
logger.Debug("[Template] Parsing: %s", templateName)
e.templates[templateName] = template.Must(template.New("base").Funcs(e.funcMap.Map()).Parse(string(fileData)))
}
return nil
}

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ t "page.offline.title" }} - Miniflux</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="dark light">
<meta name="theme-color" content="{{ theme_color .theme }}">
</head>
<body>
<p>{{ t "page.offline.message" }} <a href="{{ route "unread" }}">{{ t "page.offline.refresh_page" }}</a>.</p>
</body>
</html>