summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-30 19:25:22 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-30 19:25:22 +0200
commit622c259708503eb9eb766fe0b00c28b979e2e653 (patch)
tree8289d95ab3afca4b7540f8207800c1e37db5ffdd
parent82931dd6661221f1d138f2de5af0668e9080ef26 (diff)
downloadhakyll-622c259708503eb9eb766fe0b00c28b979e2e653.tar.gz
Adapted examples to general style guide.
Because I thought the examples should follow the same style guidelines as the Hakyll code itself, I adapted them to it.
-rw-r--r--examples/brochure/hakyll.hs5
-rw-r--r--examples/categoryblog/hakyll.hs35
-rw-r--r--examples/feedblog/hakyll.hs12
-rw-r--r--examples/simpleblog/hakyll.hs13
-rw-r--r--examples/tagblog/hakyll.hs29
5 files changed, 55 insertions, 39 deletions
diff --git a/examples/brochure/hakyll.hs b/examples/brochure/hakyll.hs
index 93a2393..a74bee1 100644
--- a/examples/brochure/hakyll.hs
+++ b/examples/brochure/hakyll.hs
@@ -8,5 +8,6 @@ main = hakyll "http://example.com" $ do
render "about.rst"
render "index.markdown"
render "code.lhs"
- where render = renderChain ["templates/default.html"]
- . createPage
+ where
+ render = renderChain ["templates/default.html"]
+ . createPage
diff --git a/examples/categoryblog/hakyll.hs b/examples/categoryblog/hakyll.hs
index cea7498..dd3051d 100644
--- a/examples/categoryblog/hakyll.hs
+++ b/examples/categoryblog/hakyll.hs
@@ -10,7 +10,7 @@ import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
import Text.Hakyll.ContextManipulations (renderDate, copyValue, changeValue)
import Text.Hakyll.Util (link)
import Data.Map (toList)
-import Control.Monad (mapM_, liftM, (<=<))
+import Control.Monad (forM_, liftM, (<=<))
import Data.Either (Either(..))
main = hakyll "http://example.com" $ do
@@ -34,38 +34,43 @@ main = hakyll "http://example.com" $ do
withTagMap categoryMap renderListForCategory
-- Render index, including recent posts.
+ let categoryList' = categoryMap >>> categoryList
let index = createListing "index.html"
["templates/postitem.html"]
(take 3 renderablePosts)
[ ("title", Left "Home")
- , ("categories", Right $ categoryMap >>> categoryList)
+ , ("categories", Right $ categoryList')
]
renderChain ["index.html", "templates/default.html"] index
-- Render all posts.
- mapM_ (renderChain ["templates/post.html"
- ,"templates/default.html"
- ]) renderablePosts
+ forM_ renderablePosts $ renderChain [ "templates/post.html"
+ , "templates/default.html"
+ ]
-- Render rss feed
renderRss myFeedConfiguration $
map (>>> copyValue "body" "description") (take 3 renderablePosts)
- where postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
- >>> renderCategoryLink
+ where
+ postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
+ >>> renderCategoryLink
- renderCategoryLink = changeValue "category" (\c -> link c $ categoryToUrl c)
+ renderCategoryLink =
+ changeValue "category" (\c -> link c $ categoryToUrl c)
- categoryToUrl category = "$root/categories/" ++ removeSpaces category ++ ".html"
+ categoryToUrl c = "$root/categories/" ++ removeSpaces c ++ ".html"
- categoryList = arr $ uncurry categoryListItem <=< toList
+ categoryList = arr $ uncurry categoryListItem <=< toList
- categoryListItem category posts = "<li>" ++ link category (categoryToUrl category)
- ++ " - " ++ show (length posts) ++ " items.</li>"
+ categoryListItem category posts =
+ "<li>" ++ link category (categoryToUrl category)
+ ++ " - " ++ show (length posts) ++ " items.</li>"
- renderPostList url title posts = do
- let list = createListing url ["templates/postitem.html"] posts [("title", Left title)]
- renderChain ["posts.html", "templates/default.html"] list
+ renderPostList url title posts = do
+ let list = createListing url ["templates/postitem.html"]
+ posts [("title", Left title)]
+ renderChain ["posts.html", "templates/default.html"] list
myFeedConfiguration = FeedConfiguration
{ feedUrl = "rss.xml"
diff --git a/examples/feedblog/hakyll.hs b/examples/feedblog/hakyll.hs
index c8633a9..e261c0e 100644
--- a/examples/feedblog/hakyll.hs
+++ b/examples/feedblog/hakyll.hs
@@ -9,7 +9,7 @@ import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
import Text.Hakyll.ContextManipulations (copyValue)
import Text.Hakyll.Feed (FeedConfiguration (..), renderRss)
import Data.List (sort)
-import Control.Monad (mapM_, liftM)
+import Control.Monad (forM_, liftM)
import Control.Monad.Reader (liftIO)
import Data.Either (Either(..))
@@ -22,16 +22,20 @@ main = hakyll "http://example.com" $ do
let postPages = map createPage postPaths
-- Render index, including recent posts.
- let index = createListing "index.html" ["templates/postitem.html"] (take 3 postPages) [("title", Left "Home")]
+ let index = createListing "index.html" ["templates/postitem.html"]
+ (take 3 postPages) [("title", Left "Home")]
renderChain ["index.html", "templates/default.html"] index
-- Render all posts list.
- let posts = createListing "posts.html" ["templates/postitem.html"] postPages [("title", Left "All posts")]
+ let posts = createListing "posts.html" ["templates/postitem.html"]
+ postPages [("title", Left "All posts")]
renderChain ["posts.html", "templates/default.html"] posts
-- Render all posts.
liftIO $ putStrLn "Generating posts..."
- mapM_ (renderChain ["templates/post.html", "templates/default.html"]) postPages
+ forM_ postPages $ renderChain [ "templates/post.html"
+ , "templates/default.html"
+ ]
-- Render RSS feed.
renderRss myFeedConfiguration $
diff --git a/examples/simpleblog/hakyll.hs b/examples/simpleblog/hakyll.hs
index 75173f8..38472d5 100644
--- a/examples/simpleblog/hakyll.hs
+++ b/examples/simpleblog/hakyll.hs
@@ -6,7 +6,7 @@ import Text.Hakyll.Context
import Text.Hakyll.File (getRecursiveContents, directory)
import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
import Data.List (sort)
-import Control.Monad (mapM_, liftM)
+import Control.Monad (forM_, liftM)
import Control.Monad.Reader (liftIO)
import Data.Either (Either(..))
@@ -19,14 +19,17 @@ main = hakyll "http://example.com" $ do
let postPages = map createPage postPaths
-- Render index, including recent posts.
- let index = createListing "index.html" ["templates/postitem.html"] (take 3 postPages) [("title", Left "Home")]
+ let index = createListing "index.html" ["templates/postitem.html"]
+ (take 3 postPages) [("title", Left "Home")]
renderChain ["index.html", "templates/default.html"] index
-- Render all posts list.
- let posts = createListing "posts.html" ["templates/postitem.html"] postPages [("title", Left "All posts")]
+ let posts = createListing "posts.html" ["templates/postitem.html"]
+ postPages [("title", Left "All posts")]
renderChain ["posts.html", "templates/default.html"] posts
-- Render all posts.
liftIO $ putStrLn "Generating posts..."
- mapM_ (renderChain ["templates/post.html", "templates/default.html"]) postPages
-
+ forM_ postPages $ renderChain [ "templates/post.html"
+ , "templates/default.html"
+ ]
diff --git a/examples/tagblog/hakyll.hs b/examples/tagblog/hakyll.hs
index 4c6b89c..a81c280 100644
--- a/examples/tagblog/hakyll.hs
+++ b/examples/tagblog/hakyll.hs
@@ -10,7 +10,7 @@ import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
import Text.Hakyll.ContextManipulations (renderDate, copyValue)
import Data.List (sort)
import Data.Map (toList)
-import Control.Monad (mapM_, liftM)
+import Control.Monad (forM_, liftM)
import Data.Either (Either(..))
main = hakyll "http://example.com" $ do
@@ -28,9 +28,10 @@ main = hakyll "http://example.com" $ do
renderPostList "posts.html" "All posts" renderablePosts
-- Render post list per tag
- let renderListForTag tag posts = renderPostList (tagToUrl tag) ("Posts tagged " ++ tag)
- (map (>>> postManipulation) posts)
- withTagMap tagMap renderPostList
+ let renderListForTag tag posts =
+ renderPostList (tagToUrl tag) ("Posts tagged " ++ tag)
+ (map (>>> postManipulation) posts)
+ withTagMap tagMap renderListForTag
-- Render index, including recent posts.
let tagCloud = tagMap >>> renderTagCloud tagToUrl 100 200
@@ -43,22 +44,24 @@ main = hakyll "http://example.com" $ do
renderChain ["index.html", "templates/default.html"] index
-- Render all posts.
- mapM_ (renderChain ["templates/post.html"
- ,"templates/default.html"
- ]) renderablePosts
+ forM_ renderablePosts $ renderChain [ "templates/post.html"
+ , "templates/default.html"
+ ]
-- Render rss feed
renderRss myFeedConfiguration $
map (>>> copyValue "body" "description") (take 3 renderablePosts)
- where postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
- >>> renderTagLinks tagToUrl
+ where
+ postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
+ >>> renderTagLinks tagToUrl
- tagToUrl tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
+ tagToUrl tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
- renderPostList url title posts = do
- let list = createListing url ["templates/postitem.html"] posts [("title", Left title)]
- renderChain ["posts.html", "templates/default.html"] list
+ renderPostList url title posts = do
+ let list = createListing url ["templates/postitem.html"]
+ posts [("title", Left title)]
+ renderChain ["posts.html", "templates/default.html"] list
myFeedConfiguration = FeedConfiguration
{ feedUrl = "rss.xml"