forked from snoyberg/yesoddocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Feed.hs
33 lines (29 loc) · 950 Bytes
/
Feed.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-}
module Handler.Feed
( getFeedR
, getFeedItemR
) where
import Wiki
import Yesod.Feed
getFeedR :: Handler RepAtomRss
getFeedR = do
now <- liftIO getCurrentTime
entries <- runDB $ selectList [] [Desc NewsItemCreated, LimitTo 30] >>= (mapM $ \(nid, n) -> return FeedEntry
{ feedEntryLink = FeedItemR nid
, feedEntryUpdated = newsItemCreated n
, feedEntryTitle = newsItemTitle n
, feedEntryContent = newsItemContent n
})
newsFeed Feed
{ feedTitle = "Yesod Wiki"
, feedLinkSelf = FeedR
, feedLinkHome = RootR
, feedDescription = ""
, feedLanguage = "en"
, feedUpdated = now
, feedEntries = entries
}
getFeedItemR :: NewsItemId -> Handler ()
getFeedItemR nid = do
NewsItem { newsItemUrl = url } <- runDB $ get404 nid
redirectText RedirectPermanent url