diff --git a/client/index.html b/client/index.html index 2cff8645..7194cff8 100644 --- a/client/index.html +++ b/client/index.html @@ -6,7 +6,7 @@ - + diff --git a/client/manifest.json b/client/manifest.json deleted file mode 100644 index 1454b7f6..00000000 --- a/client/manifest.json +++ /dev/null @@ -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": "/" -} diff --git a/server/ctrl/static.go b/server/ctrl/static.go index 6209b745..d056413d 100644 --- a/server/ctrl/static.go +++ b/server/ctrl/static.go @@ -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 { diff --git a/server/main.go b/server/main.go index 21be8db4..7bb074f5 100644 --- a/server/main.go +++ b/server/main.go @@ -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") diff --git a/webpack.config.js b/webpack.config.js index f9af9356..c56d21d6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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/*" },