static_manifest.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui // import "miniflux.app/ui"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/context"
  8. "miniflux.app/http/response/json"
  9. "miniflux.app/http/route"
  10. "miniflux.app/model"
  11. )
  12. // WebManifest renders web manifest file.
  13. func (c *Controller) WebManifest(w http.ResponseWriter, r *http.Request) {
  14. type webManifestIcon struct {
  15. Source string `json:"src"`
  16. Sizes string `json:"sizes"`
  17. Type string `json:"type"`
  18. }
  19. type webManifest struct {
  20. Name string `json:"name"`
  21. Description string `json:"description"`
  22. ShortName string `json:"short_name"`
  23. StartURL string `json:"start_url"`
  24. Icons []webManifestIcon `json:"icons"`
  25. Display string `json:"display"`
  26. ThemeColor string `json:"theme_color"`
  27. BackgroundColor string `json:"background_color"`
  28. }
  29. ctx := context.New(r)
  30. themeColor := model.ThemeColor(ctx.UserTheme())
  31. manifest := &webManifest{
  32. Name: "Miniflux",
  33. ShortName: "Miniflux",
  34. Description: "Minimalist Feed Reader",
  35. Display: "minimal-ui",
  36. StartURL: route.Path(c.router, "unread"),
  37. ThemeColor: themeColor,
  38. BackgroundColor: themeColor,
  39. Icons: []webManifestIcon{
  40. webManifestIcon{Source: route.Path(c.router, "appIcon", "filename", "icon-120.png"), Sizes: "120x120", Type: "image/png"},
  41. webManifestIcon{Source: route.Path(c.router, "appIcon", "filename", "icon-192.png"), Sizes: "192x192", Type: "image/png"},
  42. webManifestIcon{Source: route.Path(c.router, "appIcon", "filename", "icon-512.png"), Sizes: "512x512", Type: "image/png"},
  43. },
  44. }
  45. json.OK(w, r, manifest)
  46. }