diff --git a/config.yml b/config.yml index 47a122f..2827c57 100644 --- a/config.yml +++ b/config.yml @@ -6,8 +6,9 @@ output: dir: output file: index.html template: - markdown: template.md + info: template_info.html html_head: template_head.html + log: template_log.html time: format: 2006-01-02 15:04:05 MST timezone: UTC \ No newline at end of file diff --git a/main.go b/main.go index 848647f..9fa8725 100644 --- a/main.go +++ b/main.go @@ -14,8 +14,9 @@ type Config struct { RedisPassword string OutputDir string OutputFilename string - TemplateFilename string + TemplateInfoFilename string TemplateHeadFilename string + templateLogFilename string TimeFormat string Timezone string } @@ -38,7 +39,8 @@ func main() { RedisPassword: viper.GetString("redis.password"), OutputDir: viper.GetString("output.dir"), OutputFilename: viper.GetString("output.file"), - TemplateFilename: viper.GetString("template.markdown"), + TemplateInfoFilename: viper.GetString("template.info"), + templateLogFilename: viper.GetString("template.log"), TemplateHeadFilename: viper.GetString("template.html_head"), TimeFormat: viper.GetString("time.format"), Timezone: viper.GetString("time.timezone"), @@ -52,15 +54,8 @@ func main() { ctx := context.Background() // 获取订阅者和关注者列表 subscribeAndFollowers := GetSubcribesAndFollowers(rdb, ctx) - // 读取模板文件 - templateFile, err := os.ReadFile(config.TemplateFilename) - if err != nil { - fmt.Printf("Failed to read template file: %s\n", config.TemplateFilename) - panic(err) - } // 生成 HTML 文件 - bodyHtml := MdToHTML(FillMarkdownTemplate(templateFile, subscribeAndFollowers)) - htmlBytes := FillHtml(bodyHtml) + htmlBytes := GenHtml(&subscribeAndFollowers) // 输出HTML文件 // 检查输出目录是否存在,如果不存在则创建 if _, err := os.Stat(config.OutputDir); os.IsNotExist(err) { diff --git a/page.go b/page.go index 6b76639..01ed8a0 100644 --- a/page.go +++ b/page.go @@ -23,27 +23,41 @@ func MdToHTML(md []byte) []byte { return markdown.Render(doc, renderer) } -func FillHtml(html []byte) []byte { - htmlStr := string(html) +func GenHtml(subList *[]string) []byte { + var htmlStr string // 添加 html 头 htmlHead, err := os.ReadFile(config.TemplateHeadFilename) if err != nil { fmt.Printf("Failed to read template file: %s\n", config.TemplateHeadFilename) panic(err) } - htmlStr = string(htmlHead) + "\n
\n" + "列表最后更新于 %s
\n", time.Now().In(loc).Format(config.TimeFormat)) + // 添加实时日志 + logBody, err := os.ReadFile(config.templateLogFilename) + if err != nil { + fmt.Printf("Failed to read template file: %s\n", config.templateLogFilename) + panic(err) + } + htmlStr += "\n" + string(logBody) // 添加 html 尾 htmlStr += "\n欢迎~
+ +如果订阅异常可以试试移除中继再重新订阅!
+ +所使用的后端为 yukimochi/Activity-Relay
+ +页面生成器:isle-activity-relay-frontend
+ +有问题可以联系 @Claire
+ +每 5 分钟更新一次
+ + + \ No newline at end of file diff --git a/template_log.html b/template_log.html new file mode 100644 index 0000000..6925798 --- /dev/null +++ b/template_log.html @@ -0,0 +1,41 @@ +