@@ -50,7 +50,8 @@ data FeedConfiguration = FeedConfiguration
50 } deriving (Show, Eq)
50 } deriving (Show, Eq)
52-- | This is an auxiliary function to create a listing that is, in fact, a feed.
52-- | This is an auxiliary function to create a listing that is, in fact, a feed.
53−-- The items should be sorted on date. The @$timestamp@ field should be set.
53+-- The items should be sorted on date. The @$updated@ field should be set for
55createFeed :: Template -- ^ Feed template
56createFeed :: Template -- ^ Feed template
56 -> Template -- ^ Item template
57 -> Template -- ^ Item template
@@ -60,7 +61,7 @@ createFeed :: Template -- ^ Feed template
60 -> String -- ^ Resulting feed
61 -> String -- ^ Resulting feed
61createFeed feedTemplate itemTemplate url configuration items =
62createFeed feedTemplate itemTemplate url configuration items =
62 pageBody $ applyTemplate feedTemplate
63 pageBody $ applyTemplate feedTemplate
63− $ trySetField "timestamp" timestamp
64+ $ trySetField "updated" updated
64 $ trySetField "title" (feedTitle configuration)
65 $ trySetField "title" (feedTitle configuration)
65 $ trySetField "description" (feedDescription configuration)
66 $ trySetField "description" (feedDescription configuration)
66 $ trySetField "authorName" (feedDescription configuration)
67 $ trySetField "authorName" (feedDescription configuration)
@@ -75,10 +76,10 @@ createFeed feedTemplate itemTemplate url configuration items =
75 -- Body: concatenated items
76 -- Body: concatenated items
76 body = concat $ map pageBody items'
77 body = concat $ map pageBody items'
78− -- Take the first timestamp, which should be the most recent
79+ -- Take the first updated, which should be the most recent
79− timestamp = fromMaybe "Unknown" $ do
80+ updated = fromMaybe "Unknown" $ do
80 p <- listToMaybe items
81 p <- listToMaybe items
81− return $ getField "timestamp" p
82+ return $ getField "updated" p
84-- | Abstract function to render any feed.
85-- | Abstract function to render any feed.
@@ -107,18 +108,23 @@ renderFeed feedTemplate itemTemplate configuration =
108renderRss :: FeedConfiguration -- ^ Feed configuration
109renderRss :: FeedConfiguration -- ^ Feed configuration
109 -> Compiler [Page String] String -- ^ Feed compiler
110 -> Compiler [Page String] String -- ^ Feed compiler
110−renderRss configuration = arr (map renderDate)
111+renderRss configuration = arr (map (addUpdated . renderDate))
111 >>> renderFeed "templates/rss.xml" "templates/rss-item.xml" configuration
112 >>> renderFeed "templates/rss.xml" "templates/rss-item.xml" configuration
113− renderDate = renderDateField "timestamp" "%a, %d %b %Y %H:%M:%S UT"
114+ renderDate = renderDateField "published" "%a, %d %b %Y %H:%M:%S UT"
114 "No date found."
115 "No date found."
116-- | Render an Atom feed with a number of items.
117-- | Render an Atom feed with a number of items.
118renderAtom :: FeedConfiguration -- ^ Feed configuration
119renderAtom :: FeedConfiguration -- ^ Feed configuration
119 -> Compiler [Page String] String -- ^ Feed compiler
120 -> Compiler [Page String] String -- ^ Feed compiler
120−renderAtom configuration = arr (map renderDate)
121+renderAtom configuration = arr (map (addUpdated . renderDate))
121 >>> renderFeed "templates/atom.xml" "templates/atom-item.xml" configuration
122 >>> renderFeed "templates/atom.xml" "templates/atom-item.xml" configuration
123− renderDate = renderDateField "timestamp" "%Y-%m-%dT%H:%M:%SZ"
124+ renderDate = renderDateField "published" "%Y-%m-%dT%H:%M:%SZ"
124 "No date found."
125 "No date found."
127+-- | Copies @$updated$@ from @$published$@ if it is not already set.
129+addUpdated :: Page a -> Page a
130+addUpdated page = trySetField "updated" (getField "published" page) page