|
| 1 | +<!DOCTYPE html> |
| 2 | +<!-- |
| 3 | + Stage 9 + Stage 15 (spec 015-neuroscape-context): smart root 404. |
| 4 | +
|
| 5 | + gh-pages serves a SINGLE `404.html` from the publishing-source root |
| 6 | + for every path that doesn't resolve to a static file. With the |
| 7 | + Stage 15 three-mode deployment (`/`, `/ohbm2026/`, `/neuroscape/`), |
| 8 | + this single file has to hand a deep-linked request off to the RIGHT |
| 9 | + per-mode SvelteKit shell: |
| 10 | +
|
| 11 | + 1. **Path inside `/ohbm2026/`** (e.g. `<host>/ohbm2026/abstract/<n>/`) → |
| 12 | + bounce to `<host>/ohbm2026/?spa=<encoded-original-path>`. The |
| 13 | + OHBM 2026 SvelteKit shell at `/ohbm2026/index.html` boots, reads |
| 14 | + `?spa=` in `+layout.svelte`'s `onMount`, and `goto`s the deep link. |
| 15 | +
|
| 16 | + 2. **Path inside `/neuroscape/`** (e.g. |
| 17 | + `<host>/neuroscape/abstract/<pubmed_id>/`) → bounce to |
| 18 | + `<host>/neuroscape/?spa=…`. Same SvelteKit handoff, different |
| 19 | + bundle. |
| 20 | +
|
| 21 | + 3. **Path inside the atlas-root deploy** (e.g. `<host>/some-random/`) |
| 22 | + — no subroutes exist there yet, so bounce to the atlas-root home. |
| 23 | +
|
| 24 | + PR previews add a `/pr-<N>/` prefix and the legacy staging used |
| 25 | + `/sandbox/` — both have to be honoured in every branch. The prefix |
| 26 | + is detected from the request URL so the SAME file works at the |
| 27 | + gh-pages root, at every per-PR root, and at the sandbox root. |
| 28 | +
|
| 29 | + Relative paths like `./neuroscape/` are NOT safe here — the browser |
| 30 | + resolves them against the REQUEST URL, not the file's gh-pages |
| 31 | + location. Absolute paths composed from the detected prefix are |
| 32 | + correct in every case. |
| 33 | +--> |
| 34 | +<html lang="en"> |
| 35 | +<head> |
| 36 | + <meta charset="utf-8"> |
| 37 | + <title>Abstract Atlas — locating your page</title> |
| 38 | + <meta name="robots" content="noindex"> |
| 39 | + <script> |
| 40 | + (function () { |
| 41 | + var p = window.location.pathname; |
| 42 | + var search = window.location.search; |
| 43 | + var hash = window.location.hash; |
| 44 | + // Detect the prefix the user landed under (per-PR preview or |
| 45 | + // the legacy sandbox staging root) so absolute redirects |
| 46 | + // compose correctly. |
| 47 | + var prefixMatch = p.match(/^(\/(?:pr-\d+|sandbox))\//); |
| 48 | + var prefix = prefixMatch ? prefixMatch[1] : ''; |
| 49 | + |
| 50 | + // LOOP SAFETY: if we got here AFTER already issuing a |
| 51 | + // `?spa=` redirect to the same subsite shell, the target |
| 52 | + // SvelteKit bundle isn't deployed in this environment |
| 53 | + // (e.g. /neuroscape/ exists in PR-preview but not on |
| 54 | + // production until the spec-015 PR merges). Re-redirecting |
| 55 | + // would loop forever. Detect that case and fall through |
| 56 | + // to the safe atlas-root home instead. |
| 57 | + var alreadyRedirected = /[?&]spa=/.test(search); |
| 58 | + |
| 59 | + // 1. Inside /neuroscape/ → bounce to that bundle's SPA shell. |
| 60 | + var ns = p.match(/^(\/(?:pr-\d+|sandbox))?\/neuroscape\//); |
| 61 | + if (ns && !alreadyRedirected) { |
| 62 | + var nsBase = (ns[1] || '') + '/neuroscape'; |
| 63 | + var stash = p + search + hash; |
| 64 | + try { sessionStorage.setItem('ohbm2026.spa.redirect', stash); } catch (e) {} |
| 65 | + window.location.replace(nsBase + '/?spa=' + encodeURIComponent(stash)); |
| 66 | + return; |
| 67 | + } |
| 68 | + |
| 69 | + // 2. Inside /ohbm2026/ → bounce to that bundle's SPA shell. |
| 70 | + var m = p.match(/^(\/(?:pr-\d+|sandbox))?\/ohbm2026\//); |
| 71 | + if (m && !alreadyRedirected) { |
| 72 | + var base = (m[1] || '') + '/ohbm2026'; |
| 73 | + var stash2 = p + search + hash; |
| 74 | + try { sessionStorage.setItem('ohbm2026.spa.redirect', stash2); } catch (e) {} |
| 75 | + window.location.replace(base + '/?spa=' + encodeURIComponent(stash2)); |
| 76 | + return; |
| 77 | + } |
| 78 | + |
| 79 | + // 3. Outside any known subsite — OR a loop-safety fall- |
| 80 | + // through — bounce to the atlas-root home for the current |
| 81 | + // prefix. Trailing slash matters because gh-pages serves |
| 82 | + // the root index from `/`, not `''`. |
| 83 | + window.location.replace((prefix || '') + '/' + search + hash); |
| 84 | + })(); |
| 85 | + </script> |
| 86 | + <!-- No-JS fallback: a 2-second meta-refresh + a manual link to |
| 87 | + each subsite. Deep-link recovery requires JS and is best-effort. --> |
| 88 | + <meta http-equiv="refresh" content="2; url=/"> |
| 89 | +</head> |
| 90 | +<body> |
| 91 | + <noscript> |
| 92 | + <p>Page not found. Try one of:</p> |
| 93 | + <ul> |
| 94 | + <li><a href="/">Cross-conference atlas</a></li> |
| 95 | + <li><a href="/ohbm2026/">OHBM 2026 Atlas</a></li> |
| 96 | + <li><a href="/neuroscape/">NeuroScape PubMed Atlas</a></li> |
| 97 | + </ul> |
| 98 | + </noscript> |
| 99 | +</body> |
| 100 | +</html> |
0 commit comments