Server cleanup: extract app-specific config into SX
Phase 1 Step 2 of architecture roadmap. The OCaml HTTP server is now generic — all sx_docs-specific values (layout components, path prefix, title, warmup paths, handler prefixes, CSS/JS, client libs) move into sx/sx/app-config.sx as a __app-config dict. Server reads config at startup with hardcoded defaults as fallback, so it works with no config, partial config, or full config. Removed: 9 demo data stubs, stepper cookie cache logic, page-functions.sx directory heuristic. Added: 29-test server config test suite covering standard, custom, no-config, and minimal-config scenarios. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,14 +2,18 @@
|
||||
sx-url-to-expr
|
||||
(fn
|
||||
(path)
|
||||
(cond
|
||||
(or (= path "/") (= path "/sx/") (= path "/sx"))
|
||||
"home"
|
||||
(starts-with? path "/sx/")
|
||||
(join " " (split (slice path 4 (len path)) "."))
|
||||
(starts-with? path "/")
|
||||
(join " " (split (slice path 1 (len path)) "."))
|
||||
:else path)))
|
||||
(let
|
||||
((prefix (cek-try (fn () (or (dict-get __app-config :path-prefix) "/sx/")) (fn (e) "/sx/")))
|
||||
(prefix-len (len prefix))
|
||||
(prefix-bare (slice prefix 0 (- prefix-len 1))))
|
||||
(cond
|
||||
(or (= path "/") (= path prefix) (= path prefix-bare))
|
||||
"home"
|
||||
(starts-with? path prefix)
|
||||
(join " " (split (slice path prefix-len (len path)) "."))
|
||||
(starts-with? path "/")
|
||||
(join " " (split (slice path 1 (len path)) "."))
|
||||
:else path))))
|
||||
|
||||
(define
|
||||
sx-auto-quote
|
||||
@@ -52,5 +56,13 @@
|
||||
(nil? page-ast)
|
||||
nil
|
||||
(let
|
||||
((nav-path (if (and (>= (len path) 4) (= (slice path 0 4) "/sx/")) path (str "/sx" path))))
|
||||
((prefix (cek-try (fn () (or (dict-get __app-config :path-prefix) "/sx/")) (fn (e) "/sx/")))
|
||||
(prefix-len (len prefix))
|
||||
(nav-path
|
||||
(if
|
||||
(and
|
||||
(>= (len path) prefix-len)
|
||||
(= (slice path 0 prefix-len) prefix))
|
||||
path
|
||||
(str (slice prefix 0 (- prefix-len 1)) path))))
|
||||
{:page-ast page-ast :nav-path nav-path :is-ajax is-ajax})))))
|
||||
|
||||
Reference in New Issue
Block a user