host: revert legacy-editor shims — clean over fancy, 181/181
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s
Pull out the debt that revived the legacy editor: removed kg-compat.sx (uncommitted bare->namespaced kg-card aliases), the ./blog container mount, the legacy sx-editor.js + hardcoded asset URLs + ~editor/sx-editor-styles reuse at /new, and the blog/sx preloads. /new is now a clean minimal form. Finding that reshapes Phase 5: render-page (5.1) renders STATIC component trees but is NOT the full evaluator — a component with a data loop ((map fn items) over (unquote data)) errors 'Not callable: nil'. So clean dynamic component pages + a native island editor need the aser SSR pipeline (5.2), not just render-page. Posts still render via per-block guarded render-page; unsupported editor cards (~kg-md) show placeholders by design (no alias shim). All endpoints 200, boot clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -28,9 +28,6 @@ services:
|
||||
- ./spec:/app/spec:ro
|
||||
- ./lib:/app/lib:ro
|
||||
- ./web:/app/web:ro
|
||||
# blog app SX — reused for the editor's style component (transitional;
|
||||
# retire when the editor + its styles are host-owned / asset-managed)
|
||||
- ./blog:/app/blog:ro
|
||||
# OCaml server binary — this worktree's build (has the SX_HTTP_HOST bind fix)
|
||||
- ./hosts/ocaml/_build/default/bin/sx_server.exe:/app/bin/sx_server:ro
|
||||
# Durable persist store (the SX op-log/kv on disk) — survives restarts.
|
||||
|
||||
@@ -116,43 +116,25 @@
|
||||
|
||||
(define host/blog-index (fn (req) (host/ok (host/blog-list))))
|
||||
|
||||
;; ── create page (GET /new) — the real WYSIWYG block editor ──────────
|
||||
;; Mounts the self-contained sx-editor.js (Ghost/Koenig-style block editor) that
|
||||
;; serializes the visual edit to `sx_content`. Assets (sx-browser.js for Sx.parse,
|
||||
;; sx-editor.js, editor.css) are referenced from the docs static host
|
||||
;; (sx.rose-ash.com/static/scripts) — no host static-serving needed. On submit the
|
||||
;; handle's getSx() fills the hidden sx_content field, then it POSTs to /new.
|
||||
;; (This reuses the legacy JS editor; a native SX-island editor is the future.)
|
||||
(define host/blog--asset "https://sx.rose-ash.com/static/scripts")
|
||||
;; ── create page (GET /new) — clean minimal form ────────────────────
|
||||
;; A plain create form: title + sx_content (SX element markup) + status. No
|
||||
;; legacy JS editor, no external assets, no shims. The rich WYSIWYG is a future
|
||||
;; native SX-island editor served via the Phase-5.2 SSR pipeline (render-page
|
||||
;; alone can't render dynamic-logic component bodies — proven). Posts to /new.
|
||||
(define host/blog-new-form
|
||||
(fn (req)
|
||||
(dream-html
|
||||
(str
|
||||
"<!doctype html><html><head><meta charset=\"utf-8\"><title>New post</title>"
|
||||
;; FontAwesome for the editor's +/slash-menu icons.
|
||||
"<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css\">"
|
||||
;; The sx-editor's own styles (.sx-*), rendered from its component via 5.1.
|
||||
(render-page (quote (~editor/sx-editor-styles)))
|
||||
"<style>body{max-width:768px;margin:2rem auto;padding:0 1rem;font-family:system-ui}"
|
||||
"#title-input{width:100%;font-size:1.9em;font-weight:700;border:none;outline:none;margin:.5rem 0}"
|
||||
".bar{display:flex;gap:1rem;align-items:center;margin-top:1.5rem;border-top:1px solid #eee;padding-top:1rem}</style>"
|
||||
"</head><body>"
|
||||
"<form id=\"post-new-form\" method=\"post\" action=\"/new\">"
|
||||
"<input id=\"title-input\" name=\"title\" placeholder=\"Post title\" autocomplete=\"off\">"
|
||||
"<input type=\"hidden\" id=\"sx-content-input\" name=\"sx_content\" value=\"\">"
|
||||
"<div id=\"sx-editor\"></div>"
|
||||
"<div class=\"bar\">"
|
||||
"<select name=\"status\"><option value=\"draft\">Draft</option>"
|
||||
"<option value=\"published\" selected>Published</option></select>"
|
||||
"<button type=\"submit\">Publish</button>"
|
||||
"<a href=\"/\">all posts</a></div>"
|
||||
"</form>"
|
||||
"<script src=\"" host/blog--asset "/sx-browser.js\"></script>"
|
||||
"<script src=\"" host/blog--asset "/sx-editor.js\"></script>"
|
||||
"<script>(function(){var h=SxEditor.mount('sx-editor',{});"
|
||||
"document.getElementById('post-new-form').addEventListener('submit',function(){"
|
||||
"document.getElementById('sx-content-input').value=h.getSx();});})();</script>"
|
||||
"</body></html>"))))
|
||||
(host/blog--page "New post"
|
||||
(str
|
||||
"<h1>New post</h1>"
|
||||
"<form method=\"post\" action=\"/new\">"
|
||||
"<p><input name=\"title\" placeholder=\"Title\" style=\"font-size:1.4em;width:100%\"></p>"
|
||||
"<p><textarea name=\"sx_content\" rows=\"12\" style=\"width:100%;font-family:monospace\" "
|
||||
"placeholder=\"(p "Your post as SX markup")\"></textarea></p>"
|
||||
"<p><select name=\"status\"><option value=\"draft\">Draft</option>"
|
||||
"<option value=\"published\">Published</option></select> "
|
||||
"<button type=\"submit\">Publish</button></p>"
|
||||
"</form><p><a href=\"/\">← all posts</a></p>")))))
|
||||
|
||||
;; ── write handlers ──────────────────────────────────────────────────
|
||||
;; POST /new — form-urlencoded ingest (the editor's submit shape: title,
|
||||
|
||||
@@ -63,8 +63,6 @@ MODULES=(
|
||||
"lib/persist/durable.sx"
|
||||
"spec/render.sx"
|
||||
"web/adapter-html.sx"
|
||||
"blog/sx/layouts.sx"
|
||||
"blog/sx/editor.sx"
|
||||
"lib/dream/types.sx"
|
||||
"lib/dream/json.sx"
|
||||
"lib/dream/auth.sx"
|
||||
|
||||
@@ -68,8 +68,6 @@ MODULES=(
|
||||
"lib/persist/durable.sx"
|
||||
"spec/render.sx"
|
||||
"web/adapter-html.sx"
|
||||
"blog/sx/layouts.sx"
|
||||
"blog/sx/editor.sx"
|
||||
"lib/dream/types.sx"
|
||||
"lib/dream/json.sx"
|
||||
"lib/dream/auth.sx"
|
||||
|
||||
@@ -228,9 +228,21 @@ Sub-steps (each independently gated/verified):
|
||||
mangling). Root cause confirmed: bare render-to-html on an *evaluated* tree
|
||||
mangles attrs; `render-page` renders the *unevaluated* expr so expansion +
|
||||
attr-collection happen in render-to-html.
|
||||
- [ ] **5.2 Shell statics in the host env.** Run `http_inject_shell_statics` for
|
||||
the host's loaded components so the shell can inline defs/CSS/asset-hashes.
|
||||
Gate: a full page shell emits with component defs inlined.
|
||||
- [ ] **5.2 Shell statics + aser SSR (the real dynamic-page path).** `render-page`
|
||||
(5.1) renders STATIC component trees, but is NOT the full evaluator —
|
||||
dynamic-logic bodies fail (proven: a component doing `(map fn items)` over
|
||||
`(unquote data)` → "Not callable: nil"). Clean dynamic component pages
|
||||
(a posts loop) + island pages therefore need the **aser** pipeline (evaluate
|
||||
control flow, serialise tags) + `http_inject_shell_statics` (component defs /
|
||||
CSS / asset hashes) + `~shared:shell/sx-page-shell`. Gate: a page with a data
|
||||
loop renders, and a full shell emits with defs inlined.
|
||||
NOTE (2026-06-19): the legacy-editor stopgaps (kg-compat aliases, `./blog`
|
||||
mount, legacy `sx-editor.js` + hardcoded asset URLs at `/new`, the
|
||||
`~editor/sx-editor-styles` reuse) were REVERTED — they were debt to revive
|
||||
stale code. `/new` is now a clean minimal form; host pages still use minimal
|
||||
shell HTML until the aser path lands. Posts render via per-block guarded
|
||||
`render-page`; unsupported editor cards (e.g. `~kg-md`) show placeholders by
|
||||
design (no alias shim).
|
||||
- [ ] **5.3 Static-asset serving.** Serve `/scripts/*.js`, `/*.css`, `/wasm/*`
|
||||
from `shared/static`. Host has none today — needs a kernel file-serving
|
||||
route in the `http-listen` server (or a file-read prim + SX static handler).
|
||||
|
||||
Reference in New Issue
Block a user