Add web manifest file

This commit is contained in:
Frédéric Guillot 2017-12-22 20:16:49 -08:00
parent f6a5d7d6ed
commit 589aee9f89
5 changed files with 38 additions and 3 deletions

View file

@ -50,7 +50,7 @@ func (s *UserSessionMiddleware) Handler(next http.Handler) http.Handler {
func (s *UserSessionMiddleware) isPublicRoute(r *http.Request) bool {
route := mux.CurrentRoute(r)
switch route.GetName() {
case "login", "checkLogin", "stylesheet", "javascript", "oauth2Redirect", "oauth2Callback", "appIcon", "favicon":
case "login", "checkLogin", "stylesheet", "javascript", "oauth2Redirect", "oauth2Callback", "appIcon", "favicon", "webManifest":
return true
default:
return false

View file

@ -80,6 +80,7 @@ func getRoutes(cfg *config.Config, store *storage.Storage, feedHandler *feed.Han
router.Handle("/js", uiHandler.Use(uiController.Javascript)).Name("javascript").Methods("GET")
router.Handle("/favicon.ico", uiHandler.Use(uiController.Favicon)).Name("favicon").Methods("GET")
router.Handle("/icon/{filename}", uiHandler.Use(uiController.AppIcon)).Name("appIcon").Methods("GET")
router.Handle("/manifest.json", uiHandler.Use(uiController.WebManifest)).Name("webManifest").Methods("GET")
router.Handle("/subscribe", uiHandler.Use(uiController.AddSubscription)).Name("addSubscription").Methods("GET")
router.Handle("/subscribe", uiHandler.Use(uiController.SubmitSubscription)).Name("submitSubscription").Methods("POST")

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2017-12-22 11:25:01.981502305 -0800 PST m=+0.046470067
// 2017-12-22 20:01:12.434799064 -0800 PST m=+0.047000060
package template
@ -33,6 +33,7 @@ var templateCommonMap = map[string]string{
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Miniflux">
<link rel="manifest" href="{{ route "webManifest" }}">
<meta name="robots" content="noindex,nofollow">
<meta name="referrer" content="no-referrer">
@ -127,6 +128,6 @@ var templateCommonMap = map[string]string{
var templateCommonMapChecksums = map[string]string{
"entry_pagination": "f1465fa70f585ae8043b200ec9de5bf437ffbb0c19fb7aefc015c3555614ee27",
"layout": "ade38fbe1058c8dac86b973c289a716e3f97289735e7ad8e8d1731dc6807e38c",
"layout": "778c5cd419c3bd0e35141b1c17bc6775c58b36c650b7566c27ccfd51a6f1417d",
"pagination": "6ff462c2b2a53bc5448b651da017f40a39f1d4f16cef4b2f09784f0797286924",
}

View file

@ -8,6 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Miniflux">
<link rel="manifest" href="{{ route "webManifest" }}">
<meta name="robots" content="noindex,nofollow">
<meta name="referrer" content="no-referrer">

View file

@ -63,3 +63,35 @@ func (c *Controller) AppIcon(ctx *core.Context, request *core.Request, response
response.Cache("image/png", static.BinariesChecksums[filename], blob, 48*time.Hour)
}
// WebManifest renders web manifest file.
func (c *Controller) WebManifest(ctx *core.Context, request *core.Request, response *core.Response) {
type webManifestIcon struct {
Source string `json:"src"`
Sizes string `json:"sizes"`
Type string `json:"type"`
}
type webManifest struct {
Name string `json:"name"`
Description string `json:"description"`
ShortName string `json:"short_name"`
StartURL string `json:"start_url"`
Icons []webManifestIcon `json:"icons"`
Display string `json:"display"`
}
manifest := &webManifest{
Name: "Miniflux",
ShortName: "Miniflux",
Description: "Minimalist Feed Reader",
Display: "minimal-ui",
StartURL: ctx.Route("unread"),
Icons: []webManifestIcon{
webManifestIcon{Source: ctx.Route("appIcon", "filename", "touch-icon-ipad-retina.png"), Sizes: "144x144", Type: "image/png"},
webManifestIcon{Source: ctx.Route("appIcon", "filename", "touch-icon-iphone-retina.png"), Sizes: "114x114", Type: "image/png"},
},
}
response.JSON().Standard(manifest)
}