feat: 站点单页、时间线导入与行级 BBCode 短代码
首页右栏接入单页入口与公告置顶/全部页;Markdown 编辑器支持可视化时间线与 Git 导入;隐藏块改为 [hide]/[timeline] 命名闭合,并修复单页/公告 GORM 更新只改 updated_at 的问题。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
37
backend/service/content_hide.go
Normal file
37
backend/service/content_hide.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/freefire/jiang13-bbs/markdown"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrAnnouncementReplyHideNotAllowed 公告不可评论,禁止回复可见块
|
||||
ErrAnnouncementReplyHideNotAllowed = errors.New("公告不可评论,不能使用回复可见")
|
||||
// ErrSitePageHideNotAllowed 站点单页正文禁止 [hide](本轮单页仍无评论/解锁)
|
||||
ErrSitePageHideNotAllowed = errors.New("页面不支持隐藏内容")
|
||||
)
|
||||
|
||||
// rejectHideBlocks 若正文含 [hide] 开标记(忽略代码围栏内伪语法)则返回指定错误。
|
||||
func rejectHideBlocks(content string, deny error) error {
|
||||
if markdown.HasHideBlocks(content) {
|
||||
return deny
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// rejectReplyHideBlocks 若正文含回复可见隐藏块则返回指定错误。
|
||||
func rejectReplyHideBlocks(content string, deny error) error {
|
||||
blocks, err := markdown.ParseHideBlocks(content)
|
||||
if err != nil {
|
||||
// 语法错误交给 ValidateHideContent;此处不阻断「无有效块」的脏文本
|
||||
return nil
|
||||
}
|
||||
for _, b := range blocks {
|
||||
if b.Kind == markdown.HideKindReply {
|
||||
return deny
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user