summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/RenderAction.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-04 22:09:41 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-04 22:09:41 +0100
commit11996929aae640c9cd3737fdb2736e6562c705de (patch)
treeafd6bcd7fe1aaf364a05100e851dd28a1cb3f273 /src/Text/Hakyll/RenderAction.hs
parent192c4a16ea01c9398a55f61025425d8e0e87e0f8 (diff)
downloadhakyll-11996929aae640c9cd3737fdb2736e6562c705de.tar.gz
Got it to compile again, disabled Tags for now.
Diffstat (limited to 'src/Text/Hakyll/RenderAction.hs')
-rw-r--r--src/Text/Hakyll/RenderAction.hs40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/Text/Hakyll/RenderAction.hs b/src/Text/Hakyll/RenderAction.hs
index a84ce46..26fa445 100644
--- a/src/Text/Hakyll/RenderAction.hs
+++ b/src/Text/Hakyll/RenderAction.hs
@@ -1,6 +1,10 @@
module Text.Hakyll.RenderAction
( RenderAction (..)
- , fromRenderable
+ , createRenderAction
+ , createSimpleRenderAction
+ , createManipulationAction
+ , chain
+ , runRenderAction
) where
import Prelude hiding ((.), id)
@@ -9,32 +13,42 @@ import Control.Monad ((<=<), mplus)
import Text.Hakyll.Hakyll
import Text.Hakyll.Context
-import Text.Hakyll.Renderable
data RenderAction a b = RenderAction
{ actionDependencies :: [FilePath]
- , actionDestination :: Maybe (Hakyll FilePath)
+ , actionUrl :: Maybe (Hakyll FilePath)
, actionFunction :: a -> Hakyll b
}
+createRenderAction :: (a -> Hakyll b) -> RenderAction a b
+createRenderAction f = RenderAction
+ { actionDependencies = []
+ , actionUrl = Nothing
+ , actionFunction = f
+ }
+
+createSimpleRenderAction :: Hakyll b -> RenderAction () b
+createSimpleRenderAction x = createRenderAction (const x)
+
instance Category RenderAction where
id = RenderAction
{ actionDependencies = []
- , actionDestination = Nothing
+ , actionUrl = Nothing
, actionFunction = return
}
x . y = RenderAction
{ actionDependencies = actionDependencies x ++ actionDependencies y
- , actionDestination = actionDestination y `mplus` actionDestination x
+ , actionUrl = actionUrl y `mplus` actionUrl x
, actionFunction = actionFunction x <=< actionFunction y
}
-fromRenderable :: (Renderable a)
- => a
- -> RenderAction () Context
-fromRenderable renderable = RenderAction
- { actionDependencies = getDependencies renderable
- , actionDestination = Just $ getUrl renderable
- , actionFunction = const $ toContext renderable
- }
+createManipulationAction :: ContextManipulation -> RenderAction Context Context
+createManipulationAction manipulation =
+ createRenderAction (return . manipulation)
+
+chain :: [RenderAction a a] -> RenderAction a a
+chain = foldl1 (>>>)
+
+runRenderAction :: RenderAction () a -> Hakyll a
+runRenderAction action = actionFunction action ()