Public: anyone can read this; the crew can change it.
Every page's <title> names the object, then the forge, and a test walks thirty routes #13987
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13976-every-page-s-title-names-the-object-then → main 3 commits fork 3 threads · 3 unresolved
10 files
changed +26
−17
src/web/layout.ts +3 −3
| @@ -781,13 +781,13 @@ function pageDescription(options: PageOptions): string { | ||
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | /** |
| 784 | * The tab title: the forge named once, whether or not the page's own title | |
| 785 | * already ends in it, or opens with it ("forge: …" names it already). | |
| 784 | * The tab title: the object, then the forge, named once whether or not the | |
| 785 | * page's own title already ends in it. | |
| 786 | 786 | */ |
| 787 | 787 | export function tabTitle(title: string): string { |
| 788 | 788 | const own = title.replace(/(?: · forge)+$/, ""); |
| 789 | 789 | if (own === "" || own === "forge") return "forge"; |
| 790 | return own.startsWith("forge: ") || own.startsWith("Open Platform Forge: ") ? own : `${own} · forge`; | |
| 790 | return `${own} · forge`; | |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | export function page(options: PageOptions, status = 200): Response { |
src/web/pages/offline.ts +1 −1
| @@ -36,7 +36,7 @@ export function offlineHtml(at: Date): string { | ||
| 36 | 36 | '<!doctype html><html lang="en"><head><meta charset="utf-8">' + |
| 37 | 37 | '<meta name="viewport" content="width=device-width,initial-scale=1">' + |
| 38 | 38 | '<meta http-equiv="refresh" content="5">' + |
| 39 | "<title>The forge is unreachable</title>" + | |
| 39 | "<title>Unreachable · forge</title>" + | |
| 40 | 40 | `<style>${STYLE}</style></head><body><main>` + |
| 41 | 41 | "<h1>The forge is unreachable</h1>" + |
| 42 | 42 | "<p>This page tries again every few seconds.</p>" + |
src/web/pages/pricing.ts +1 −1
| @@ -98,7 +98,7 @@ export function pricingPage(ctx: Ctx): Response { | ||
| 98 | 98 | const plans = getPlans(ctx.app.db); |
| 99 | 99 | const response = page({ |
| 100 | 100 | ctx, |
| 101 | title: "Open Platform Forge: pricing and your own forge", | |
| 101 | title: "Pricing and your own forge", | |
| 102 | 102 | description: "What each forge plan costs and the CPU, memory, disk and crew credit it includes.", |
| 103 | 103 | tight: true, |
| 104 | 104 | 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) }), |
src/web/studio/door_claimed.ts +1 −1
| @@ -37,7 +37,7 @@ export function claimedDoor(ctx: Ctx, owner: string, tiles: Html[]): Response { | ||
| 37 | 37 | </div>`; |
| 38 | 38 | return page({ |
| 39 | 39 | ctx, |
| 40 | title: `${owner}'s forge`, | |
| 40 | title: owner, | |
| 41 | 41 | description: `${owner}'s forge. Sign in to see what they are building.`, |
| 42 | 42 | body, |
| 43 | 43 | scriptJs: liveRegionsJs, |
src/web/studio/home.ts +1 −1
| @@ -851,7 +851,7 @@ bun run src/main.ts</code></pre> | ||
| 851 | 851 | </div>`; |
| 852 | 852 | const res = page({ |
| 853 | 853 | ctx, |
| 854 | title: "Open Platform Forge: software for what you're building, yours to keep", | |
| 854 | title: "Software for what you're building, yours to keep", | |
| 855 | 855 | description: SITE_WHAT, |
| 856 | 856 | body, |
| 857 | 857 | scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${funnelJs}\n${startNameJs}`, |
test/home-claimed-forge.test.ts +1 −1
| @@ -41,7 +41,7 @@ test("a claimed hosted forge says whose it is, with Sign in and no start form", | ||
| 41 | 41 | expect(made.ok).toBe(true); |
| 42 | 42 | const body = await get("/"); |
| 43 | 43 | expect(body).toContain("This is riley's forge"); |
| 44 | expect(body).toContain("<title>riley's forge"); | |
| 44 | expect(body).toContain("<title>riley · forge"); | |
| 45 | 45 | expect(body).not.toContain("Start my forge"); |
| 46 | 46 | expect(body).not.toContain('id="start-forge"'); |
| 47 | 47 | expect(body).toContain("Get your own forge"); |
test/offline-page.test.ts +6
| @@ -113,3 +113,9 @@ test("a failed non-navigation request never gets the page", async () => { | ||
| 113 | 113 | expect(res === null || (await res.text()) !== "OFFLINE").toBe(true); |
| 114 | 114 | } |
| 115 | 115 | }); |
| 116 | ||
| 117 | test("the offline page's title is the object, then the forge, under 70 characters", () => { | |
| 118 | const title = /<title>([^<]*)<\/title>/.exec(offlineHtml(new Date()))?.[1] ?? ""; | |
| 119 | expect(title).toEndWith(" · forge"); | |
| 120 | expect(title.length).toBeLessThan(70); | |
| 121 | }); |
test/page-title.test.ts +5 −6
| @@ -27,9 +27,9 @@ const page = async (path: string) => (await fetch(`${servers.url}${path}`)).text | ||
| 27 | 27 | test("the front page names the forge once", async () => { |
| 28 | 28 | const raw = await page("/"); |
| 29 | 29 | const title = /<title>([^<]*)<\/title>/.exec(raw)?.[1] ?? ""; |
| 30 | expect(title).toStartWith("Open Platform Forge: "); | |
| 30 | expect(title).toEndWith(" · forge"); | |
| 31 | 31 | expect(title.match(/forge/gi)).toHaveLength(1); |
| 32 | expect(raw).toContain(`property="og:title" content="${title}"`); | |
| 32 | expect(raw).toContain(`property="og:title" content="${title.replace(/ · forge$/, "")}"`); | |
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | 35 | test("another page keeps its suffix", async () => { |
| @@ -41,10 +41,9 @@ test("no title ends in the suffix twice", async () => { | ||
| 41 | 41 | expect(tabTitle("Search · forge")).toBe("Search · forge"); |
| 42 | 42 | expect(tabTitle("Issues · forge · forge")).toBe("Issues · forge"); |
| 43 | 43 | expect(tabTitle("forge")).toBe("forge"); |
| 44 | // A title that opens with the forge's name names it already. | |
| 45 | expect(tabTitle("forge: software for what you're building")).toBe("forge: software for what you're building"); | |
| 44 | // Always the object, then the forge. | |
| 45 | expect(tabTitle("forge: software")).toBe("forge: software · forge"); | |
| 46 | 46 | expect(tabTitle("forge-x")).toBe("forge-x · forge"); |
| 47 | expect(tabTitle("Open Platform Forge: pricing")).toBe("Open Platform Forge: pricing"); | |
| 48 | for (const path of ["/search?q=forge", "/trevato/forge/issues", "/trevato/forge/pulls"]) | |
| 47 | for (const path of ["/search?q=forge", "/trevato/forge/issues", "/trevato/forge/pulls"]) | |
| 49 | 48 | expect(await page(path)).not.toContain("· forge · forge"); |
| 50 | 49 | }); |
test/page-titles.test.ts +6 −2
| @@ -70,6 +70,10 @@ async function walk(headers: Record<string, string>) { | ||
| 70 | 70 | const title = entity(raw).trim(); |
| 71 | 71 | if (GENERIC.has(title.toLowerCase())) return void bad.push(`${path}: generic or empty title "${title}"`); |
| 72 | 72 | if (!/forge/i.test(title)) bad.push(`${path}: "${title}" does not name the forge`); |
| 73 | if (title.length >= 70) bad.push(`${path}: "${title}" is ${title.length} characters, 70 at most`); | |
The issue says the test walks thirty routes, but the tests only assert |
||
| 74 | if (!/ · forge$/i.test(title)) { | |
outdated
The |
||
| 75 | bad.push(`${path}: "${title}" does not read object then forge`); | |
| 76 | } | |
| 73 | 77 | if (ALIASES.has(path)) return; |
| 74 | 78 | titles.set(title, [...(titles.get(title) ?? []), path]); |
| 75 | 79 | }), |
| @@ -81,12 +85,12 @@ async function walk(headers: Record<string, string>) { | ||
| 81 | 85 | |
| 82 | 86 | test("as a stranger, every static page has its own title naming the forge", async () => { |
| 83 | 87 | const { bad, count } = await walk({}); |
| 84 | expect(count).toBeGreaterThan(10); | |
| 88 | expect(count).toBeGreaterThanOrEqual(25); // a stranger is sent to /signin from many pages; the owner walk holds the thirty; | |
| 85 | 89 | expect(bad).toEqual([]); |
| 86 | 90 | }, 60_000); |
| 87 | 91 | |
| 88 | 92 | test("as a signed-in owner, every static page has its own title naming the forge", async () => { |
| 89 | 93 | const { bad, count } = await walk({ cookie }); |
| 90 | expect(count).toBeGreaterThan(10); | |
| 94 | expect(count).toBeGreaterThanOrEqual(30); | |
| 91 | 95 | expect(bad).toEqual([]); |
| 92 | 96 | }, 60_000); |
new above
offline
This page is served outside the router, so the new title rule never sees it. Add a test that
offlineHtml(new Date())has a title ending ' · forge' and under 70 chars.