@@ -50,7 +50,8 @@ data FeedConfiguration = FeedConfiguration
5050 } deriving (Show, Eq)
5151
5252-- | 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
54+-- each item.
5455--
5556createFeed :: Template -- ^ Feed template
5657 -> Template -- ^ Item template
@@ -60,7 +61,7 @@ createFeed :: Template -- ^ Feed template
6061 -> String -- ^ Resulting feed
6162createFeed feedTemplate itemTemplate url configuration items =
6263 pageBody $ applyTemplate feedTemplate
63− $ trySetField "timestamp" timestamp
64+ $ trySetField "updated" updated
6465 $ trySetField "title" (feedTitle configuration)
6566 $ trySetField "description" (feedDescription configuration)
6667 $ trySetField "authorName" (feedDescription configuration)
@@ -75,10 +76,10 @@ createFeed feedTemplate itemTemplate url configuration items =
7576 -- Body: concatenated items
7677 body = concat $ map pageBody items'
7778
78− -- Take the first timestamp, which should be the most recent
79− timestamp = fromMaybe "Unknown" $ do
79+ -- Take the first updated, which should be the most recent
80+ updated = fromMaybe "Unknown" $ do
8081 p <- listToMaybe items
81− return $ getField "timestamp" p
82+ return $ getField "updated" p
8283
8384
8485-- | Abstract function to render any feed.
@@ -107,18 +108,23 @@ renderFeed feedTemplate itemTemplate configuration =
107108--
108109renderRss :: FeedConfiguration -- ^ Feed configuration
109110 -> Compiler [Page String] String -- ^ Feed compiler
110−renderRss configuration = arr (map renderDate)
111+renderRss configuration = arr (map (addUpdated . renderDate))
111112 >>> renderFeed "templates/rss.xml" "templates/rss-item.xml" configuration
112113 where
113− renderDate = renderDateField "timestamp" "%a, %d %b %Y %H:%M:%S UT"
114+ renderDate = renderDateField "published" "%a, %d %b %Y %H:%M:%S UT"
114115 "No date found."
115116
116117-- | Render an Atom feed with a number of items.
117118--
118119renderAtom :: FeedConfiguration -- ^ Feed configuration
119120 -> Compiler [Page String] String -- ^ Feed compiler
120−renderAtom configuration = arr (map renderDate)
121+renderAtom configuration = arr (map (addUpdated . renderDate))
121122 >>> renderFeed "templates/atom.xml" "templates/atom-item.xml" configuration
122123 where
123− renderDate = renderDateField "timestamp" "%Y-%m-%dT%H:%M:%SZ"
124+ renderDate = renderDateField "published" "%Y-%m-%dT%H:%M:%SZ"
124125 "No date found."
126+
127+-- | Copies @$updated$@ from @$published$@ if it is not already set.
128+--
129+addUpdated :: Page a -> Page a
130+addUpdated page = trySetField "updated" (getField "published" page) page