mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 02:18:22 +02:00
Dynamize manifest.json with configurable options
This commit is contained in:
parent
1cf4f520f8
commit
333d40ed4f
@ -268,6 +268,9 @@ branding:
|
||||
<p>Powered by <a href="https://github.com/glanceapp/glance">Glance</a></p>
|
||||
logo-url: /assets/logo.png
|
||||
favicon-url: /assets/logo.png
|
||||
app-name: "My Dashboard"
|
||||
app-icon-url: "/assets/app-icon.png"
|
||||
app-bg-color: "#151519"
|
||||
```
|
||||
|
||||
### Properties
|
||||
@ -279,6 +282,9 @@ branding:
|
||||
| logo-text | string | no | G |
|
||||
| logo-url | string | no | |
|
||||
| favicon-url | string | no | |
|
||||
| app-name | string | no | Glance |
|
||||
| app-icon-url | string | no | |
|
||||
| app-bg-color | string | no | #151519 |
|
||||
|
||||
#### `hide-footer`
|
||||
Hides the footer when set to `true`.
|
||||
@ -295,6 +301,15 @@ Specify a URL to a custom image to use instead of the "G" found in the navigatio
|
||||
#### `favicon-url`
|
||||
Specify a URL to a custom image to use for the favicon.
|
||||
|
||||
#### `app-name`
|
||||
Specify the name of the web app shown in browser tab and PWA. Defaults to "Glance".
|
||||
|
||||
#### `app-icon-url`
|
||||
Specify URL for PWA and browser tab icon (512x512 PNG). Defaults to Glance icon if not set.
|
||||
|
||||
#### `app-bg-color`
|
||||
Specify background color for PWA. Must be a valid CSS color. Defaults to "#151519".
|
||||
|
||||
## Theme
|
||||
Theming is done through a top level `theme` property. Values for the colors are in [HSL](https://giggster.com/guide/basics/hue-saturation-lightness/) (hue, saturation, lightness) format. You can use a color picker [like this one](https://hslpicker.com/) to convert colors from other formats to HSL. The values are separated by a space and `%` is not required for any of the numbers.
|
||||
|
||||
|
@ -55,6 +55,9 @@ type config struct {
|
||||
LogoText string `yaml:"logo-text"`
|
||||
LogoURL string `yaml:"logo-url"`
|
||||
FaviconURL string `yaml:"favicon-url"`
|
||||
AppName string `yaml:"app-name"`
|
||||
AppIconURL string `yaml:"app-icon-url"`
|
||||
AppBgColor string `yaml:"app-bg-color"`
|
||||
} `yaml:"branding"`
|
||||
|
||||
Pages []page `yaml:"pages"`
|
||||
|
@ -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)
|
||||
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "Glance",
|
||||
"display": "standalone",
|
||||
"background_color": "#151519",
|
||||
"scope": "/",
|
||||
"start_url": "/",
|
||||
"icons": [
|
||||
{
|
||||
"src": "app-icon.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
]
|
||||
}
|
14
internal/glance/templates/manifest.json
Normal file
14
internal/glance/templates/manifest.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "{{ .App.Config.Branding.AppName }}",
|
||||
"display": "standalone",
|
||||
"background_color": "{{ .App.Config.Branding.AppBgColor }}",
|
||||
"scope": "/",
|
||||
"start_url": "/",
|
||||
"icons": [
|
||||
{
|
||||
"src": "{{ .App.Config.Branding.AppIconURL }}",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user