Add authors to the rss feed

This commit is contained in:
Las Zenow 2020-04-23 10:54:59 +00:00
parent 497a020f9a
commit 154867c50c

View file

@ -12,6 +12,7 @@ import (
type rss struct { type rss struct {
XMLName xml.Name `xml:"rss"` XMLName xml.Name `xml:"rss"`
Version string `xml:"version,attr"` Version string `xml:"version,attr"`
XmlnsDC string `xml:"xmlns:dc,attr"`
Channel channel `xml:"channel"` Channel channel `xml:"channel"`
} }
@ -25,6 +26,7 @@ type channel struct {
type item struct { type item struct {
Title string `xml:"title"` Title string `xml:"title"`
Creator []string `xml:"dc:creator,omitempty"`
Description string `xml:"description"` Description string `xml:"description"`
Link string `xml:"link"` Link string `xml:"link"`
GUID *guid `xml:"guid,omitempty"` GUID *guid `xml:"guid,omitempty"`
@ -71,6 +73,7 @@ func newsRss(data interface{}) (rss, error) {
feed := rss{ feed := rss{
Version: "2.0", Version: "2.0",
XmlnsDC: "http://purl.org/dc/elements/1.1/",
Channel: channel{ Channel: channel{
Title: news.S.Title, Title: news.S.Title,
Description: "News of the library", Description: "News of the library",
@ -104,6 +107,7 @@ func searchRss(data interface{}) (rss, error) {
feed := rss{ feed := rss{
Version: "2.0", Version: "2.0",
XmlnsDC: "http://purl.org/dc/elements/1.1/",
Channel: channel{ Channel: channel{
Title: search.S.Title, Title: search.S.Title,
Description: description, Description: description,
@ -122,6 +126,7 @@ func listRss(data interface{}) (rss, error) {
feed := rss{ feed := rss{
Version: "2.0", Version: "2.0",
XmlnsDC: "http://purl.org/dc/elements/1.1/",
Channel: channel{ Channel: channel{
Title: lb.S.Title, Title: lb.S.Title,
Description: strings.Join(lb.List.Description, "\n"), Description: strings.Join(lb.List.Description, "\n"),
@ -138,6 +143,7 @@ func bookListRss(books []database.Book, baseURL string) []item {
for i, b := range books { for i, b := range books {
items[i] = item{ items[i] = item{
Title: b.Title, Title: b.Title,
Creator: b.Authors,
Description: b.Description, Description: b.Description,
Link: baseURL + "/download/" + b.ID, Link: baseURL + "/download/" + b.ID,
Category: b.Tags, Category: b.Tags,