diff options
Diffstat (limited to 'internal/web')
| -rw-r--r-- | internal/web/server.go | 16 | ||||
| -rw-r--r-- | internal/web/server_test.go | 10 | ||||
| -rw-r--r-- | internal/web/templates/settings.html | 4 |
3 files changed, 15 insertions, 15 deletions
diff --git a/internal/web/server.go b/internal/web/server.go index a586534..2674802 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -62,7 +62,7 @@ func (s *server) apply(cfg config.Config, tbl *bible.BookTable) { // query parameters; it is never mutated -- /settings applies changes to a // live, mutable copy held by server, which every handler reads per request. func NewServer(cfg config.Config) http.Handler { - tbl, _ := bible.LoadBookTable(config.UserBooksTOML()) + tbl, _ := bible.LoadBookTable(config.UserBooksINI()) s := &server{cfg: cfg, tbl: tbl, bm: bookmarks.Open()} mux := http.NewServeMux() @@ -719,7 +719,7 @@ func themeCSSHandler(cfg config.Config) http.HandlerFunc { // settingsData drives templates/settings.html. type settingsData struct { Cfg config.Config - Books string // current books.toml text (user override, else the embedded default) + Books string // current books.ini text (user override, else the embedded default) ThemeOpts []themeOpt // for the web_theme <select> VersionOpts []versionOpt // all five, Checked if in Cfg.Versions WebVersionOpts []versionOpt // all five, Checked if in Cfg.WebVersions @@ -768,10 +768,10 @@ func newSettingsData(cfg config.Config, books, errMsg string, saved bool) settin } func currentBooksText() string { - if b := config.UserBooksTOML(); len(b) > 0 { + if b := config.UserBooksINI(); len(b) > 0 { return string(b) } - return string(bible.DefaultBooksTOML()) + return string(bible.DefaultBooksINI()) } // settingsGet renders the settings form for the live config. @@ -785,7 +785,7 @@ func settingsGet(s *server) http.HandlerFunc { } } -// settingsPost validates and persists the submitted settings + books.toml, then +// settingsPost validates and persists the submitted settings + books.ini, then // applies them to the running server and redirects (PRG). On a validation error // it re-renders the form with the message and the user's edits, HTTP 200. func settingsPost(s *server) http.HandlerFunc { @@ -819,12 +819,12 @@ func settingsPost(s *server) http.HandlerFunc { renderSettingsError(w, cfg, booksText, err.Error()) return } - // Validate books.toml (parse via the same loader the app uses). + // Validate books.ini (parse via the same loader the app uses). var newTbl *bible.BookTable if strings.TrimSpace(booksText) != "" { t, berr := bible.LoadBookTable([]byte(booksText)) if berr != nil { - renderSettingsError(w, cfg, booksText, "books.toml: "+berr.Error()) + renderSettingsError(w, cfg, booksText, "books.ini: "+berr.Error()) return } newTbl = t @@ -835,7 +835,7 @@ func settingsPost(s *server) http.HandlerFunc { renderSettingsError(w, cfg, booksText, "saving config: "+err.Error()) return } - // Only write books.toml when the editor actually carried content, so a + // Only write books.ini when the editor actually carried content, so a // submit with an empty/absent books field never clobbers an existing // override (the form always pre-fills the textarea). if strings.TrimSpace(booksText) != "" { diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 284a454..12542e5 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -561,19 +561,19 @@ func TestSettingsPostInvalidBooks(t *testing.T) { post.Header.Set("Content-Type", "application/x-www-form-urlencoded") rec := httptest.NewRecorder() srv.ServeHTTP(rec, post) - if rec.Code != 200 || !strings.Contains(rec.Body.String(), "books.toml") { + if rec.Code != 200 || !strings.Contains(rec.Body.String(), "books.ini") { t.Errorf("invalid books should re-render with an error, got %d", rec.Code) } } -func bibleDefaultBooks() []byte { return bible.DefaultBooksTOML() } +func bibleDefaultBooks() []byte { return bible.DefaultBooksINI() } // TestSettingsPostEmptyBooksPreservesFile guards that a submit without a books -// field never clobbers an existing books.toml override. +// field never clobbers an existing books.ini override. func TestSettingsPostEmptyBooksPreservesFile(t *testing.T) { dir := t.TempDir() t.Setenv("LECTIO_CONFIG", filepath.Join(dir, "config.toml")) - booksPath := filepath.Join(dir, "books.toml") + booksPath := filepath.Join(dir, "books.ini") original := []byte("[en]\nJohn = [\"Jn\", \"John\"]\n") if err := os.WriteFile(booksPath, original, 0o644); err != nil { t.Fatal(err) @@ -594,7 +594,7 @@ func TestSettingsPostEmptyBooksPreservesFile(t *testing.T) { t.Fatalf("status %d", rec.Code) } if got, _ := os.ReadFile(booksPath); string(got) != string(original) { - t.Errorf("empty books submit clobbered books.toml: got %q", got) + t.Errorf("empty books submit clobbered books.ini: got %q", got) } } diff --git a/internal/web/templates/settings.html b/internal/web/templates/settings.html index be08e6d..e2ee39e 100644 --- a/internal/web/templates/settings.html +++ b/internal/web/templates/settings.html @@ -1,5 +1,5 @@ {{/* settings.html — lectio-web /settings page: a form for every config - setting plus a raw books.toml editor. A plain POST form (no htmx) -- + setting plus a raw books.ini editor. A plain POST form (no htmx) -- saving redirects (PRG) back here with ?saved=1. On a validation error the form re-renders with the submitted values and an inline message instead of redirecting. Self-contained and theme-aware, like index.html. */}} @@ -100,7 +100,7 @@ <input type="text" name="pager" value="{{.Cfg.Pager}}"> </label> - <label>books.toml + <label>books.ini <textarea name="books" rows="20">{{.Books}}</textarea> </label> |
