Use xml marshaling to create the rss feed

This commit is contained in:
Las Zenow 2020-04-11 16:54:32 +00:00
parent 04c452853a
commit 0637cb7602
7 changed files with 159 additions and 82 deletions

View file

@ -55,7 +55,6 @@ func GetStatus(h handler) Status {
type Template struct {
html *html_tmpl.Template
rss *txt_tmpl.Template
opds *txt_tmpl.Template
}
@ -71,18 +70,6 @@ func InitTemplate(assetsPath string) *Template {
log.Critical("Error loading html templates: ", err)
}
t.rss, err = txt_tmpl.New("rss").Funcs(txt_tmpl.FuncMap{
"book_list": func(books, baseURL interface{}) (map[string]interface{}, error) {
data := make(map[string]interface{}, 2)
data["Books"] = books
data["BaseURL"] = baseURL
return data, nil
},
}).ParseGlob(path.Join(templatePath, "*.rss"))
if err != nil {
log.Critical("Error loading rss templates: ", err)
}
t.opds, err = txt_tmpl.ParseGlob(path.Join(templatePath, "*.opds"))
if err != nil {
log.Critical("Error loading opds templates: ", err)