writeonce/docs/examples/site/packages/view.wo
shoney.arickathil ef37b8ffa2 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

61 lines
2.1 KiB
Text

-- packages/view.wo — the VIEW for /packages and /packages/:name.
--
-- Three components: a card for the index, the index itself (holding its
-- cards as CHILDREN through the structural interface), and the detail
-- page. None of them knows where the catalogue came from.
use view
pub class PackageCard {
name: Text
summary: Text
fn render() -> Text {
return `
<div class="bg-white rounded-lg border shadow-sm p-6">
<h3 class="text-lg font-bold mb-2"><a href="/packages/{{ self.name }}">{{ self.name }}</a></h3>
<p class="leading-relaxed text-gray-700">{{ self.summary }}</p>
</div>`;
}
}
pub class PackagesPage {
cards: multi Component
fn render() -> Text {
return `
<h1 class="text-3xl font-bold mb-4">Packages</h1>
<p class="leading-relaxed mb-6">A package is a git repository with a
<code>wo.toml</code> that says <code>kind = "library"</code>. There is no
registry and no publish step: you depend on a URL and a revision, and
<code>wo.lock</code> pins exactly what you built against. These are the
libraries this site itself is built on.</p>
<div class="grid grid-cols-2 gap-6 mb-8">${render_all(self.cards)}</div>`;
}
}
pub class PackagePage {
name: Text
summary: Text
git: Text
rev: Text
what: Text
usage: Text
fn render() -> Text {
let dep = code_block("[deps]\n" .. self.name .. " = { git = \"" .. self.git .. "\", rev = \"" .. self.rev .. "\" }");
let head = `
<h1 class="text-3xl font-bold mb-2">{{ self.name }}</h1>
<p class="leading-relaxed text-gray-700 mb-6">{{ self.summary }}</p>
<h2 class="text-2xl font-bold mb-2">Install</h2>
<p class="leading-relaxed mb-4">Add it to your <code>wo.toml</code>. The
KEY is the module name — that is what <code>use</code> imports.</p>`;
let what = `
<h2 class="text-2xl font-bold mb-2 mt-8">What you get</h2>
${self.what}`;
let usage = `
<h2 class="text-2xl font-bold mb-2 mt-8">Usage</h2>
${self.usage}`;
let back = el("p", "mt-8", link("/packages", "", "← all packages"));
return head .. dep .. what .. usage .. back;
}
}