Skip to content

A self-hosted dashboard that puts all your feeds in one place

Update branding config

Svilen Markovf57bdeec12a1
diff --git a/internal/assets/static/main.css b/internal/assets/static/main.css
index 1a4692e..51b429e 100644
--- a/internal/assets/static/main.css
+++ b/internal/assets/static/main.css
@@ -660,6 +660,16 @@ kbd:active {
padding-right: var(--widget-content-horizontal-padding);
}
+.logo:has(img) {
+ display: flex;
+ align-items: center;
+}
+
+.logo img {
+ aspect-ratio: 1;
+ max-width: 2.7rem;
+}
+
.nav {
height: 100%;
gap: var(--header-items-gap);
diff --git a/internal/assets/templates/document.html b/internal/assets/templates/document.html
index d37ac56..4ac65d8 100644
--- a/internal/assets/templates/document.html
+++ b/internal/assets/templates/document.html
@@ -12,9 +12,8 @@
<meta name="apple-mobile-web-app-title" content="Glance">
<meta name="theme-color" content="{{ if ne nil .App.Config.Theme.BackgroundColor }}{{ .App.Config.Theme.BackgroundColor }}{{ else }}hsl(240, 8%, 9%){{ end }}">
<link rel="apple-touch-icon" sizes="512x512" href="{{ .App.AssetPath "app-icon.png" }}">
- <link rel="icon" type="image/png" sizes="50x50" href="{{ .App.AssetPath "favicon.png" }}">
<link rel="manifest" href="{{ .App.AssetPath "manifest.json" }}">
- <link rel="icon" type="image/png" href="{{ .App.AssetPath "favicon.png" }}" />
+ <link rel="icon" type="image/png" href="{{ .App.Config.Branding.FaviconURL }}" />
<link rel="stylesheet" href="{{ .App.AssetPath "main.css" }}">
<script type="module" src="{{ .App.AssetPath "main.js" }}"></script>
{{ block "document-head-after" . }}{{ end }}
diff --git a/internal/assets/templates/page.html b/internal/assets/templates/page.html
index efb8529..d0add29 100644
--- a/internal/assets/templates/page.html
+++ b/internal/assets/templates/page.html
@@ -32,7 +32,7 @@
<div class="header-container content-bounds">
<div class="header flex padding-inline-widget widget-content-frame">
<!-- TODO: Replace G with actual logo, first need an actual logo -->
- <div class="logo">G</div>
+ <div class="logo">{{ if ne "" .App.Config.Branding.LogoURL }}<img src="{{ .App.Config.Branding.LogoURL }}" alt="">{{ else if ne "" .App.Config.Branding.LogoText }}{{ .App.Config.Branding.LogoText }}{{ else }}{{ end }}</div>
<div class="nav flex grow">
{{ template "navigation-links" . }}
</div>
@@ -63,7 +63,7 @@
</div>
</div>
- {{ if not .App.Config.Branding.Show }}
+ {{ if not .App.Config.Branding.HideFooter }}
<div class="footer flex items-center flex-column">
<div>
<a class="size-h3" href="https://github.com/glanceapp/glance" target="_blank" rel="noreferrer">Glance</a> {{ if ne "dev" .App.Version }}<a class="visited-indicator" title="Release notes" href="https://github.com/glanceapp/glance/releases/tag/{{ .App.Version }}" target="_blank" rel="noreferrer">{{ .App.Version }}</a>{{ else }}({{ .App.Version }}){{ end }}
diff --git a/internal/glance/config.go b/internal/glance/config.go
index 2d73a5c..b0da40e 100644
--- a/internal/glance/config.go
+++ b/internal/glance/config.go
@@ -8,10 +8,10 @@ import (
)
type Config struct {
- Server Server `yaml:"server"`
- Theme Theme `yaml:"theme"`
- Pages []Page `yaml:"pages"`
- Branding Branding `yaml:"branding"`
+ Server Server `yaml:"server"`
+ Theme Theme `yaml:"theme"`
+ Branding Branding `yaml:"branding"`
+ Pages []Page `yaml:"pages"`
}
func NewConfigFromYml(contents io.Reader) (*Config, error) {
@@ -51,9 +51,7 @@ func NewConfig() *Config {
config.Server.Host = ""
config.Server.Port = 8080
- config.Branding.Show = true
- config.Branding.Name = "Glance"
- config.Branding.ShortName = "G"
+ config.Branding.LogoText = "G"
return config
}
diff --git a/internal/glance/glance.go b/internal/glance/glance.go
index d31d08f..c48fe38 100644
--- a/internal/glance/glance.go
+++ b/internal/glance/glance.go
@@ -49,9 +49,10 @@ type Server struct {
}
type Branding struct {
- Show bool `yaml:show`
- Name string `yaml:name`
- ShortName string `yaml:"short-name"`
+ HideFooter bool `yaml:"hide-footer"`
+ LogoText string `yaml:"logo-text"`
+ LogoURL string `yaml:"logo-url"`
+ FaviconURL string `yaml:"favicon-url"`
}
type Column struct {
@@ -108,6 +109,14 @@ func titleToSlug(s string) string {
return s
}
+func (a *Application) TransformUserDefinedAssetPath(path string) string {
+ if strings.HasPrefix(path, "/assets/") {
+ return a.Config.Server.BaseURL + path
+ }
+
+ return path
+}
+
func NewApplication(config *Config) (*Application, error) {
if len(config.Pages) == 0 {
return nil, fmt.Errorf("no pages configured")
@@ -120,6 +129,7 @@ func NewApplication(config *Config) (*Application, error) {
widgetByID: make(map[uint64]widget.Widget),
}
+ app.Config.Server.AssetsHash = assets.PublicFSHash
app.slugToPage[""] = &config.Pages[0]
for p := range config.Pages {
@@ -140,13 +150,16 @@ func NewApplication(config *Config) (*Application, error) {
config = &app.Config
config.Server.BaseURL = strings.TrimRight(config.Server.BaseURL, "/")
+ config.Theme.CustomCSSFile = app.TransformUserDefinedAssetPath(config.Theme.CustomCSSFile)
- if config.Server.BaseURL != "" &&
- config.Theme.CustomCSSFile != "" &&
- strings.HasPrefix(config.Theme.CustomCSSFile, "/assets/") {
- config.Theme.CustomCSSFile = config.Server.BaseURL + config.Theme.CustomCSSFile
+ if config.Branding.FaviconURL == "" {
+ config.Branding.FaviconURL = app.AssetPath("favicon.png")
+ } else {
+ config.Branding.FaviconURL = app.TransformUserDefinedAssetPath(config.Branding.FaviconURL)
}
+ config.Branding.LogoURL = app.TransformUserDefinedAssetPath(config.Branding.LogoURL)
+
return app, nil
}
@@ -244,8 +257,6 @@ func (a *Application) AssetPath(asset string) string {
}
func (a *Application) Serve() error {
- a.Config.Server.AssetsHash = assets.PublicFSHash
-
// TODO: add gzip support, static files must have their gzipped contents cached
// TODO: add HTTPS support
mux := http.NewServeMux()