Finalize/fix RSS feeds
This commit is contained in:
+1
-1
@@ -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>
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<section>
|
||||
<h2>
|
||||
Feed RSS
|
||||
<a href="/news/feed"> <i class="fa-solid fa-rss"></i></a>
|
||||
<a href="/news/rss"> <i class="fa-solid fa-rss"></i></a>
|
||||
</h2>
|
||||
<h1>
|
||||
<i class="far fa-newspaper"></i>
|
||||
|
||||
+2
-2
@@ -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)
|
||||
}
|
||||
|
||||
+6
-4
@@ -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
|
||||
|
||||
+2
-2
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user