2018-04-30 01:35:04 +02:00
|
|
|
// Copyright 2018 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2018-08-25 06:51:50 +02:00
|
|
|
package ui // import "miniflux.app/ui"
|
2018-04-30 01:35:04 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2018-08-25 06:51:50 +02:00
|
|
|
"miniflux.app/http/context"
|
|
|
|
"miniflux.app/http/response/json"
|
|
|
|
"miniflux.app/http/route"
|
|
|
|
"miniflux.app/model"
|
2018-04-30 01:35:04 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// WebManifest renders web manifest file.
|
|
|
|
func (c *Controller) WebManifest(w http.ResponseWriter, r *http.Request) {
|
|
|
|
type webManifestIcon struct {
|
|
|
|
Source string `json:"src"`
|
|
|
|
Sizes string `json:"sizes"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type webManifest struct {
|
2018-07-19 07:30:05 +02:00
|
|
|
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"`
|
|
|
|
ThemeColor string `json:"theme_color"`
|
|
|
|
BackgroundColor string `json:"background_color"`
|
2018-04-30 01:35:04 +02:00
|
|
|
}
|
|
|
|
|
2018-07-19 07:30:05 +02:00
|
|
|
ctx := context.New(r)
|
|
|
|
themeColor := model.ThemeColor(ctx.UserTheme())
|
|
|
|
|
2018-04-30 01:35:04 +02:00
|
|
|
manifest := &webManifest{
|
2018-07-19 07:30:05 +02:00
|
|
|
Name: "Miniflux",
|
|
|
|
ShortName: "Miniflux",
|
|
|
|
Description: "Minimalist Feed Reader",
|
|
|
|
Display: "minimal-ui",
|
|
|
|
StartURL: route.Path(c.router, "unread"),
|
|
|
|
ThemeColor: themeColor,
|
|
|
|
BackgroundColor: themeColor,
|
2018-04-30 01:35:04 +02:00
|
|
|
Icons: []webManifestIcon{
|
2018-07-19 06:30:54 +02:00
|
|
|
webManifestIcon{Source: route.Path(c.router, "appIcon", "filename", "icon-120.png"), Sizes: "120x120", Type: "image/png"},
|
|
|
|
webManifestIcon{Source: route.Path(c.router, "appIcon", "filename", "icon-192.png"), Sizes: "192x192", Type: "image/png"},
|
|
|
|
webManifestIcon{Source: route.Path(c.router, "appIcon", "filename", "icon-512.png"), Sizes: "512x512", Type: "image/png"},
|
2018-04-30 01:35:04 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-07-20 04:27:05 +02:00
|
|
|
json.OK(w, r, manifest)
|
2018-04-30 01:35:04 +02:00
|
|
|
}
|