27 Commits

Author SHA1 Message Date
xfy
a0067c73d6 chore(core): yggdrasil-core 接入构建管线与全局注入
Dioxus.toml 追加 yggdrasil-core 的 css/script;Makefile 加
build-core / build-core-incremental,接入 build/build-linux/dev/test。
2026-06-26 13:58:54 +08:00
xfy
2b5cd5f64f docs(makefile): cargo doc 默认使用 ayu 主题
通过 RUSTDOCFLAGS="--default-theme=ayu" 透传给 rustdoc,生成产物
根节点写入 data-theme="ayu"。默认值语义:浏览器未记住主题时生效。
2026-06-26 10:17:12 +08:00
xfy
96da2f27d5 docs: 补齐 tiptap_bridge 文档注释并新增 make doc 目标
- tiptap_bridge.rs: 为 wasm-bindgen 桥接层全部 19 处 pub 项补文档
  (JS 类型映射、getter/setter、EditorHandle::new、pub use 重导出)
- markdown.rs: 用反引号包裹注释内字面量 <span>,消除 rustdoc 警告
- Makefile: 新增 doc / doc-open,纯 binary crate 需 --document-private-items
  才能让内部模块进文档
2026-06-25 18:26:56 +08:00
xfy
05e2989278 build(lightbox): use npm install (npm 11 ci rejects cross-platform rolldawn optional deps) 2026-06-24 11:18:40 +08:00
xfy
adf9e9cf07 build: add build-lightbox targets, wire into build/build-linux/dev/test 2026-06-24 11:06:03 +08:00
xfy
368a651fa6 build: make test runs both cargo test and vitest 2026-06-24 10:14:20 +08:00
xfy
ef6a3f0da2 fix(home,editor): repair post card nested anchors and editor upload state
首页审查修复(home/post_card/image_viewer/search/home_skeleton):
- PostCard 消除嵌套 <a>:外层 Link 包裹改为绝对定位覆盖层链接,
  标题/摘要/封面降级为普通元素,标签用 z-10 叠在覆盖层之上并
  stop_propagation,整卡点击跳转文章详情。
- ImageViewer 新增 lightbox prop(默认 true),卡片封面传 false
  禁用灯箱以归一为单一跳转交互;文章详情页零改动。
- home.rs 越界页码守卫:分页仅在 total>0 渲染,避免 /page/9999
  出现孤立空分页;错误文案脱敏为"加载失败"。
- search.rs 错误文案脱敏为"搜索失败",与首页/标签页一致。
- HomeSkeleton 卡片 5→10,对齐 POSTS_PER_PAGE。

编辑器上传重构(write/tiptap_bridge):
- consume_upload_event 改用 upload_errors Vec 自身判重,移除
  seen_error_ids 副本状态;Signal 参数加 mut 修复 E0596 编译错误。
- make_upload_closure 构造阶段错误以 rejected Promise 返回而非
  panic,单张坏文件不再拖垮整个编辑器。
- write.rs 移除未用的 success signal,编辑保存后统一跳转 Posts,
  标签分隔符支持半角/全角逗号与分号,提取 META_*_CLASS 常量去重。
- Makefile dev 目标清理 static/ 目录。
2026-06-23 14:14:28 +08:00
xfy
ad0d884065 fix(makefile): disable SSR cache in dev to avoid stale rendered HTML
dx serve 热重载(重新编译代码)不会清除进程内的 IncrementalRenderer
缓存(DashMap<Uri, CachedHTML> in-process)。改了 SSR 渲染逻辑(如
markdown 渲染、组件结构)后,即使二进制重新编译了,dev server 仍返回
进程启动时缓存的旧 HTML,直到 TTL(默认 3600s)过期。

坑: Ctrl+C 重启 make dev 时,如果 dx serve 子进程没被真正杀掉(进程
PID 不变),内存缓存持续存在。表现为"代码改了但页面不变"。

修复: dev target 给 dx serve 加 SSR_CACHE_SECS=0,禁用 SSR 缓存。
每次请求都重新渲染,改代码立即生效。仅影响 dev,不影响生产构建。
2026-06-23 09:33:13 +08:00
xfy
6ff37322b2 feat(editor): add image upload to slash command and build tiptap in make dev
斜杠命令图片上传 + Makefile dev 构建修复

