mirror of
https://github.com/mickael-kerjean/filestash
synced 2026-01-06 15:55:30 +01:00
feature (manifest): generate application manifest server side
the app manifest used to be statically generated meaning it would show Filestash whenever user tries to install as an app. Now admin can change that to show something else
This commit is contained in:
parent
4ec94902b5
commit
2e10feff4f
5 changed files with 32 additions and 26 deletions
|
|
@ -6,7 +6,7 @@
|
|||
<meta name="author" content="Mickael Kerjean <mickael@kerjean.me>">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport">
|
||||
<link rel="manifest" href="/assets/manifest.json">
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<link rel="apple-touch-icon" href="/assets/logo/apple-touch-icon.png">
|
||||
<link rel="stylesheet" href="/custom.css">
|
||||
<link rel="preload" href="/api/config" as="script">
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name": "Filestash",
|
||||
"short_name": "Filestash",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/assets/logo/android-chrome-192x192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "/assets/logo/android-chrome-512x512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"theme_color": "#f2f3f5",
|
||||
"background_color": "#f2f3f5",
|
||||
"orientation": "any",
|
||||
"display": "standalone",
|
||||
"start_url": "/"
|
||||
}
|
||||
|
|
@ -121,6 +121,35 @@ func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) {
|
|||
}})
|
||||
}
|
||||
|
||||
func ManifestHandler(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
res.WriteHeader(http.StatusFound)
|
||||
res.Write([]byte(fmt.Sprintf(`{
|
||||
"name": "%s",
|
||||
"short_name": "%s",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/assets/logo/android-chrome-192x192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "/assets/logo/android-chrome-512x512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"theme_color": "#f2f3f5",
|
||||
"background_color": "#f2f3f5",
|
||||
"orientation": "any",
|
||||
"display": "standalone",
|
||||
"start_url": "/"
|
||||
}`, Config.Get("general.name"), Config.Get("general.name"))))
|
||||
}
|
||||
|
||||
func RobotsHandler(ctx App, res http.ResponseWriter, req *http.Request) {
|
||||
res.Write([]byte(""))
|
||||
}
|
||||
|
||||
func InitPluginList(code []byte) {
|
||||
listOfPackages := regexp.MustCompile(`github.com/mickael-kerjean/([^\"]+)`).FindAllString(string(code), -1)
|
||||
for _, packageName := range listOfPackages {
|
||||
|
|
|
|||
|
|
@ -104,9 +104,8 @@ func Init(a *App) {
|
|||
r.HandleFunc("/report", NewMiddlewareChain(ReportHandler, middlewares, *a)).Methods("POST")
|
||||
middlewares = []Middleware{IndexHeaders}
|
||||
r.HandleFunc("/about", NewMiddlewareChain(AboutHandler, middlewares, *a)).Methods("GET")
|
||||
r.HandleFunc("/robots.txt", func(res http.ResponseWriter, req *http.Request) {
|
||||
res.Write([]byte(""))
|
||||
})
|
||||
r.HandleFunc("/robots.txt", NewMiddlewareChain(RobotsHandler, []Middleware{}, *a))
|
||||
r.HandleFunc("/manifest.json", NewMiddlewareChain(ManifestHandler, []Middleware{}, *a)).Methods("GET")
|
||||
r.HandleFunc("/.well-known/security.txt", NewMiddlewareChain(WellKnownSecurityHandler, []Middleware{}, *a)).Methods("GET")
|
||||
r.HandleFunc("/healthz", NewMiddlewareChain(HealthHandler, []Middleware{}, *a)).Methods("GET")
|
||||
r.HandleFunc("/custom.css", NewMiddlewareChain(CustomCssHandler, []Middleware{}, *a)).Methods("GET")
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ const config = {
|
|||
}),
|
||||
new CopyWebpackPlugin([
|
||||
{ from: "locales/*.json", to: "assets/" },
|
||||
{ from: "manifest.json", to: "assets/" },
|
||||
{ from: "worker/*.js", to: "assets/" },
|
||||
{ from: "assets/logo/*" },
|
||||
{ from: "assets/icons/*" },
|
||||
|
|
|
|||
Loading…
Reference in a new issue