From 0d2422ff1800bfc9563aa56c3819922867de9e0a Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 09 Jan 2026 10:30:29 +0000 Subject: [PATCH] appview/state: refactor manifest.json incorporates changes suggested by @boltless.me Co-authored-by: Seongmin Lee Signed-off-by: oppiliappan --- appview/state/manifest.go | 29 +++++++++++++++++++++++++++++ appview/state/router.go | 2 +- appview/state/state.go | 23 ----------------------- 3 file(s) changed, 30 insertion(s)(+), 24 deletion(s)(-) diff --git a/appview/state/manifest.go b/appview/state/manifest.go new file mode 100644 --- /dev/null +++ b/appview/state/manifest.go @@ -0,0 +1,29 @@ +package state + +import ( + "encoding/json" + "net/http" +) + +// https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest +// https://www.w3.org/TR/appmanifest/ +var manifestData = map[string]any{ + "name": "tangled", + "description": "tightly-knit social coding.", + "icons": []map[string]string{ + { + "src": "/static/logos/dolly.svg", + "sizes": "144x144", + }, + }, + "start_url": "/", + "id": "https://tangled.org", + "display": "standalone", + "background_color": "#111827", + "theme_color": "#111827", +} + +func (p *State) WebAppManifest(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/manifest+json") + json.NewEncoder(w).Encode(manifestData) +} diff --git a/appview/state/router.go b/appview/state/router.go --- a/appview/state/router.go +++ b/appview/state/router.go @@ -32,7 +32,7 @@ s.pages, ) - router.Get("/pwa-manifest.json", s.PWAManifest) + router.Get("/pwa-manifest.json", s.WebAppManifest) router.Get("/robots.txt", s.RobotsTxt) userRouter := s.UserRouter(&middleware) diff --git a/appview/state/state.go b/appview/state/state.go --- a/appview/state/state.go +++ b/appview/state/state.go @@ -212,29 +212,6 @@ w.Write([]byte(robotsTxt)) } -// https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest -const manifestJson = `{ - "name": "tangled", - "description": "tightly-knit social coding.", - "icons": [ - { - "src": "/favicon.svg", - "sizes": "144x144" - } - ], - "start_url": "/", - "id": "org.tangled", - - "display": "standalone", - "background_color": "#111827", - "theme_color": "#111827" -}` - -func (p *State) PWAManifest(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(manifestJson)) -} - func (s *State) TermsOfService(w http.ResponseWriter, r *http.Request) { user := s.oauth.GetUser(r) s.pages.TermsOfService(w, pages.TermsOfServiceParams{ -- tangled.sh