1. 斜杠命令接入图片上传管线
   - slash-command.ts: SlashCommand 扩展改为 Extension.create<Options>,
     新增 onImageUpload 选项;原单一"图片"命令拆成两个:
     · "上传图片"(📤): 仅在 onImageUpload 可用时出现,触发原生文件选择器
       (accept 限定 jpeg/png/gif/webp,与 upload 端点 MIME 一致),
       上传成功后 setImage 插入,失败 console.error(与 FileHandler 一致)
     · "图片链接"(🖼): 保留原 window.prompt URL 方式
   - index.ts: SlashCommand.configure({ onImageUpload }) 透传宿主回调,
     复用 write.rs 已注入的 /api/upload 管线,无需 Rust 端改动

2. Makefile: make dev 不再忽略 tiptap 构建
   - 根因: 原 dev target 只起 tailwindcss watch + dx serve,从不构建
     tiptap 编辑器,导致 dev server 始终 serve 上次 make build 残留的
     旧 editor.js(本次新增的"上传图片"命令在 dev 下永远不生效)
   - 新增 build-editor-incremental target (跳过 npm ci,直接 vite build,~1s)
   - dev 现在依赖 build-editor-incremental,启动前先增量构建编辑器

3. Makefile: clean 不再删 public/tiptap
   - public/tiptap 是跨子项目(npm)构建产物,删除后必须重跑 make build-editor
     (含 npm ci) 才能恢复;原 clean 会删它是陷阱(make clean && make dev
     会导致编辑器直接消失)。现在 clean 只清 Rust 产物和缓存
2026-06-22 14:18:05 +08:00
xfy
449a545886 security: fix critical issues from repository review
Some checks failed
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
P0 blockers:
- Fix migration numbering conflict and duplicate indexes
- Change comments.post_id FK to ON DELETE CASCADE
- Restrict public post detail endpoint to published posts only
- Fix rate-limiting IP extraction and fallback to ConnectInfo
- Harden HTML sanitizer: deny unknown URL schemes, restrict data URIs
- Remove session token from login response body
- Enforce image pixel/dimension limits on upload and serving

P1 high-risk:
- Validate uploads by magic bytes and decode GIF/WebP
- Add pagination/rate-limiting to search, tag posts, and comments
- Make first-admin registration and slug uniqueness check atomic
- HTML-escape comment author fields
- Improve HTML minify cache key and skip admin/error responses
- Add mobile navigation menu

P2 accessibility/quality:
- Associate form labels with inputs
- Key PostDetail article by slug to re-init scripts on navigation
- Improve image viewer keyboard accessibility
- Make theme toggle SSR-friendly and add aria-label
- Invalidate slug 404 cache on create and pending count on new comment
- Deduplicate tags case-insensitively

P3 cleanup:
- Remove unused tower-http dependency, expand make clean
- Configure DB pool timeouts and verified recycling
- Run background cleanup tasks immediately on startup
- Use SHA-256 for stable disk cache keys
- Log DB errors with Display instead of Debug
- Update README migration instructions

All tests pass (321), clippy clean, dx check clean.
2026-06-17 10:34:14 +08:00
xfy
0159b2321a fix(build): make build-linux produce a statically linked musl binary
- Work around Dioxus 0.7.9 leaking getrandom_backend=wasm_js cfg into
  the musl server build by disabling DX's auto flag and setting it only
  for wasm32 in .cargo/config.toml.
- Split build-linux into @client and @server steps so the server build
  can explicitly enable the server feature and target
  x86_64-unknown-linux-musl.
- Configure the musl linker to use x86_64-linux-musl-gcc.
2026-06-16 17:53:05 +08:00
xfy
b37e33dbf4 fix(build): 修复 Tailwind v4 与 Tiptap 编辑器构建
Tailwind v4 将 CLI 拆为独立包 @tailwindcss/cli,核心包 tailwindcss
不再带 bin,npx tailwindcss 会因找不到可执行入口而失败;即便改用
@tailwindcss/cli,npx 装到全局缓存,@import "tailwindcss" 仍解析不到
./node_modules/tailwindcss。回到直接调用 PATH 上的 tailwindcss 二进制
(brew 安装或 CI 的 npm i -g @tailwindcss/cli),这也是 v4 升级时的
原始设计。

