packages feed

hakyll 3.2.3.2 → 3.2.4.0

raw patch · 6 files changed

+21/−14 lines, 6 files

Files

data/templates/atom-item.xml view
@@ -2,6 +2,7 @@     <title>$title$</title>     <link href="$root$$url$" />     <id>$root$$url$</id>-    <published>$timestamp$</published>+    <published>$published$</published>+    <updated>$updated$</updated>     <summary type="html"><![CDATA[$description$]]></summary> </entry>
data/templates/atom.xml view
@@ -7,6 +7,6 @@     <author>         <name>$authorName$</name>     </author>-    <updated>$timestamp$</updated>+    <updated>$updated$</updated>     $body$ </feed>
data/templates/rss-item.xml view
@@ -2,6 +2,6 @@     <title>$title$</title>     <link>$root$$url$</link>     <description><![CDATA[$description$]]></description>-    <pubDate>$timestamp$</pubDate>+    <pubDate>$published$</pubDate>     <guid>$root$$url$</guid> </item>
data/templates/rss.xml view
@@ -6,7 +6,7 @@         <description><![CDATA[$description$]]></description>         <atom:link href="$root$$url$" rel="self"                    type="application/rss+xml" />-        <lastBuildDate>$timestamp$</lastBuildDate>+        <lastBuildDate>$updated$</lastBuildDate>         $body$     </channel>  </rss>
hakyll.cabal view
@@ -1,5 +1,5 @@ Name:    hakyll-Version: 3.2.3.2+Version: 3.2.4.0  Synopsis: A static website compiler library Description:
src/Hakyll/Web/Feed.hs view
@@ -50,7 +50,8 @@     } deriving (Show, Eq)  -- | This is an auxiliary function to create a listing that is, in fact, a feed.--- The items should be sorted on date. The @$timestamp@ field should be set.+-- The items should be sorted on date. The @$updated@ field should be set for+-- each item. -- createFeed :: Template           -- ^ Feed template            -> Template           -- ^ Item template@@ -60,7 +61,7 @@            -> String             -- ^ Resulting feed createFeed feedTemplate itemTemplate url configuration items =     pageBody $ applyTemplate feedTemplate-             $ trySetField "timestamp"   timestamp+             $ trySetField "updated"     updated              $ trySetField "title"       (feedTitle configuration)              $ trySetField "description" (feedDescription configuration)              $ trySetField "authorName"  (feedDescription configuration)@@ -75,10 +76,10 @@     -- Body: concatenated items     body = concat $ map pageBody items' -    -- Take the first timestamp, which should be the most recent-    timestamp = fromMaybe "Unknown" $ do+    -- Take the first updated, which should be the most recent+    updated = fromMaybe "Unknown" $ do         p <- listToMaybe items-        return $ getField "timestamp" p+        return $ getField "updated" p   -- | Abstract function to render any feed.@@ -107,18 +108,23 @@ -- renderRss :: FeedConfiguration              -- ^ Feed configuration           -> Compiler [Page String] String  -- ^ Feed compiler-renderRss configuration = arr (map renderDate)+renderRss configuration = arr (map (addUpdated . renderDate))     >>> renderFeed "templates/rss.xml" "templates/rss-item.xml" configuration   where-    renderDate = renderDateField "timestamp" "%a, %d %b %Y %H:%M:%S UT"+    renderDate = renderDateField "published" "%a, %d %b %Y %H:%M:%S UT"                                  "No date found."  -- | Render an Atom feed with a number of items. -- renderAtom :: FeedConfiguration              -- ^ Feed configuration            -> Compiler [Page String] String  -- ^ Feed compiler-renderAtom configuration = arr (map renderDate)+renderAtom configuration = arr (map (addUpdated . renderDate))     >>> renderFeed "templates/atom.xml" "templates/atom-item.xml" configuration   where-    renderDate = renderDateField "timestamp" "%Y-%m-%dT%H:%M:%SZ"+    renderDate = renderDateField "published" "%Y-%m-%dT%H:%M:%SZ"                                  "No date found."++-- | Copies @$updated$@ from @$published$@ if it is not already set.+--+addUpdated :: Page a -> Page a+addUpdated page = trySetField "updated" (getField "published" page) page