From aaa1c702124a6f0044b458482b349dc725816674 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 27 Jul 2026 13:20:28 +0200 Subject: feat(config): 'use' layer stack + CalendarsDir() --- internal/config/config.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'internal/config/config.go') diff --git a/internal/config/config.go b/internal/config/config.go index bf46224..2fb4daa 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -45,6 +45,8 @@ const configHeader = `# lectio configuration (INI). Full-line comments only (# o # web_mono true | false (monospace reading face in the web UI) # web_versions any of: bt, wuj, vul, grb, drb (comma list); empty = just default_version # pager shell command, e.g. less -R; empty = off +# use calendar layers to stack over the universal calendar: names of +# ~/.config/lectio/calendars/.ini files (comma list, order = precedence) # # [calendar] — computed-calendar placement options (defaults = Universal Roman Calendar): # epiphany fixed | sunday (fixed = Jan 6; sunday = the Sunday of Jan 2-8) @@ -165,6 +167,10 @@ type Config struct { CalEpiphany string `toml:"-"` CalAscension string `toml:"-"` CalCorpusChristi string `toml:"-"` + + // Use is the ordered stack of user calendar-layer ids (INI "use"); each id + // names a /.ini file layered over the universal calendar. + Use []string `toml:"-"` } // PartShown reports whether a part renders: true unless explicitly set false. @@ -254,6 +260,16 @@ func configPath() (path string, isDefault bool, err error) { return filepath.Join(dir, "lectio", "config.ini"), true, nil } +// CalendarsDir returns the directory holding user calendar-layer files +// (/calendars). +func CalendarsDir() (string, error) { + p, _, err := configPath() + if err != nil { + return "", err + } + return filepath.Join(filepath.Dir(p), "calendars"), nil +} + // BooksPath returns the path to the optional user books.toml (in the same // directory as the config file). There is no embedded seed on disk -- absence // means "use the built-in defaults". @@ -438,6 +454,8 @@ func applyScalar(cfg *Config, key, val string) { cfg.WebVersions = ini.List(val) case "pager": cfg.Pager = val + case "use": + cfg.Use = ini.List(val) } } @@ -511,6 +529,7 @@ func renderConfigINI(cfg Config) []byte { fmt.Fprintf(&b, "web_mono = %t\n", cfg.WebMono) fmt.Fprintf(&b, "web_versions = %s\n", strings.Join(cfg.WebVersions, ", ")) fmt.Fprintf(&b, "pager = %s\n", cfg.Pager) + fmt.Fprintf(&b, "use = %s\n", strings.Join(cfg.Use, ", ")) b.WriteString("\n# Computed-calendar national placement options.\n[calendar]\n") fmt.Fprintf(&b, "epiphany = %s\n", orDefault(cfg.CalEpiphany, "fixed")) -- cgit v1.3