62 Commits

Author SHA1 Message Date
xfy
14e4a26dc0 fix(api): use rendered HTML with anchors in row_to_post 2026-06-02 18:28:24 +08:00
xfy
5544ea0c18 feat(admin): add cover_image input field in write form 2026-06-02 18:22:22 +08:00
xfy
6b1f2e27c9 feat(components): add post page components (header, toc, content, footer, nav) 2026-06-02 18:21:25 +08:00
xfy
a07f6ca51b feat(style): add PaperMod theme variables and component styles 2026-06-02 18:18:40 +08:00
xfy
1088691dca feat(api): enhance markdown rendering with TOC, anchors, word count; add cover_image support; prev/next post navigation 2026-06-02 18:17:21 +08:00
xfy
203591ff65 feat(model): extend Post with cover_image, reading_time, word_count, toc_html, prev/next nav 2026-06-02 18:13:04 +08:00
xfy
cf783d8f6e feat(migration): add cover_image column to posts table 2026-06-02 18:12:45 +08:00
xfy
f3c1718cd0 feat: add use_delayed_loading hook to prevent skeleton flash 2026-06-02 17:53:04 +08:00
xfy
9c5b09a278 chore: code cleanup - formatting, EOF newlines, model helper, and UI tweaks 2026-06-02 17:33:28 +08:00
xfy
1950646bef feat: add shared components, new pages, and pagination 2026-06-02 17:33:28 +08:00
xfy
36231a8ec2 feat: add XSS sanitization with ammonia for markdown rendering 2026-06-02 17:33:28 +08:00
xfy
327738c2e0 refactor: replace post_status ENUM with TEXT + CHECK constraint 2026-06-02 17:33:28 +08:00
xfy
42ed54a752 feat: add database migration helper script 2026-06-02 17:33:28 +08:00
xfy
32e8407ed7 fix: use Debug format {:?} for database errors
tokio-postgres Display only shows 'db error', use {:?} for full error chain
2026-06-02 17:33:28 +08:00
xfy
5695b1c62b feat: add explicit error logging and startup validation
- Add DATABASE_URL validation on server startup (exit early with clear error)
- Add tracing::error! to all server functions in api/auth.rs
- Bulk add tracing::error! to all database error handlers in api/posts.rs
- Server 500 errors now log detailed context to terminal
2026-06-02 17:33:28 +08:00
xfy
b6cabe489f feat: migrate frontend to database-driven posts
- Replace hardcoded POSTS with API-driven data in home, archives, tags
- Add post detail page /post/:slug with HTML rendering
- Add admin posts management page with list and soft delete
- Update dashboard with real stats from database
- Add admin navigation for posts management
- Fix PartialEq derives for Post, Tag, PostStats models
- Use use_resource and use_memo for data fetching with proper loading states
2026-06-02 17:33:28 +08:00
xfy
df339cb084 feat: add post creation form to write.rs
- Add summary, slug, tags, status fields to editor
- Integrate create_post API with validation
- Add loading and error states
- Keep Tiptap editor initialization intact
2026-06-02 17:33:28 +08:00
xfy
973d6f3d57 feat: add posts, tags database schema and API
- Add migration 002_posts.sql with posts, tags, post_tags tables
- Add Post/Tag/PostStats models with PostStatus enum
- Add posts API with full CRUD:
  - create_post, update_post, delete_post (admin only)
  - get_post_by_slug, list_published_posts (public)
  - list_posts, get_post_stats (admin)
  - list_tags, get_posts_by_tag, search_posts (public)
