[add] pwa manifest, [fix] missing koplugin import

This commit is contained in:
Evan Reichard 2023-09-18 19:57:18 -04:00
parent f2163c8fd9
commit bf24207948
6 changed files with 16 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

@ -13,6 +13,7 @@ local WidgetContainer = require("ui/widget/container/widgetcontainer")
local _ = require("gettext") local _ = require("gettext")
local logger = require("logger") local logger = require("logger")
local md5 = require("ffi/sha2").md5 local md5 = require("ffi/sha2").md5
local random = require("random")
------------------------------------------ ------------------------------------------
------------ Helper Functions ------------ ------------ Helper Functions ------------

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>