431 Commits

Author SHA1 Message Date
xfy
facb75d632 feat: make HTTP compression algorithms configurable via COMPRESSION_ALGORITHMS
Some checks failed
CI / check (push) Failing after 6m57s
CI / build (push) Has been skipped
2026-06-17 16:38:41 +08:00
xfy
31d5a99d2a Merge cleanup/redundancies: remove dead comment code and duplicate DB indexes
Some checks failed
CI / check (push) Failing after 7m33s
CI / build (push) Has been skipped
2026-06-17 15:24:47 +08:00
xfy
70e61ab65d docs: explain why ConnectInfo is optional for image routes 2026-06-17 15:16:26 +08:00
xfy
018b3876b7 fix: return 404 for bare /uploads path and correct CHANGELOG 2026-06-17 14:47:22 +08:00
xfy
2d45e0991b docs: clarify image cache invalidation behavior 2026-06-17 14:22:20 +08:00
xfy
dc7eb77fad docs: document image cache-control defaults 2026-06-17 14:19:42 +08:00
xfy
abdfd2e3f9 fix: make If-None-Match comparison RFC 7232 compliant 2026-06-17 14:14:37 +08:00
xfy
27ce878771 feat: support If-None-Match 304 for image responses 2026-06-17 14:08:45 +08:00
xfy
21b665f41d feat: add Cache-Control and ETag headers for image responses 2026-06-17 13:59:17 +08:00
xfy
fe6e5bd045 perf: offload image decode/resize/encode to spawn_blocking 2026-06-17 13:52:05 +08:00
xfy
b48590ced3 feat: add compression and timeout middleware, skip uploads and image routes 2026-06-17 13:45:55 +08:00
xfy
7bad3ce382 fix: make ConnectInfo optional in serve_image to prevent 500 2026-06-17 13:40:17 +08:00
xfy
28fd38e6b8 docs(plan): remove stale references to removed comment APIs 2026-06-17 13:11:53 +08:00
xfy
3df6633428 chore(deps): update Cargo.lock after removing http-body-util 2026-06-17 13:11:53 +08:00
xfy
48888a9886 feat(migrations): add cleanup migration for duplicate indexes 2026-06-17 13:11:53 +08:00
xfy
08895f504e refactor(migrations): remove duplicate idx_tags_name and idx_post_tags_tag_id 2026-06-17 13:11:53 +08:00
xfy
73aa680202 refactor(migrations): remove redundant idx_posts_slug index 2026-06-17 13:11:53 +08:00
xfy
36055f99fa chore(deps): remove unused http-body-util and tower-http dependencies 2026-06-17 13:11:52 +08:00
xfy
260b26c693 deps: add tower-http for compression, timeout, trace middleware 2026-06-17 13:03:59 +08:00
xfy
d1c9cea683 refactor(cache): remove unused per-post comment count cache 2026-06-17 11:52:57 +08:00
xfy
07cb0a5b0d refactor(comments): stop invalidating removed comment count cache in updates 2026-06-17 11:45:49 +08:00
xfy
a7fb8405c3 refactor(comments): stop invalidating removed comment count cache 2026-06-17 11:43:16 +08:00
xfy
a4954a6c1b refactor(comments): remove unused CommentCountResponse and PendingCommentsResponse 2026-06-17 11:39:12 +08:00
xfy
fc9fce1f4d refactor(comments): remove dead re-exports from comments module 2026-06-17 11:30:14 +08:00
xfy
472d8e91fa refactor(comments): remove unused get_comment_count server function 2026-06-17 11:26:50 +08:00
xfy
0545412cf3 refactor(comments): remove unused get_pending_comments server function 2026-06-17 11:23:00 +08:00
xfy
d826afbe15 fix(db): 为 deadpool-postgres 连接池指定 Tokio1 runtime
Some checks failed
CI / check (push) Failing after 6m5s
CI / build (push) Has been skipped
2026-06-17 11:07:23 +08:00
xfy
b045a1b978 fix build errors 2026-06-17 10:52:01 +08:00
xfy
2c1190d8fb 移除 SSR HTML minify 中间件及相关工具
Some checks failed
CI / check (push) Failing after 5m21s
CI / build (push) Has been skipped
2026-06-17 10:43:09 +08:00
xfy
476fad27e5 fix(minify): preserve Dioxus hydration markers and remove unsafe per-URL cache
- Keep Dioxus SSR comments (<!--#-->, <!--node-id<N>-->, <!--placeholder-->)

  during HTML minification to avoid hydration failures.

- Drop the per-URL minify cache in the Axum middleware: the same URL can

  render differently for logged-in vs anonymous users, so URL-level caching

  risks leaking admin UI into public responses.

- Let the middleware handle HTML minification once instead of minifying in

  markdown rendering as well.

- Consolidate CSS comment stripping into the existing minify_css path and

  add a benchmark for html_minify.
2026-06-17 10:43:09 +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
bd659c5b4f perf: add HTML/CSS minification for SSR responses and highlight CSS
Some checks failed
CI / check (push) Failing after 5m54s
CI / build (push) Has been skipped
- Add lol_html-based HTML whitespace minifier (utils/html_minify.rs)
  that collapses whitespace and strips comments while preserving
  <pre>, <code>, <textarea>, <script>, <style> content
- Add Axum middleware (middleware/minify_html.rs) that minifies
  text/html responses with per-URL moka cache (256 entries, 300s TTL)
- Wire middleware into the server router in main.rs
- Add CSS minifier to generate_highlight_css build step
- Apply minify_html to rendered markdown output and TOC
- Add http-body-util dependency for body collection in middleware
2026-06-17 09:49:44 +08:00
xfy
ae84c37f21 build: add Dockerfile and .dockerignore for static musl image
Some checks failed
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
- Multi-stage build using rust:1.96-bookworm builder and scratch runtime.
- Produces a fully statically linked x86_64-unknown-linux-musl server binary.
- Builds frontend assets (Tiptap, Tailwind, Dioxus WASM) and bundles public/.
- Image size ~25 MB; server listens on 0.0.0.0:3000.
2026-06-17 09:48:12 +08:00
xfy
56adbcf227 build: strip symbols from release binaries
Some checks failed
CI / check (push) Failing after 6m6s
CI / build (push) Has been skipped
2026-06-16 17:53:05 +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
2caca3a48d fix(dead_code): 清理假阳性与真死代码
Some checks failed
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
- settings.rs: retention 常量与 clamp_retention 仅服务端使用,加 #[cfg(feature = "server")]
- comment.rs: 删除未使用的 Comment 结构体
- cache.rs: 删除未使用的 invalidate_all_comment_caches 及其测试

验证: cargo check (server/wasm), cargo test (311 passed), dx check, cargo clippy
2026-06-16 17:48:47 +08:00
xfy
7d713cabc2 docs: document server-only optional dependencies in AGENTS.md
Some checks failed
CI / check (push) Failing after 5m15s
CI / build (push) Has been skipped
2026-06-16 17:32:04 +08:00
xfy
1a56c0cd3f test: gate AppError helper tests behind server feature
Some checks failed
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
2026-06-16 17:28:43 +08:00
xfy
a06e4a5b9d build: remove uuid js feature and commit Cargo.lock updates 2026-06-16 17:21:22 +08:00
xfy
2dcd300930 build: allow dead_code on CommentCountResponse for WASM builds 2026-06-16 17:12:35 +08:00
xfy
1444ccef86 build: make sha2 and hex optional and gated by server feature 2026-06-16 17:11:15 +08:00
xfy
fa5216c6c5 build: make http optional and gated by server feature 2026-06-16 17:10:52 +08:00
xfy
d246adbb32 build: make rand optional and remove explicit getrandom dependency 2026-06-16 17:10:27 +08:00
xfy
726c6ec4e5 build: make pulldown-cmark optional and gated by server feature 2026-06-16 17:09:39 +08:00
xfy
6489ac604e build: make regex optional and gated by server feature 2026-06-16 17:09:16 +08:00
xfy
837f120621 build: make uuid optional and gated by server feature 2026-06-16 17:08:48 +08:00
xfy
6a98e8767d build: make argon2 optional and gated by server feature 2026-06-16 17:08:19 +08:00
xfy
cafbddb861 refactor: replace server-only dead_code allows with cfg(feature = "server")
Replace #[allow(dead_code)] on server-only helpers with #[cfg(feature = "server")]
to make the server/WASM split explicit and avoid compiling unused server logic
into the WASM frontend.

- Gate password/session/auth/comment helpers and model parsers with server feature
- Gate related imports and tests accordingly
- Remove genuinely unused CreatePostRequest and CreateCommentRequest
- Keep #[allow(dead_code)] for true dead code (stub methods, unused public APIs)
- Use #[cfg(any(target_arch = "wasm32", test))] for THEME_KEY
- Update AGENTS.md note
2026-06-16 16:45:08 +08:00
xfy
b7afd12538 fix(highlight): 大小写不敏感的语法名称匹配,修复 haskell 等高亮失效
Some checks failed
CI / check (push) Failing after 25m52s
CI / build (push) Has been skipped
2026-06-16 16:20:21 +08:00
xfy
6ce8915e6c fix(editor): 修复 focus() 把源码视图滚动到底部
切换到源码模式时 sourceTextarea.focus() 会触发浏览器将光标
所在行滚动进可视区域,光标默认在内容末尾,导致 textarea 被
拉到底部覆盖已设的滚动位置。改为 focus 后立即恢复 scrollTop。

同时移除调试日志。
2026-06-16 16:13:46 +08:00