writeonce/docs/examples/site/layout/app.wo
shoney.arickathil 47a920f19a feat(serve+view): file serving, downloads, supported systems; rename
- rename the two libraries: writeonce-framework -> writeonce-serve
  (`use serve`), wo-html -> writeonce-view (`use view`). Names say the
  ROLE now; every sample, script, gate and live doc follows
- stories/specs/plans keep the old names: they are dated records, and
  both library READMEs carry a "renamed 2026-08-25" note
- serve/http/files.wo: StaticFiles { dir, max_bytes } — traversal
  refused not normalised, extension content types, attachment
  disposition for archives. Lifted out of the shop, which had said in
  a comment that it belonged in the framework
- shop drops its private copy and mounts the framework's
- site: /dl/*path over $WO_DIST (default ./dist), 16 MiB ceiling
- /install gains supported systems — Linux x86-64, glibc >= 2.38,
  not musl — read off `file` and the binaries' GLIBC_ symbol
  versions, not off a wish list; plus GitHub release as primary,
  /dl as mirror, and the sha256 verify step
- site-accept: 17 -> 21 checks (supported systems, gzip download with
  a binary-safe probe, checksum, /dl traversal 404)

Verified on 192.168.0.165: the real 960,820-byte tarball downloads
as application/gzip and its sha256 matches the published digest.

Gates: oop-accept MET, site 21/0, web-app 46/0, fibers 10/0,
db-actor 8/0; shop rebuilt and its /assets served by the framework.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-25 04:41:00 +02:00

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 serve/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() };
}