feat: RSS feeds for {news,guide}

This commit is contained in:
2022-08-27 20:17:08 +02:00
parent 9c10e1b8fc
commit c1a701353a
7 changed files with 78 additions and 1 deletions
+25
View File
@@ -9,6 +9,7 @@ import (
"git.phc.dm.unipi.it/phc/website/articles"
"git.phc.dm.unipi.it/phc/website/auth"
"git.phc.dm.unipi.it/phc/website/model"
"git.phc.dm.unipi.it/phc/website/rss"
"git.phc.dm.unipi.it/phc/website/templates"
"git.phc.dm.unipi.it/phc/website/util"
)
@@ -27,6 +28,8 @@ type Service interface {
HandleProfilePage(w io.Writer, ctx Context) error
HandleNewsArticlePage(w io.Writer, articleID string, ctx Context) error
HandleGuideArticlePage(w io.Writer, articleID string, ctx Context) error
HandleNewsFeedPage(w io.Writer) error
HandleGuideFeedPage(w io.Writer) error
}
//
@@ -188,3 +191,25 @@ func (h *DefaultHandler) HandleGuideArticlePage(w io.Writer, articleID string, c
"ContentHTML": template.HTML(html),
})
}
func (h *DefaultHandler) HandleNewsFeedPage(w io.Writer) error {
registry, err := h.NewsArticlesRegistry.GetArticles()
if err != nil {
return err
}
newsFeed := rss.GenerateRssFeed(registry)
return newsFeed.WriteRss(w)
}
func (h *DefaultHandler) HandleGuideFeedPage(w io.Writer) error {
registry, err := h.GuideArticlesRegistry.GetArticles()
if err != nil {
return err
}
guideFeed := rss.GenerateRssFeed(registry)
return guideFeed.WriteRss(w)
}