content: HTML page wrapper (page.sx) + 7 tests (455/455)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ if [ ! -x "$SX_SERVER" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
SUITES=(block doc render api meta markdown text section stats table validate store snapshot crdt crdt-store sync md-import fed)
|
||||
SUITES=(block doc render api meta page markdown text section stats table validate store snapshot crdt crdt-store sync md-import fed)
|
||||
|
||||
OUT_JSON="lib/content/scoreboard.json"
|
||||
OUT_MD="lib/content/scoreboard.md"
|
||||
@@ -47,6 +47,7 @@ run_suite() {
|
||||
(load "lib/content/section.sx")
|
||||
(load "lib/content/stats.sx")
|
||||
(load "lib/content/table.sx")
|
||||
(load "lib/content/page.sx")
|
||||
(load "lib/content/markdown.sx")
|
||||
(load "lib/content/validate.sx")
|
||||
(load "lib/content/store.sx")
|
||||
|
||||
26
lib/content/page.sx
Normal file
26
lib/content/page.sx
Normal file
@@ -0,0 +1,26 @@
|
||||
;; content-on-sx — full HTML page wrapper.
|
||||
;;
|
||||
;; content/page composes the metadata + render layers into the shippable
|
||||
;; artifact the blog serves: a minimal valid HTML5 document with an escaped
|
||||
;; <title> (from doc metadata, falling back to the id) and the rendered blocks
|
||||
;; as the body.
|
||||
;;
|
||||
;; Requires (loaded by harness): doc.sx, render.sx (asHTML + htmlEscaped),
|
||||
;; meta.sx (doc-title).
|
||||
|
||||
(define ct-html-escape (fn (s) (str (st-send s "htmlEscaped" (list)))))
|
||||
|
||||
(define
|
||||
content/page-title
|
||||
(fn (doc) (let ((t (doc-title doc))) (if (= t nil) (doc-id doc) t))))
|
||||
|
||||
(define
|
||||
content/page
|
||||
(fn
|
||||
(doc)
|
||||
(str
|
||||
"<!doctype html><html><head><meta charset=\"utf-8\"><title>"
|
||||
(ct-html-escape (content/page-title doc))
|
||||
"</title></head><body>"
|
||||
(asHTML doc)
|
||||
"</body></html>")))
|
||||
@@ -5,6 +5,7 @@
|
||||
"render": {"pass": 42, "fail": 0},
|
||||
"api": {"pass": 26, "fail": 0},
|
||||
"meta": {"pass": 27, "fail": 0},
|
||||
"page": {"pass": 7, "fail": 0},
|
||||
"markdown": {"pass": 20, "fail": 0},
|
||||
"text": {"pass": 20, "fail": 0},
|
||||
"section": {"pass": 25, "fail": 0},
|
||||
@@ -19,7 +20,7 @@
|
||||
"md-import": {"pass": 24, "fail": 0},
|
||||
"fed": {"pass": 20, "fail": 0}
|
||||
},
|
||||
"total_pass": 448,
|
||||
"total_pass": 455,
|
||||
"total_fail": 0,
|
||||
"total": 448
|
||||
"total": 455
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ _Generated by `lib/content/conformance.sh`_
|
||||
| render | 42 | 0 | 42 |
|
||||
| api | 26 | 0 | 26 |
|
||||
| meta | 27 | 0 | 27 |
|
||||
| page | 7 | 0 | 7 |
|
||||
| markdown | 20 | 0 | 20 |
|
||||
| text | 20 | 0 | 20 |
|
||||
| section | 25 | 0 | 25 |
|
||||
@@ -22,4 +23,4 @@ _Generated by `lib/content/conformance.sh`_
|
||||
| sync | 14 | 0 | 14 |
|
||||
| md-import | 24 | 0 | 24 |
|
||||
| fed | 20 | 0 | 20 |
|
||||
| **Total** | **448** | **0** | **448** |
|
||||
| **Total** | **455** | **0** | **455** |
|
||||
|
||||
42
lib/content/tests/page.sx
Normal file
42
lib/content/tests/page.sx
Normal file
@@ -0,0 +1,42 @@
|
||||
;; Extension — full HTML page wrapper.
|
||||
|
||||
(st-bootstrap-classes!)
|
||||
(content/bootstrap!)
|
||||
|
||||
(define
|
||||
d
|
||||
(doc-with-title
|
||||
(doc-append (doc-empty "post") (mk-heading "h" 1 "Hi"))
|
||||
"My Title"))
|
||||
|
||||
(content-test
|
||||
"page"
|
||||
(content/page d)
|
||||
"<!doctype html><html><head><meta charset=\"utf-8\"><title>My Title</title></head><body><h1>Hi</h1></body></html>")
|
||||
|
||||
(content-test
|
||||
"page title escaped"
|
||||
(content/page (doc-with-title (doc-empty "x") "A < B"))
|
||||
"<!doctype html><html><head><meta charset=\"utf-8\"><title>A < B</title></head><body></body></html>")
|
||||
|
||||
(content-test
|
||||
"page falls back to id"
|
||||
(content/page (doc-empty "fallback"))
|
||||
"<!doctype html><html><head><meta charset=\"utf-8\"><title>fallback</title></head><body></body></html>")
|
||||
|
||||
(content-test "page-title from meta" (content/page-title d) "My Title")
|
||||
(content-test
|
||||
"page-title fallback id"
|
||||
(content/page-title (doc-empty "z"))
|
||||
"z")
|
||||
|
||||
(content-test
|
||||
"page body reflects edits"
|
||||
(content/page (doc-update d "h" "text" "Bye"))
|
||||
"<!doctype html><html><head><meta charset=\"utf-8\"><title>My Title</title></head><body><h1>Bye</h1></body></html>")
|
||||
|
||||
(content-test
|
||||
"page multi-block body"
|
||||
(content/page
|
||||
(doc-append (doc-with-title (doc-empty "p") "T") (mk-text "x" "para")))
|
||||
"<!doctype html><html><head><meta charset=\"utf-8\"><title>T</title></head><body><p>para</p></body></html>")
|
||||
Reference in New Issue
Block a user