Files
dynamicbrain.neuroinf.jp/README.md
T
orrisroot 87c0274bc1 feat: migrate from Create React App to Vite
Rebuild the site on the stack the other converted sites share: Vite 8,
React 19, TypeScript 7, react-router 8, Biome and sanitize.css, with the
site data moved out of the bundle into static-contents/.

- base the database, credits and pico code on cerebellum.neuroinf.jp,
  keeping this site's item types, rankings and menus
- port the MediaWiki pages to function components
- serve all module data from modules/, redirecting the old download and
  /database/file URLs
- tile the plate texture and keep form controls on white
- track page views with GA4
2026-09-14 16:57:14 +09:00

109 lines
3.9 KiB
Markdown

# Dynamic Brain Platform
Static front-end for the archived [Dynamic Brain Platform](https://dynamicbrain.neuroinf.jp/),
built with [Vite](https://vite.dev/), React and TypeScript.
## Requirements
- Node.js 20.19+ / 22.12+ (Vite 8)
- npm
## Setup
```sh
npm install
```
## Site data
The pages are rendered from JSON dumped out of the original XOOPS installation
by [xoops-static-exporter](https://git.ni.riken.jp/niu/xoops-static-exporter)
(`sites/dynamicbrain.neuroinf.jp/`). All of it lives in `static-contents/`,
which sits next to the repository rather than inside it:
```
dynamicbrain.neuroinf.jp/
├── dynamicbrain.neuroinf.jp/ this repository
└── static-contents/
├── modules/ one directory per source XOOPS module
│ ├── credits/ credits.json, images/
│ ├── documents/ pico: config.json, <content id>.json, images/
│ ├── hackathon/ pico: config.json, <content id>.json, images/, data/
│ ├── mediawiki/ contents.json, contents/<id>.json, images/
│ └── xoonips/ tree.json, items.json, rankings, file/<id>/
├── conferences/ static conference sites, served as they are
├── hetero/ static project site, served as it is
└── rss.xml
```
The `RewriteBase` in every `modules/xoonips/file/<id>/.htaccess` carries the
absolute path of that directory, and the image and file URLs inside the JSON
carry `/modules/<module>/...`; both have to move with the layout.
The dev and preview servers mount that directory at the site root. It is kept
out of `dist/`, and it is not tracked in git.
## Scripts
| Command | Description |
| --- | --- |
| `npm run dev` | Start the dev server on http://localhost:5173 |
| `npm run build` | Type-check and build into `dist/` |
| `npm run preview` | Serve the production build on http://localhost:4173 |
| `npm run lint` | Lint with [Biome](https://biomejs.dev/) |
| `npm run format` | Format with Biome |
| `npm run check` | Lint, format and organize imports, applying the safe fixes |
`@types/node` is pinned to the major that matches the Node runtime in use (24);
`.ncurc.js` keeps `npm-check-updates` from bumping it past that.
There is currently no test suite.
## Styles
The base stylesheet is `sanitize.css` with its `forms` and `typography` sheets,
with its `box-sizing: border-box` kept. Where one of its defaults does not suit
the theme, the theme rule for that place sets its own value rather than
overriding the element everywhere.
## Deployment
Build locally and copy the result up; the server does not need a toolchain.
```sh
npm ci
npm run check
npm run build
../deploy.sh
```
`deploy.sh`, next to `static-contents/`, sends the data to
`archive:/data/www/dynamicbrain.neuroinf.jp/static-contents/`, then `dist/` to
`.../html/`, and finally links every top-level entry of `static-contents/` into
the document root over ssh (`ln -sfn ../static-contents/* .`). The data has to
go first: the document root's `rsync --delete` removes those links, and they
are only put back at the end.
Apache needs `Options FollowSymLinks` and `AllowOverride All` on both
directories. Use symlinks rather than `Alias`: an `Alias` maps the URL outside
the document root, so `.htaccess` no longer applies and the SPA fallback and
the redirects stop working.
### Redirects
`.htaccess` redirects these addresses with a 301:
| From | To |
| --- | --- |
| `/modules/xoonips/download.php?file_id=N` | `/modules/xoonips/file/N` |
| `/database/file/...` | `/modules/xoonips/file/...` |
XOOPS-style addresses (`/modules/xoonips/detail.php?item_id=N`,
`/modules/mediawiki/index.php/<page>`, `/modules/documents/...`,
`/modules/credits/...`, `/index.php`) are redirected inside the app.
## Google Analytics
`GOOGLE_ANALYTICS_TRACKING_ID` in `src/config.ts` carries the GA4 measurement
ID. Emptying it disables tracking. Only production builds send page views.