@ -6,7 +6,7 @@
<section>
<h2>
Feed RSS
<a href="/guide/feed"> <i class="fa-solid fa-rss"></i></a>
<a href="/guide/rss"> <i class="fa-solid fa-rss"></i></a>
</h2>
<h1>
<i class="fa-solid fa-person-chalkboard"></i>
<a href="/news/feed"> <i class="fa-solid fa-rss"></i></a>
<a href="/news/rss"> <i class="fa-solid fa-rss"></i></a>
<i class="far fa-newspaper"></i>
@ -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 {
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)
@ -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
@ -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 {
return h.HandleGuideFeedPage(c)