writeonce/docs/examples/shop/orders/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

54 lines
1.2 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- orders/view.wo — the confirmation page and the orders table.
-- Raw text literals for the bodies; see product_list/view.wo for the
-- convention.
use view
pub class OrderOk {
name: Text
qty: Int
total: Float
fn render() -> Text {
return `
<div class="card">
<h1>Order placed</h1>
<p>${self.qty} × {{ self.name }} — total € ${self.total}</p>
<p><a href="/orders">See all orders</a> · <a href="/">Keep shopping</a></p>
</div>`;
}
}
pub class OrderRow {
name: Text
qty: Int
total: Float
status: Text
fn render() -> Text {
return `
<tr>
<td>{{ self.name }}</td>
<td>${self.qty}</td>
<td>€ ${self.total}</td>
<td>{{ self.status }}</td>
</tr>`;
}
}
pub class OrdersPage {
rows: multi Component
fn render() -> Text {
if len(self.rows) == 0 {
return `
<h1>Orders</h1>
<p>No orders yet — <a href="/">go buy something</a>.</p>`;
}
return `
<h1>Orders</h1>
<table class="orders">
<tr><th>Product</th><th>Qty</th><th>Total</th><th>Status</th></tr>
${render_all(self.rows)}
</table>`;
}
}