diff --git a/README.md b/README.md
index 674a8ef..37255c1 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,10 @@ typical workflow.
After ingesting the data with `lieu ingest`, you can also use lieu to search the
corpus in the terminal with `lieu search`.
+## Theming
+
+Tweak the `theme` values of the config, specified below.
+
## Config
The config file is written in [TOML](https://toml.io/en/).
@@ -68,6 +72,12 @@ name = "Merveilles Webring"
url = "https://webring.xxiivv.com"
port = 10001
+[theme]
+# colors specified in hex (or valid css names) which determine the theme of the lieu instance
+foreground = "#ffffff"
+background = "#000000"
+links = "#ffffff"
+
[data]
# the source file should contain the crawl command's output
source = "data/crawled.txt"
diff --git a/html/head.html b/html/head.html
index 01d5c25..1e54e43 100644
--- a/html/head.html
+++ b/html/head.html
@@ -12,6 +12,7 @@
+
diff --git a/server/server.go b/server/server.go
index a5bec6b..da9a22b 100644
--- a/server/server.go
+++ b/server/server.go
@@ -227,7 +227,23 @@ 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 == "" {
+ return
+ }
+ colors := fmt.Sprintf(`:root {
+ --primary: %s;
+ --secondary: %s;
+ --link: %s;
+}\n`, theme.Foreground, theme.Background, theme.Links)
+ err := os.WriteFile("html/assets/theme.css", []byte(colors), 0644)
+ util.Check(err)
+}
+
func Serve(config types.Config) {
+ WriteTheme(config)
db := database.InitDB(config.Data.Database)
handler := RequestHandler{config: config, db: db}
diff --git a/types/types.go b/types/types.go
index d27e0d9..c9e2b25 100644
--- a/types/types.go
+++ b/types/types.go
@@ -21,6 +21,11 @@ type Config struct {
URL string `json:url`
Port int `json:port`
} `json:general`
+ Theme struct {
+ Foreground string `json:"foreground"`
+ Background string `json:"background"`
+ Links string `json:"links"`
+ } `json:"theme"`
Data struct {
Source string `json:source`
Database string `json:database`
diff --git a/util/util.go b/util/util.go
index aa6259d..070a518 100644
--- a/util/util.go
+++ b/util/util.go
@@ -105,6 +105,12 @@ name = "Sweet Webring"
url = "https://example.com/"
port = 10001
+[theme]
+# colors specified in hex (or valid css names) which determine the theme of the lieu instance
+foreground = "#ffffff"
+background = "#000000"
+links = "#ffffff"
+
[data]
# the source file should contain the crawl command's output
source = "data/crawled.txt"