diff --git a/README.md b/README.md index 72a4d08..533f3e9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This project won first place at a hackathon demo day selected from 32 finalist t Public demo: [https://draw-one-crystals-projects-0006cdef.vercel.app/](https://draw-one-crystals-projects-0006cdef.vercel.app/) -Open `index.html` in a browser to run it locally. No backend is required for the current public demo. +Open `paper/arrival.html` in a browser to run it locally (the Vercel root routes there). No backend is required for the current public demo. The earlier `index.html` prototype is kept in the repo for the content-truth test suite but is no longer served. ## What It Does @@ -95,5 +95,5 @@ Draw One is still a prototype. The product direction has been validated at demo No backend is required. ```bash -open index.html +open paper/arrival.html ``` diff --git a/assets/favicon.svg b/assets/favicon.svg new file mode 100644 index 0000000..a1c3be8 --- /dev/null +++ b/assets/favicon.svg @@ -0,0 +1 @@ + diff --git a/paper/arrival.html b/paper/arrival.html index 7bb198b..86a9013 100644 --- a/paper/arrival.html +++ b/paper/arrival.html @@ -4,6 +4,7 @@ 抽一 Draw One — 埕 + diff --git a/scripts/test-draw-pool.mjs b/scripts/test-draw-pool.mjs index bf3c9f9..da87599 100644 --- a/scripts/test-draw-pool.mjs +++ b/scripts/test-draw-pool.mjs @@ -160,7 +160,12 @@ buildMustFail("lone surrogate code unit in poem", (d) => (d.slips[13].poem_text buildMustFail("U+FFFD in edition_title", (d) => (d.slips[14].edition_title += "�")); // --------------------------------------------------------------------------- -console.log("T5 public page truth rules"); +// T5 — legacy index.html truth rules. Since #33 the live public page is +// paper/arrival.html (Vercel root rewrite) and index.html is a retired route +// (permanent redirect to /). The file is kept on disk, not deleted, so these +// content guarantees still apply to it (no banned oracle text, no inline arrays). +// Routing truth itself is asserted in scripts/test-routing.mjs. +console.log("T5 legacy index.html truth rules (retired route, file retained)"); const html = readFileSync(join(ROOT, "index.html"), "utf8"); const BANNED_PAGE_STRINGS = [ "神明正在回應中", diff --git a/scripts/test-routing.mjs b/scripts/test-routing.mjs new file mode 100644 index 0000000..d7d3574 --- /dev/null +++ b/scripts/test-routing.mjs @@ -0,0 +1,48 @@ +// test-routing.mjs — Vercel routing truth after legacy-route retirement (#33). +// The only production host is Vercel. Root serves Arrival (rewrite, URL unchanged); +// the legacy prototype routes are permanently redirected to root. The 解曰 layer +// (guard / artifact / custody) must be untouched by this change. +import { readFileSync, existsSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const ROOT = join(dirname(fileURLToPath(import.meta.url)), ".."); +let pass = 0, fail = 0; +const check = (name, ok) => { console.log((ok ? " ✓ " : " ✗ ") + name); ok ? pass++ : fail++; }; + +const vc = JSON.parse(readFileSync(join(ROOT, "vercel.json"), "utf8")); + +console.log("A root still enters Arrival (rewrite, not redirect)"); +const rw = vc.rewrites || []; +check("/ rewrites to /paper/arrival.html", rw.some((r) => r.source === "/" && r.destination === "/paper/arrival.html")); +check("root is a rewrite, never a redirect (URL stays /)", !(vc.redirects || []).some((r) => r.source === "/")); + +console.log("B legacy routes are PERMANENT redirects to /"); +const reds = vc.redirects || []; +const permTo = (src) => reds.some((r) => r.source === src && r.destination === "/" && r.permanent === true); +check("/index.html → / (permanent)", permTo("/index.html")); +check("/research → / (permanent)", permTo("/research")); +check("/research/ → / (permanent)", permTo("/research/")); +check("/research/index.html → / (permanent)", permTo("/research/index.html")); +check("every redirect is permanent (308) and lands on /", reds.length > 0 && reds.every((r) => r.permanent === true && r.destination === "/")); +// modern config: routes[] must not coexist with redirects/rewrites (Vercel rejects the mix) +check("uses modern redirects/rewrites, not legacy routes[]", !("routes" in vc)); + +console.log("C favicon so the browser stops probing"); +check("favicon.svg exists and is non-empty", existsSync(join(ROOT, "assets/favicon.svg")) && readFileSync(join(ROOT, "assets/favicon.svg"), "utf8").length > 0); +const arrival = readFileSync(join(ROOT, "paper/arrival.html"), "utf8"); +check("arrival links the favicon", /]+rel="icon"[^>]+favicon\.svg/.test(arrival)); + +console.log("D 解曰 layer untouched by the routing change"); +check("guard + artifact + custody all present", ["assets/jieyue-guard.js", "assets/interpretation-pool.guanyin.js", "data/corpora/guanyin/jieyue_custody.json"].every((p) => existsSync(join(ROOT, p)))); +const win = {}; new Function("window", readFileSync(join(ROOT, "assets/interpretation-pool.guanyin.js"), "utf8"))(win); +const gwin = {}; new Function("window", readFileSync(join(ROOT, "assets/jieyue-guard.js"), "utf8"))(gwin); +check("guard content_version still bound to artifact", gwin.JIEYUE_GUARD.CONTRACT.content_version === win.INTERPRETATION_POOL.content_version); +check("arrival still loads guard + artifact", arrival.includes("jieyue-guard.js") && arrival.includes("interpretation-pool.guanyin.js")); + +console.log("E legacy index.html retained on disk (redirected, not deleted)"); +check("index.html file still exists (source kept; only the route retires)", existsSync(join(ROOT, "index.html"))); +check("research questionnaire source kept (Apps Script not deleted)", existsSync(join(ROOT, "research/google-apps-script.gs"))); + +console.log(`\n${pass} passed, ${fail} failed`); +process.exit(fail ? 1 : 0); diff --git a/vercel.json b/vercel.json index b3f54b4..48227d8 100644 --- a/vercel.json +++ b/vercel.json @@ -1,10 +1,12 @@ { "$schema": "https://openapi.vercel.sh/vercel.json", - "routes": [ - { - "src": "/", - "dest": "/paper/arrival.html" - }, - { "handle": "filesystem" } + "redirects": [ + { "source": "/index.html", "destination": "/", "permanent": true }, + { "source": "/research", "destination": "/", "permanent": true }, + { "source": "/research/", "destination": "/", "permanent": true }, + { "source": "/research/index.html", "destination": "/", "permanent": true } + ], + "rewrites": [ + { "source": "/", "destination": "/paper/arrival.html" } ] }