diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 15:00:17 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 15:00:17 +0200 |
| commit | aa6c9dad764089a3f0e287b5f90937e97dde3921 (patch) | |
| tree | 213f7f56bf3c5ca1db82f0eee7c482886fa9ce43 /internal/config/config.go | |
| parent | 66a17fda33e44e9022d6724f850323f754715259 (diff) | |
| download | lectio-aa6c9dad764089a3f0e287b5f90937e97dde3921.tar.gz lectio-aa6c9dad764089a3f0e287b5f90937e97dde3921.zip | |
web: horizontal/vertical/interlinear display modes + web_display config
Adds a display-layout option to lectio-web alongside the existing colour
themes:
- config: WebDisplay field (toml web_display), default "horizontal",
normalized on load via the new exported config.NormalizeDisplay
(unknown -> "horizontal", same lenient style as the other web_* fields).
- render: extracts the citation/ToEnglishRef resolution shared by
GatherVersion into an unexported resolveRef helper (GatherVersion's
signature/behavior unchanged) and adds GatherVerses(version, sec,
lectionary) returning raw bible.Verse structs plus a versified flag, for
column/interlinear alignment.
- web/render: RenderReadings gains a display parameter. "horizontal" is
the original stacked layout, byte-for-byte the same code path as
before. "vertical" reuses the same per-version column data in a
.display-vertical/.vcol grid (the CLI compare view, browser-side).
"interlinear" maps versions through render.OfflineVersions' pl->wuj
substitution (pl has no verse numbers), gathers GatherVerses per
version, and interleaves them by chapter:verse into .ilverse/.illine
blocks (ordered union of keys, first versified version's order first).
- server: adds a display <select> to the top bar wired into the existing
#controls HTMX form; a resolveQuery(cfg, r) helper replaces the
duplicated date/lectionary/all/versions(+now display) resolution in
indexHandler and readingsHandler.
- fold-in from the B2 review: indexHandler now populates indexData.Lookup
via a shared renderLookup(ref, versions) helper (also used by
lookupHandler), so a bookmarked "/?ref=...&v=..." link shows its
lookup result instead of an empty pane.
- base.css: layout-only rules for the two new modes (no colours; themes
stay colour-only).
go test ./..., go vet ./..., gofmt clean; go build ./cmd/lectio-web ok.
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 9c3c3cd..c15b5a0 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -11,6 +11,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "github.com/pelletier/go-toml/v2" ) @@ -30,6 +31,26 @@ var validVersions = map[string]bool{ "drb": true, } +// validDisplays are the lectio-web reading-pane layouts. +var validDisplays = map[string]bool{ + "horizontal": true, + "vertical": true, + "interlinear": true, +} + +// NormalizeDisplay lower-cases display and falls back to "horizontal" when +// it is not one of validDisplays -- the same lenient style as the rest of +// lectio-web's config fields (no error, just a safe default). Exported so +// internal/web can apply the identical normalization to an explicit +// ?display= query override, keeping the valid set in this one place. +func NormalizeDisplay(display string) string { + d := strings.ToLower(display) + if !validDisplays[d] { + return "horizontal" + } + return d +} + // Config holds lectio's user-configurable settings. type Config struct { SchemaVersion int `toml:"schema_version"` @@ -42,6 +63,7 @@ type Config struct { Offline bool `toml:"offline"` WebTheme string `toml:"web_theme"` WebPort int `toml:"web_port"` + WebDisplay string `toml:"web_display"` Parts map[string]map[string]bool `toml:"parts"` } @@ -69,6 +91,7 @@ func Default() Config { Offline: false, WebTheme: "transfiguration", WebPort: 0, + WebDisplay: "horizontal", Parts: nil, } } @@ -134,6 +157,7 @@ func Load() (Config, error) { fmt.Fprintf(os.Stderr, "lectio: warning: invalid config at %s: %v; using defaults\n", path, err) return def, nil } + cfg.WebDisplay = NormalizeDisplay(cfg.WebDisplay) if err := validate(cfg); err != nil { return Config{}, err |
