|
|
|
package rss
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.phc.dm.unipi.it/phc/website/articles"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/config"
|
|
|
|
"github.com/gorilla/feeds"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GenerateRssFeed(entries []*articles.Article, sectionName string, title string, link string, description string) *feeds.Feed {
|
|
|
|
|
|
|
|
// Initialize RSS 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,
|
|
|
|
Title: entry.Title,
|
|
|
|
Link: &feeds.Link{Href: config.BaseUrl + "/" + sectionName + "/" + entry.Id},
|
|
|
|
Description: entry.Description,
|
|
|
|
Created: entry.PublishDate,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
feed.Items = feedItems
|
|
|
|
|
|
|
|
return feed
|
|
|
|
}
|