announcement v1

This commit is contained in:
tamakyi
2026-10-22 15:08:24 +08:00
parent c9f22cb81b
commit e1e840f895
12 changed files with 589 additions and 13 deletions
+9
View File
@@ -65,6 +65,15 @@ func FuncMap() []template.FuncMap {
"SentryDSN": func() string {
return conf.App.SentryDSN
},
// announcement 返回当前应展示的公告(已转义的安全 HTML),窗口外返回空串。
// 时间窗判定放在服务端:不依赖访客时钟,也不会先渲染出来再被脚本抹掉。
"announcement": func() template.HTML {
content, ok := conf.Announcement.Active(time.Now())
if !ok {
return ""
}
return AnnouncementHTML(content)
},
"ParsePublicURLs": func(input datatypes.JSON) string {
urls := make(map[string]string)
if err := json.Unmarshal(input, &urls); err != nil {