73 lines
No EOL
29 KiB
HTML
73 lines
No EOL
29 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Fractal Hush in Teal — exploration</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body { background: #0a0a0f; color: #3a3a4a; font-family: ui-monospace, monospace; overflow: hidden; }
|
|
#grid { padding: 20px; font-size: 12px; line-height: 1.4; white-space: pre; }
|
|
.c { display: inline-block; transition: all 0.3s; }
|
|
.c.active { color: #fde68a; text-shadow: 0 0 6px rgba(253,230,138,0.5); }
|
|
.c.strong { color: #34d399; text-shadow: 0 0 10px rgba(52,211,153,0.6); font-weight: bold; }
|
|
.c.dead { color: #1a1a2a; }
|
|
#info { position: fixed; bottom: 10px; left: 20px; color: #3a3a4a; font-size: 11px; }
|
|
#controls { position: fixed; top: 10px; right: 20px; color: #666; font-size: 11px; }
|
|
#controls span { cursor: pointer; margin-left: 12px; color: #fde68a; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="grid"></div>
|
|
<div id="info">neurameba · physarum exploration</div>
|
|
<div id="controls"><span id="play-btn">play</span><span id="reset-btn">reset</span></div>
|
|
<script>
|
|
const text = "# API Reference\n\nmotd is API-first. Every feature is an endpoint. Build clients, bots, integrations — whatever you want.\n\n## Base URL\n\n```\nhttps://motd.social/api\n```\n\nLocal dev: `http://localhost:3006/api`\n\n## Response Format\n\nEvery endpoint returns the same envelope:\n\n**Success:**\n```json\n{ \"ok\": true, \"data\": { ... } }\n```\n\n**Error:**\n```json\n{ \"ok\": false, \"error\": \"Something went wrong.\" }\n```\n\nHTTP status codes are standard: 200 success, 400 bad request, 401 unauthorized, 404 not found, 409 conflict.\n\n## Authentication\n\nMost endpoints require authentication. Get a token by registering or logging in, then send it as a Bearer token or let the browser handle it via cookies.\n\n**Header auth (for scripts and clients):**\n```\nAuthorization: Bearer <token>\n```\n\n**Cookie auth (for the web client):**\nThe login endpoints set an `motd_session` httpOnly cookie automatically.\n\nSessions expire after 7 days. Use `/login-permanently` in the web client to persist across tabs (stored in localStorage instead of sessionStorage — the token is the same).\n\n---\n\n## Auth\n\n### POST /api/auth/register\n\nCreate a new account.\n\n**Auth:** none\n\n**Body:**\n```json\n{ \"username\": \"alice\", \"password\": \"hunter2pwd\" }\n```\n\n**Rules:**\n- Username: 3-20 characters, letters, numbers, underscore only\n- Password: minimum 8 characters\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"token\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"user\": {\n \"username\": \"alice\",\n \"display_name\": \"alice\"\n }\n }\n}\n```\n\n**Errors:**\n- `400` — username or password missing, invalid format\n- `409` — username taken\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/auth/register \\\n -H \"Content-Type: application/json\" \\\n -d '{\"username\":\"alice\",\"password\":\"hunter2pwd\"}'\n```\n\n### POST /api/auth/login\n\nLog in to an existing account.\n\n**Auth:** none\n\n**Body:**\n```json\n{ \"username\": \"alice\", \"password\": \"hunter2pwd\" }\n```\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"token\": \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\",\n \"user\": {\n \"username\": \"alice\",\n \"display_name\": \"Alice\"\n }\n }\n}\n```\n\n**Errors:**\n- `400` — missing fields\n- `401` — invalid username or password\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/auth/login \\\n -H \"Content-Type: application/json\" \\\n -d '{\"username\":\"alice\",\"password\":\"hunter2pwd\"}'\n```\n\n### GET /api/auth/me\n\nGet the current authenticated user.\n\n**Auth:** required\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"user\": {\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"bio\": \"building things\",\n \"created_at\": \"2026-03-15T10:30:00.000Z\"\n }\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/auth/me \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n### POST /api/auth/logout\n\nEnd the current session.\n\n**Auth:** required\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"message\": \"Logged out.\" } }\n```\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/auth/logout \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n---\n\n## Profile\n\n### GET /api/profile/:username\n\nView a user's profile.\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"bio\": \"building things\",\n \"created_at\": \"2026-03-15T10:30:00.000Z\",\n \"posts\": 42,\n \"avatar\": [\n \"████ ████\",\n \" ████████ \",\n \"████████████\",\n \" ████████ \",\n \"██ ████ ██\"\n ]\n }\n}\n```\n\n**Errors:**\n- `404` — user not found\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/profile/alice\n```\n\n### PUT /api/profile\n\nUpdate your display name and/or bio.\n\n**Auth:** required\n\n**Body:**\n```json\n{ \"display_name\": \"Alice W.\", \"bio\": \"shipping code\" }\n```\n\nBoth fields are optional. Send only what you want to change.\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"username\": \"alice\",\n \"display_name\": \"Alice W.\",\n \"bio\": \"shipping code\",\n \"created_at\": \"2026-03-15T10:30:00.000Z\"\n }\n}\n```\n\n**Errors:**\n- `400` — nothing to update\n\n**Example:**\n```bash\ncurl -X PUT http://localhost:3006/api/profile \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"bio\":\"shipping code\"}'\n```\n\n### GET /api/profile/search?q=\n\nSearch users by username or display name.\n\n**Auth:** none\n\n**Params:**\n- `q` — search query (required, min 1 character)\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"users\": [\n { \"username\": \"alice\", \"display_name\": \"Alice\", \"bio\": \"building things\" },\n { \"username\": \"alice2\", \"display_name\": \"Alice Too\", \"bio\": null }\n ]\n }\n}\n```\n\n**Example:**\n```bash\ncurl \"http://localhost:3006/api/profile/search?q=alice\"\n```\n\n---\n\n## Posts\n\n### POST /api/posts\n\nPublish a post.\n\n**Auth:** required\n\n**Body:**\n```json\n{ \"content\": \"just shipped the wasm compiler [rust] [wasm]\" }\n```\n\n**Optional fields:**\n- `reply_to` — post ID to reply to\n\n**Inline commands:**\n- `/attach <media_id>` — attach previously uploaded media to the post. The `/attach` command is stripped from the displayed content.\n\n**Rules:**\n- Content: 1-500 characters\n- Tags use [brackets]: `[rust]`, `[music]`, `[coding]`\n- Tags are auto-extracted and stored\n- New tags are auto-assigned to the \"general\" category\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"id\": \"a3kf9x\",\n \"content\": \"just shipped the wasm compiler [rust] [wasm]\",\n \"reply_to\": null,\n \"tags\": [\"rust\", \"wasm\"],\n \"media_id\": null,\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"created_at\": \"2026-03-22T14:00:00.000Z\"\n }\n}\n```\n\n**Errors:**\n- `400` — empty content, too long, media not found/not yours\n- `404` — reply_to post not found\n\n**Examples:**\n\nSimple post:\n```bash\ncurl -X POST http://localhost:3006/api/posts \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"content\":\"just shipped the wasm compiler [rust] [wasm]\"}'\n```\n\nReply to a post:\n```bash\ncurl -X POST http://localhost:3006/api/posts \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"content\":\"nice work!\",\"reply_to\":\"a3kf9x\"}'\n```\n\nPost with media attachment:\n```bash\ncurl -X POST http://localhost:3006/api/posts \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"content\":\"screenshot of the new UI /attach x7km2p [showcase]\"}'\n```\n\n### GET /api/posts/feed\n\nGet the chronological feed. Public — works without auth. Authenticated users get kill-filtered results; guests get unfiltered posts (still subject to system-level filter_score suppression).\n\n**Auth:** optional\n\n**Params:**\n- `limit` — max posts to return (default 50, max 100)\n- `offset` — pagination offset (default 0)\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"posts\": [\n {\n \"id\": \"a3kf9x\",\n \"content\": \"just shipped the wasm compiler [rust] [wasm]\",\n \"reply_to\": null,\n \"tags\": [\"rust\", \"wasm\"],\n \"media_id\": null,\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"created_at\": \"2026-03-22T14:00:00.000Z\"\n }\n ]\n }\n}\n```\n\n**Examples:**\n```bash\n# Guest (unfiltered)\ncurl \"http://localhost:3006/api/posts/feed?limit=20\"\n\n# Authenticated (kill-filtered)\ncurl \"http://localhost:3006/api/posts/feed?limit=20\" \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n### GET /api/posts/:id\n\nGet a single post by ID.\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"id\": \"a3kf9x\",\n \"content\": \"just shipped the wasm compiler [rust] [wasm]\",\n \"reply_to\": null,\n \"tags\": [\"rust\", \"wasm\"],\n \"media_id\": null,\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"created_at\": \"2026-03-22T14:00:00.000Z\"\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/posts/a3kf9x\n```\n\n### GET /api/posts/:id/thread\n\nGet a post and all its replies.\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"post\": {\n \"id\": \"a3kf9x\",\n \"content\": \"just shipped the wasm compiler [rust] [wasm]\",\n \"reply_to\": null,\n \"tags\": [\"rust\", \"wasm\"],\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"created_at\": \"2026-03-22T14:00:00.000Z\"\n },\n \"replies\": [\n {\n \"id\": \"b7xm2k\",\n \"content\": \"nice work!\",\n \"reply_to\": \"a3kf9x\",\n \"tags\": [],\n \"username\": \"bob\",\n \"display_name\": \"Bob\",\n \"created_at\": \"2026-03-22T14:05:00.000Z\"\n }\n ]\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/posts/a3kf9x/thread\n```\n\n### GET /api/posts/search\n\nSearch posts by content. Searches active posts by default, or archived posts with the `archive` flag.\n\n**Auth:** none\n\n**Params:**\n- `q` — search query (required)\n- `archive` — set to `true` to search archived posts instead\n\n**Response (active):**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"posts\": [\n {\n \"id\": \"a3kf9x\",\n \"content\": \"just shipped the wasm compiler [rust] [wasm]\",\n \"tags\": [\"rust\", \"wasm\"],\n \"media_id\": null,\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"created_at\": \"2026-03-22T14:00:00.000Z\",\n \"archived\": false\n }\n ]\n }\n}\n```\n\n**Response (archive):**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"posts\": [\n {\n \"id\": \"b7xm2k\",\n \"content\": \"old post about [rust]\",\n \"tags\": [\"rust\"],\n \"username\": \"alice\",\n \"display_name\": \"Alice\",\n \"created_at\": \"2025-12-01T08:00:00.000Z\",\n \"archived\": true\n }\n ]\n }\n}\n```\n\n**Examples:**\n```bash\n# Search active posts\ncurl \"http://localhost:3006/api/posts/search?q=rust\"\n\n# Search archived posts\ncurl \"http://localhost:3006/api/posts/search?q=rust&archive=true\"\n```\n\n---\n\n## Filter (Kill)\n\nThe `/kill` command maps to the filter API. The word \"kill\" never appears in the database or API.\n\n### POST /api/filter\n\nAdd a filter. Hides a user or post from your feed.\n\n**Auth:** required\n\n**Body:**\n```json\n{ \"target_type\": \"user\", \"target_id\": \"bob\" }\n```\n\n- `target_type` — `\"user\"` or `\"post\"`\n- `target_id` — username (for users) or post ID (for posts)\n\nFiltering a user also increments their hidden `filter_score`. Users filtered by enough people get suppressed from everyone's feed silently (threshold: ~5 active filters, with 7-day half-life decay).\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"message\": \"Filtered.\" } }\n```\n\n**Errors:**\n- `400` — missing fields, invalid type, can't filter yourself\n- `404` — user not found\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/filter \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"target_type\":\"user\",\"target_id\":\"spammer\"}'\n```\n\n### GET /api/filter\n\nGet your current filter list.\n\n**Auth:** required\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"filters\": [\n { \"type\": \"user\", \"id\": \"uuid-of-filtered-user\" },\n { \"type\": \"post\", \"id\": \"b7xm2k\" }\n ]\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/filter \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n---\n\n## Media\n\nSupported formats: PNG (max 5MB), MP3 (max 10MB), MP4 (max 25MB).\n\nPNG uploads are processed into multiple variants: original (downscaled to max 1MB), thumbnail (80px wide), large (800px wide), and ASCII art.\n\n### POST /api/media/upload\n\nUpload a file.\n\n**Auth:** required\n\n**Body:** multipart/form-data with `file` field\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"media_id\": \"x7km2p\",\n \"type\": \"png\"\n }\n}\n```\n\n**Errors:**\n- `400` — no file, unsupported type, file too large\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/media/upload \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -F \"file=@screenshot.png\"\n```\n\n### GET /api/media/:id\n\nServe the original file.\n\n**Auth:** none\n\n**Response:** raw file with appropriate Content-Type header (`image/png`, `audio/mpeg`, `video/mp4`)\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/media/x7km2p -o image.png\n```\n\n### GET /api/media/:id/thumb\n\nServe the thumbnail (PNG only, max 80px wide).\n\n**Auth:** none\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/media/x7km2p/thumb -o thumb.png\n```\n\n### GET /api/media/:id/large\n\nServe the large version (PNG only, max 800px wide).\n\n**Auth:** none\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/media/x7km2p/large -o large.png\n```\n\n### GET /api/media/:id/ascii\n\nGet the ASCII art representation (PNG only).\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"ascii\": \" @@@@ \\n @ @ \\n @ @ \\n @@@@ \\n\"\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/media/x7km2p/ascii\n```\n\n---\n\n## Avatar\n\n### POST /api/avatar\n\nUpload a profile picture. PNG only, max 5MB. Processes into thumb, large, and ASCII art versions. Sets as your avatar immediately.\n\n**Auth:** required\n\n**Body:** multipart/form-data with `file` field\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"avatar_id\": \"x7km2p\" } }\n```\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/avatar \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -F \"file=@photo.png\"\n```\n\n### GET /api/avatar/:username\n\nGet a user's avatar image (large version, 800px max).\n\n**Auth:** none\n\n**Response:** raw PNG with `Content-Type: image/png`\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/avatar/alice -o avatar.png\n```\n\nReturns 404 if the user has no uploaded avatar.\n\n---\n\n## Bookmarks\n\nBookmarks are private. Nobody sees your bookmarks. No counts, no notifications. One concept for everything: users, tags, posts, docs.\n\n### POST /api/bookmarks\n\nAdd a bookmark.\n\n**Auth:** required\n\n**Body:**\n```json\n{ \"target_type\": \"user\", \"target_id\": \"alice\" }\n```\n\n- `target_type` — `\"user\"`, `\"tag\"`, `\"post\"`, or `\"doc\"`\n- `target_id` — username, tag name, post ID, or doc name\n\nBookmarking the same thing twice is a no-op, not an error.\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"message\": \"Bookmarked.\" } }\n```\n\n**Errors:**\n- `400` — missing fields, invalid type\n\n**Example:**\n```bash\n# Bookmark a user\ncurl -X POST http://localhost:3006/api/bookmarks \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"target_type\":\"user\",\"target_id\":\"alice\"}'\n\n# Bookmark a tag\ncurl -X POST http://localhost:3006/api/bookmarks \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"target_type\":\"tag\",\"target_id\":\"rust\"}'\n\n# Bookmark a post\ncurl -X POST http://localhost:3006/api/bookmarks \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"target_type\":\"post\",\"target_id\":\"a3kf9x\"}'\n\n# Bookmark a doc\ncurl -X POST http://localhost:3006/api/bookmarks \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"target_type\":\"doc\",\"target_id\":\"api\"}'\n```\n\n### DELETE /api/bookmarks\n\nRemove a bookmark.\n\n**Auth:** required\n\n**Body:**\n```json\n{ \"target_type\": \"user\", \"target_id\": \"alice\" }\n```\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"message\": \"Unbookmarked.\" } }\n```\n\n**Example:**\n```bash\ncurl -X DELETE http://localhost:3006/api/bookmarks \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"target_type\":\"user\",\"target_id\":\"alice\"}'\n```\n\n### GET /api/bookmarks\n\nList your bookmarks. Optionally filter by type.\n\n**Auth:** required\n\n**Params:**\n- `type` — optional: `user`, `tag`, `post`, or `doc`\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"bookmarks\": [\n { \"type\": \"user\", \"id\": \"alice\" },\n { \"type\": \"tag\", \"id\": \"rust\" },\n {\n \"type\": \"post\",\n \"id\": \"a3kf9x\",\n \"preview\": \"just shipped the wasm compiler...\",\n \"username\": \"alice\"\n },\n {\n \"type\": \"post\",\n \"id\": \"old123\",\n \"preview\": \"this was archived...\",\n \"archived\": true\n },\n {\n \"type\": \"post\",\n \"id\": \"gone99\",\n \"expired\": true\n },\n { \"type\": \"doc\", \"id\": \"api\" }\n ]\n }\n}\n```\n\nPost bookmarks are enriched with a content preview (60 chars), the author's username, and status flags (`archived`, `expired`) when applicable.\n\n**Examples:**\n```bash\n# All bookmarks\ncurl http://localhost:3006/api/bookmarks \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n\n# Only bookmarked tags\ncurl \"http://localhost:3006/api/bookmarks?type=tag\" \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n---\n\n## Docs\n\n### GET /api/docs\n\nList all available documentation files.\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"docs\": [\n { \"name\": \"about\", \"path\": \"docs/about.md\" },\n { \"name\": \"api\", \"path\": \"docs/api.md\" },\n { \"name\": \"commands\", \"path\": \"docs/commands.md\" },\n { \"name\": \"changelog\", \"path\": \"docs/changelog.md\" }\n ]\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/docs\n```\n\n### GET /api/docs/:name\n\nGet the contents of a specific document. The `.md` extension is optional.\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"name\": \"api\",\n \"content\": \"# API Reference\\n\\n...\"\n }\n}\n```\n\n**Errors:**\n- `400` — path traversal attempt\n- `404` — document not found\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/docs/api\n```\n\n---\n\n## Categories\n\n### GET /api/categories\n\nGet the category tree with tags. Used by `/tree -cat` in the client.\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"categories\": [\n {\n \"id\": \"coding\",\n \"name\": \"coding\",\n \"tags\": [\"rust\", \"python\", \"wasm\", \"js\", \"frontend\", \"backend\"]\n },\n {\n \"id\": \"creative\",\n \"name\": \"creative\",\n \"tags\": [\"music\", \"art\", \"writing\", \"gamedev\"]\n },\n {\n \"id\": \"meta\",\n \"name\": \"meta\",\n \"tags\": [\"motd\", \"bugs\", \"ideas\", \"feedback\"]\n },\n {\n \"id\": \"general\",\n \"name\": \"general\",\n \"tags\": [\"offtopic\", \"introductions\", \"showcase\"]\n }\n ]\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/categories\n```\n\n---\n\n## Commands\n\n### GET /api/commands\n\nGet the full command list grouped by category. Used by `/help` and `/menu` in the client.\n\n**Auth:** none\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"categories\": [\n {\n \"name\": \"General\",\n \"commands\": [\n { \"command\": \"/help\", \"description\": \"Show all available commands\" },\n { \"command\": \"/menu\", \"description\": \"Toggle the command menu\" },\n { \"command\": \"/clear\", \"description\": \"Clear the terminal\" },\n { \"command\": \"/read [path]\", \"description\": \"Read a document\" },\n { \"command\": \"/tree -cat\", \"description\": \"Browse categories and tags\" },\n { \"command\": \"/link [target]\", \"description\": \"Navigate to user, tag, post, or doc\" }\n ]\n }\n ]\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/commands\n```\n\n---\n\n## Telegram Connect\n\n### POST /api/connect/telegram\n\nGenerate a Telegram deep link to connect your account.\n\n**Auth:** required\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"link\": \"https://t.me/motdsocial_bot?start=alice_a8f3k2\",\n \"expires_in\": 600\n }\n}\n```\n\nIf already connected:\n```json\n{\n \"ok\": true,\n \"data\": {\n \"already_connected\": true,\n \"message\": \"Telegram already connected.\"\n }\n}\n```\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/connect/telegram \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n### DELETE /api/connect/telegram\n\nDisconnect your Telegram account.\n\n**Auth:** required\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"message\": \"Telegram disconnected.\" } }\n```\n\n**Example:**\n```bash\ncurl -X DELETE http://localhost:3006/api/connect/telegram \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n### POST /api/connect/email\n\nSend a verification email to connect your email address.\n\n**Auth:** required\n\n**Body:**\n```json\n{ \"email\": \"you@gmail.com\" }\n```\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"message\": \"Verification email sent to you@gmail.com\",\n \"tip\": \"Tip: add noreply@motd.social to your contacts so notifications don't go to spam.\"\n }\n}\n```\n\n**Example:**\n```bash\ncurl -X POST http://localhost:3006/api/connect/email \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"email\":\"you@gmail.com\"}'\n```\n\n### GET /api/connect/email/verify\n\nVerify email address from link in verification email.\n\n**Auth:** none (link from email)\n\n**Params:**\n- `code` — verification code from the email link\n\nReturns an HTML confirmation page on success.\n\n### DELETE /api/connect/email\n\nDisconnect your email address.\n\n**Auth:** required\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"message\": \"Email disconnected.\" } }\n```\n\n**Example:**\n```bash\ncurl -X DELETE http://localhost:3006/api/connect/email \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n### GET /api/connect/status\n\nCheck your Telegram and email connection status and notification settings.\n\n**Auth:** required\n\n**Response:**\n```json\n{\n \"ok\": true,\n \"data\": {\n \"telegram\": {\n \"connected\": true,\n \"username\": \"alice_tg\",\n \"notify\": true,\n \"notify_bookmarks\": true,\n \"notify_mentions\": true\n },\n \"email\": {\n \"connected\": true,\n \"address\": \"alice@gmail.com\",\n \"notify\": true,\n \"notify_bookmarks\": true,\n \"notify_mentions\": true\n }\n }\n}\n```\n\n**Example:**\n```bash\ncurl http://localhost:3006/api/connect/status \\\n -H \"Authorization: Bearer YOUR_TOKEN\"\n```\n\n---\n\n## Account\n\n### DELETE /api/account\n\nPermanently delete your account. This is irreversible. Deletes all posts, media, sessions, and user data.\n\n**Auth:** required\n\n**Body:**\n```json\n{ \"confirm_username\": \"alice\" }\n```\n\nThe `confirm_username` must match your actual username.\n\n**Response:**\n```json\n{ \"ok\": true, \"data\": { \"message\": \"Account terminated.\" } }\n```\n\n**Errors:**\n- `400` — username confirmation doesn't match\n\n**Example:**\n```bash\ncurl -X DELETE http://localhost:3006/api/account \\\n -H \"Authorization: Bearer YOUR_TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"confirm_username\":\"alice\"}'\n```\n";
|
|
const passes = [{"t":0,"r":933,"c":2,"a":"hold","s":0.2722268179224736,"ps":9,"e":100.82781454337979,"pr":1.1},{"t":0,"r":1068,"c":36,"a":"extend","s":0.42489483628409375,"ps":9,"e":71.43441108319092,"pr":1.1},{"t":0,"r":167,"c":0,"a":"died","s":0,"ps":8,"e":100,"pr":1},{"t":1,"r":933,"c":2,"a":"hold","s":0.24789993472819316,"ps":9,"e":101.46101402120533,"pr":1.1},{"t":1,"r":1068,"c":36,"a":"extend","s":0.47018144575923293,"ps":9,"e":51.692103854485346,"pr":1.1},{"t":1,"r":1068,"c":37,"a":"hold","s":0.19664377580559064,"ps":5,"e":31.43789781352655,"pr":1.2000000000000002},{"t":2,"r":933,"c":2,"a":"retracted","s":0.24789993472819316,"ps":8,"e":102.24421349903088,"pr":1.05},{"t":2,"r":1068,"c":36,"a":"extend","s":0.47018144575923293,"ps":8,"e":37.97748879439144,"pr":1.05},{"t":2,"r":1068,"c":37,"a":"hold","s":0.19279140635436884,"ps":4,"e":32.3802290643615,"pr":1.1500000000000001},{"t":2,"r":1068,"c":35,"a":"hold","s":0.3525127022592327,"ps":5,"e":24.2238604128533,"pr":1.2000000000000002},{"t":3,"r":1068,"c":36,"a":"extend","s":0.42489483628409375,"ps":8,"e":28.12365323926493,"pr":1.05},{"t":3,"r":1068,"c":37,"a":"retracted","s":0.19664377580559064,"ps":4,"e":33.35337927080623,"pr":1.1},{"t":3,"r":1068,"c":35,"a":"hold","s":0.36080804696698815,"ps":5,"e":26.360324788589203,"pr":1.2000000000000002},{"t":4,"r":1068,"c":36,"a":"extend","s":0.42489483628409375,"ps":7,"e":21.330968350676372,"pr":1},{"t":4,"r":1068,"c":35,"a":"retracted","s":0.36080804696698815,"ps":4,"e":28.646789164325106,"pr":1.1500000000000001},{"t":5,"r":1068,"c":36,"a":"extend","s":0.401124774909063,"ps":7,"e":16.44297658496421,"pr":1},{"t":5,"r":1068,"c":37,"a":"hold","s":0.14117002405636941,"ps":5,"e":9.521203771312258,"pr":1.1},{"t":6,"r":1068,"c":36,"a":"extend","s":0.401124774909063,"ps":6,"e":13.1263823489657,"pr":0.95},{"t":6,"r":1068,"c":37,"a":"hold","s":0.1870546712616784,"ps":5,"e":10.267641141405687,"pr":1.1},{"t":6,"r":1068,"c":35,"a":"hold","s":0.24641181958060135,"ps":5,"e":8.268284521629473,"pr":1.1},{"t":7,"r":1068,"c":36,"a":"hold","s":0.3474974071802458,"ps":6,"e":15.006361606407667,"pr":0.95},{"t":7,"r":1068,"c":37,"a":"retracted","s":0.1870546712616784,"ps":4,"e":11.164078511499113,"pr":1.05},{"t":7,"r":1068,"c":35,"a":"hold","s":0.27289061434187195,"ps":5,"e":9.701409436364449,"pr":1.1},{"t":8,"r":1068,"c":36,"a":"hold","s":0.3474974071802458,"ps":5,"e":17.036340863849635,"pr":0.8999999999999999},{"t":8,"r":1068,"c":35,"a":"retracted","s":0.27289061434187195,"ps":4,"e":11.284534351099424,"pr":1.05},{"t":9,"r":1068,"c":36,"a":"retracted","s":0.3205297295326896,"ps":5,"e":18.85057870011115,"pr":0.8999999999999999}];
|
|
const lines = text.split('\n');
|
|
const gridEl = document.getElementById('grid');
|
|
const charEls = [];
|
|
for (let r = 0; r < lines.length; r++) {
|
|
const row = [];
|
|
for (let c = 0; c < lines[r].length; c++) {
|
|
const s = document.createElement('span');
|
|
s.className = 'c';
|
|
s.textContent = lines[r][c];
|
|
row.push(s);
|
|
gridEl.appendChild(s);
|
|
}
|
|
charEls.push(row);
|
|
gridEl.appendChild(document.createTextNode('\n'));
|
|
}
|
|
let tick = -1, playing = false, iv;
|
|
function apply(t) {
|
|
for (const r of charEls) for (const e of r) e.className = 'c';
|
|
const active = new Map();
|
|
for (const p of passes) {
|
|
if (p.t > t) break;
|
|
const k = p.r+','+p.c;
|
|
if (p.a === 'died' || p.a === 'retracted') active.set(k, 'dead');
|
|
else if (p.ps > 16) active.set(k, 'strong');
|
|
else active.set(k, 'active');
|
|
}
|
|
for (const [k, cls] of active) {
|
|
const [r, c] = k.split(',').map(Number);
|
|
if (charEls[r]?.[c]) charEls[r][c].className = 'c ' + cls;
|
|
}
|
|
document.getElementById('info').textContent = 'tick ' + t + ' · ' + [...active.values()].filter(v=>v!=='dead').length + ' alive';
|
|
}
|
|
function play() {
|
|
if (playing) return;
|
|
playing = true;
|
|
document.getElementById('play-btn').textContent = 'pause';
|
|
const max = passes.length > 0 ? passes[passes.length-1].t : 0;
|
|
iv = setInterval(() => { tick++; if (tick > max) { pause(); return; } apply(tick); }, 900);
|
|
}
|
|
function pause() { playing = false; clearInterval(iv); document.getElementById('play-btn').textContent = 'play'; }
|
|
function reset() { pause(); tick = -1; for (const r of charEls) for (const e of r) e.className = 'c'; document.getElementById('info').textContent = 'neurameba'; }
|
|
document.getElementById('play-btn').addEventListener('click', () => playing ? pause() : play());
|
|
document.getElementById('reset-btn').addEventListener('click', reset);
|
|
setTimeout(play, 1000);
|
|
</script>
|
|
</body>
|
|
</html> |