From c54d1689df7d0deb54f629dbba9be295643becf8 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Wed, 20 Sep 2023 20:55:52 -0400 Subject: [PATCH] [add] pwa manifest --- api/api.go | 1 + api/app-routes.go | 5 +++++ assets/manifest.json | 7 +++++++ templates/base.html | 1 + templates/login.html | 1 + 5 files changed, 15 insertions(+) create mode 100644 assets/manifest.json diff --git a/api/api.go b/api/api.go index f8716dc..ba0d93c 100644 --- a/api/api.go +++ b/api/api.go @@ -72,6 +72,7 @@ func (api *API) registerWebAppRoutes() { api.Router.HTMLRender = render + api.Router.GET("/manifest.json", api.webManifest) api.Router.GET("/login", api.createAppResourcesRoute("login")) api.Router.GET("/register", api.createAppResourcesRoute("login", gin.H{"Register": true})) api.Router.GET("/logout", api.authWebAppMiddleware, api.authLogout) diff --git a/api/app-routes.go b/api/app-routes.go index be3f4d8..002ec64 100644 --- a/api/app-routes.go +++ b/api/app-routes.go @@ -25,6 +25,11 @@ func baseResourceRoute(template string, args ...map[string]any) func(c *gin.Cont } } +func (api *API) webManifest(c *gin.Context) { + c.Header("Content-Type", "application/manifest+json") + c.File("./assets/manifest.json") +} + func (api *API) createAppResourcesRoute(routeName string, args ...map[string]any) func(*gin.Context) { // Merge Optional Template Data var templateVarsBase = gin.H{} diff --git a/assets/manifest.json b/assets/manifest.json new file mode 100644 index 0000000..1008563 --- /dev/null +++ b/assets/manifest.json @@ -0,0 +1,7 @@ +{ + "short_name": "Book Manager", + "name": "Book Manager", + "theme_color": "#1F2937", + "background_color": "#1F2937", + "display": "standalone" +} diff --git a/templates/base.html b/templates/base.html index 93dcbb4..40e5e78 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,7 @@ + diff --git a/templates/login.html b/templates/login.html index 34c2cae..045df2e 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,6 +1,7 @@ +