- docs/examples/writeonce-serve -> docs/examples/porch (git mv, history kept); `[deps]` key and import are now `porch` / `porch/http` / `porch/router` - name history preserved on the library README, not rewritten into dated records: writeonce-framework -> writeonce-serve (08-25) -> porch (08-26). Stories, specs, plans and the audit reports keep the older name by the repo's own convention; only live docs and every path link were rewritten - left alone deliberately: `internal/serve.wo`, `pub fn serve`, `serve_conn`, `app.serve(...)` — those are functions, not the module name - web-app/wo.toml comment corrected: it claimed hyphens are not identifier characters and named a key this file never used. lexer.ml's `is_ident_cont` DOES accept `-` (an internal dash is part of the identifier, which is why binary minus needs spaces), so a hyphenated key would be legal too - site now teaches the name: package card, the two-deps chapter and the handlers-are-classes chapter say `porch`; site-accept asserted the old /packages/serve route and caught the rename, as a gate should - gates: web-app 46/0, site 21/0, deps-accept 8/0, oop-e2e 116/0, linkcheck 0 broken / 0 anchors; porch typechecks entry-less as kind=library Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
49 lines
1.8 KiB
Text
49 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 (writeonce-view's `page()` does that), so the shell
|
|
-- fills writeonce-view'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 porch/http
|
|
use view
|
|
|
|
pub class AppShell {
|
|
title: Text
|
|
container: Text
|
|
content: Text
|
|
|
|
fn render() -> Text {
|
|
let l = Layout {
|
|
title: self.title,
|
|
head: head_links(),
|
|
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() };
|
|
}
|