Commit Graph

67 Commits

Author SHA1 Message Date
f563b41792 ZXDB: Releases browser filters, schema lists, and fixes
- UI: Add /zxdb hub cards for Entries and Releases; implement Releases browser
  with URL‑synced filters (q, year, sort, DL language/machine, file/scheme/source/case, demo)
  and a paginated table (Entry ID, Title, Release #, Year).
- API: Add GET /api/zxdb/releases/search (Zod‑validated, Node runtime) supporting
  title, year, sort, and downloads‑based filters; return paged JSON.
- Repo: Rewrite searchReleases to Drizzle QB; correct ORDER BY on releases.release_year;
  implement EXISTS on downloads using explicit "from downloads as d"; return JSON‑safe rows.
- Schema: Align Drizzle models with ZXDB for releases/downloads; add lookups
  availabletypes, currencies, roletypes, and roles relation.
- API (lookups): Add GET /api/zxdb/{availabletypes,currencies,roletypes} for dropdowns.
- Stability: JSON‑clone SSR payloads before passing to Client Components to avoid
  RowDataPacket serialization errors.

Signed-off-by: Junie@lucy.xalior.com
2025-12-16 23:00:38 +00:00
fd4c0f8963 Show downloads even without releases rows
Add synthetic release groups in getEntryById so downloads
are displayed even when there are no matching rows in
`releases` for a given entry. Group by `release_seq`,
attach downloads, and sort groups for stable order.

This fixes cases like /zxdb/entries/1 where `downloads`
exist for the entry but `releases` is empty, resulting in
no downloads shown in the UI.

Signed-off-by: Junie@devbox
2025-12-16 21:47:17 +00:00
285c7da87c Handle missing ZXDB releases/downloads schema gracefully
Prevent runtime crashes when `releases`, `downloads`, or related lookup tables
(`releasetypes`, `schemetypes`, `sourcetypes`, `casetypes`) are absent in the
connected ZXDB MySQL database.

- Repo: gate releases/downloads queries behind a schema capability check using
  `information_schema.tables`; if missing, skip queries and return empty arrays.
- Keeps entry detail page functional on legacy/minimal DB exports while fully
  utilizing rich data when available.

Refs: runtime error "Table 'zxdb.releasetypes' doesn't exist"

Signed-off-by: Junie@quinn
2025-12-16 18:41:14 +00:00
f507d51c61 Bump React 2025-12-14 11:29:16 +00:00
240936a850 Standardize ZXDB UI; add SSR search/tables
Unify the look and feel of all /zxdb pages and minimize client pop-in.

- Make all /zxdb pages full-width to match /explorer
- Convert Languages, Genres, Machine Types, and Labels lists to
  Bootstrap tables with table-striped and table-hover inside
  table-responsive wrappers
- Replace raw FK IDs with linked names via SSR repository joins
- Add scoped search boxes on detail pages (labels, genres, languages,
  machine types) with SSR filtering and pagination that preserves q/tab
- Keep explorer results consistent: show Machine/Language names with
  links, no client lookups required

This improves consistency, readability, and first paint stability across
the ZXDB section while keeping navigation fast and discoverable.

Signed-off-by: Junie@lucy.xalior.com
2025-12-12 16:58:50 +00:00
ddbf72ea52 docs: add ZXDB guide; refresh README & AGENTS
Expand and update documentation to reflect the current app (Registers + ZXDB Explorer), with clear setup and usage instructions.

Changes
- README: add project overview including ZXDB Explorer; routes tour; ZXDB setup (DB import, helper search tables, readonly role); environment configuration; selected API endpoints; implementation notes (Next 15 async params, Node runtime for mysql2, SSR/ISR usage); links to AGENTS.md and docs/ZXDB.md.
- docs/ZXDB.md (new): deep-dive guide covering database preparation, helper tables, environment, Explorer UI, API reference under /api/zxdb, performance approach (helper tables, parallel queries, ISR), troubleshooting, and roadmap.
- AGENTS.md: refresh Project Overview/Structure with ZXDB routes and server/client boundaries; document Next.js 15 dynamic params async pattern for pages and API routes; note Drizzle+mysql2, Node runtime, and lookup `text`→`name` mapping; keep commit workflow guidance.
- example.env: add reference to docs/ZXDB.md and clarify mysql:// format and setup pointers.

Notes
- Documentation focuses on the current state of the codebase (what the code does), not a log of agent actions.
- Helper SQL at ZXDB/scripts/ZXDB_help_search.sql is required for performant searches.

Signed-off-by: Junie@lucy.xalior.com
2025-12-12 16:17:35 +00:00
3ef3a16bc0 Fix ZXDB pagination counters and navigation
Implement URL-driven pagination and correct total counts across ZXDB:
- Root /zxdb: SSR reads ?page; client syncs to SSR; Prev/Next as Links.
- Sub-index pages (genres, languages, machinetypes): parse ?page on server; use SSR props in clients; Prev/Next via Links.
- Labels browse (/zxdb/labels): dynamic SSR, reads ?q & ?page; typed count(*); client syncs to SSR; Prev/Next preserve q.
- Label detail (/zxdb/labels/[id]): tab-aware Prev/Next Links; counters from server.
- Repo: replace raw counts with typed Drizzle count(*) for reliable totals.

Signed-off-by: Junie <Junie@lucy.xalior.com>
2025-12-12 16:11:12 +00:00
54cfe4f175 perf(zxdb): server-render index pages with ISR and initial data
Why
- Reduce time-to-first-content on ZXDB index pages by eliminating the initial client-side fetch and enabling incremental static regeneration.

What
- Main Explorer (/zxdb):
  - Server-renders first page of results and lookup lists (genres, languages, machinetypes) and passes them as initial props.
  - Keeps client interactivity for subsequent searches/filters.
- Labels index (/zxdb/labels):
  - Server-renders first page of empty search and passes as initial props to skip the first fetch.
- Category lists:
  - Genres (/zxdb/genres), Languages (/zxdb/languages), Machine Types (/zxdb/machinetypes) now server-render their lists and export revalidate=3600.
  - Refactored list components to accept server-provided items; removed on-mount fetching.
- Links & prefetch:
  - Replaced remaining anchors with Next Link to enable prefetch where applicable.

Tech details
- Added revalidate=3600 to the index pages for ISR.
- Updated ZxdbExplorer to accept initial results and initial filter lists; skips first client fetch when initial props are present.
- Updated LabelsSearch to accept initial payload and skip first fetch in default state.
- Updated GenreList, LanguageList, MachineTypeList to be presentational components receiving items from server pages.

Notes
- Low-churn list APIs already emit Cache-Control for CDN; list pages now render instantly from server.
- Further polish (breadcrumbs, facet counts UI) can build on this foundation without reintroducing initial network waits.

Signed-off-by: Junie@lucy.xalior.com
2025-12-12 15:31:10 +00:00
ad77b47117 chore: commit pending ZXDB explorer changes prior to index perf work
Context
- Housekeeping commit to capture all current ZXDB Explorer work before index-page performance optimizations.

Includes
- Server-rendered entry detail page with ISR and parallelized DB queries.
- Node runtime for ZXDB API routes and params validation updates for Next 15.
- ZXDB repository extensions (facets, label queries, category queries).
- Cross-linking and Link-based prefetch across ZXDB UI.
- Cache headers on low-churn list APIs.

Notes
- Follow-up commit will focus specifically on speeding up index pages via SSR initial data and ISR.

Signed-off-by: Junie@lucy.xalior.com
2025-12-12 15:25:35 +00:00
3fe6f980c6 feat: integrate ZXDB with Drizzle + deep explorer UI; fix Next 15 dynamic params; align ZXDB schema columns
End-to-end ZXDB integration with environment validation, Drizzle ORM MySQL
setup, typed repositories, Zod-validated API endpoints, and a deep, cross‑
linked Explorer UI under `/zxdb`. Also update dynamic route pages to the
Next.js 15 async `params` API and align ZXDB lookup table columns (`text` vs
`name`).

Summary
- Add t3.gg-style Zod environment validation and typed `env` access
- Wire Drizzle ORM to ZXDB (mysql2 pool, singleton) and minimal schemas
- Implement repositories for search, entry details, label browsing, and
  category listings (genres, languages, machinetypes)
- Expose a set of Next.js API routes with strict Zod validation
- Build the ZXDB Explorer UI with search, filters, sorting, deep links, and
  entity pages (entries, labels, genres, languages, machinetypes)
- Fix Next 15 “sync-dynamic-apis” warning by awaiting dynamic `params`
- Correct ZXDB lookup model columns to use `text` (aliased as `name`)

Details
Env & DB
- example.env: document `ZXDB_URL` with readonly role notes
- src/env.ts: Zod schema validates `ZXDB_URL` as `mysql://…`; fails fast on
  invalid env
- src/server/db.ts: create mysql2 pool from `ZXDB_URL`; export Drizzle instance
- drizzle.config.ts: drizzle-kit configuration (schema path, mysql2 driver)

Schema (Drizzle)
- src/server/schema/zxdb.ts:
  - entries: id, title, is_xrated, machinetype_id, language_id, genretype_id
  - helper tables: search_by_titles, search_by_names, search_by_authors,
    search_by_publishers
  - relations: authors, publishers
  - lookups: labels, languages, machinetypes, genretypes
  - map lookup display columns from DB `text` to model property `name`

Repository
- src/server/repo/zxdb.ts:
  - searchEntries: title search via helper table with filters (genre, language,
    machine), sorting (title, id_desc), and pagination
  - getEntryById: join lookups and aggregate authors/publishers
  - Label flows: searchLabels (helper table), getLabelById, getLabelAuthoredEntries,
    getLabelPublishedEntries
  - Category lists: listGenres, listLanguages, listMachinetypes
  - Category pages: entriesByGenre, entriesByLanguage, entriesByMachinetype

API (Node runtime, Zod validation)
- GET /api/zxdb/search: search entries with filters and sorting
- GET /api/zxdb/entries/[id]: fetch entry detail
- GET /api/zxdb/labels/search, GET /api/zxdb/labels/[id]: label search and detail
- GET /api/zxdb/genres, /api/zxdb/genres/[id]
- GET /api/zxdb/languages, /api/zxdb/languages/[id]
- GET /api/zxdb/machinetypes, /api/zxdb/machinetypes/[id]

UI (App Router)
- /zxdb: Explorer page with search box, filters (genre, language, machine), sort,
  paginated results & links to entries; quick browse links to hubs
- /zxdb/entries/[id]: entry detail client component shows title, badges
  (genre/lang/machine), authors and publishers with cross-links
- /zxdb/labels (+ /[id]): search & label detail with "Authored" and "Published"
  tabs, paginated lists linking to entries
- /zxdb/genres, /zxdb/languages, /zxdb/machinetypes and their /[id] detail pages
  listing paginated entries and deep links
- Navbar: add ZXDB link

Next 15 dynamic routes
- Convert Server Component dynamic pages to await `params` before accessing
  properties:
  - /zxdb/entries/[id]/page.tsx
  - /zxdb/labels/[id]/page.tsx
  - /zxdb/genres/[id]/page.tsx
  - /zxdb/languages/[id]/page.tsx
  - /registers/[hex]/page.tsx (Registers section)
- /api/zxdb/entries/[id]/route.ts: await `ctx.params` before validation

ZXDB schema column alignment
- languages, machinetypes, genretypes tables use `text` for display columns;
  models now map to `name` to preserve API/UI contracts and avoid MySQL 1054
  errors in joins (e.g., entry detail endpoint).

Notes
- Ensure ZXDB helper tables are created (ZXDB/scripts/ZXDB_help_search.sql)
  — required for fast title/name searches and author/publisher lookups.
- Pagination defaults to 20 (max 100). No `select *` used in queries.
- API responses are `cache: no-store` for now; can be tuned later.

Deferred (future work)
- Facet counts in the Explorer sidebar
- Breadcrumbs and additional a11y polish
- Media assets and download links per release

Signed-off-by: Junie@lucy.xalior.com

Signed-off-by: Junie@lucy.xalior.com
2025-12-12 14:41:19 +00:00
dbbad09b1b chore: ZXDB env validation, MySQL setup, API & UI
This sanity commit wires up the initial ZXDB integration and a minimal UI to explore it.

Key changes:
- Add Zod-based env parsing (`src/env.ts`) validating `ZXDB_URL` as a mysql:// URL (t3.gg style).
- Configure Drizzle ORM with mysql2 connection pool (`src/server/db.ts`) driven by `ZXDB_URL`.
- Define minimal ZXDB schema models (`src/server/schema/zxdb.ts`): `entries` and helper `search_by_titles`.
- Implement repository search with pagination using helper table (`src/server/repo/zxdb.ts`).
- Expose Next.js API route `GET /api/zxdb/search` with Zod query validation and Node runtime (`src/app/api/zxdb/search/route.ts`).
- Create new app section “ZXDB Explorer” at `/zxdb` with search UI, results table, and pagination (`src/app/zxdb/*`).
- Add navbar link to ZXDB (`src/components/Navbar.tsx`).
- Update example.env with readonly-role notes and example `ZXDB_URL`.
- Add drizzle-kit config scaffold (`drizzle.config.ts`).
- Update package.json deps: drizzle-orm, mysql2, zod; devDeps: drizzle-kit. Lockfile updated.
- Extend .gitignore to exclude large ZXDB structure dump.

Notes:
- Ensure ZXDB data and helper tables are loaded (see `ZXDB/scripts/ZXDB_help_search.sql`).
- This commit provides structure-only browsing; future work can enrich schema (authors, labels, publishers) and UI filters.

Signed-off-by: Junie@lucy.xalior.com
2025-12-12 14:06:58 +00:00
4222eba8ba Ready to start adding SQL binding 2025-12-12 13:43:30 +00:00
79aabd9b62 Update, before adding massive new feature 2025-12-12 13:28:51 +00:00
417fd997a7 feat(registers): deep‑linkable search via ?q=; docs: add docs/ and update README
- Register Explorer:
  - Sync search input with URL query param `q` for shareable deep links
  - Initialize search from `q` on load; update URL on input; remove `q` when cleared
  - Implemented with Next.js `useSearchParams`, `useRouter`, `usePathname`
  - File: src/app/registers/RegisterBrowser.tsx

- Documentation:
  - Add docs/ hub and initial guides
    - docs/index.md (docs index)
    - docs/getting-started.md (install/dev/build/start/lint/deploy)
    - docs/architecture.md (structure, theming, styling, key paths, scripts)
    - docs/registers.md (Register Explorer overview, search, deep links, implementation notes)
  - Rewrite README.md with project overview, features, quick start, scripts, and links to docs

Notes:
- Dev server uses port 4000 (Turbopack) via package.json
- Example deep link: /registers?q=vram

Date: 2025-12-11 13:11 (Junie@lucy.xalior.com)
2025-12-11 13:11:56 +00:00
ea90d72252 Get Junie to propogate the search query to the URL, so we can deeplink searches 2025-12-11 12:12:27 +00:00
ba8ac35f74 Bump next to handle security holes 2025-12-04 11:48:43 +00:00
0a71b5f62e feat(parser): add multi-line footnote support to default register description parser
i
Authored by Junie (AI assistant), not the user. Date: 2025-11-13 15:29 local.

What I changed
•
Implemented multi-line footnote parsing in src/utils/register_parsers/reg_default.ts.
•
Centralized footnote detection so it works both inside and outside access sections (R), (W), (R/W).
•
Added a small parsing state machine for footnotes:
◦
inFootnote: tracks whether we’re currently inside a footnote block.
◦
footnoteBaseIndent: indentation level of the * line that starts the footnote.
◦
currentFootnote: Note: accumulates continued text for the active footnote.
•
When a line starts with *, create a Note and push it to the appropriate collection:
◦
Within an access block → accessData.notes.
◦
Outside an access block → reg.notes.
•
Treat following, more-indented lines as continuations of the same footnote until indentation returns to the base level (or shallower). Continuation lines are appended to the note’s text with their content preserved (trailing spaces trimmed, at least one leading indent removed relative to the base).
•
Ensured any active footnote is closed if EOF is reached.
•
Preserved existing behavior for:
◦
Access sections (R), (W), (R/W) state transitions and finalization to detail.
◦
Bit operation parsing, including extracting trailing * references into footnoteRef.
◦
General text handling, comment skipping (//), and Issue 4 Only flag detection.
•
Minor cleanup: safe optional chaining when computing spaces_at_start.
Why I made these changes
•
The input documentation uses multi-line footnotes that continue on more-indented lines. Previously, only single-line footnotes were supported; continuation lines were misclassified as normal text or operation descriptions.
•
Using indentation to detect continuation cleanly models the authoring style and prevents footnote fragments from leaking into unrelated fields.
•
Centralizing footnote handling avoids duplicate logic and makes the parser more predictable and maintainable.
Notes/assumptions
•
Indentation strictly drives footnote continuation: a line is part of the footnote only if it’s more-indented than the opening * line; returning to the same or shallower indent ends the footnote.
•
Continuation lines remove at least one extra leading indent relative to the base to keep text readable; exact indentation preservation can be adjusted later if required.
•
Data model remains unchanged; only Note typing was imported in this file.
Impact and compatibility
•
No breaking API changes.
•
Behavior is unchanged for non-footnote content.
•
Other parsers unchanged.
Testing and verification
•
Manually exercised the parser against representative excerpts from data/nextreg.txt containing:
◦
Single-line and multi-line footnotes both globally and within access blocks.
◦
Footnote continuation lines with varying indentation.
◦
Bit operation lines with trailing * references.
•
Verified that:
◦
Footnotes aggregate expected text lines.
◦
Access block boundaries and operation parsing remain intact.
◦
Dangling footnotes at EOF are closed without error.
Follow-ups (optional)
•
If exact whitespace fidelity in footnote bodies is desired, adjust continuation concatenation to preserve full leading indentation after the base level.
•
Consider adding parser unit tests that cover footnote edge cases and indentation boundaries.
2025-11-13 15:31:02 +00:00
dd8794af60 GONE 2025-11-13 15:21:30 +00:00
374f4c044d Surpress hydration warning 2025-10-17 13:59:49 +01:00
052b14ca40 Let the server set the theme based on the cookie sent at request time, which should stop flashing 2025-10-17 13:39:25 +01:00
8e687fe176 Attempt 2 to add a darkmode 2025-10-17 12:38:22 +01:00
59d16ebde1 Attempt 1 to add a darkmode 2025-10-17 12:35:48 +01:00
8df71a6457 Manual fixes to GPTs search cache 2025-10-17 11:28:29 +01:00
0beba170a3 Fix dev runner 2025-10-17 11:27:33 +01:00
c306976f3a Adding notes for future work 2025-10-15 23:04:08 +01:00
5b39e84b02 Update parsers to handle more wikilink formats 2025-10-14 13:51:24 +01:00
7c4d93d7ba Fixing up wikilinks 2025-10-13 18:36:05 +01:00
9bc2557ff2 More whitespace, more footnotes, more Case Matching 2025-10-13 18:31:07 +01:00
1bc613dd4e Update whitespace and bullet point refs 2025-10-13 18:12:27 +01:00
d5253f073b Make searching just more robust, by making it a lot dumber 2025-10-13 15:27:55 +01:00
6ce8f6dbdc Make searching just more robust, by making it a lot dumber 2025-10-13 15:19:14 +01:00
ce95d7bcaf Adding more versatile searching 2025-10-13 13:08:52 +01:00
d721ca1758 Some **MANUAL** 😱 CSS changes 2025-10-10 21:14:50 +01:00
3ba737eb03 More whitespace changes 2025-10-10 21:00:50 +01:00
7031088bcd Moving towards a "custom" parser for NextReg 0xF0 2025-10-10 17:17:35 +01:00
20764d74d3 Moving towards multiple register parsers, to handle more exotic register types 2025-10-10 13:46:21 +01:00
5aa4c33059 Move parsers to unique files 2025-10-10 13:29:45 +01:00
f8745808b9 Adding source viewer to individual registers 2025-10-10 13:03:39 +01:00
cb3b9abaaa Adding 'source' to register types 2025-10-10 13:00:04 +01:00
4fb1cb1f8c Stop iOS turning bitfields into clickable phone numbers... 2025-10-10 12:56:46 +01:00
7c827975ae Move parser out to on demand (maybe move to on-startup, or on schedule, later) 2025-10-10 12:47:47 +01:00
029aea7f0c Manual building time 2025-10-08 14:58:48 +01:00
91ce41b4f0 Manual building time 2025-10-08 14:58:04 +01:00
3976210740 Manual building time 2025-10-08 14:57:31 +01:00
2685915dc7 Manual building time 2025-10-08 14:54:26 +01:00
bcfd0db2aa Manual building time 2025-10-08 14:52:41 +01:00
36ff2a6410 Manual building time 2025-10-08 14:52:23 +01:00
bf5bd7c69f Manual building time 2025-10-08 14:44:00 +01:00
c4e5c8619b Manual building time 2025-10-08 14:39:31 +01:00
05f260347a Manual building time 2025-10-08 14:36:56 +01:00