From 7128cc9b5f77eb40bfb0b04d74ddfe2e10a171fe Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 29 Jan 2010 12:19:53 +0100 Subject: Updated simpleblog, rssblog and tagblog examples to trunk. --- examples/rssblog/hakyll.hs | 21 +++++++-------------- examples/rssblog/index.html | 2 +- examples/rssblog/posts.html | 2 +- examples/rssblog/templates/rss.xml | 2 +- examples/simpleblog/hakyll.hs | 8 ++++---- examples/tagblog/hakyll.hs | 30 +++++++++++++----------------- examples/tagblog/index.html | 2 +- examples/tagblog/posts.html | 2 +- 8 files changed, 29 insertions(+), 40 deletions(-) (limited to 'examples') diff --git a/examples/rssblog/hakyll.hs b/examples/rssblog/hakyll.hs index 8d403b4..50970f8 100644 --- a/examples/rssblog/hakyll.hs +++ b/examples/rssblog/hakyll.hs @@ -4,7 +4,7 @@ import Control.Monad.Reader (liftIO) import Text.Hakyll (hakyll) import Text.Hakyll.Render (renderAndConcat, renderChain, css) import Text.Hakyll.File (getRecursiveContents, directory) -import Text.Hakyll.Renderables (createPagePath, createCustomPage) +import Text.Hakyll.Renderables (createPagePath, createCustomPage, createListing) import Data.List (sort) import Control.Monad (mapM_, liftM) import Data.Either (Either(..)) @@ -18,24 +18,17 @@ main = hakyll $ do let renderablePosts = map createPagePath postPaths -- Render index, including recent posts. - let recentPosts = renderAndConcat ["templates/postitem.html"] $ take 3 renderablePosts - renderChain ["index.html", "templates/default.html"] $ - createCustomPage "index.html" ("templates/postitem.html" : take 3 postPaths) - [("title", Left "Home"), ("posts", Right recentPosts)] + let index = createListing "index.html" "templates/postitem.html" (take 3 renderablePosts) [("title", "Home")] + renderChain ["index.html", "templates/default.html"] index -- Render all posts list. - let postItems = renderAndConcat ["templates/postitem.html"] $ renderablePosts - renderChain ["posts.html", "templates/default.html"] $ - createCustomPage "posts.html" ("templates/postitem.html" : postPaths) - [("title", Left "All posts"), ("posts", Right postItems)] + let posts = createListing "posts.html" "templates/postitem.html" renderablePosts [("title", "All posts")] + renderChain ["posts.html", "templates/default.html"] posts -- Render all posts. liftIO $ putStrLn "Generating posts..." mapM_ (renderChain ["templates/post.html", "templates/default.html"]) renderablePosts -- Render rss feed - let recentRSSItems = renderAndConcat ["templates/rssitem.xml"] $ take 3 renderablePosts - let rssPage = createCustomPage "rss.xml" - ("templates/postitem.html" : take 3 postPaths) - [("items", Right recentRSSItems)] - renderChain ["templates/rss.xml"] rssPage + let rss = createListing "rss.xml" "templates/rssitem.xml" (take 3 renderablePosts) [] + renderChain ["templates/rss.xml"] rss diff --git a/examples/rssblog/index.html b/examples/rssblog/index.html index 201cc18..88cc0a2 100644 --- a/examples/rssblog/index.html +++ b/examples/rssblog/index.html @@ -1,7 +1,7 @@

Recent posts

All posts...
diff --git a/examples/rssblog/posts.html b/examples/rssblog/posts.html index bc1741b..7db1a59 100644 --- a/examples/rssblog/posts.html +++ b/examples/rssblog/posts.html @@ -1,4 +1,4 @@

All posts

