diff --git a/_views/guide.html b/_views/guide.html index df4fb69..57df57a 100644 --- a/_views/guide.html +++ b/_views/guide.html @@ -6,7 +6,7 @@

Feed RSS - +

diff --git a/_views/news.html b/_views/news.html index c8a7d36..33aefd4 100644 --- a/_views/news.html +++ b/_views/news.html @@ -6,7 +6,7 @@

Feed RSS - +

diff --git a/handler/handler.go b/handler/handler.go index 06952c8..54f5da5 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -198,7 +198,7 @@ func (h *DefaultHandler) HandleNewsFeedPage(w io.Writer) error { return err } - newsFeed := rss.GenerateRssFeed(registry) + newsFeed := rss.GenerateRssFeed(registry, "Feed Notizie PHC", "https://phc.dm.unipi.it/news", "Le ultime nuove sul PHC.") return newsFeed.WriteRss(w) } @@ -209,7 +209,7 @@ func (h *DefaultHandler) HandleGuideFeedPage(w io.Writer) error { return err } - guideFeed := rss.GenerateRssFeed(registry) + guideFeed := rss.GenerateRssFeed(registry, "Feed Guide PHC", "https://phc.dm.unipi.it/guide", "Le piĆ¹ recenti guide a carattere informatico a cura dei macchinisti del PHC.") return guideFeed.WriteRss(w) } diff --git a/rss/feed.go b/rss/feed.go index 7fcd03d..381c146 100644 --- a/rss/feed.go +++ b/rss/feed.go @@ -5,16 +5,19 @@ import ( "github.com/gorilla/feeds" ) -func GenerateRssFeed(entries []*articles.Article) *feeds.Feed { +func GenerateRssFeed(entries []*articles.Article, title string, link string, description string) *feeds.Feed { // Initialize RSS Feed - feed := &feeds.Feed{} + feed := &feeds.Feed{ + Title: title, + Link: &feeds.Link{Href: link}, + Description: description, + } var feedItems []*feeds.Item // Add items to RSS feeds for _, entry := range entries { - feedItems = append(feedItems, &feeds.Item{ Id: entry.Id, @@ -24,7 +27,6 @@ func GenerateRssFeed(entries []*articles.Article) *feeds.Feed { Created: entry.PublishDate, }) } - feed.Items = feedItems return feed diff --git a/server/fiber.go b/server/fiber.go index 097c55f..0104f6a 100644 --- a/server/fiber.go +++ b/server/fiber.go @@ -105,12 +105,12 @@ func routes(h handler.Service, r fiber.Router) { return h.HandleGuidePage(c, CreateContext(c)) }) - r.Get("/news/feed", func(c *fiber.Ctx) error { + r.Get("/news/rss", func(c *fiber.Ctx) error { c.Type("xml") return h.HandleNewsFeedPage(c) }) - r.Get("/guide/feed", func(c *fiber.Ctx) error { + r.Get("/guide/rss", func(c *fiber.Ctx) error { c.Type("xml") return h.HandleGuideFeedPage(c) })