5407bf4dff
Deploy / deploy (push) Successful in 8m0s
A page is now an ordered list of independent blocks (analysis.page_block), no sections and no headings; every block has an id shown on the page so it can be pointed at. Paper detail pages use page "paper/<conf>/<ext_id>", analysis pages on /contents use "content/<node id>". - /api/blocks (list, replace a page, add) and /api/blocks/:id (get, patch, move, delete) - dynamic block types (stats, tool-table, paper-table, benchmark-table) are filled from the database at render time; the two content pages are rendered from their blocks (seeded with defaults on first view) - one-time migration copies the legacy articles into blocks (section titles dropped, links become a links block); legacy tables are kept untouched - old /api/articles, ArticleView and PaperGroup removed Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FbMbJPadPzVwvt9rU9GBNo
21 lines
897 B
TypeScript
21 lines
897 B
TypeScript
import { route, bodyObject, HttpError } from '../../../lib/api';
|
|
import { deleteBlock, getBlock, patchBlock } from '../../../lib/block-store';
|
|
|
|
export const config = { api: { bodyParser: { sizeLimit: '8mb' } } };
|
|
|
|
const id = (req: { query: Record<string, string | string[] | undefined> }) => {
|
|
const n = Number(req.query.id);
|
|
if (!Number.isInteger(n) || n < 1) throw new HttpError(400, 'block id must be a positive integer');
|
|
return n;
|
|
};
|
|
|
|
// GET /api/blocks/:id one block
|
|
// PATCH /api/blocks/:id {"data": {...}} replaces the data; {"set": {"key": value|null}} changes some keys; {"type": ...} changes the type;
|
|
// {"after": id} or {"before": id} moves it within its page
|
|
// DELETE /api/blocks/:id
|
|
export default route({
|
|
GET: (req) => getBlock(id(req)),
|
|
PATCH: (req) => patchBlock(id(req), bodyObject(req)),
|
|
DELETE: (req) => deleteBlock(id(req)),
|
|
});
|