Files
jiang13-bbs/backend/handler/timeline.go
freefire a83276060f feat: 站点单页、时间线导入与行级 BBCode 短代码
首页右栏接入单页入口与公告置顶/全部页;Markdown 编辑器支持可视化时间线与 Git 导入;隐藏块改为 [hide]/[timeline] 命名闭合,并修复单页/公告 GORM 更新只改 updated_at 的问题。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 19:52:06 +08:00

30 lines
714 B
Go

package handler
import (
"net/http"
"github.com/gin-gonic/gin"
)
// TimelineFromGit 从 Git commits 页 URL 导入时间线条目(登录 + CSRF + 限流)
func (h *Handlers) TimelineFromGit(c *gin.Context) {
var req struct {
URLs []string `json:"urls"`
FollowPages *bool `json:"follow_pages"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "请求参数无效"})
return
}
follow := true
if req.FollowPages != nil {
follow = *req.FollowPages
}
result, err := h.Setting.ImportTimelineFromGit(req.URLs, follow)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, result)
}