static_manifest.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/request"
  8. "miniflux.app/http/response/json"
  9. "miniflux.app/http/route"
  10. "miniflux.app/model"
  11. )
  12. func (h *handler) showWebManifest(w http.ResponseWriter, r *http.Request) {
  13. type webManifestIcon struct {
  14. Source string `json:"src"`
  15. Sizes string `json:"sizes"`
  16. Type string `json:"type"`
  17. }
  18. type webManifest struct {
  19. Name string `json:"name"`
  20. Description string `json:"description"`
  21. ShortName string `json:"short_name"`
  22. StartURL string `json:"start_url"`
  23. Icons []webManifestIcon `json:"icons"`
  24. Display string `json:"display"`
  25. ThemeColor string `json:"theme_color"`
  26. BackgroundColor string `json:"background_color"`
  27. }
  28. themeColor := model.ThemeColor(request.UserTheme(r))
  29. manifest := &webManifest{
  30. Name: "Miniflux",
  31. ShortName: "Miniflux",
  32. Description: "Minimalist Feed Reader",
  33. Display: "minimal-ui",
  34. StartURL: route.Path(h.router, "unread"),
  35. ThemeColor: themeColor,
  36. BackgroundColor: themeColor,
  37. Icons: []webManifestIcon{
  38. webManifestIcon{Source: route.Path(h.router, "appIcon", "filename", "icon-120.png"), Sizes: "120x120", Type: "image/png"},
  39. webManifestIcon{Source: route.Path(h.router, "appIcon", "filename", "icon-192.png"), Sizes: "192x192", Type: "image/png"},
  40. webManifestIcon{Source: route.Path(h.router, "appIcon", "filename", "icon-512.png"), Sizes: "512x512", Type: "image/png"},
  41. },
  42. }
  43. json.OK(w, r, manifest)
  44. }