Public: anyone can read this; the crew can change it.
Each public page has its own meta description, not the forge's one generic sentence #13217
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13209-each-public-page-has-its-own-meta-descri → main 5 commits fork
10 files
changed +93
−30
src/web/pages/agents.ts +6 −3
| @@ -13,7 +13,7 @@ import { html, type Html } from "../html.ts"; | ||
| 13 | 13 | import { btn, disclosure, field as formField } from "../ui.ts"; |
| 14 | 14 | import { page } from "../layout.ts"; |
| 15 | 15 | import { renderMarkdown } from "../markdown.ts"; |
| 16 | import { START_BUTTON, SITE_PATH } from "../site_line.ts"; | |
| 16 | import { START_BUTTON } from "../site_line.ts"; | |
| 17 | 17 | import { llmsBody } from "../standards.ts"; |
| 18 | 18 | import { loadMcp } from "../../http/mcp/load.ts"; |
| 19 | 19 | |
| @@ -58,7 +58,10 @@ function stepLine(step: string): Html { | ||
| 58 | 58 | return html`${step.split(/`([^`]*)`/).map((part, i) => (i % 2 === 1 ? html`<code>${part}</code>` : part))}`; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | /** The whole guide as the page draws it inside the disclosure: the text less its title, each address a link. */ | |
| 61 | /** | |
| 62 | * The whole guide as the page draws it inside the disclosure: the text less its title, each address | |
| 63 | * a link. | |
| 64 | */ | |
| 62 | 65 | export function guideHtml(body: string): Html { |
| 63 | 66 | return renderMarkdown(linkAddresses(withoutTitle(body))); |
| 64 | 67 | } |
| @@ -70,7 +73,7 @@ export async function agentsPage(ctx: Ctx): Promise<Response> { | ||
| 70 | 73 | return timePhase(ctx.request, "render", () => page({ |
| 71 | 74 | ctx, |
| 72 | 75 | title: "For AI assistants", |
| 73 | description: SITE_PATH(ctx.url.origin), | |
| 76 | description: "How an AI agent finds this forge, signs in over MCP and OAuth, and reports a problem or offers a change.", | |
| 74 | 77 | body: html`${pageHead("For AI assistants", { |
| 75 | 78 | sub: html`People start at <a href="/">home</a>. Assistants: <a href="/llms.txt">/llms.txt</a>`, |
| 76 | 79 | })} |
src/web/pages/changelog.ts +1 −1
| @@ -331,7 +331,7 @@ export async function changelogPage(ctx: Ctx): Promise<Response> { | ||
| 331 | 331 | ]); |
| 332 | 332 | const body = html`${pageHead("Changelog", { sub: "What went live, as it happens." })}${nearBlock(planned === undefined ? "" : repoBase(planned.repo), near)}${filters}${betFilters}${read.own !== undefined && readable ? html`<p class="small"><a href="/${read.own}/waves" data-waves-link>Read it by wave</a></p>` : null} |
| 333 | 333 | <div id="shipped" data-live="${LIVE}" aria-live="polite">${shippedRegion(read, choice, new Date(), "UTC", toLive, readable, chapters, bet, target)}</div>`; |
| 334 | const response = page({ ctx, title: "Changelog", body, feed: { href: "/changelog.atom", title: "Changelog" }, json: { href: `/api/v1/changelog${choice === read.own ? "" : `?repo=${encodeURIComponent(choice)}`}`, title: "Changelog (JSON)" }, scriptJs: `${liveRegionsJs}\n${localDaysJs}` }); | |
| 334 | const response = page({ ctx, title: "Changelog", description: "What shipped on this forge, newest first: each change that landed and when.", body, feed: { href: "/changelog.atom", title: "Changelog" }, json: { href: `/api/v1/changelog${choice === read.own ? "" : `?repo=${encodeURIComponent(choice)}`}`, title: "Changelog (JSON)" }, scriptJs: `${liveRegionsJs}\n${localDaysJs}` }); | |
| 335 | 335 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 336 | 336 | if (keep === undefined) return response; |
| 337 | 337 | const headers = new Headers(response.headers); |
src/web/pages/packs.ts +3 −2
| @@ -1,7 +1,8 @@ | ||
| 1 | 1 | /** |
| 2 | 2 | * `/packs` and `/packs/:name`: the forge packs this forge ships (`src/packs/`). |
| 3 | 3 | * A pack's page says what it brings, the one command that deploys it on your |
| 4 | * own machine, and a link to start a forge of your own. Server-rendered, no script; anyone may read it. | |
| 4 | * own machine, and a link to start a forge of your own. Server-rendered, no script; anyone may read | |
| 5 | * it. | |
| 5 | 6 | */ |
| 6 | 7 | |
| 7 | 8 | import { notePhase, takeSessionTime } from "../../core/route_timing.ts"; |
| @@ -102,7 +103,7 @@ export async function packsPage(ctx: Ctx): Promise<Response> { | ||
| 102 | 103 | </form>` |
| 103 | 104 | : null} |
| 104 | 105 | </section>`}`; |
| 105 | const response = page({ ctx, title: "Packs", body }); | |
| 106 | const response = page({ ctx, title: "Packs", description: "Packs of apps and crew members you can take whole and make your own.", body }); | |
| 106 | 107 | notePhase(ctx.request, "render", performance.now() - started); |
| 107 | 108 | return response; |
| 108 | 109 | } |
src/web/pages/pricing.ts +10 −6
| @@ -23,7 +23,7 @@ import { field, readForm } from "../form.ts"; | ||
| 23 | 23 | import { html, type Html } from "../html.ts"; |
| 24 | 24 | import { page, redirect } from "../layout.ts"; |
| 25 | 25 | import { planOfferRow } from "../plan_offer_row.ts"; |
| 26 | import { START_BUTTON, SITE_PATH } from "../site_line.ts"; | |
| 26 | import { START_BUTTON } from "../site_line.ts"; | |
| 27 | 27 | import { offerData, sharedProperties } from "../offer.ts"; |
| 28 | 28 | import { safeJson } from "../structured_data.ts"; |
| 29 | 29 | import { btn, field as formField } from "../ui.ts"; |
| @@ -40,7 +40,8 @@ interface Values { | ||
| 40 | 40 | const isBuyer = (ctx: Ctx): boolean => ctx.auth.user === undefined || ctx.auth.user.kind === "user"; |
| 41 | 41 | |
| 42 | 42 | function plansView(ctx: Ctx, values: Values, errors: Partial<Record<Refusal["field"], string>>): Html { |
| 43 | // The order this browser paid for, from its own cookie: the page that opens it needs the address of the order. | |
| 43 | // The order this browser paid for, from its own cookie: the page that opens it needs the address | |
| 44 | // of the order. | |
| 44 | 45 | const held = (cookieValue(ctx.request, COOKIE) ?? "").split(".")[0] ?? ""; |
| 45 | 46 | const ordered = /^ord_[0-9a-f]{32}$/.test(held) ? held : undefined; |
| 46 | 47 | const selling = checkoutOf(ctx.app) !== undefined; |
| @@ -93,7 +94,7 @@ export function pricingPage(ctx: Ctx): Response { | ||
| 93 | 94 | const response = page({ |
| 94 | 95 | ctx, |
| 95 | 96 | title: "Open Platform Forge: pricing and your own forge", |
| 96 | description: SITE_PATH(ctx.url.origin), | |
| 97 | description: "What each forge plan costs and the CPU, memory, disk and crew credit it includes.", | |
| 97 | 98 | tight: true, |
| 98 | 99 | jsonLd: safeJson({ "@context": "https://schema.org", "@type": "Product", name: "Open Platform Forge", url: `${ctx.url.origin}/`, additionalProperty: sharedProperties(lapseRule(ctx.app.db)), offers: offerData(plans, ctx.url.origin, lapseRule(ctx.app.db), true) }), |
| 99 | 100 | body: plansView(ctx, { name: (ctx.url.searchParams.get("name") ?? "").slice(0, 38), email: "" }, {}), |
| @@ -105,7 +106,8 @@ export function pricingPage(ctx: Ctx): Response { | ||
| 105 | 106 | const cookieFor = (ctx: Ctx, value: string, maxAge: number): string => |
| 106 | 107 | setCookie(COOKIE, value, { path: "/pricing", maxAge, secure: secureFor(ctx.url, ctx.app.config.url) }); |
| 107 | 108 | |
| 108 | // POST /pricing/order — free goes on to the free path; a paid plan holds the name and goes to checkout. | |
| 109 | // POST /pricing/order — free goes on to the free path; a paid plan holds the name and goes to | |
| 110 | // checkout. | |
| 109 | 111 | export async function pricingOrder(ctx: Ctx): Promise<Response> { |
| 110 | 112 | if (!isBuyer(ctx)) return notFoundPage(ctx); |
| 111 | 113 | const form = await readForm(ctx, ctx.auth.user === undefined ? undefined : "admin"); |
| @@ -144,7 +146,8 @@ const waiting = (ctx: Ctx, says: string): Response => { | ||
| 144 | 146 | return res; |
| 145 | 147 | }; |
| 146 | 148 | |
| 147 | // GET /pricing/done?order= — reconciles the order with the provider, waits for the forge, shows the link once. | |
| 149 | // GET /pricing/done?order= — reconciles the order with the provider, waits for the forge, shows the | |
| 150 | // link once. | |
| 148 | 151 | export async function pricingDone(ctx: Ctx): Promise<Response> { |
| 149 | 152 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 150 | 153 | const rendering = performance.now(); |
| @@ -198,7 +201,8 @@ export function resendPage(ctx: Ctx): Response { | ||
| 198 | 201 | return response; |
| 199 | 202 | } |
| 200 | 203 | |
| 201 | // POST /pricing/resend — the link goes to the order's own email; the answer is the same whether or not an order matched. | |
| 204 | // POST /pricing/resend — the link goes to the order's own email; the answer is the same whether or | |
| 205 | // not an order matched. | |
| 202 | 206 | export async function resendSubmit(ctx: Ctx): Promise<Response> { |
| 203 | 207 | if (!isBuyer(ctx)) return notFoundPage(ctx); |
| 204 | 208 | const form = await readForm(ctx, ctx.auth.user === undefined ? undefined : "admin"); |
src/web/pages/privacy.ts +1
| @@ -14,6 +14,7 @@ export function privacyPage(ctx: Ctx): Response { | ||
| 14 | 14 | page({ |
| 15 | 15 | ctx, |
| 16 | 16 | title: "Privacy", |
| 17 | description: "What this forge keeps about visitors, for how long, and what it never keeps.", | |
| 17 | 18 | body: html`<div class="page-head"><h1>Privacy</h1></div> |
| 18 | 19 | <ul class="list"> |
| 19 | 20 | <li> |
src/web/pages/site.ts +8 −4
| @@ -206,7 +206,8 @@ export function terminalCard(ctx: Ctx): Html { | ||
| 206 | 206 | // the feed (`studioHome`, #599), whatever the mode (#625). |
| 207 | 207 | export async function home(ctx: Ctx): Promise<Response> { |
| 208 | 208 | const user = ctx.auth.user; |
| 209 | // A gift link (`/?code=`) keeps the code in a cookie and opens the new-forge form, so the next address has no code in it (#11157). | |
| 209 | // A gift link (`/?code=`) keeps the code in a cookie and opens the new-forge form, so the next | |
| 210 | // address has no code in it (#11157). | |
| 210 | 211 | const gift = ctx.url.searchParams.get("code"); |
| 211 | 212 | if (gift !== null && gift !== "") return keepGift(gift.slice(0, 64), "/forges/new", ctx.url, ctx.app.config.url); |
| 212 | 213 | // The home is one page (`pages/home_flow.ts`): the switch it was tried behind goes to it. |
| @@ -477,7 +478,7 @@ export function signinPage(ctx: Ctx): Response { | ||
| 477 | 478 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 478 | 479 | const body = authForm(ctx, "signin"); |
| 479 | 480 | return timePhase(ctx.request, "render", () => |
| 480 | page({ ctx, title: "Sign in", body, scriptJs: passkeyJs }), | |
| 481 | page({ ctx, title: "Sign in", description: "Sign in to your forge with your passkey.", body, scriptJs: passkeyJs }), | |
| 481 | 482 | ); |
| 482 | 483 | } |
| 483 | 484 | |
| @@ -493,7 +494,10 @@ export function inviteOf(ctx: Ctx): string | undefined { | ||
| 493 | 494 | return token === "" ? undefined : token; |
| 494 | 495 | } |
| 495 | 496 | |
| 496 | /** The one place the forge says its accounts are closed: `/signin` (and `/signup` through its own message), never the home page (#11325). */ | |
| 497 | /** | |
| 498 | * The one place the forge says its accounts are closed: `/signin` (and `/signup` through its own | |
| 499 | * message), never the home page (#11325). | |
| 500 | */ | |
| 497 | 501 | function byInvitationLine(): Html { |
| 498 | 502 | return html`<p class="small mb" id="by-invitation">Accounts on this forge are by invitation. <a href="/#yours">Start your own forge instead.</a></p>`; |
| 499 | 503 | } |
| @@ -527,7 +531,7 @@ export function signupPage(ctx: Ctx): Response { | ||
| 527 | 531 | if (first) return first; |
| 528 | 532 | const body = authForm(ctx, "signup"); |
| 529 | 533 | return timePhase(ctx.request, "render", () => |
| 530 | page({ ctx, title: "Sign up", body, turnstile: siteKey(ctx) !== undefined, scriptJs: passkeyJs }), | |
| 534 | page({ ctx, title: "Sign up", description: "Make your forge: pick a username and create a passkey, and a crew starts building your apps.", body, turnstile: siteKey(ctx) !== undefined, scriptJs: passkeyJs }), | |
| 531 | 535 | ); |
| 532 | 536 | } |
| 533 | 537 |
src/web/studio/explore.ts +7 −3
| @@ -139,7 +139,10 @@ function chipRow(query: ExploreQuery): Html { | ||
| 139 | 139 | </div>`; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | /** What the filter's terms are, for a link that takes one away: the owner too, which `terms` leaves to the line. */ | |
| 142 | /** | |
| 143 | * What the filter's terms are, for a link that takes one away: the owner too, which `terms` leaves | |
| 144 | * to the line. | |
| 145 | */ | |
| 143 | 146 | function removable(query: ExploreQuery): { term: string; without: ExploreQuery }[] { |
| 144 | 147 | const out = terms(query).filter((t) => !t.term.startsWith("sort:")); |
| 145 | 148 | if (query.owner !== undefined) { |
| @@ -276,8 +279,9 @@ export async function explorePage(ctx: Ctx): Promise<Response> { | ||
| 276 | 279 | })}${more === null |
| 277 | 280 | ? html`` |
| 278 | 281 | : html`<div class="explore-more">${btn("More results", { href: `${here}${here.includes("?") ? "&" : "?"}cursor=${encodeURIComponent(more)}`, variant: "outline", extra: "explore-more-link" })}</div>`}</div>`; |
| 279 | const drawn = page({ ctx, title: "Explore", body: compact(body), feed: { href: "/explore.atom", title: "Explore" } }); | |
| 280 | // An unknown filter is ignored with a plain note on the page (200); the API and the MCP stay strict. | |
| 282 | const drawn = page({ ctx, title: "Explore", description: "Apps, forges and people on this forge, ranked by use, forks, ships and freshness.", body: compact(body), feed: { href: "/explore.atom", title: "Explore" } }); | |
| 283 | // An unknown filter is ignored with a plain note on the page (200); the API and the MCP stay | |
| 284 | // strict. | |
| 281 | 285 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 282 | 286 | return drawn; |
| 283 | 287 | } |
src/web/studio/home.ts +11 −6
| @@ -2,8 +2,8 @@ | ||
| 2 | 2 | * The home in the studio: signed in, the feed — the composer, then one |
| 3 | 3 | * timeline — with your apps and what is on you beside it (#599). Built from |
| 4 | 4 | * the same cards as the rest of the forge, from grouped reads only, so the |
| 5 | * page does not get slower as the apps grow. A stranger gets the door instead: the forge featured, then the | |
| 6 | * best of what is public (`actions/front.ts`). | |
| 5 | * page does not get slower as the apps grow. A stranger gets the door instead: the forge featured, | |
| 6 | * then the best of what is public (`actions/front.ts`). | |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | import { UPSTREAM_REPO } from "../../core/upstream.ts"; |
| @@ -39,7 +39,7 @@ import { liveRegionsJs } from "../client.ts"; | ||
| 39 | 39 | import { html, when, type Html } from "../html.ts"; |
| 40 | 40 | import { fragment, page, redirect } from "../layout.ts"; |
| 41 | 41 | import { START_REFUSALS, startRefusalIn } from "../start_refusal.ts"; |
| 42 | import { SITE_PATH, SITE_WHAT } from "../site_line.ts"; | |
| 42 | import { SITE_WHAT } from "../site_line.ts"; | |
| 43 | 43 | import { siteStructuredData } from "../structured_data.ts"; |
| 44 | 44 | import { running } from "../../kernel/version.ts"; |
| 45 | 45 | import { biggestMilestones, homeMilestones } from "./milestone_lines.ts"; |
| @@ -483,7 +483,9 @@ function frontControls(ctx: Ctx, front: FrontPage): Html { | ||
| 483 | 483 | ); |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | /** How many apps the door shows: the pins, then the best of the rest, with a link to all of them. */ | |
| 486 | /** | |
| 487 | * How many apps the door shows: the pins, then the best of the rest, with a link to all of them. | |
| 488 | */ | |
| 487 | 489 | const DOOR_TILES = 8; |
| 488 | 490 | |
| 489 | 491 | /** The live address of an app a stranger may open, or nothing. */ |
| @@ -500,7 +502,10 @@ const DOOR_STATE: Partial<Record<EnvState, string>> = { | ||
| 500 | 502 | deploying: "Updating", |
| 501 | 503 | }; |
| 502 | 504 | |
| 503 | /** What a stranger can do to help with an app: make an account if this forge takes new ones, or send its keepers a note. */ | |
| 505 | /** | |
| 506 | * What a stranger can do to help with an app: make an account if this forge takes new ones, or send | |
| 507 | * its keepers a note. | |
| 508 | */ | |
| 504 | 509 | function helpDoor(repo: FrontEntry["repo"], accounts: boolean): Html { |
| 505 | 510 | return accounts |
| 506 | 511 | ? html`<a href="/signup?next=${encodeURIComponent(repoBase(repo))}">Help build</a>` |
| @@ -833,7 +838,7 @@ bun run src/main.ts</code></pre> | ||
| 833 | 838 | const res = page({ |
| 834 | 839 | ctx, |
| 835 | 840 | title: "Open Platform Forge: software for what you're building, yours to keep", |
| 836 | description: `${SITE_WHAT} ${SITE_PATH(origin)}`, | |
| 841 | description: SITE_WHAT, | |
| 837 | 842 | body, |
| 838 | 843 | scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${funnelJs}\n${startNameJs}`, |
| 839 | 844 | jsonLd: siteStructuredData(origin, running().version), |
test/page-descriptions.test.ts added +43
| @@ -0,0 +1,43 @@ | ||
| 1 | /** | |
| 2 | * Every signed-out public page says in one sentence what it is; no two share one, none falls back | |
| 3 | * to the site line. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 11 | ||
| 12 | const PAGES = ["/", "/pricing", "/explore", "/changelog", "/signup", "/signin", "/privacy", "/packs", "/docs", "/agents"]; | |
| 13 | const SITE_DEFAULT = "Your software and the crew that builds it, in one place."; | |
| 14 | ||
| 15 | let dir: string; | |
| 16 | let app: App; | |
| 17 | let servers: Servers; | |
| 18 | beforeAll(async () => { | |
| 19 | dir = await mkdtemp(join(tmpdir(), "forge-descriptions-")); | |
| 20 | app = createApp({ dataDir: dir, port: 0 }); | |
| 21 | servers = await serve(app); | |
| 22 | }); | |
| 23 | afterAll(async () => { | |
| 24 | servers.stop(); | |
| 25 | app.close(); | |
| 26 | await rm(dir, { recursive: true, force: true }); | |
| 27 | }); | |
| 28 | ||
| 29 | test("each public page has its own short description", async () => { | |
| 30 | const seen = new Map<string, string>(); | |
| 31 | for (const path of PAGES) { | |
| 32 | const res = await fetch(`${servers.url}${path}`, { redirect: "follow" }); | |
| 33 | const text = await res.text(); | |
| 34 | const m = text.match(/<meta name="description" content="([^"]*)"/); | |
| 35 | expect(m, `${path} has a description`).not.toBeNull(); | |
| 36 | const d = m![1]!; | |
| 37 | expect(d, `${path} is not the site default`).not.toBe(SITE_DEFAULT); | |
| 38 | expect(d.length, `${path} is under 160 characters`).toBeLessThan(160); | |
| 39 | expect(d.length).toBeGreaterThan(20); | |
| 40 | expect(seen.get(d), `${path} shares its description with ${seen.get(d)}`).toBeUndefined(); | |
| 41 | seen.set(d, path); | |
| 42 | } | |
| 43 | }); |
new above
offline