Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
```
1 change: 1 addition & 0 deletions assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions paper/arrival.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<title>抽一 Draw One — 埕</title>
<link rel="icon" type="image/svg+xml" href="../assets/favicon.svg" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400..700&family=Noto+Sans+TC:wght@300;400;500&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="../assets/slip.css?v=3" />
Expand Down
7 changes: 6 additions & 1 deletion scripts/test-draw-pool.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
"神明正在回應中",
Expand Down
48 changes: 48 additions & 0 deletions scripts/test-routing.mjs
Original file line number Diff line number Diff line change
@@ -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", /<link[^>]+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);
14 changes: 8 additions & 6 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -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" }
]
}
Loading