[add] pwa manifest

This commit is contained in:
Evan Reichard 2023-09-20 20:55:52 -04:00
parent f2163c8fd9
commit c54d1689df
5 changed files with 15 additions and 0 deletions

View File

@ -72,6 +72,7 @@ func (api *API) registerWebAppRoutes() {
api.Router.HTMLRender = render api.Router.HTMLRender = render
api.Router.GET("/manifest.json", api.webManifest)
api.Router.GET("/login", api.createAppResourcesRoute("login")) api.Router.GET("/login", api.createAppResourcesRoute("login"))
api.Router.GET("/register", api.createAppResourcesRoute("login", gin.H{"Register": true})) api.Router.GET("/register", api.createAppResourcesRoute("login", gin.H{"Register": true}))
api.Router.GET("/logout", api.authWebAppMiddleware, api.authLogout) api.Router.GET("/logout", api.authWebAppMiddleware, api.authLogout)

View File

@ -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) { func (api *API) createAppResourcesRoute(routeName string, args ...map[string]any) func(*gin.Context) {
// Merge Optional Template Data // Merge Optional Template Data
var templateVarsBase = gin.H{} var templateVarsBase = gin.H{}

7
assets/manifest.json Normal file
View File

@ -0,0 +1,7 @@
{
"short_name": "Book Manager",
"name": "Book Manager",
"theme_color": "#1F2937",
"background_color": "#1F2937",
"display": "standalone"
}

View File

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<link rel="manifest" href="./manifest.json" />
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>

View File

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<link rel="manifest" href="./manifest.json" />
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>