From 22d180233750c59fb3cade40b321c43253eb5b06 Mon Sep 17 00:00:00 2001 From: Slatian Date: Sat, 3 Dec 2022 22:49:04 +0100 Subject: [PATCH] Documented the theming part a bit better --- README.md | 2 ++ server/server.go | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a19888a..c7ecdd5 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ port = 10001 [theme] # colors specified in hex (or valid css names) which determine the theme of the lieu instance +# NOTE: If (and only if) all three values are set lieu uses those to generate the file html/assets/theme.css at startup. +# You can also write directly to that file istead of adding this section to your configuration file foreground = "#ffffff" background = "#000000" links = "#ffffff" diff --git a/server/server.go b/server/server.go index c94e634..ce58175 100644 --- a/server/server.go +++ b/server/server.go @@ -240,14 +240,15 @@ func (h RequestHandler) renderView(res http.ResponseWriter, tmpl string, view *T func WriteTheme(config types.Config) { theme := config.Theme // no theme is set, use the default - if theme.Foreground == "" { + if theme.Foreground == "" || theme.Background == "" || theme.Links =="" { return } - colors := fmt.Sprintf(`:root { + colors := fmt.Sprintf(`/*This file will be automatically regenerated by lieu on startup if the theme colors are set in the configuration file*/ +:root { --primary: %s; --secondary: %s; --link: %s; -}\n`, theme.Foreground, theme.Background, theme.Links) +}`, theme.Foreground, theme.Background, theme.Links) err := os.WriteFile("html/assets/theme.css", []byte(colors), 0644) util.Check(err) }