@@ -1,13 +1,13 @@
1−-- | This is the module which exports @RenderAction@.
1+-- | This is the module which exports @HakyllAction@.
2−module Text.Hakyll.RenderAction
2+module Text.Hakyll.HakyllAction
3− ( RenderAction (..)
3+ ( HakyllAction (..)
4− , createRenderAction
4+ , createHakyllAction
5− , createSimpleRenderAction
5+ , createSimpleHakyllAction
6− , createFileRenderAction
6+ , createFileHakyllAction
7 , createManipulationAction
7 , createManipulationAction
9− , runRenderAction
9+ , runHakyllAction
10− , runRenderActionIfNeeded
10+ , runHakyllActionIfNeeded
11 , Renderable
11 , Renderable
@@ -23,85 +23,85 @@ import Text.Hakyll.File (toDestination, isFileMoreRecent)
23import Text.Hakyll.Hakyll
23import Text.Hakyll.Hakyll
25-- | Type used for rendering computations that carry along dependencies.
25-- | Type used for rendering computations that carry along dependencies.
26−data RenderAction a b = RenderAction
26+data HakyllAction a b = HakyllAction
27− { -- | Dependencies of the @RenderAction@.
27+ { -- | Dependencies of the @HakyllAction@.
28 actionDependencies :: [FilePath]
28 actionDependencies :: [FilePath]
29− , -- | URL pointing to the result of this @RenderAction@.
29+ , -- | URL pointing to the result of this @HakyllAction@.
30 actionUrl :: Maybe (Hakyll FilePath)
30 actionUrl :: Maybe (Hakyll FilePath)
31 , -- | The actual render function.
31 , -- | The actual render function.
32 actionFunction :: a -> Hakyll b
32 actionFunction :: a -> Hakyll b
35−-- | Create a @RenderAction@ from a function.
35+-- | Create a @HakyllAction@ from a function.
36−createRenderAction :: (a -> Hakyll b) -- ^ Function to execute.
36+createHakyllAction :: (a -> Hakyll b) -- ^ Function to execute.
37− -> RenderAction a b
37+ -> HakyllAction a b
38−createRenderAction f = id { actionFunction = f }
38+createHakyllAction f = id { actionFunction = f }
40−-- | Create a @RenderAction@ from a simple @Hakyll@ value.
40+-- | Create a @HakyllAction@ from a simple @Hakyll@ value.
41−createSimpleRenderAction :: Hakyll b -- ^ Hakyll value to pass on.
41+createSimpleHakyllAction :: Hakyll b -- ^ Hakyll value to pass on.
42− -> RenderAction () b
42+ -> HakyllAction () b
43−createSimpleRenderAction = createRenderAction . const
43+createSimpleHakyllAction = createHakyllAction . const
45−-- | Create a @RenderAction@ that operates on one file.
45+-- | Create a @HakyllAction@ that operates on one file.
46−createFileRenderAction :: FilePath -- ^ File to operate on.
46+createFileHakyllAction :: FilePath -- ^ File to operate on.
47 -> Hakyll b -- ^ Value to pass on.
47 -> Hakyll b -- ^ Value to pass on.
48− -> RenderAction () b -- ^ The resulting action.
48+ -> HakyllAction () b -- ^ The resulting action.
49−createFileRenderAction path action = RenderAction
49+createFileHakyllAction path action = HakyllAction
50 { actionDependencies = [path]
50 { actionDependencies = [path]
51 , actionUrl = Just $ return path
51 , actionUrl = Just $ return path
52 , actionFunction = const action
52 , actionFunction = const action
55−-- | Create a @RenderAction@ from a @ContextManipulation@.
55+-- | Create a @HakyllAction@ from a @ContextManipulation@.
56createManipulationAction :: ContextManipulation -- ^ Manipulation to apply.
56createManipulationAction :: ContextManipulation -- ^ Manipulation to apply.
57− -> RenderAction Context Context
57+ -> HakyllAction Context Context
58−createManipulationAction = createRenderAction . (return .)
58+createManipulationAction = createHakyllAction . (return .)
60−-- | Run a @RenderAction@ now.
60+-- | Run a @HakyllAction@ now.
61−runRenderAction :: RenderAction () a -- ^ Render action to run.
61+runHakyllAction :: HakyllAction () a -- ^ Render action to run.
62 -> Hakyll a -- ^ Result of the action.
62 -> Hakyll a -- ^ Result of the action.
63−runRenderAction action = actionFunction action ()
63+runHakyllAction action = actionFunction action ()
65−-- | Run a @RenderAction@, but only when it is out-of-date. At this point, the
65+-- | Run a @HakyllAction@, but only when it is out-of-date. At this point, the
66-- @actionUrl@ field must be set.
66-- @actionUrl@ field must be set.
67−runRenderActionIfNeeded :: RenderAction () () -- ^ Action to run.
67+runHakyllActionIfNeeded :: HakyllAction () () -- ^ Action to run.
68 -> Hakyll () -- ^ Empty result.
68 -> Hakyll () -- ^ Empty result.
69−runRenderActionIfNeeded action = do
69+runHakyllActionIfNeeded action = do
70 url <- case actionUrl action of
70 url <- case actionUrl action of
71 (Just u) -> u
71 (Just u) -> u
72 Nothing -> error "No url when checking dependencies."
72 Nothing -> error "No url when checking dependencies."
73 destination <- toDestination url
73 destination <- toDestination url
74 valid <- isFileMoreRecent destination $ actionDependencies action
74 valid <- isFileMoreRecent destination $ actionDependencies action
75 unless valid $ do liftIO $ hPutStrLn stderr $ "Rendering " ++ destination
75 unless valid $ do liftIO $ hPutStrLn stderr $ "Rendering " ++ destination
76− runRenderAction action
76+ runHakyllAction action
78−-- | Chain a number of @RenderAction@ computations.
78+-- | Chain a number of @HakyllAction@ computations.
79−chain :: [RenderAction a a] -- ^ Actions to chain.
79+chain :: [HakyllAction a a] -- ^ Actions to chain.
80− -> RenderAction a a -- ^ Resulting action.
80+ -> HakyllAction a a -- ^ Resulting action.
81chain [] = id
81chain [] = id
82chain list@(_:_) = foldl1 (>>>) list
82chain list@(_:_) = foldl1 (>>>) list
84−-- | This is a specialized version of @RenderAction@, a @Context@ that can be
84+-- | This is a specialized version of @HakyllAction@, a @Context@ that can be
85-- rendered.
85-- rendered.
86−type Renderable = RenderAction () Context
86+type Renderable = HakyllAction () Context
88−instance Category RenderAction where
88+instance Category HakyllAction where
89− id = RenderAction
89+ id = HakyllAction
90 { actionDependencies = []
90 { actionDependencies = []
91 , actionUrl = Nothing
91 , actionUrl = Nothing
92 , actionFunction = return
92 , actionFunction = return
95− x . y = RenderAction
95+ x . y = HakyllAction
96 { actionDependencies = actionDependencies x ++ actionDependencies y
96 { actionDependencies = actionDependencies x ++ actionDependencies y
97 , actionUrl = actionUrl y `mplus` actionUrl x
97 , actionUrl = actionUrl y `mplus` actionUrl x
98 , actionFunction = actionFunction x <=< actionFunction y
98 , actionFunction = actionFunction x <=< actionFunction y
101−instance Arrow RenderAction where
101+instance Arrow HakyllAction where
102 arr f = id { actionFunction = return . f }
102 arr f = id { actionFunction = return . f }
104− first x = RenderAction
104+ first x = HakyllAction
105 { actionDependencies = actionDependencies x
105 { actionDependencies = actionDependencies x
106 , actionUrl = actionUrl x
106 , actionUrl = actionUrl x
107 , actionFunction = \(y, z) -> do y' <- actionFunction x y
107 , actionFunction = \(y, z) -> do y' <- actionFunction x y