From 20dd4f2a72fea12409e8aaa7d1cc3f3d9a137bec Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Mon, 14 Sep 2026 13:19:50 +0900 Subject: [PATCH] feat: serve the atlas data from XOOPS-style paths v2.0.0 put every atlas under /data//, which broke the original //static/ download links and kept the data out of the modules/ layout the other sites use. - read tree.json and items.json from //modules/xoonips/ and link the files under //modules/xoonips/file/ - redirect download.php, the v2.0.0 /data/ paths and the older //file/ paths with a 301 - send directories without an index.html to the SPA as well: the atlas directories now exist on disk, and the old rule served them as a 404 --- public/.htaccess | 18 ++++++++++-------- src/xoonips/lib/IndexUtil.ts | 2 +- src/xoonips/lib/ItemUtil.ts | 6 +++--- vite.config.ts | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/public/.htaccess b/public/.htaccess index 7ded808..416a079 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -2,20 +2,22 @@ RewriteEngine On RewriteBase / +# XOOPS download URLs point at the file directory, whose own .htaccess serves the file. RewriteCond %{QUERY_STRING} (^|&)file_id=([0-9]+)($|&) -RewriteRule ^degu/modules/xoonips/download.php /data/degu/file/%2? [R=301,L] +RewriteRule ^(degu|jm|marmoset)/modules/xoonips/download\.php$ /$1/modules/xoonips/file/%2? [R=301,L] -RewriteCond %{QUERY_STRING} (^|&)file_id=([0-9]+)($|&) -RewriteRule ^jm/modules/xoonips/download.php /data/jm/file/%2? [R=301,L] - -RewriteCond %{QUERY_STRING} (^|&)file_id=([0-9]+)($|&) -RewriteRule ^marmoset/modules/xoonips/download.php /data/marmoset/file/%2? [R=301,L] +# The v2.0.0 layout served everything under /data/; keep those links alive. +RewriteRule ^data/(degu|jm|marmoset)/file/(.*)$ /$1/modules/xoonips/file/$2 [R=301,L] +RewriteRule ^data/(degu|jm|marmoset)/static/(.*)$ /$1/static/$2 [R=301,L] +# An older static layout put the files at //file/. +RewriteRule ^(degu|jm|marmoset)/file/(.*)$ /$1/modules/xoonips/file/$2 [R=301,L] RewriteRule ^index\.html$ - [L] +# Anything that is not a real file goes to the SPA -- including the atlas +# directories themselves, which now exist on disk as data roots. RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-l [OR] +RewriteCond %{REQUEST_FILENAME} !-d [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME}index.html !-f RewriteRule . /index.html [L] diff --git a/src/xoonips/lib/IndexUtil.ts b/src/xoonips/lib/IndexUtil.ts index 1860cfd..146c474 100644 --- a/src/xoonips/lib/IndexUtil.ts +++ b/src/xoonips/lib/IndexUtil.ts @@ -49,7 +49,7 @@ class IndexUtil { this.indexes.set(type, collection); this.loading.set(type, true); this.callbacks.set(type, []); - ky.get(new URL(`${Config.BASE_URL}/data/${type}/tree.json`, window.location.href)) + ky.get(new URL(`${Config.BASE_URL}/${type}/modules/xoonips/tree.json`, window.location.href)) .json() .then((data) => { const store = (indexesData: IndexesData, parentId: number) => { diff --git a/src/xoonips/lib/ItemUtil.ts b/src/xoonips/lib/ItemUtil.ts index 7793c29..4f55312 100644 --- a/src/xoonips/lib/ItemUtil.ts +++ b/src/xoonips/lib/ItemUtil.ts @@ -425,7 +425,7 @@ class ItemUtil { this.items.set(type, collection); this.loading.set(type, true); this.callbacks.set(type, []); - ky.get(new URL(`${Config.BASE_URL}/data/${type}/items.json`, window.location.href)) + ky.get(new URL(`${Config.BASE_URL}/${type}/modules/xoonips/items.json`, window.location.href)) .json() .then((data) => { const itemsJson = data; @@ -492,11 +492,11 @@ class ItemUtil { } getFileUrl(type: BrainAtlasType, file: ItemBasicFile): string { - return `${Config.BASE_URL}/data/${type}/file/${file.file_id}/${Functions.escapeUrl(file.original_file_name)}`; + return `${Config.BASE_URL}/${type}/modules/xoonips/file/${file.file_id}/${Functions.escapeUrl(file.original_file_name)}`; } getPreviewFileUrl(type: BrainAtlasType, file: ItemBasicFile): string { - return `${Config.BASE_URL}/data/${type}/file/${file.file_id}/.png`; + return `${Config.BASE_URL}/${type}/modules/xoonips/file/${file.file_id}.png`; } getSearchByKeywordUrl(type: BrainAtlasType, ksType: KeywordSearchType, keyword: string): string { diff --git a/vite.config.ts b/vite.config.ts index 2e185f4..6fdda15 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,7 +6,7 @@ import type { Connect, Plugin, ResolvedConfig } from 'vite'; import { defineConfig } from 'vite'; /** - * `static-contents/` holds the dumped atlas data (`data//`). + * `static-contents/` holds the dumped atlas data (`/modules/xoonips/`, `/static/`). * It sits next to the repository and is served from the site root next to * `public/`, but it is deliberately kept out of the bundle: it runs to * gigabytes of frozen data that the web server maps in directly. The dev and