forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

appview/state: refactor manifest.json

incorporates changes suggested by @boltless.me

Co-authored-by: Seongmin Lee <git@boltless.me>
Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 0d2422ff 0fde3513

verified
Changed files
+30 -24
appview
+29
appview/state/manifest.go
··· 1 + package state 2 + 3 + import ( 4 + "encoding/json" 5 + "net/http" 6 + ) 7 + 8 + // https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest 9 + // https://www.w3.org/TR/appmanifest/ 10 + var manifestData = map[string]any{ 11 + "name": "tangled", 12 + "description": "tightly-knit social coding.", 13 + "icons": []map[string]string{ 14 + { 15 + "src": "/static/logos/dolly.svg", 16 + "sizes": "144x144", 17 + }, 18 + }, 19 + "start_url": "/", 20 + "id": "https://tangled.org", 21 + "display": "standalone", 22 + "background_color": "#111827", 23 + "theme_color": "#111827", 24 + } 25 + 26 + func (p *State) WebAppManifest(w http.ResponseWriter, r *http.Request) { 27 + w.Header().Set("Content-Type", "application/manifest+json") 28 + json.NewEncoder(w).Encode(manifestData) 29 + }
+1 -1
appview/state/router.go
··· 32 32 s.pages, 33 33 ) 34 34 35 - router.Get("/pwa-manifest.json", s.PWAManifest) 35 + router.Get("/pwa-manifest.json", s.WebAppManifest) 36 36 router.Get("/robots.txt", s.RobotsTxt) 37 37 38 38 userRouter := s.UserRouter(&middleware)
-23
appview/state/state.go
··· 212 212 w.Write([]byte(robotsTxt)) 213 213 } 214 214 215 - // https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest 216 - const manifestJson = `{ 217 - "name": "tangled", 218 - "description": "tightly-knit social coding.", 219 - "icons": [ 220 - { 221 - "src": "/favicon.svg", 222 - "sizes": "144x144" 223 - } 224 - ], 225 - "start_url": "/", 226 - "id": "org.tangled", 227 - 228 - "display": "standalone", 229 - "background_color": "#111827", 230 - "theme_color": "#111827" 231 - }` 232 - 233 - func (p *State) PWAManifest(w http.ResponseWriter, r *http.Request) { 234 - w.Header().Set("Content-Type", "application/json") 235 - w.Write([]byte(manifestJson)) 236 - } 237 - 238 215 func (s *State) TermsOfService(w http.ResponseWriter, r *http.Request) { 239 216 user := s.oauth.GetUser(r) 240 217 s.pages.TermsOfService(w, pages.TermsOfServiceParams{