Dynamize manifest.json with configurable options
This commit is contained in:
@@ -96,6 +96,18 @@ func newApplication(config *config) (*application, error) {
|
||||
config.Branding.FaviconURL = app.transformUserDefinedAssetPath(config.Branding.FaviconURL)
|
||||
}
|
||||
|
||||
if config.Branding.AppName == "" {
|
||||
config.Branding.AppName = "Glance"
|
||||
}
|
||||
|
||||
if config.Branding.AppIconURL == "" {
|
||||
config.Branding.AppIconURL = app.AssetPath("app-icon.png")
|
||||
}
|
||||
|
||||
if config.Branding.AppBgColor == "" {
|
||||
config.Branding.AppBgColor = "#151519"
|
||||
}
|
||||
|
||||
config.Branding.LogoURL = app.transformUserDefinedAssetPath(config.Branding.LogoURL)
|
||||
|
||||
return app, nil
|
||||
@@ -257,6 +269,26 @@ func (a *application) server() (func() error, func() error) {
|
||||
w.Write(bundledCSSContents)
|
||||
})
|
||||
|
||||
mux.HandleFunc(fmt.Sprintf("GET /static/%s/manifest.json", staticFSHash), func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Cache-Control", cssBundleCacheControlValue)
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
||||
template, err := template.New("manifest.json").
|
||||
Funcs(globalTemplateFunctions).
|
||||
ParseFS(templateFS, "manifest.json")
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(fmt.Sprintf("Error parsing manifest.json template: %v", err)))
|
||||
return
|
||||
}
|
||||
|
||||
if err := template.Execute(w, pageTemplateData{App: a}); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(fmt.Sprintf("Error executing manifest.json template: %v", err)))
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
var absAssetsPath string
|
||||
if a.Config.Server.AssetsPath != "" {
|
||||
absAssetsPath, _ = filepath.Abs(a.Config.Server.AssetsPath)
|
||||
|
||||
Reference in New Issue
Block a user