- lexer: backtick raw text literal — content verbatim, no escape
processing, common source margin removed at lex time; `${ }` raw and
`{{ }}` auto-escaping holes
- `{{ e }}` desugars to `esc(${e})` in parser.ml — a Call on the `esc`
in scope, so types/owner/emit/.wob/VM are untouched
- WO-E004 unterminated raw literal; WO-E005 newline inside "..." —
closes a hole where a missing quote silently ate the rest of the file
- wo-html: `Component` interface, `render_all`, `Layout`, README
- framework: `ok_html` joins ok_text/ok_json in http/types.wo
- site + shop restructured to one-feature-one-module MVC (view +
controller per directory, model at the root, bootstrap-only main)
- removed the filler `pad: Int` convention — verified unnecessary for
plain classes, interface dispatch, containers and actors
- corrected recorded claims: gap #1 blocks neither the build nor the
layout; a class crosses module lines, only a free fn is scoped
- docs/guides/language-surface.md — the full grammar inventory
- story 37 landed and moved to done/
Gates: oop-accept MET, oop-e2e 116/0, woc-test 556/0, site 11/0,
web-app 46/0, fibers 10/0, db-actor 8/0
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
48 lines
1.8 KiB
Text
48 lines
1.8 KiB
Text
-- layout/app.wo — the app shell: one component wrapping every page with
|
|
-- the shared header and footer. Unlike the shop template, this site
|
|
-- INLINES its stylesheet (wo-html's `page()` does that), so the shell
|
|
-- fills wo-html's own `Layout` rather than writing its own document.
|
|
--
|
|
-- The only thing that varies between pages is the container width, so
|
|
-- that is the one extra slot — and the two widths are named once, here,
|
|
-- instead of as class strings scattered through the controllers.
|
|
use framework/http
|
|
use html
|
|
|
|
pub class AppShell {
|
|
title: Text
|
|
container: Text
|
|
content: Text
|
|
|
|
fn render() -> Text {
|
|
let l = Layout {
|
|
title: self.title,
|
|
nav: header(),
|
|
content: el("div", self.container, self.content),
|
|
footer: footer()
|
|
};
|
|
return l.render();
|
|
}
|
|
}
|
|
|
|
-- Chapter pages keep a reading width.
|
|
pub fn reading_shell(title: Text, content: Text) -> AppShell {
|
|
return AppShell { title: title, container: "mx-auto max-w-3xl px-4 py-8", content: content };
|
|
}
|
|
|
|
-- The homepage uses the wider container (the go.dev shape).
|
|
pub fn wide_shell(title: Text, content: Text) -> AppShell {
|
|
return AppShell { title: title, container: "mx-auto max-w-5xl px-4", content: content };
|
|
}
|
|
|
|
-- Every non-200 HTML answer goes through here, so an error page is a
|
|
-- real page: same chrome, same shell, just a different status.
|
|
pub fn html_error(status: Int, title: Text, msg: Text) -> Resp {
|
|
let content = el("h1", "text-2xl font-bold mb-4", title) ..
|
|
el("p", "", msg) ..
|
|
el("p", "", link("/", "", "Back to the chapters"));
|
|
let shell = reading_shell("writeonce — ${title}", content);
|
|
let h: map<Text, Text> = {};
|
|
h["content-type"] = "text/html; charset=utf-8";
|
|
return Resp { status: status, headers: h, body: shell.render() };
|
|
}
|