- Slug auto-generation with uniqueness check
- Server-side markdown rendering with pulldown-cmark
- Auto-summary extraction from markdown
- Soft delete support
2026-06-02 17:33:28 +08:00
xfy
e48253c6f7 添加 AGENTS.md 项目开发指南文档 2026-06-02 17:33:28 +08:00
xfy
a58e0f4e3b 修复 Footer 组件滚动监听器未正确清理的问题 2026-06-02 17:33:28 +08:00
xfy
6ddc02a815 将 rust-analyzer 配置从 JSON 迁移为 TOML 格式
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 17:33:28 +08:00
xfy
b0bb94d184 添加 rust-analyzer 配置,排除无关目录以优化启动速度
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 17:33:28 +08:00
xfy
2b90fd05d6 将 session 清理错误日志改为 Debug 格式并忽略 tiptap 资源目录
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 17:33:28 +08:00
xfy
c924b1e643 修复编译器警告并改进代码质量 2026-06-02 17:33:28 +08:00
xfy
24b04ee638 修复请求日志不输出的问题
TraceLayer 默认使用 DEBUG 级别,被 INFO 过滤器过滤;且放在
serve_dioxus_application 之前会被其重建路由时丢弃。将级别提升
至 INFO 并移至 serve_dioxus_application 之后。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 17:33:28 +08:00
李林军
4093178fc3 添加tracing日志并重构服务器启动逻辑 2026-05-27 11:39:09 +08:00
xfy
9c834ba1df 添加骨架屏组件,优化 admin 路由切换和编辑器初始化体验
- AdminLayout 使用骨架屏替代简单"加载中"文字,保持布局结构一致避免闪烁
- WritePage 添加编辑器初始化骨架屏和就绪状态轮询
- 新增 admin_skeleton.rs 和 write_skeleton.rs 组件

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 09:25:26 +08:00
xfy
61376f6ba9 修复 admin 路由切换闪烁,全局替换原生导航为客户端路由
- 新增全局 UserContext,将用户认证状态提升到 App 级别缓存
- 将 /admin 和 /admin/write 改为嵌套路由,AdminLayout 作为共享父布局
- AdminLayout 使用 Outlet 渲染子页面,避免路由切换时重复挂载
- 修复所有原生 <a> 标签导致的整页刷新问题:
  - Header 导航栏 Logo 和 NavItem
  - 首页文章卡片、分页按钮
  - 归档页文章条目
  - 标签页标签云、文章卡片、标签链接
  - 登录/注册页面链接
  - Dashboard 快捷操作按钮

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 00:18:15 +08:00
xfy
5d523fbfc7 添加 dev 监听 0.0.0.0 2026-05-26 23:59:31 +08:00
xfy
0be0719fdb 将 session cookie 改为后端 HttpOnly 设置
- login 通过 Set-Cookie 响应头设置 HttpOnly cookie
- get_current_user 从请求 Cookie header 读取 token,匹配具体 session
- logout 通过 Set-Cookie 清除 cookie,并删除对应 session
- 移除前端 document.cookie 操作代码

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 23:54:58 +08:00
xfy
e358f2af7d 登录页面支持回车键提交表单
将 on_submit 改为 Callback::new,在用户名和密码输入框上监听
onkeydown 事件,按下 Enter 键时触发登录提交。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 23:45:24 +08:00
xfy
f3204e108b 添加项目 README
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:06:28 +08:00
xfy
956b2d7374 修复编辑器暗色主题和列表样式
- CSS 暗色主题选择器从 [data-theme="dark"] 改为 .dark
- 恢复无序列表圆点(覆盖 Tailwind preflight 重置)
- placeholder 改用 :has() 选择器适配 Tiptap v3

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:02:52 +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
91d9c04a3d 支持使用邮箱登录
- 登录查询同时匹配 username 或 email
- 更新登录页标签和 placeholder

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:16:40 +08:00
xfy
8b9c6aa83d 重构 admin 模块,新增共享组件和文章撰写页面
- 将 monolithic admin.rs 拆分为 admin/ 目录模块(dashboard、write)
- 新增 components 模块:Header、Footer、AdminLayout
- 新增 /admin/write 文章撰写页面,支持 Markdown 实时预览
- 添加 pulldown-cmark 依赖用于 Markdown 渲染
- .env 移出版本控制,新增 .env.example 模板
- Home、Archives、Tags、Login、Register 等页面适配新组件

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:13:18 +08:00
xfy
4a73e4d931 将生成的 style.css 从版本控制中移除 2026-05-26 14:29:59 +08:00
xfy
06302b14de 实现 PaperMod 风格标签页面:标签列表 + 标签详情
- 新增 /tags 页面:展示所有标签及文章数量,按字母排序
- 新增 /tags/:tag 动态路由:展示该标签下的文章列表
- Post/POSTS 改为 pub,供 tags 模块复用
- NavItem 高亮也匹配 TagDetailPage
- 修复 CSS 路径为绝对路径,解决子路由下样式失效

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 13:43:38 +08:00
xfy
7599bfbb13 实现 PaperMod 风格归档页面,支持按年份月份分组
- 新增 ArchivesPage 组件,三级结构:年份 → 月份 → 文章
- Header/NavItem/Footer 改为 pub 共享,NavItem 通过路由动态判断高亮
- 编译 Tailwind CSS 包含归档页面所需 utility classes

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 13:31:35 +08:00
xfy
a15394c935 返回顶部按钮迁移为 PaperMod 风格
- button "↑" → <a href="#top"> + 内联 SVG 双上箭头图标
- 滚动超过一屏才显示,添加 opacity/translate-y 过渡动画
- 平滑滚动到顶部并清除 URL hash(history.replaceState)
- 无障碍属性:aria-label、title、accesskey="g"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 13:20:25 +08:00
xfy
61c1ec7282 修复暗色模式:class 变体、状态同步、FOUC 预防、系统偏好
- 配置 Tailwind v4 @custom-variant dark 使用 class 模式
- 用 use_context_provider 共享主题状态,修复 AppRouter/ThemeToggle 不同步
- 默认跟随系统偏好(matchMedia),无 localStorage 时自动检测
- 统一暗色标记为 .dark class,移除 data-theme 冗余
- ThemePreload 内联脚本在 DOM 解析前设置 class,消除首屏闪烁
- SVG 内联 + currentColor,图标颜色随主题切换
- Cargo.toml 补充 web-sys MediaQueryList/DomTokenList feature

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 11:31:06 +08:00
xfy
3079f1a505 ThemeToggle:用 SVG 图标替换 emoji,移除灰色背景
- 亮色模式使用太阳 SVG 图标
- 暗色模式使用月亮 SVG 图标
- 移除按钮的灰色背景,改为 hover 透明度变化

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 11:11:44 +08:00
xfy
f52b3165da 首页首区改为个人简介(HomeInfo)
- 删除 FirstEntry(首篇文章精选)组件
- 新增 HomeInfo 组件:居中标题 "Yggdrasil" + 简介
- 文章列表从第 1 篇开始显示(共 6 篇)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 10:46:18 +08:00
xfy
1d57c91836 编译 Tailwind CSS,包含首页所需的 utility classes
- line-clamp-2, duration-250, backdrop-blur 等样式
- 验证首页 SSR 渲染正确

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 10:36:18 +08:00
xfy
452e7d8312 实现博客首页(PaperMod 风格)
- Header: 顶部导航栏,Logo + 首页/归档/标签/搜索/关于 + 主题切换
- FirstEntry: 首篇文章精选区,大标题 + 完整摘要
- PostEntry: 文章卡片列表,圆角边框 + hover 上浮效果
- Pagination: 下一页按钮
- Footer: 版权信息 + 返回顶部按钮
- 6 篇中文占位文章数据

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 10:34:54 +08:00
xfy
8b3aab21de 恢复首页路由,添加归档/标签/搜索/关于路由占位
- router.rs: / 恢复为 HomePage,新增 /archives /tags /search /about
- mod.rs: 导出 home 模块
- theme.rs: ThemeToggle 从浮动按钮改为内联样式
- home.rs: 创建空占位文件

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 10:31:52 +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
xfy
61638fafcc 更新依赖版本:http 1.4.1, log 0.4.30, regex 1.12
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 08:28:49 +08:00
xfy
d5010024d4 添加 release profile 优化配置
- opt-level = "z": 优化二进制体积
- lto = true: 启用链接时优化
- codegen-units = 1: 单代码生成单元以换取更优优化
- panic = "abort": 移除 panic 展开开销
- strip = true: 去除调试符号

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