Skip to content

Enhance image upload and post category features - #16

Closed
ZTZK wants to merge 3 commits into
TransHistoria:defaultfrom
ZTZK:default
Closed

Enhance image upload and post category features#16
ZTZK wants to merge 3 commits into
TransHistoria:defaultfrom
ZTZK:default

Conversation

@ZTZK

@ZTZK ZTZK commented May 29, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces a major refactor to how post categories ("sections") are handled, moving from a tag-based system to an explicit, user-selectable post section taxonomy. It updates the database schema, API, and UI to support new section types, improves file and attachment uploads in the post editor, and enhances the Markdown preview and rendering experience for posts.

Post Section Refactor and UI Updates:

  • Migrated from tag-based post categorization to a new explicit section field with options: "QUESTION", "OFFLINE_MEETUP", "MEDICAL", "RESOURCE", "REFLECTION", and legacy "POST". The database schema and API types are updated accordingly, including a migration script to enforce the new taxonomy. [1] [2] [3]
  • Updated post creation and editing forms (PostForm) to allow users to select a section for their post. The selected section is saved and displayed throughout the UI. [1] [2] [3]
  • Replaced tag display with the new section label in post cards and detail pages. Removed tag parsing and tag label logic from the UI. [1] [2] [3] [4] [5] [6]

Markdown Rendering and Preview Improvements:

  • Enhanced Markdown rendering for posts: added custom handling for images and links to resolve API file URLs, and improved the Markdown preview experience in the post editor with a toggleable preview mode. [1] [2] [3]

File and Attachment Uploads:

  • Added support for uploading both images (max 5MB) and attachments (max 10MB) in the post editor. Uploaded files are inserted as Markdown links or images, with improved feedback and error handling. [1] [2]

Content and UI Copy Adjustments:

  • Updated instructional and placeholder texts to reflect the new section system and clarify the AI moderation process. [1] [2] [3]

These changes modernize and clarify the post categorization system, streamline the user experience for creating and viewing posts, and lay groundwork for more flexible content organization.

ZTZK added 3 commits May 29, 2026 08:32
- files.ts: 上传接口返回绝对URL而非相对路径,解决跨端口图片加载问题
- PostDetailPageClient.tsx: 自定义img组件,处理相对/绝对URL兼容,
  添加图片样式,移除rehype-sanitize避免意外过滤
- 0008 migration: 更新posts表section CHECK约束,允许新分类值
  (QUESTION/OFFLINE_MEETUP/REFLECTION)
- PostForm: 新增板块选择器下拉框(提问求助/线下交友/医疗信息/资源分享/感悟)
- PostForm: 图片预览改用 URL.createObjectURL (blob URL),不依赖 R2 服务
- PostForm: 移除上传文件后的预览卡片,简化 UI
- Worker posts.ts: 新增 userPickedTags(),根据用户选择的 section 自动派生 tags
- Worker posts.ts: create/PATCH 路由优先使用用户传入的 section,LLM 作为 fallback
- Worker files.ts: 上传接口返回相对 URL (/api/files/...),跨环境可移植
- PostCard/PostDetail: 始终显示板块标签(POST_SECTION_LABEL),移除冗余 tag 徽章
- api.ts: Post 接口 section 类型补全所有板块
- PostForm: 预览模式下 ReactMarkdown 添加 img/a 自定义组件,
  使用 api.files.url() 解析相对 URL,修复图片裂图和链接不可用
- PostForm: 移除预览卡片 UI,改用 编辑/预览 切换模式
- PostForm: 图片限制 5MB,附件限制 10MB
- files.ts: 同步缩小限制为 5MB/10MB,修复错误提示文案
@ZTZK
ZTZK requested a review from cyanmint May 29, 2026 05:06
@cyanmint
cyanmint deleted the branch TransHistoria:default June 1, 2026 10:55
@cyanmint cyanmint closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants