Permalink
Browse files

Update examples to new matching mechanism

  • Loading branch information...
1 parent 7f3860d commit 51412d94a6181b04e1819651a63aca7a7021c7c4 @jaspervdj committed Apr 5, 2011
Showing with 107 additions and 114 deletions.
  1. +10 −8 brochure/hakyll.hs
  2. +22 −26 feedblog/hakyll.hs
  3. +18 −16 hakyll/hakyll.hs
  4. +12 −11 morepages/hakyll.hs
  5. +21 −25 simpleblog/hakyll.hs
  6. +24 −28 tagblog/hakyll.hs
View
@@ -6,13 +6,15 @@ import Hakyll
main :: IO ()
main = hakyll $ do
- route "css/*" idRoute
- compile "css/*" compressCssCompiler
+ match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
- compile "templates/*" templateCompiler
+ match "templates/*" $ compile templateCompiler
- forM_ ["about.rst", "index.markdown", "code.lhs"] $ \page -> do
- route page $ setExtension "html"
- compile page $ pageCompiler
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ forM_ ["about.rst", "index.markdown", "code.lhs"] $ \page ->
+ match page $ do
+ route $ setExtension "html"
+ compile $ pageCompiler
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
View
@@ -11,47 +11,43 @@ import Hakyll
main :: IO ()
main = hakyll $ do
-- Compress CSS
- route "css/*" idRoute
- compile "css/*" compressCssCompiler
+ match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
-- Render posts
- route "posts/*" $ setExtension ".html"
- compile "posts/*" $
- pageCompiler
+ match "posts/*" $ do
+ route $ setExtension ".html"
+ compile $ pageCompiler
>>> applyTemplateCompiler "templates/post.html"
>>> applyTemplateCompiler "templates/default.html"
>>> relativizeUrlsCompiler
-- Render posts list
- route "posts.html" $ idRoute
- create "posts.html" $
- constA mempty
- >>> arr (setField "title" "All posts")
- >>> requireAllA "posts/*" addPostList
- >>> applyTemplateCompiler "templates/posts.html"
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ match "posts.html" $ route idRoute
+ create "posts.html" $ constA mempty
+ >>> arr (setField "title" "All posts")
+ >>> requireAllA "posts/*" addPostList
+ >>> applyTemplateCompiler "templates/posts.html"
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Index
- route "index.html" $ idRoute
- create "index.html" $
- constA mempty
- >>> arr (setField "title" "Home")
- >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList)
- >>> applyTemplateCompiler "templates/index.html"
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ match "index.html" $ route idRoute
+ create "index.html" $ constA mempty
+ >>> arr (setField "title" "Home")
+ >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList)
+ >>> applyTemplateCompiler "templates/index.html"
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Render RSS feed
- route "rss.xml" $ idRoute
+ match "rss.xml" $ route idRoute
create "rss.xml" $
requireAll_ "posts/*" >>> renderRss feedConfiguration
-- Read templates
- compile "templates/*" templateCompiler
-
- -- End
- return ()
+ match "templates/*" $ compile templateCompiler
-- | Auxiliary compiler: generate a post list from a list of given posts, and
-- add it to the current page under @$posts@
View
@@ -6,35 +6,37 @@ import Text.Pandoc
main :: IO ()
main = hakyll $ do
- route "css/*" idRoute
- compile "css/*" compressCssCompiler
+ match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
-- Static directories
- forM_ ["images/*", "examples/*", "reference/*"] $ \f -> do
- route f idRoute
- compile f copyFileCompiler
+ forM_ ["images/*", "examples/*", "reference/*"] $ \f -> match f $ do
+ route idRoute
+ compile copyFileCompiler
-- Pages
- forM_ pages $ \p -> do
- route p $ setExtension "html"
- compile p $ pageCompiler
+ forM_ pages $ \p -> match p $ do
+ route $ setExtension "html"
+ compile $ pageCompiler
>>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
>>> applyTemplateCompiler "templates/default.html"
>>> relativizeUrlsCompiler
-- Tutorial
- route "tutorial.markdown" $ setExtension "html"
- compile "tutorial.markdown" $ readPageCompiler
- >>> pageRenderPandocWith defaultHakyllParserState withToc
- >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ match "tutorial.markdown" $ do
+ route $ setExtension "html"
+ compile $ readPageCompiler
+ >>> pageRenderPandocWith defaultHakyllParserState withToc
+ >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody)
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Sidebar
- compile "sidebar.markdown" pageCompiler
+ match "sidebar.markdown" $ compile pageCompiler
-- Templates
- compile "templates/*" templateCompiler
+ match "templates/*" $ compile templateCompiler
where
withToc = defaultHakyllWriterOptions
{ writerTableOfContents = True
View
@@ -9,20 +9,21 @@ import Hakyll
main :: IO ()
main = hakyll $ do
-- Compress CSS
- route "css/*" idRoute
- compile "css/*" compressCssCompiler
+ match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
-- Render static pages
- forM_ ["about.markdown", "index.markdown", "products.markdown"] $ \p -> do
- route p $ setExtension ".html"
- compile p $
- pageCompiler
- >>> requireA "footer.markdown" (setFieldA "footer" $ arr pageBody)
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ forM_ ["about.markdown", "index.markdown", "products.markdown"] $ \p ->
+ match p $ do
+ route $ setExtension ".html"
+ compile $ pageCompiler
+ >>> requireA "footer.markdown" (setFieldA "footer" $ arr pageBody)
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Compile footer
- compile "footer.markdown" pageCompiler
+ match "footer.markdown" $ compile pageCompiler
-- Read templates
- compile "templates/*" templateCompiler
+ match "templates/*" $ compile templateCompiler
View
@@ -11,42 +11,38 @@ import Hakyll
main :: IO ()
main = hakyll $ do
-- Compress CSS
- route "css/*" idRoute
- compile "css/*" compressCssCompiler
+ match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
-- Render posts
- route "posts/*" $ setExtension ".html"
- compile "posts/*" $
- pageCompiler
+ match "posts/*" $ do
+ route $ setExtension ".html"
+ compile $ pageCompiler
>>> applyTemplateCompiler "templates/post.html"
>>> applyTemplateCompiler "templates/default.html"
>>> relativizeUrlsCompiler
-- Render posts list
- route "posts.html" $ idRoute
- create "posts.html" $
- constA mempty
- >>> arr (setField "title" "All posts")
- >>> requireAllA "posts/*" addPostList
- >>> applyTemplateCompiler "templates/posts.html"
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ match "posts.html" $ route idRoute
+ create "posts.html" $ constA mempty
+ >>> arr (setField "title" "All posts")
+ >>> requireAllA "posts/*" addPostList
+ >>> applyTemplateCompiler "templates/posts.html"
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Index
- route "index.html" idRoute
- create "index.html" $
- constA mempty
- >>> arr (setField "title" "Home")
- >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList)
- >>> applyTemplateCompiler "templates/index.html"
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ match "index.html" $ route idRoute
+ create "index.html" $ constA mempty
+ >>> arr (setField "title" "Home")
+ >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList)
+ >>> applyTemplateCompiler "templates/index.html"
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Read templates
- compile "templates/*" templateCompiler
-
- -- End
- return ()
+ match "templates/*" $ compile templateCompiler
-- | Auxiliary compiler: generate a post list from a list of given posts, and
-- add it to the current page under @$posts@
View
@@ -12,62 +12,58 @@ import Hakyll
main :: IO ()
main = hakyll $ do
-- Compress CSS
- route "css/*" idRoute
- compile "css/*" compressCssCompiler
+ match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
-- Render posts
- route "posts/*" $ setExtension ".html"
- compile "posts/*" $
- pageCompiler
+ match "posts/*" $ do
+ route $ setExtension ".html"
+ compile $ pageCompiler
>>> arr (renderDateField "date" "%B %e, %Y" "Date unknown")
>>> renderTagsField "prettytags" (fromCaptureString "tags/*")
>>> applyTemplateCompiler "templates/post.html"
>>> applyTemplateCompiler "templates/default.html"
>>> relativizeUrlsCompiler
-- Render posts list
- route "posts.html" $ idRoute
- create "posts.html" $
- constA mempty
- >>> arr (setField "title" "All posts")
- >>> requireAllA "posts/*" addPostList
- >>> applyTemplateCompiler "templates/posts.html"
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ match "posts.html" $ route idRoute
+ create "posts.html" $ constA mempty
+ >>> arr (setField "title" "All posts")
+ >>> requireAllA "posts/*" addPostList
+ >>> applyTemplateCompiler "templates/posts.html"
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Index
- route "index.html" $ idRoute
- create "index.html" $
- constA mempty
- >>> arr (setField "title" "Home")
- >>> requireA "tags" (setFieldA "tagcloud" (renderTagCloud'))
- >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList)
- >>> applyTemplateCompiler "templates/index.html"
- >>> applyTemplateCompiler "templates/default.html"
- >>> relativizeUrlsCompiler
+ match "index.html" $ route idRoute
+ create "index.html" $ constA mempty
+ >>> arr (setField "title" "Home")
+ >>> requireA "tags" (setFieldA "tagcloud" (renderTagCloud'))
+ >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList)
+ >>> applyTemplateCompiler "templates/index.html"
+ >>> applyTemplateCompiler "templates/default.html"
+ >>> relativizeUrlsCompiler
-- Tags
create "tags" $
requireAll "posts/*" (\_ ps -> readTags ps :: Tags String)
-- Add a tag list compiler for every tag
- route "tags/*" $ setExtension ".html"
+ match "tags/*" $ route $ setExtension ".html"
metaCompile $ require_ "tags"
>>> arr (M.toList . tagsMap)
>>> arr (map (\(t, p) -> (tagIdentifier t, makeTagList t p)))
-- Render RSS feed
- route "rss.xml" $ idRoute
+ match "rss.xml" $ route idRoute
create "rss.xml" $
requireAll_ "posts/*"
>>> mapCompiler (arr $ copyBodyToField "description")
>>> renderRss feedConfiguration
-- Read templates
- compile "templates/*" templateCompiler
-
- -- End
- return ()
+ match "templates/*" $ compile templateCompiler
where
renderTagCloud' :: Compiler (Tags String) String
renderTagCloud' = renderTagCloud tagIdentifier 100 120

0 comments on commit 51412d9

Please sign in to comment.