745 Commits

Author SHA1 Message Date
xfy
c40a771989 feat(search): cache search results with short TTL 2026-06-17 17:20:54 +08:00
xfy
1d216faa2f feat(auth): add in-memory session cache 2026-06-17 17:20:47 +08:00
xfy
75b8f80631 fix(posts): wrap empty_trash in transaction and lock rows for precise invalidation 2026-06-17 17:05:07 +08:00
xfy
05b9a3a595 feat: enable all HTTP compression algorithms by default
Some checks failed
CI / check (push) Failing after 14m38s
CI / build (push) Has been skipped
- COMPRESSION_ALGORITHMS defaults to 'all' when unset

- Support 'none'/'off' to explicitly disable compression

- Add parse_compression_algorithms helper and unit tests

- Update .env.example comment to reflect new default
2026-06-17 17:03:17 +08:00
xfy
7bd02d0ea9 perf(cache): run tag post invalidations concurrently 2026-06-17 16:59:29 +08:00
xfy
2d8f1e0d98 refactor(posts): avoid redundant cache invalidation in bulk fallback paths 2026-06-17 16:59:24 +08:00
xfy
c77f751377 refactor(posts): apply precise invalidation limit to batch_restore_posts 2026-06-17 16:59:18 +08:00
xfy
ca212a2aab fix(posts): lock rows and read metadata in transaction for delete/purge/restore 2026-06-17 16:58:54 +08:00
xfy
634f733e36 feat: add Cache-Control headers for public pages and static assets
- Public SSR pages: public, max-age=300, stale-while-revalidate=3600

- Static assets (/_dioxus/, /wasm/, *.js, *.wasm, style.css, highlight.css): public, max-age=31536000, immutable

- API, admin, auth pages and non-GET/HEAD requests remain uncached

- Add unit tests for cache control path matching
2026-06-17 16:57:42 +08:00
xfy
1092fbb3ce fix(posts): ensure rebuild invalidates tag posts cache 2026-06-17 16:44:32 +08:00
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
c03093fc8b refactor(posts): use precise cache invalidation in rebuild 2026-06-17 16:37:20 +08:00
xfy
bb34e2c36e refactor(posts): use precise cache invalidation in trash operations 2026-06-17 16:37:20 +08:00
xfy
82b070e7ac refactor(posts): use precise cache invalidation in create/update/delete 2026-06-17 16:37:20 +08:00
xfy
c528936abb feat(cache): add invalidate_tag_posts_for helper 2026-06-17 16:37:20 +08:00
xfy
15e7e2578d refactor(utils): extract reading_time helper 2026-06-17 16:25:22 +08:00
xfy
e683efe0ea refactor(models): remove dead Post status methods, add PostListItem tests 2026-06-17 16:24:50 +08:00
xfy
9f41ea7354 refactor(posts): remove orphan row_to_post_list and use row_to_post_full for get_post_by_id 2026-06-17 16:24:38 +08:00
xfy
1eedab8f21 perf(posts): remove content_md from list/search SQL, read stored word counts 2026-06-17 16:06:27 +08:00
xfy
a6f08d5d3f feat(db): add word_count and reading_time columns to posts 2026-06-17 16:06:21 +08:00
xfy
51e20980db perf(stats): combine three COUNT queries into one conditional aggregation 2026-06-17 15:51:29 +08:00
xfy
170c021b37 feat(cache): add PostListItem DTO and use it in list/tag/search caches 2026-06-17 15:51:19 +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
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
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
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
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
2dcd300930 build: allow dead_code on CommentCountResponse for WASM builds 2026-06-16 17:12:35 +08:00
xfy
6489ac604e build: make regex optional and gated by server feature 2026-06-16 17:09:16 +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