on 036c583 help sign in
CHANGELOG.md−13
since splitsnapshots
unifiedsplit
@@ -4,19 +4,6 @@ title: Releases
4
4
5# Releases
5# Releases
6
6
7−## Hakyll 4.13.0.0 (2019-08-30)
8−
9−- Improved documentation in many places (contribution by Bergi)
10−- Significantly improve error messages when reading and applying templates
11− (contribution by Bergi)
12− * `empty` and `fail` for `Compiler` now fail without or with a message,
13− allowing for much better debug output
14− * `renderFeed`, `renderRssWithTemplates` and `renderAtomWithTemplates` now
15− take `Template` rather than `String` arguments
16−- Add option to specify date in directory structure,e.g.
17− `posts/2019/05/10/tomorrow.md` (contribution by Taeer Bar-Ya)
18−- Bump QuickCheck to 2.13
19−
20## Hakyll 4.12.5.2 (2019-05-09)
7## Hakyll 4.12.5.2 (2019-05-09)
21
8
22- Bump pandoc to 2.7
9- Bump pandoc to 2.7
hakyll.cabal+1−1
@@ -1,5 +1,5 @@
1Name: hakyll
1Name: hakyll
2−Version: 4.13.0.0
2+Version: 4.12.5.2
3
3
4Synopsis: A static website compiler library
4Synopsis: A static website compiler library
5Description:
5Description:
lib/Hakyll/Web/Template/Context.hs+1−14
@@ -21,7 +21,6 @@
21--------------------------------------------------------------------------------
21--------------------------------------------------------------------------------
22{-# LANGUAGE CPP #-}
22{-# LANGUAGE CPP #-}
23{-# LANGUAGE ExistentialQuantification #-}
23{-# LANGUAGE ExistentialQuantification #-}
24−{-# LANGUAGE RankNTypes #-}
25module Hakyll.Web.Template.Context
24module Hakyll.Web.Template.Context
26 ( ContextField (..)
25 ( ContextField (..)
27 , Context (..)
26 , Context (..)
@@ -49,7 +48,6 @@ module Hakyll.Web.Template.Context
49 , teaserField
48 , teaserField
50 , teaserFieldWithSeparator
49 , teaserFieldWithSeparator
51 , missingField
50 , missingField
52− , bindItem
53 ) where
51 ) where
54
52
55
53
@@ -178,11 +176,7 @@ listField key c xs = listFieldWith key c (const xs)
178
176
179
177
180--------------------------------------------------------------------------------
178--------------------------------------------------------------------------------
181−-- | Produces a new 'Context' which has list field 'key'. All fields from
182−-- 'c' are also accessible from the produced context.
183−-- Be careful when doing @listFieldWith k ca f <> cb@ as any fields in @ca@
184−-- will override fields in @cb@ with the same name.
185−-- Creates a list field like 'listField', but supplies the current page
179+-- | Creates a list field like 'listField', but supplies the current page
186-- to the compiler.
180-- to the compiler.
187listFieldWith
181listFieldWith
188 :: String -> Context a -> (Item b -> Compiler [Item a]) -> Context b
182 :: String -> Context a -> (Item b -> Compiler [Item a]) -> Context b
@@ -472,10 +466,3 @@ parseTimeM = TF.parseTimeM
472#else
466#else
473parseTimeM _ = TF.parseTime
467parseTimeM _ = TF.parseTime
474#endif
468#endif
475−
476−--------------------------------------------------------------------------------
477−
478−-- | Binds an 'Item' to a given 'Context', allowing it to be combined with any
479−-- other 'Context' of any type.
480−bindItem :: Context a -> Item a -> forall b. Context b
481−bindItem (Context ctx) ia = Context $ \k args _ -> ctx k args ia
lib/Hakyll/Web/Template/Internal.hs+2−3
@@ -21,8 +21,7 @@ module Hakyll.Web.Template.Internal
21
21
22
22
23--------------------------------------------------------------------------------
23--------------------------------------------------------------------------------
24−import Control.Monad (forM)
24+import Control.Monad.Except (catchError)
25−import Control.Monad.Except (MonadError (..), catchError)
26import Data.Binary (Binary)
25import Data.Binary (Binary)
27import Data.List (intercalate)
26import Data.List (intercalate)
28import qualified Data.List.NonEmpty as NonEmpty
27import qualified Data.List.NonEmpty as NonEmpty
@@ -172,7 +171,7 @@ applyTemplate' tes context x = go tes
172 StringField _ -> expected "list" "string" typeMsg
171 StringField _ -> expected "list" "string" typeMsg
173 ListField c xs -> withErrorMessage bodyMsg $ do
172 ListField c xs -> withErrorMessage bodyMsg $ do
174 sep <- maybe (return "") go s
173 sep <- maybe (return "") go s
175− bs <- forM xs $ applyTemplate' b $ c <> bindItem context x
174+ bs <- mapM (applyTemplate' b c) xs
176 return $ intercalate sep bs
175 return $ intercalate sep bs
177 where
176 where
178 headMsg = "In expr '$for(" ++ show e ++ ")$'"
177 headMsg = "In expr '$for(" ++ show e ++ ")$'"
tests/Hakyll/Web/Tags/Tests.hsnew file+42
@@ -0,0 +1,42 @@
1+--------------------------------------------------------------------------------
2+{-# LANGUAGE OverloadedStrings #-}
3+module Hakyll.Web.Tags.Tests
4+ ( tests
5+ ) where
6+
7+--------------------------------------------------------------------------------
8+import Test.Tasty (TestTree, testGroup)
9+import Test.Tasty.HUnit (Assertion, testCase, (@?=))
10+
11+--------------------------------------------------------------------------------
12+import Hakyll.Core.Identifier
13+import Hakyll.Core.Provider
14+import Hakyll.Core.Store (Store)
15+import Hakyll.Web.Tags
16+import TestSuite.Util
17+
18+tests :: TestTree
19+tests = testGroup "Hakyll.Web.Tags"
20+ [ testCase "testGetCategory" testGetCategory
21+ ]
22+
23+testGetCategory :: Assertion
24+testGetCategory = do
25+ store <- newTestStore
26+ provider <- newTestProvider store
27+
28+ noCategory <- testCategoryDone store provider "example.md"
29+ noCategory @?= [""]
30+
31+ oneCategory1 <- testCategoryDone store provider "posts/2010-08-26-birthday.md"
32+ oneCategory1 @?= ["posts"]
33+
34+ oneCategory2 <- testCategoryDone store provider "posts/2019/05/10/tomorrow.md"
35+ oneCategory2 @?= ["10"]
36+
37+ cleanTestEnv
38+
39+--------------------------------------------------------------------------------
40+testCategoryDone :: Store -> Provider -> Identifier -> IO [String]
41+testCategoryDone store provider identifier =
42+ testCompilerDone store provider identifier $ getCategory identifier
tests/Hakyll/Web/Template/Context/Tests.hs−28
@@ -13,11 +13,9 @@ import Test.Tasty.HUnit (Assertion, testCase, (@=?))
13--------------------------------------------------------------------------------
13--------------------------------------------------------------------------------
14import Hakyll.Core.Compiler
14import Hakyll.Core.Compiler
15import Hakyll.Core.Identifier
15import Hakyll.Core.Identifier
16−import Hakyll.Core.Item
17import Hakyll.Core.Provider
16import Hakyll.Core.Provider
18import Hakyll.Core.Store (Store)
17import Hakyll.Core.Store (Store)
19import Hakyll.Web.Template.Context
18import Hakyll.Web.Template.Context
20−import Hakyll.Web.Template.Internal
21import TestSuite.Util
19import TestSuite.Util
22
20
23
21
@@ -25,7 +23,6 @@ import TestSuite.Util
25tests :: TestTree
23tests :: TestTree
26tests = testGroup "Hakyll.Web.Template.Context.Tests"
24tests = testGroup "Hakyll.Web.Template.Context.Tests"
27 [ testCase "testDateField" testDateField
25 [ testCase "testDateField" testDateField
28− , testCase "testOuerLoopContextAccess" testOuerLoopContextAccess
29 ]
26 ]
30
27
31
28
@@ -68,28 +65,3 @@ testContextDone store provider identifier key context =
68 _ -> error $
65 _ -> error $
69 "Hakyll.Web.Template.Context.Tests.testContextDone: " ++
66 "Hakyll.Web.Template.Context.Tests.testContextDone: " ++
70 "expected StringField"
67 "expected StringField"
71−
72−--------------------------------------------------------------------------------
73−
74−testOuerLoopContextAccess :: Assertion
75−testOuerLoopContextAccess = do
76− store <- newTestStore
77− provider <- newTestProvider store
78− test store provider ctx "baz"
79− test store provider (ctx' <> ctx) "not baz"
80− test store provider (ctx <> ctx') "baz"
81−
82− cleanTestEnv
83− where
84− tpl = readTemplate "$for(foo)$$for(bar)$$qux$$endfor$$endfor$"
85− ctx = mconcat [
86− field "qux" $ const $ return "baz"
87− , listField "foo" (listField "bar" mempty $ return [mockItem])
88− $ return [mockItem]
89− ]
90− ctx' = field "qux" $ const $ return "not baz"
91− mockItem = Item "" ()
92− test store provider context str = do
93− str' <- testCompilerDone store provider ""
94− $ applyTemplate tpl context mockItem
95− str @=? itemBody str'