diff --git a/examples/rssblog/templates/rss.xml b/examples/rssblog/templates/rss.xml index be918af..1217b4e 100644 --- a/examples/rssblog/templates/rss.xml +++ b/examples/rssblog/templates/rss.xml @@ -4,6 +4,6 @@ The SimpleBlog http://example.com Simple blog in hakyll - $items + $body diff --git a/examples/simpleblog/hakyll.hs b/examples/simpleblog/hakyll.hs index 8b53215..638861a 100644 --- a/examples/simpleblog/hakyll.hs +++ b/examples/simpleblog/hakyll.hs @@ -19,12 +19,12 @@ main = hakyll $ do let renderablePosts = map createPagePath postPaths -- Render index, including recent posts. - renderChain ["index.html", "templates/default.html"] $ - createListing "index.html" "templates/postitem.html" (take 3 renderablePosts) [("title", "Home")] + let index = createListing "index.html" "templates/postitem.html" (take 3 renderablePosts) [("title", "Home")] + renderChain ["index.html", "templates/default.html"] index -- Render all posts list. - renderChain ["posts.html", "templates/default.html"] $ - createListing "posts.html" "templates/postitem.html" renderablePosts [("title", "All posts")] + let posts = createListing "posts.html" "templates/postitem.html" renderablePosts [("title", "All posts")] + renderChain ["posts.html", "templates/default.html"] posts -- Render all posts. liftIO $ putStrLn "Generating posts..." diff --git a/examples/tagblog/hakyll.hs b/examples/tagblog/hakyll.hs index dcbb943..de1d1a0 100644 --- a/examples/tagblog/hakyll.hs +++ b/examples/tagblog/hakyll.hs @@ -4,7 +4,7 @@ import Text.Hakyll (hakyll) import Text.Hakyll.Render import Text.Hakyll.Tags (readTagMap, renderTagCloud, renderTagLinks) import Text.Hakyll.File (getRecursiveContents, directory, removeSpaces) -import Text.Hakyll.Renderables (createPagePath, createCustomPage) +import Text.Hakyll.Renderables (createPagePath, createCustomPage, createListingWith) import Text.Hakyll.Context (ContextManipulation, renderDate) import Data.List (sort) import Data.Map (toList) @@ -20,23 +20,24 @@ main = hakyll $ do let renderablePosts = map createPagePath postPaths -- Read tag map. - tagMap <- readTagMap "postTags" postPaths + tagMap <- readTagMap "postTags" renderablePosts -- Render all posts list. - renderPostList "posts.html" "All posts" postPaths + renderPostList "posts.html" "All posts" renderablePosts -- Render post list per tag mapM_ (\(tag, posts) -> renderPostList (tagToURL tag) ("Posts tagged " ++ tag) posts) (toList tagMap) -- Render index, including recent posts. - let recentPosts = renderAndConcatWith postManipulation - ["templates/postitem.html"] - (take 3 renderablePosts) - renderChain ["index.html", "templates/default.html"] $ - createCustomPage "index.html" ("templates/postitem.html" : take 3 postPaths) - [("title", Left "Home"), ("posts", Right recentPosts), - ("tagcloud", Left $ renderTagCloud tagMap tagToURL 100 200)] + let tagCloud = renderTagCloud tagMap tagToURL 100 200 + let index = createListingWith postManipulation "index.html" + "templates/postitem.html" + (take 3 renderablePosts) + [ ("title", "Home") + , ("tagcloud", tagCloud) + ] + renderChain ["index.html", "templates/default.html"] index -- Render all posts. mapM_ (renderChainWith postManipulation @@ -61,10 +62,5 @@ main = hakyll $ do tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html" renderPostList url title posts = do - let postItems = renderAndConcatWith postManipulation - ["templates/postitem.html"] - (map createPagePath posts) - customPage = createCustomPage url - ("templates/postitem.html" : posts) - [("title", Left title), ("posts", Right postItems)] - renderChain ["posts.html", "templates/default.html"] customPage + let list = createListingWith postManipulation url "templates/postitem.html" posts [("title", title)] + renderChain ["posts.html", "templates/default.html"] list diff --git a/examples/tagblog/index.html b/examples/tagblog/index.html index e520791..4cade0f 100644 --- a/examples/tagblog/index.html +++ b/examples/tagblog/index.html @@ -1,7 +1,7 @@

Recent posts

All posts...
diff --git a/examples/tagblog/posts.html b/examples/tagblog/posts.html index ef86c40..ee2ed78 100644 --- a/examples/tagblog/posts.html +++ b/examples/tagblog/posts.html @@ -1,4 +1,4 @@

$title

    - $posts + $body
-- cgit v1.2.3