build-editor 中 npm ci 受全局 --omit=dev 影响会跳过 vite,npx vite
退而拉取 latest(v8,不兼容)。改用 npm ci --include=dev 确保装上
lock 钉死的 vite@5.4.21,并以 npm run build 走本地 .bin/vite,避免
npx 版本漂移。
2026-06-16 10:53:37 +08:00
xfy
6fe7dc3ff5 build: use npx tailwindcss instead of global binary
Some checks failed
CI / check (push) Successful in 8m46s
CI / build (push) Has been cancelled
2026-06-12 18:09:20 +08:00
xfy
b72bc512c2 chore(make): use npm ci for tiptap editor to avoid lockfile drift 2026-06-12 16:27:12 +08:00
xfy
28d3ed998a chore: optimize release profile for fullstack and add linux static build target
- Change opt-level from 'z' to 3 for better runtime performance
- Use thin LTO for faster compilation with similar results
- Remove panic=abort and strip=true to preserve server debuggability
- Add --debug-symbols=false to dx build for smaller WASM
- Add build-linux target for static musl binary
2026-06-09 10:30:36 +08:00
xfy
4f368e6fb8 test: add 122 unit tests across 12 modules
Cover utils/text, api/slug, auth/password, auth/session,
models/post, models/user, api/auth validation, api/markdown,
api/image, highlight, api/rate_limit. Add make test target.
2026-06-09 09:25:44 +08:00
xfy
0dbd07198b fix: remove leftover --wasm-split flag from dx serve dev command
Amends the wasm-split rollback by also cleaning up the dev server
flag that was missed in the previous revert commit.
2026-06-04 17:46:44 +08:00
xfy
f81656bb18 revert: disable wasm-split due to fullstack SSR incompatibility
wasm-split is incompatible with Dioxus fullstack SSR/hydration.
The feature causes hydration failures because split WASM chunks
are not available during client-side hydration of server-rendered HTML.

Changes reverted:
- Remove wasm-split feature from dioxus and dioxus-router
- Remove --wasm-split flag from dx build in Makefile
2026-06-04 17:44:33 +08:00
xfy
73fd3c30e2 build: remove obsolete WASM path fix and tracked index.html 2026-06-04 17:34:12 +08:00
xfy
a282d1dd29 feat: enable wasm-split for route-based code splitting
Enable Dioxus 0.7 automatic WASM bundle splitting by route:

- Add wasm-split feature to dioxus and dioxus-router in Cargo.toml
- Add --wasm-split flag to dx build in Makefile
- Router definitions stay as plain #[route] — splitting is automatic

Dioxus 0.7.9 handles splitting automatically when the feature and
CLI flag are enabled. Per-route #[wasm_split] attributes are not
required (and not supported by this version's derive macro).
2026-06-04 17:32:00 +08:00
xfy
cd45ab17de build: simplify tiptap build by setting fixed output filename in vite config 2026-06-04 16:26:25 +08:00
xfy
aebdcd6d99 fix(build): fix WASM 404 in production by creating symlinks in wasm/ directory 2026-06-04 11:34:13 +08:00
xfy
11261836c7 feat: add syntect code highlighting with catppuccin themes
- Add syntect dependency (server feature, fancy-regex backend)
- Create highlight module with LazyLock globals for SyntaxSet + themes
- Intercept CodeBlock events in markdown rendering for syntax highlighting
- Update ammonia whitelist to allow span/pre/code class/style attributes
- Add generate_highlight_css binary for CSS generation
- Add highlight-css Makefile target (runs before tailwindcss)
- Import generated highlight.css in input.css
- Remove hardcoded code block colors, let catppuccin CSS take over
2026-06-03 11:52:58 +08:00
xfy
5d523fbfc7 添加 dev 监听 0.0.0.0 2026-05-26 23:59:31 +08:00
xfy
f6d60520eb 集成 Tiptap Markdown 编辑器到文章撰写页面
- 新增 libs/tiptap-editor/ 打包子项目(Tiptap Core + StarterKit + Markdown)
- 构建产物输出到 public/tiptap/
- 替换原有的 textarea + pulldown_cmark 预览为 WYSIWYG 编辑器
- Makefile 新增 build-editor target
- Dioxus.toml 引入 editor.js 和 editor.css

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 17:46:04 +08:00
xfy
c2d5619855 移除首页,将根路径重定向到登录页,添加注册链接
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 10:22:05 +08:00
xfy
390ab98b86 升级 Tailwind CSS 到 v4 并简化构建流程
- 将 input.css 从 v3 的 @tailwind 指令迁移到 v4 的 @import "tailwindcss"
- 删除 tailwind.config.js(v4 不再需要配置文件)
- 删除 package.json(完全使用本地 tailwindcss CLI)
- 重新构建 public/style.css 为 v4 格式
- 添加 Makefile 提供 dev/build/css/css-watch/clean 命令

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 09:59:42 +08:00