on master help sign in
Adds render{Rss,Atom}WithTemmplates function in the Web.Feed module
commitf3a17454fae3b140ada30ebef13f508179f4cd0d authorAbhinav Sarkar <abhinav.sarkar@gmail.com> dateSat 24 Nov 2018, 17:06 (8 years ago) parente2db1b2
1 file changed+32−6
lib/Hakyll/Web/Feed.hs+32−6
lib/Hakyll/Web/Feed.hs+32−6
@@ -22,6 +22,8 @@ module Hakyll.Web.Feed
2222 ( FeedConfiguration (..)
2323 , renderRss
2424 , renderAtom
25+ , renderRssWithTemplates
26+ , renderAtomWithTemplates
2527 ) where
2628
2729
@@ -125,15 +127,41 @@ renderFeed defFeed defItem config itemContext items = do
125127 readTemplateFile value = pure $ template $ readTemplateElems value
126128
127129
130+--------------------------------------------------------------------------------
131+-- | Render an RSS feed using given templates with a number of items.
132+renderRssWithTemplates ::
133+ String -- ^ Feed template
134+ -> String -- ^ Item template
135+ -> FeedConfiguration -- ^ Feed configuration
136+ -> Context String -- ^ Item context
137+ -> [Item String] -- ^ Feed items
138+ -> Compiler (Item String) -- ^ Resulting feed
139+renderRssWithTemplates feedTemplate itemTemplate config context = renderFeed
140+ feedTemplate itemTemplate config
141+ (makeItemContext "%a, %d %b %Y %H:%M:%S UT" context)
142+
143+
144+--------------------------------------------------------------------------------
145+-- | Render an Atom feed using given templates with a number of items.
146+renderAtomWithTemplates ::
147+ String -- ^ Feed template
148+ -> String -- ^ Item template
149+ -> FeedConfiguration -- ^ Feed configuration
150+ -> Context String -- ^ Item context
151+ -> [Item String] -- ^ Feed items
152+ -> Compiler (Item String) -- ^ Resulting feed
153+renderAtomWithTemplates feedTemplate itemTemplate config context = renderFeed
154+ feedTemplate itemTemplate config
155+ (makeItemContext "%Y-%m-%dT%H:%M:%SZ" context)
156+
157+
128158--------------------------------------------------------------------------------
129159-- | Render an RSS feed with a number of items.
130160renderRss :: FeedConfiguration -- ^ Feed configuration
131161 -> Context String -- ^ Item context
132162 -> [Item String] -- ^ Feed items
133163 -> Compiler (Item String) -- ^ Resulting feed
134−renderRss config context = renderFeed
135− rssTemplate rssItemTemplate config
136− (makeItemContext "%a, %d %b %Y %H:%M:%S UT" context)
164+renderRss = renderRssWithTemplates rssTemplate rssItemTemplate
137165
138166
139167--------------------------------------------------------------------------------
@@ -142,9 +170,7 @@ renderAtom :: FeedConfiguration -- ^ Feed configuration
142170 -> Context String -- ^ Item context
143171 -> [Item String] -- ^ Feed items
144172 -> Compiler (Item String) -- ^ Resulting feed
145−renderAtom config context = renderFeed
146− atomTemplate atomItemTemplate config
147− (makeItemContext "%Y-%m-%dT%H:%M:%SZ" context)
173+renderAtom = renderAtomWithTemplates atomTemplate atomItemTemplate
148174
149175
150176--------------------------------------------------------------------------------