@mccaskie-labs/workbench-site 0.0.0-stage → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,235 @@
1
+ // What Contact's enquiry form and the Enquiries admin list need besides their
2
+ // page files (docs/site-planner.md §5, §6): the form's answers file, the
3
+ // table, and the code their sections call. The builder writes each once,
4
+ // when the Enquiries page is added (Contact needs it, so no enquiry is taken
5
+ // before there is somewhere to read it); from then on they're the project's.
6
+ /** workbench/forms/enquiry.json: the form, as Claude would write it from the forms questions. `npm run forms` builds it. */
7
+ export const ENQUIRY_ANSWERS = {
8
+ format: 1,
9
+ status: "done",
10
+ form: "enquiry",
11
+ title: "Contact enquiry form",
12
+ fields: [
13
+ { name: "name", label: "Your name", kind: "text", required: true, max: 100, width: "l", limit_status: "proposed", reason: "Workbench default, not yet confirmed", column: "site_enquiries.name" },
14
+ { name: "email", label: "Your email", kind: "email", required: true, width: "l", limit_status: "proposed", reason: "Workbench default, not yet confirmed", column: "site_enquiries.email" },
15
+ { name: "phone", label: "Your phone (if you'd like a call)", kind: "phone" },
16
+ { name: "message", label: "Your message", kind: "long_text", required: true, max: 2000, limit_status: "proposed", reason: "Workbench default, not yet confirmed", column: "site_enquiries.message" },
17
+ ],
18
+ };
19
+ /**
20
+ * The table, as a Workbench tool's own migration (`<stamp>_workbench_site_enquiries`):
21
+ * a new table and its policies only, so Control applies it to staging with no
22
+ * approval. Anyone may add an enquiry (the Worker checks the form and
23
+ * Turnstile first); only the site's admins read or delete them, as
24
+ * themselves, so the project needs no secret key. An enquiry can't be dated
25
+ * by the sender: received_at is the database's own time.
26
+ */
27
+ export const ENQUIRY_MIGRATION = {
28
+ name: "workbench_site_enquiries",
29
+ up: `-- workbench-site: Contact's enquiries and the Enquiries admin list (docs/site-planner.md §5).
30
+ -- A new table and its policies only. Applied through Workbench Control: sb_migration_apply.
31
+
32
+ set lock_timeout = '5s';
33
+
34
+ create table public.site_enquiries (
35
+ id uuid primary key default gen_random_uuid(),
36
+ name varchar(100) not null,
37
+ email varchar(254) not null,
38
+ phone varchar(16),
39
+ message varchar(2000) not null,
40
+ received_at timestamptz not null default now()
41
+ );
42
+
43
+ create index site_enquiries_received on public.site_enquiries (received_at desc);
44
+
45
+ alter table public.site_enquiries enable row level security;
46
+
47
+ -- Anyone sends one, dated now: the sender can't set the time.
48
+ create policy "anyone sends an enquiry" on public.site_enquiries
49
+ for insert to anon, authenticated
50
+ with check (received_at between now() - interval '1 minute' and now() + interval '1 minute');
51
+
52
+ create policy "admins read enquiries" on public.site_enquiries
53
+ for select to authenticated using (exists (select 1 from public.app_admins a where a.user_id = (select auth.uid())));
54
+
55
+ create policy "admins delete enquiries" on public.site_enquiries
56
+ for delete to authenticated using (exists (select 1 from public.app_admins a where a.user_id = (select auth.uid())));
57
+
58
+ comment on table public.site_enquiries is 'Enquiries from the Contact page, read by the site''s admins at /admin/enquiries (workbench-site).';
59
+ `,
60
+ down: `drop table public.site_enquiries;
61
+ `,
62
+ };
63
+ /** src/pages/enquiry-store.ts: written once, then the project's. */
64
+ export const ENQUIRY_STORE = `// The site's enquiries: Contact's form and the Enquiries admin list. Written by
65
+ // @mccaskie-labs/workbench-site once; it's the project's to change.
66
+ //
67
+ // - The form is workbench/forms/enquiry.json (\`npm run forms\` builds it); its
68
+ // numbers are in the limits register and match site_enquiries' columns.
69
+ // - The table is site_enquiries (supabase/migrations/*_workbench_site_enquiries.sql).
70
+ // Anyone may add a row and only the site's admins read or delete them, as
71
+ // themselves (RLS), so the project needs no secret key.
72
+ // - The page checks the form and Turnstile before it stores an enquiry. The
73
+ // table also takes rows sent straight to the database with the publishable
74
+ // key, which skip both: each is capped in length, and admins delete what
75
+ // they don't want. To close that, add SUPABASE_SECRET_KEY (two-step), send
76
+ // with the service client, and drop the insert policy.
77
+
78
+ import { readForm, validate, type Result } from "@mccaskie-labs/workbench-forms";
79
+ import { FORMS_SCRIPT } from "@mccaskie-labs/workbench-forms/browser";
80
+ import { boundsFor } from "@mccaskie-labs/workbench-forms/limits";
81
+ import { formatDateTime } from "@mccaskie-labs/workbench-country";
82
+ import { enquiryList, formSection, type Enquiry } from "@mccaskie-labs/workbench-site";
83
+ import { sameOrigin } from "@mccaskie-labs/workbench-supabase";
84
+ import { escape, FORM_SCRIPT } from "@mccaskie-labs/workbench-ui";
85
+ import { appConfig } from "../config.ts";
86
+ import { FORMS, formContext } from "../forms/index.ts";
87
+ import { formHtml } from "../forms/page.ts";
88
+ import { READERS } from "../lib/country.ts";
89
+ import { dbAs } from "../lib/db.ts";
90
+ import { TURNSTILE_ACTION, TURNSTILE_ORIGIN, turnstileSetup, verifyTurnstile } from "../lib/turnstile.ts";
91
+ import { LIMITS } from "../limits.ts";
92
+ import type { PageContext, SitePage } from "./site.ts";
93
+
94
+ /** The form's state after a submit that didn't go through. */
95
+ export interface EnquiryState {
96
+ result?: Result;
97
+ input?: Record<string, unknown>;
98
+ /** It couldn't be sent: the check or the database is down. */
99
+ problem?: boolean;
100
+ }
101
+
102
+ const SENT = "sent";
103
+ /** At most this many shown, newest first. */
104
+ const SHOWN = 200;
105
+
106
+ function enquiryForm() {
107
+ const form = FORMS.find((f) => f.name === "enquiry");
108
+ if (!form) throw new Error("There's no enquiry form: run npm run forms (workbench/forms/enquiry.json)");
109
+ return form;
110
+ }
111
+
112
+ /** The table, as the Worker reaches it. Tests replace these. */
113
+ export const enquiryStore = {
114
+ /** Adds one enquiry as anyone (the publishable key). False when the database didn't take it. */
115
+ async send(env: object, values: { name: string; email: string; phone: string | null; message: string }): Promise<boolean> {
116
+ const c = appConfig(env);
117
+ try {
118
+ const res = await fetch(\`\${c.SUPABASE_URL}/rest/v1/site_enquiries\`, {
119
+ method: "POST",
120
+ headers: { apikey: c.SUPABASE_PUBLISHABLE_KEY, "content-type": "application/json", prefer: "return=minimal" },
121
+ body: JSON.stringify(values),
122
+ signal: AbortSignal.timeout(10_000),
123
+ });
124
+ if (!res.ok) console.warn(JSON.stringify({ event: "site_enquiry_failed", status: res.status }));
125
+ return res.ok;
126
+ } catch {
127
+ console.warn(JSON.stringify({ event: "site_enquiry_failed", status: 0 }));
128
+ return false;
129
+ }
130
+ },
131
+ /** The newest enquiries, as the signed-in admin. Null when they can't be read. */
132
+ async list(env: object, accessToken: string): Promise<{ id: string; name: string; email: string; phone: string | null; message: string; received_at: string }[] | null> {
133
+ const { data, error } = await dbAs(env, accessToken).from("site_enquiries").select("id, name, email, phone, message, received_at").order("received_at", { ascending: false }).limit(SHOWN);
134
+ if (error) {
135
+ console.warn(JSON.stringify({ event: "site_enquiries_read_failed" }));
136
+ return null;
137
+ }
138
+ return data;
139
+ },
140
+ /** Deletes one, as the signed-in admin. */
141
+ async remove(env: object, accessToken: string, id: string): Promise<boolean> {
142
+ const { error } = await dbAs(env, accessToken).from("site_enquiries").delete().eq("id", id);
143
+ return !error;
144
+ },
145
+ };
146
+
147
+ export interface EnquiryWords {
148
+ heading: string;
149
+ intro?: string;
150
+ /** The submit button's key: renderForm looks it up. */
151
+ send: string;
152
+ /** The thank-you. */
153
+ sent: string;
154
+ /** When the check or the database is down. */
155
+ unavailable: string;
156
+ }
157
+
158
+ /** Contact's enquiry form, or its thank-you once sent. */
159
+ export function enquirySection(request: Request, env: object, ctx: PageContext, w: EnquiryWords): string {
160
+ if (new URL(request.url).searchParams.get(SENT) === "1") return formSection({ id: "enquiry", heading: w.heading, done: w.sent });
161
+ const state = (ctx.form ?? {}) as EnquiryState;
162
+ const path = new URL(request.url).pathname;
163
+ let html = formHtml(enquiryForm(), request, env, { action: \`\${path}#enquiry\`, submit: w.send, ...(state.result ? { result: state.result } : {}), ...(state.input ? { input: state.input } : {}) });
164
+ const bot = turnstileSetup(env);
165
+ if (bot.state === "on") {
166
+ // Inside the form, so its token is sent with it; shown only when Cloudflare needs the person to click.
167
+ const widget = \`<div class="cf-turnstile" data-sitekey="\${escape(bot.siteKey)}" data-action="\${TURNSTILE_ACTION}" data-appearance="interaction-only" data-theme="auto"></div>\`;
168
+ const at = html.lastIndexOf("</form>");
169
+ if (at !== -1) html = html.slice(0, at) + widget + html.slice(at);
170
+ html += \`<script src="\${TURNSTILE_ORIGIN}/turnstile/v0/api.js" async defer></script>\`;
171
+ }
172
+ html += \`<script>\${FORMS_SCRIPT}</script><script>\${FORM_SCRIPT}</script>\`;
173
+ return formSection({ id: "enquiry", heading: w.heading, ...(w.intro ? { intro: w.intro } : {}), form: html, ...(state.problem ? { problem: w.unavailable } : {}) });
174
+ }
175
+
176
+ /** Contact's POST: checks the form and Turnstile, stores it, and sends the person back to the thank-you. */
177
+ export async function takeEnquiry(request: Request, env: Env, ctx: PageContext, page: SitePage): Promise<Response> {
178
+ if (!sameOrigin(request)) return new Response("Forbidden\\n", { status: 403 });
179
+ const again = async (status: number, form: EnquiryState) => {
180
+ const res = await page.render(request, env, { ...ctx, form });
181
+ return new Response(res.body, { status, headers: res.headers });
182
+ };
183
+ let data: FormData;
184
+ try {
185
+ data = await request.formData();
186
+ } catch {
187
+ return again(400, {});
188
+ }
189
+ const form = enquiryForm();
190
+ const input = readForm(form, data);
191
+ const result = validate(form, input, { ...formContext(), bounds: boundsFor(LIMITS, form) });
192
+ if (!result.ok) return again(422, { result, input });
193
+ const bot = turnstileSetup(env);
194
+ if (bot.state === "missing") return again(503, { input, problem: true });
195
+ if (bot.state === "on" && !(await verifyTurnstile(bot.secret, data.get("cf-turnstile-response"), request, bot.strict)).ok) return again(400, { input, problem: true });
196
+ const v = result.values as Record<string, unknown>;
197
+ const sent = await enquiryStore.send(env, { name: String(v.name), email: String(v.email), phone: typeof v.phone === "string" ? v.phone : null, message: String(v.message) });
198
+ if (!sent) return again(503, { input, problem: true });
199
+ const back = new URL(request.url);
200
+ back.search = \`?\${SENT}=1\`;
201
+ back.hash = "enquiry";
202
+ return new Response(null, { status: 303, headers: { location: \`\${back.pathname}\${back.search}\${back.hash}\` } });
203
+ }
204
+
205
+ /** The enquiries for the admin list, in the readers' time zone. Null when they can't be read. */
206
+ export async function listEnquiries(env: object, ctx: PageContext): Promise<Enquiry[] | null> {
207
+ if (!ctx.accessToken) return null;
208
+ const rows = await enquiryStore.list(env, ctx.accessToken);
209
+ return rows && rows.map((r) => ({ id: r.id, name: r.name, email: r.email, phone: r.phone, message: r.message, received: formatDateTime(r.received_at, { pack: READERS }) }));
210
+ }
211
+
212
+ export interface EnquiryListWords {
213
+ heading?: string;
214
+ empty: string;
215
+ unavailable: string;
216
+ remove: string;
217
+ }
218
+
219
+ /** The Enquiries admin list. */
220
+ export function enquiriesSection(request: Request, enquiries: Enquiry[] | null, w: EnquiryListWords): string {
221
+ return enquiryList({ ...w, enquiries, removeAction: new URL(request.url).pathname });
222
+ }
223
+
224
+ /** The Enquiries page's POST: deletes one, as the admin, and shows the list again. */
225
+ export async function removeEnquiry(request: Request, env: object, ctx: PageContext): Promise<Response> {
226
+ let id: unknown = null;
227
+ try {
228
+ id = (await request.formData()).get("remove");
229
+ } catch {
230
+ // Nothing to delete: shown the list again.
231
+ }
232
+ if (ctx.accessToken && typeof id === "string" && /^[0-9a-f-]{36}$/.test(id)) await enquiryStore.remove(env, ctx.accessToken, id);
233
+ return new Response(null, { status: 303, headers: { location: new URL(request.url).pathname } });
234
+ }
235
+ `;
@@ -0,0 +1,3 @@
1
+ import type { Recipe } from "../recipe.ts";
2
+ /** The "Every site" group, in the order they're offered. */
3
+ export declare const EVERY_SITE: readonly Recipe[];
@@ -0,0 +1,293 @@
1
+ // The "Every site" recipes (docs/site-planner.md §5): the pages most sites
2
+ // have (docs/default-pages.md §3). Privacy and Terms join them with their
3
+ // written clauses per country (default pages step 3). Contact's enquiry form needs the Enquiries admin
4
+ // list, so no enquiry is taken before there is somewhere to read it. Words in [square brackets] are the owner's to fill in: Workbench
5
+ // never makes up a price, an address, an opening hour or a person.
6
+ const home = {
7
+ id: "home",
8
+ version: 1,
9
+ title: "Home",
10
+ does: "The first page people see: what you do, who for, and how to get in touch.",
11
+ group: "every-site",
12
+ tier: "always",
13
+ area: "public",
14
+ path: "/",
15
+ frames: ["landing", "column"],
16
+ tools: [],
17
+ needs: [],
18
+ menu: { label: "page.home.menu", header: 0 },
19
+ pageTitle: "page.home.title",
20
+ sections: [
21
+ { kind: "hero", heading: "page.home.hero.heading", lead: "page.home.hero.lead", action: { label: "page.home.hero.action", to: "contact" } },
22
+ {
23
+ kind: "list",
24
+ heading: "page.home.points.heading",
25
+ items: [
26
+ { title: "page.home.points.first.title", body: "page.home.points.first.body" },
27
+ { title: "page.home.points.second.title", body: "page.home.points.second.body" },
28
+ { title: "page.home.points.third.title", body: "page.home.points.third.body" },
29
+ ],
30
+ },
31
+ { kind: "text", heading: "page.home.intro.heading", body: "page.home.intro.body" },
32
+ { kind: "call", heading: "page.home.call.heading", body: "page.home.call.body", action: { label: "page.home.call.action", to: "contact" } },
33
+ ],
34
+ words: {
35
+ "page.home.menu": "Home",
36
+ "page.home.title": "Home",
37
+ "page.home.hero.heading": "[What you do, in a few words]",
38
+ "page.home.hero.lead": "[One or two sentences on who you help and how.]",
39
+ "page.home.hero.action": "Get in touch",
40
+ "page.home.points.heading": "Why people choose us",
41
+ "page.home.points.first.title": "[First reason]",
42
+ "page.home.points.first.body": "[A sentence about it.]",
43
+ "page.home.points.second.title": "[Second reason]",
44
+ "page.home.points.second.body": "[A sentence about it.]",
45
+ "page.home.points.third.title": "[Third reason]",
46
+ "page.home.points.third.body": "[A sentence about it.]",
47
+ "page.home.intro.heading": "[A short heading about your business]",
48
+ "page.home.intro.body": "[A paragraph or two about your business: what you offer, where, and what makes it yours.]",
49
+ "page.home.call.heading": "Ready to talk?",
50
+ "page.home.call.body": "Send us a message and we'll get back to you.",
51
+ "page.home.call.action": "Contact us",
52
+ },
53
+ suggest: { types: [], signals: ["every site"] },
54
+ };
55
+ const about = {
56
+ id: "about",
57
+ version: 1,
58
+ title: "About",
59
+ does: "Your story: who you are, why you started and what you care about.",
60
+ group: "every-site",
61
+ tier: "ticked",
62
+ area: "public",
63
+ path: "/about",
64
+ frames: ["column", "landing"],
65
+ tools: [],
66
+ needs: [],
67
+ menu: { label: "page.about.menu", header: 10 },
68
+ pageTitle: "page.about.title",
69
+ sections: [
70
+ { kind: "hero", heading: "page.about.hero.heading", lead: "page.about.hero.lead" },
71
+ { kind: "text", heading: "page.about.story.heading", body: "page.about.story.body" },
72
+ { kind: "text", heading: "page.about.values.heading", body: "page.about.values.body" },
73
+ { kind: "call", heading: "page.about.call.heading", action: { label: "page.about.call.action", to: "contact" } },
74
+ ],
75
+ words: {
76
+ "page.about.menu": "About",
77
+ "page.about.title": "About us",
78
+ "page.about.hero.heading": "About us",
79
+ "page.about.hero.lead": "[A sentence on who you are.]",
80
+ "page.about.story.heading": "Our story",
81
+ "page.about.story.body": "[How the business started, and why.]\n\n[Where it is now, and who is part of it.]",
82
+ "page.about.values.heading": "What we care about",
83
+ "page.about.values.body": "[What matters to you in how you work.]",
84
+ "page.about.call.heading": "Want to know more?",
85
+ "page.about.call.action": "Get in touch",
86
+ },
87
+ suggest: { types: [], signals: ["every site"] },
88
+ };
89
+ const contact = {
90
+ id: "contact",
91
+ version: 2,
92
+ title: "Contact",
93
+ does: "How to reach you: email, phone, where you are and when you're open, and a form to send you a message.",
94
+ group: "every-site",
95
+ tier: "always",
96
+ area: "public",
97
+ path: "/contact",
98
+ frames: ["two-columns", "column"],
99
+ tools: [],
100
+ needs: ["enquiries"],
101
+ menu: { label: "page.contact.menu", header: 90, footer: 10 },
102
+ pageTitle: "page.contact.title",
103
+ sections: [
104
+ { kind: "hero", heading: "page.contact.hero.heading", lead: "page.contact.hero.lead" },
105
+ {
106
+ kind: "details",
107
+ heading: "page.contact.reach.heading",
108
+ rows: [
109
+ { label: "page.contact.reach.email.label", value: "page.contact.reach.email.value" },
110
+ { label: "page.contact.reach.phone.label", value: "page.contact.reach.phone.value" },
111
+ ],
112
+ },
113
+ {
114
+ kind: "details",
115
+ heading: "page.contact.visit.heading",
116
+ rows: [
117
+ { label: "page.contact.visit.address.label", value: "page.contact.visit.address.value" },
118
+ { label: "page.contact.visit.hours.label", value: "page.contact.visit.hours.value" },
119
+ ],
120
+ },
121
+ { kind: "enquiry-form", heading: "page.contact.form.heading", intro: "page.contact.form.intro", send: "page.contact.form.send", sent: "page.contact.form.sent", unavailable: "page.contact.form.unavailable" },
122
+ ],
123
+ words: {
124
+ "page.contact.menu": "Contact",
125
+ "page.contact.title": "Contact us",
126
+ "page.contact.hero.heading": "Contact us",
127
+ "page.contact.hero.lead": "We'd love to hear from you.",
128
+ "page.contact.reach.heading": "Get in touch",
129
+ "page.contact.reach.email.label": "Email",
130
+ "page.contact.reach.email.value": "[Your email address]",
131
+ "page.contact.reach.phone.label": "Phone",
132
+ "page.contact.reach.phone.value": "[Your phone number]",
133
+ "page.contact.visit.heading": "Find us",
134
+ "page.contact.visit.address.label": "Address",
135
+ "page.contact.visit.address.value": "[Your address, or the area you cover]",
136
+ "page.contact.visit.hours.label": "Opening hours",
137
+ "page.contact.visit.hours.value": "[Your opening hours]",
138
+ "page.contact.form.heading": "Send us a message",
139
+ "page.contact.form.intro": "We'll reply by email, usually within a business day.",
140
+ "page.contact.form.send": "Send message",
141
+ "page.contact.form.sent": "Thanks, your message is on its way. We'll be in touch soon.",
142
+ "page.contact.form.unavailable": "Your message couldn't be sent just now. Please try again in a minute, or email us instead.",
143
+ },
144
+ suggest: { types: [], signals: ["every site"] },
145
+ };
146
+ const faq = {
147
+ id: "faq",
148
+ version: 1,
149
+ title: "Questions and answers",
150
+ does: "The questions people ask you most, each with your answer, so they needn't message you to find out.",
151
+ group: "every-site",
152
+ tier: "ticked",
153
+ area: "public",
154
+ path: "/faq",
155
+ frames: ["column"],
156
+ tools: [],
157
+ needs: [],
158
+ menu: { label: "page.faq.menu", footer: 20 },
159
+ pageTitle: "page.faq.title",
160
+ sections: [
161
+ { kind: "hero", heading: "page.faq.hero.heading", lead: "page.faq.hero.lead" },
162
+ {
163
+ kind: "list",
164
+ items: [
165
+ { title: "page.faq.offer.question", body: "page.faq.offer.answer" },
166
+ { title: "page.faq.where.question", body: "page.faq.where.answer" },
167
+ { title: "page.faq.cost.question", body: "page.faq.cost.answer" },
168
+ { title: "page.faq.start.question", body: "page.faq.start.answer" },
169
+ { title: "page.faq.contact.question", body: "page.faq.contact.answer" },
170
+ ],
171
+ },
172
+ { kind: "call", heading: "page.faq.call.heading", body: "page.faq.call.body", action: { label: "page.faq.call.action", to: "contact" } },
173
+ ],
174
+ words: {
175
+ "page.faq.menu": "Questions and answers",
176
+ "page.faq.title": "Questions and answers",
177
+ "page.faq.hero.heading": "Questions and answers",
178
+ "page.faq.hero.lead": "The things people ask us most.",
179
+ "page.faq.offer.question": "What do you offer?",
180
+ "page.faq.offer.answer": "[A sentence or two on what you offer, and who it's for.]",
181
+ "page.faq.where.question": "Where are you, and when are you open?",
182
+ "page.faq.where.answer": "[Where to find you, or the area you cover, and your opening hours.]",
183
+ "page.faq.cost.question": "How much does it cost?",
184
+ "page.faq.cost.answer": "[Your prices, or how you work out a price.]",
185
+ "page.faq.start.question": "How do I get started?",
186
+ "page.faq.start.answer": "[How people book, order or start with you.]",
187
+ "page.faq.contact.question": "How do I get in touch?",
188
+ "page.faq.contact.answer": "Send us a message from the Contact page and we'll reply by email.",
189
+ "page.faq.call.heading": "Still have a question?",
190
+ "page.faq.call.body": "Ask us, and we'll get back to you.",
191
+ "page.faq.call.action": "Ask a question",
192
+ },
193
+ suggest: { types: [], signals: ["every site", "people ask the same questions"] },
194
+ };
195
+ const accessibility = {
196
+ id: "accessibility",
197
+ version: 1,
198
+ title: "Accessibility",
199
+ does: "What you do so everyone can use your site, anything that doesn't work well yet, and how to tell you when something is hard to use.",
200
+ group: "every-site",
201
+ tier: "offered",
202
+ area: "public",
203
+ path: "/accessibility",
204
+ frames: ["column"],
205
+ tools: [],
206
+ needs: [],
207
+ menu: { label: "page.accessibility.menu", footer: 40 },
208
+ pageTitle: "page.accessibility.title",
209
+ sections: [
210
+ { kind: "hero", heading: "page.accessibility.hero.heading", lead: "page.accessibility.hero.lead" },
211
+ { kind: "text", heading: "page.accessibility.aim.heading", body: "page.accessibility.aim.body" },
212
+ {
213
+ kind: "list",
214
+ heading: "page.accessibility.done.heading",
215
+ items: [
216
+ { title: "page.accessibility.done.read.title", body: "page.accessibility.done.read.body" },
217
+ { title: "page.accessibility.done.keys.title", body: "page.accessibility.done.keys.body" },
218
+ { title: "page.accessibility.done.forms.title", body: "page.accessibility.done.forms.body" },
219
+ ],
220
+ },
221
+ { kind: "text", heading: "page.accessibility.known.heading", body: "page.accessibility.known.body" },
222
+ { kind: "call", heading: "page.accessibility.call.heading", body: "page.accessibility.call.body", action: { label: "page.accessibility.call.action", to: "contact" } },
223
+ ],
224
+ words: {
225
+ "page.accessibility.menu": "Accessibility",
226
+ "page.accessibility.title": "Accessibility",
227
+ "page.accessibility.hero.heading": "Accessibility",
228
+ "page.accessibility.hero.lead": "We want everyone to be able to use this site.",
229
+ "page.accessibility.aim.heading": "What we aim for",
230
+ "page.accessibility.aim.body": "We aim to meet the Web Content Accessibility Guidelines (WCAG) 2.2 at level AA.",
231
+ "page.accessibility.done.heading": "What we've done",
232
+ "page.accessibility.done.read.title": "Easy to read",
233
+ "page.accessibility.done.read.body": "Text and buttons have strong contrast in light and dark, and the pages still work when you make the text bigger.",
234
+ "page.accessibility.done.keys.title": "No mouse needed",
235
+ "page.accessibility.done.keys.body": "Every link, button and form works with a keyboard, and with screen readers.",
236
+ "page.accessibility.done.forms.title": "Clear forms",
237
+ "page.accessibility.done.forms.body": "Every field has a label, and a problem with an answer is said in words, not only in colour.",
238
+ "page.accessibility.known.heading": "What doesn't work well yet",
239
+ "page.accessibility.known.body": "[Anything on the site that is hard to use, such as a video without captions or a PDF, and when you'll fix it. If you know of nothing, say so.]",
240
+ "page.accessibility.call.heading": "Something hard to use?",
241
+ "page.accessibility.call.body": "Tell us what you were trying to do, and we'll help you and fix it.",
242
+ "page.accessibility.call.action": "Tell us",
243
+ },
244
+ suggest: { types: [], signals: ["every site", "government or community funding", "older or disabled customers"] },
245
+ };
246
+ const notFound = {
247
+ id: "not-found",
248
+ version: 1,
249
+ title: "Not found",
250
+ does: "What people see when an address on your site doesn't exist, with a way back.",
251
+ group: "every-site",
252
+ tier: "always",
253
+ area: "public",
254
+ path: null,
255
+ status: 404,
256
+ frames: ["column"],
257
+ tools: [],
258
+ needs: [],
259
+ pageTitle: "page.not_found.title",
260
+ sections: [{ kind: "hero", heading: "page.not_found.hero.heading", lead: "page.not_found.hero.lead", action: { label: "page.not_found.hero.action", to: "/" } }],
261
+ words: {
262
+ "page.not_found.title": "Page not found",
263
+ "page.not_found.hero.heading": "We can't find that page",
264
+ "page.not_found.hero.lead": "The address may be mistyped, or the page may have moved.",
265
+ "page.not_found.hero.action": "Go to the home page",
266
+ },
267
+ suggest: { types: [], signals: ["every site"] },
268
+ };
269
+ const error = {
270
+ id: "error",
271
+ version: 1,
272
+ title: "Something went wrong",
273
+ does: "What people see, in your site's look, when a page breaks, instead of a blank error.",
274
+ group: "every-site",
275
+ tier: "always",
276
+ area: "public",
277
+ path: null,
278
+ status: 500,
279
+ frames: ["column"],
280
+ tools: [],
281
+ needs: [],
282
+ pageTitle: "page.error.title",
283
+ sections: [{ kind: "hero", heading: "page.error.hero.heading", lead: "page.error.hero.lead", action: { label: "page.error.hero.action", to: "/" } }],
284
+ words: {
285
+ "page.error.title": "Something went wrong",
286
+ "page.error.hero.heading": "Something went wrong",
287
+ "page.error.hero.lead": "That's our fault, not yours. Please try again in a minute.",
288
+ "page.error.hero.action": "Go to the home page",
289
+ },
290
+ suggest: { types: [], signals: ["every site"] },
291
+ };
292
+ /** The "Every site" group, in the order they're offered. */
293
+ export const EVERY_SITE = [home, about, contact, faq, accessibility, notFound, error];
@@ -0,0 +1,2 @@
1
+ import type { Recipe } from "../recipe.ts";
2
+ export declare const RECIPES: readonly Recipe[];
@@ -0,0 +1,7 @@
1
+ // The recipe catalogue: every page Workbench knows how to build
2
+ // (docs/site-planner.md §5). The business recipes join it in later steps; each tool's own pages will live in that tool's package and
3
+ // be gathered here.
4
+ import { ADMIN } from "./admin.js";
5
+ import { EVERY_SITE } from "./every-site.js";
6
+ import { MEMBERS } from "./members.js";
7
+ export const RECIPES = [...EVERY_SITE, ...MEMBERS, ...ADMIN];
@@ -0,0 +1,3 @@
1
+ import type { Recipe } from "../recipe.ts";
2
+ /** The "Members" group, in the order they're offered. */
3
+ export declare const MEMBERS: readonly Recipe[];
@@ -0,0 +1,38 @@
1
+ // The "Members" recipes (docs/site-planner.md §5): pages for the app's own
2
+ // signed-in users. Sign in itself is the template's (/sign-in). Your
3
+ // bookings and Your orders come with their tools' recipes (step 6).
4
+ const account = {
5
+ id: "account",
6
+ version: 1,
7
+ title: "Your account",
8
+ does: "Where a signed-in customer sees who they're signed in as and signs out.",
9
+ group: "members",
10
+ tier: "always",
11
+ area: "members",
12
+ path: "/account",
13
+ frames: ["column"],
14
+ tools: ["sign-in"],
15
+ needs: [],
16
+ menu: { label: "page.account.menu", header: 95 },
17
+ pageTitle: "page.account.title",
18
+ sections: [
19
+ { kind: "hero", heading: "page.account.hero.heading", lead: "page.account.hero.lead" },
20
+ { kind: "account", heading: "page.account.you.heading", signedIn: "page.account.you.signed_in", signOut: "page.account.you.sign_out" },
21
+ { kind: "call", heading: "page.account.call.heading", body: "page.account.call.body", action: { label: "page.account.call.action", to: "contact" } },
22
+ ],
23
+ words: {
24
+ "page.account.menu": "Your account",
25
+ "page.account.title": "Your account",
26
+ "page.account.hero.heading": "Your account",
27
+ "page.account.hero.lead": "Your details, in one place.",
28
+ "page.account.you.heading": "You",
29
+ "page.account.you.signed_in": "Signed in as {email}.",
30
+ "page.account.you.sign_out": "Sign out",
31
+ "page.account.call.heading": "Need a hand?",
32
+ "page.account.call.body": "Get in touch and we'll sort it out.",
33
+ "page.account.call.action": "Contact us",
34
+ },
35
+ suggest: { types: [], signals: ["customers sign in", "members", "bookings", "orders"] },
36
+ };
37
+ /** The "Members" group, in the order they're offered. */
38
+ export const MEMBERS = [account];
@@ -0,0 +1,18 @@
1
+ /** One sample: a part of the tool, or one of its layouts. */
2
+ interface ToolSample {
3
+ id: string;
4
+ title: string;
5
+ layout?: string;
6
+ html: () => string;
7
+ }
8
+ /** Every sample of one tool (workbench-ui's ToolSamples). */
9
+ export interface ToolSamples {
10
+ format: 1;
11
+ package: string;
12
+ title: string;
13
+ prefix: string;
14
+ samples: readonly ToolSample[];
15
+ }
16
+ /** Every sample of the site tool. */
17
+ export declare const SITE_SAMPLES: ToolSamples;
18
+ export {};