on master help sign in
Renamed RenderAction to HakyllAction.
commitfa28eac8a395da7e524dc50d910d10dc1fa76a12 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateWed 10 Mar 2010, 13:35 (17 years ago) parenta028b35
8 files changed+86−86
hakyll.cabal+1−1 src/Text/Hakyll/Feed.hs+2−2 src/Text/Hakyll/RenderAction.hs → src/Text/Hakyll/HakyllAction.hs+43−43 src/Text/Hakyll/Internal/Render.hs+3−3 src/Text/Hakyll/Paginate.hs+2−2 src/Text/Hakyll/Render.hs+14−14 src/Text/Hakyll/Renderables.hs+10−10 src/Text/Hakyll/Tags.hs+11−11
hakyll.cabal+1−1
@@ -48,7 +48,7 @@ library
4848 Text.Hakyll.Hakyll
4949 Text.Hakyll.Regex
5050 Text.Hakyll.Render
51− Text.Hakyll.RenderAction
51+ Text.Hakyll.HakyllAction
5252 Text.Hakyll.Renderables
5353 Text.Hakyll.Paginate
5454 Text.Hakyll.Util
src/Text/Hakyll/Feed.hs+2−2
@@ -34,7 +34,7 @@ import Text.Hakyll.Context (ContextManipulation, renderDate)
3434import Text.Hakyll.Hakyll (Hakyll)
3535import Text.Hakyll.Render (render, renderChain)
3636import Text.Hakyll.Renderables (createListingWith)
37−import Text.Hakyll.RenderAction
37+import Text.Hakyll.HakyllAction
3838
3939import Paths_hakyll
4040
@@ -71,7 +71,7 @@ createFeedWith manipulation configuration renderables template itemTemplate =
7171 ] ++ updated
7272
7373 -- Take the first timestamp, which should be the most recent.
74− updated = let action = createRenderAction $
74+ updated = let action = createHakyllAction $
7575 return . fromMaybe "foo" . M.lookup "timestamp"
7676 manip = createManipulationAction manipulation
7777 toTuple r = ("timestamp", Right $ r >>> manip >>> action)
src/Text/Hakyll/RenderAction.hs → src/Text/Hakyll/HakyllAction.hsrenamed+43−43
@@ -1,13 +1,13 @@
1−-- | This is the module which exports @RenderAction@.
2−module Text.Hakyll.RenderAction
3− ( RenderAction (..)
4− , createRenderAction
5− , createSimpleRenderAction
6− , createFileRenderAction
1+-- | This is the module which exports @HakyllAction@.
2+module Text.Hakyll.HakyllAction
3+ ( HakyllAction (..)
4+ , createHakyllAction
5+ , createSimpleHakyllAction
6+ , createFileHakyllAction
77 , createManipulationAction
88 , chain
9− , runRenderAction
10− , runRenderActionIfNeeded
9+ , runHakyllAction
10+ , runHakyllActionIfNeeded
1111 , Renderable
1212 ) where
1313
@@ -23,85 +23,85 @@ import Text.Hakyll.File (toDestination, isFileMoreRecent)
2323import Text.Hakyll.Hakyll
2424
2525-- | Type used for rendering computations that carry along dependencies.
26−data RenderAction a b = RenderAction
27− { -- | Dependencies of the @RenderAction@.
26+data HakyllAction a b = HakyllAction
27+ { -- | Dependencies of the @HakyllAction@.
2828 actionDependencies :: [FilePath]
29− , -- | URL pointing to the result of this @RenderAction@.
29+ , -- | URL pointing to the result of this @HakyllAction@.
3030 actionUrl :: Maybe (Hakyll FilePath)
3131 , -- | The actual render function.
3232 actionFunction :: a -> Hakyll b
3333 }
3434
35−-- | Create a @RenderAction@ from a function.
36−createRenderAction :: (a -> Hakyll b) -- ^ Function to execute.
37− -> RenderAction a b
38−createRenderAction f = id { actionFunction = f }
35+-- | Create a @HakyllAction@ from a function.
36+createHakyllAction :: (a -> Hakyll b) -- ^ Function to execute.
37+ -> HakyllAction a b
38+createHakyllAction f = id { actionFunction = f }
3939
40−-- | Create a @RenderAction@ from a simple @Hakyll@ value.
41−createSimpleRenderAction :: Hakyll b -- ^ Hakyll value to pass on.
42− -> RenderAction () b
43−createSimpleRenderAction = createRenderAction . const
40+-- | Create a @HakyllAction@ from a simple @Hakyll@ value.
41+createSimpleHakyllAction :: Hakyll b -- ^ Hakyll value to pass on.
42+ -> HakyllAction () b
43+createSimpleHakyllAction = createHakyllAction . const
4444
45−-- | Create a @RenderAction@ that operates on one file.
46−createFileRenderAction :: FilePath -- ^ File to operate on.
45+-- | Create a @HakyllAction@ that operates on one file.
46+createFileHakyllAction :: FilePath -- ^ File to operate on.
4747 -> Hakyll b -- ^ Value to pass on.
48− -> RenderAction () b -- ^ The resulting action.
49−createFileRenderAction path action = RenderAction
48+ -> HakyllAction () b -- ^ The resulting action.
49+createFileHakyllAction path action = HakyllAction
5050 { actionDependencies = [path]
5151 , actionUrl = Just $ return path
5252 , actionFunction = const action
5353 }
5454
55−-- | Create a @RenderAction@ from a @ContextManipulation@.
55+-- | Create a @HakyllAction@ from a @ContextManipulation@.
5656createManipulationAction :: ContextManipulation -- ^ Manipulation to apply.
57− -> RenderAction Context Context
58−createManipulationAction = createRenderAction . (return .)
57+ -> HakyllAction Context Context
58+createManipulationAction = createHakyllAction . (return .)
5959
60−-- | Run a @RenderAction@ now.
61−runRenderAction :: RenderAction () a -- ^ Render action to run.
60+-- | Run a @HakyllAction@ now.
61+runHakyllAction :: HakyllAction () a -- ^ Render action to run.
6262 -> Hakyll a -- ^ Result of the action.
63−runRenderAction action = actionFunction action ()
63+runHakyllAction action = actionFunction action ()
6464
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
6666-- @actionUrl@ field must be set.
67−runRenderActionIfNeeded :: RenderAction () () -- ^ Action to run.
67+runHakyllActionIfNeeded :: HakyllAction () () -- ^ Action to run.
6868 -> Hakyll () -- ^ Empty result.
69−runRenderActionIfNeeded action = do
69+runHakyllActionIfNeeded action = do
7070 url <- case actionUrl action of
7171 (Just u) -> u
7272 Nothing -> error "No url when checking dependencies."
7373 destination <- toDestination url
7474 valid <- isFileMoreRecent destination $ actionDependencies action
7575 unless valid $ do liftIO $ hPutStrLn stderr $ "Rendering " ++ destination
76− runRenderAction action
76+ runHakyllAction action
7777
78−-- | Chain a number of @RenderAction@ computations.
79−chain :: [RenderAction a a] -- ^ Actions to chain.
80− -> RenderAction a a -- ^ Resulting action.
78+-- | Chain a number of @HakyllAction@ computations.
79+chain :: [HakyllAction a a] -- ^ Actions to chain.
80+ -> HakyllAction a a -- ^ Resulting action.
8181chain [] = id
8282chain list@(_:_) = foldl1 (>>>) list
8383
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
8585-- rendered.
86−type Renderable = RenderAction () Context
86+type Renderable = HakyllAction () Context
8787
88−instance Category RenderAction where
89− id = RenderAction
88+instance Category HakyllAction where
89+ id = HakyllAction
9090 { actionDependencies = []
9191 , actionUrl = Nothing
9292 , actionFunction = return
9393 }
9494
95− x . y = RenderAction
95+ x . y = HakyllAction
9696 { actionDependencies = actionDependencies x ++ actionDependencies y
9797 , actionUrl = actionUrl y `mplus` actionUrl x
9898 , actionFunction = actionFunction x <=< actionFunction y
9999 }
100100
101−instance Arrow RenderAction where
101+instance Arrow HakyllAction where
102102 arr f = id { actionFunction = return . f }
103103
104− first x = RenderAction
104+ first x = HakyllAction
105105 { actionDependencies = actionDependencies x
106106 , actionUrl = actionUrl x
107107 , actionFunction = \(y, z) -> do y' <- actionFunction x y
src/Text/Hakyll/Internal/Render.hs+3−3
@@ -14,7 +14,7 @@ import Data.Maybe (fromMaybe)
1414import Text.Hakyll.Context (Context, ContextManipulation)
1515import Text.Hakyll.File
1616import Text.Hakyll.Hakyll
17−import Text.Hakyll.RenderAction
17+import Text.Hakyll.HakyllAction
1818import Text.Hakyll.Internal.Template
1919
2020-- | A pure render function.
@@ -31,8 +31,8 @@ pureRenderWith manipulation template context =
3131
3232-- | Write a page to the site destination. Final action after render
3333-- chains and such.
34−writePage :: RenderAction Context ()
35−writePage = createRenderAction $ \initialContext -> do
34+writePage :: HakyllAction Context ()
35+writePage = createHakyllAction $ \initialContext -> do
3636 additionalContext' <- askHakyll getAdditionalContext
3737 let url = fromMaybe (error "No url defined at write time.")
3838 (M.lookup "url" initialContext)
src/Text/Hakyll/Paginate.hs+2−2
@@ -8,7 +8,7 @@ module Text.Hakyll.Paginate
88import Control.Applicative ((<$>))
99
1010import Text.Hakyll.Renderables
11−import Text.Hakyll.RenderAction
11+import Text.Hakyll.HakyllAction
1212import Text.Hakyll.Util (link)
1313
1414-- | A configuration for a pagination.
@@ -60,7 +60,7 @@ paginate configuration renderables = paginate' Nothing renderables (1 :: Int)
6060 where
6161 -- Create a link with a given label, taken from the configuration.
6262 linkWithLabel f r = Right $ case actionUrl r of
63− Just l -> createSimpleRenderAction $ link (f configuration) <$> l
63+ Just l -> createSimpleHakyllAction $ link (f configuration) <$> l
6464 Nothing -> error "No link found for pagination."
6565
6666 -- The main function that creates combined renderables by recursing over
src/Text/Hakyll/Render.hs+14−14
@@ -20,22 +20,22 @@ import qualified Data.Map as M
2020import Text.Hakyll.Hakyll (Hakyll)
2121import Text.Hakyll.Context (ContextManipulation, Context)
2222import Text.Hakyll.File
23−import Text.Hakyll.RenderAction
23+import Text.Hakyll.HakyllAction
2424import Text.Hakyll.Internal.CompressCss
2525import Text.Hakyll.Internal.Render
2626import Text.Hakyll.Internal.Template (readTemplate)
2727
2828-- | Render to a Page.
2929render :: FilePath -- ^ Template to use for rendering.
30− -> RenderAction Context Context -- ^ The render computation.
30+ -> HakyllAction Context Context -- ^ The render computation.
3131render = renderWith id
3232
3333-- | Render to a Page. This function allows you to manipulate the context
3434-- first.
3535renderWith :: ContextManipulation -- ^ Manipulation to apply first.
3636 -> FilePath -- ^ Template to use for rendering.
37− -> RenderAction Context Context -- ^ The render computation.
38−renderWith manipulation templatePath = RenderAction
37+ -> HakyllAction Context Context -- ^ The render computation.
38+renderWith manipulation templatePath = HakyllAction
3939 { actionDependencies = [templatePath]
4040 , actionUrl = Nothing
4141 , actionFunction = actionFunction'
@@ -57,7 +57,7 @@ renderWith manipulation templatePath = RenderAction
5757--
5858renderAndConcat :: [FilePath] -- ^ Templates to apply on every renderable.
5959 -> [Renderable] -- ^ Renderables to render.
60− -> RenderAction () String
60+ -> HakyllAction () String
6161renderAndConcat = renderAndConcatWith id
6262
6363-- | Render each renderable with the given templates, then concatenate the
@@ -66,8 +66,8 @@ renderAndConcat = renderAndConcatWith id
6666renderAndConcatWith :: ContextManipulation
6767 -> [FilePath]
6868 -> [Renderable]
69− -> RenderAction () String
70−renderAndConcatWith manipulation templatePaths renderables = RenderAction
69+ -> HakyllAction () String
70+renderAndConcatWith manipulation templatePaths renderables = HakyllAction
7171 { actionDependencies = renders >>= actionDependencies
7272 , actionUrl = Nothing
7373 , actionFunction = actionFunction'
@@ -78,7 +78,7 @@ renderAndConcatWith manipulation templatePaths renderables = RenderAction
7878 manipulationAction = createManipulationAction manipulation
7979
8080 actionFunction' _ = do
81− contexts <- mapM runRenderAction renders
81+ contexts <- mapM runHakyllAction renders
8282 return $ concatMap (fromMaybe "" . M.lookup "body") contexts
8383
8484-- | Chain a render action for a page with a number of templates. This will
@@ -101,9 +101,9 @@ renderChainWith :: ContextManipulation
101101 -> Renderable
102102 -> Hakyll ()
103103renderChainWith manipulation templatePaths initial =
104− runRenderActionIfNeeded renderChainWith'
104+ runHakyllActionIfNeeded renderChainWith'
105105 where
106− renderChainWith' :: RenderAction () ()
106+ renderChainWith' :: HakyllAction () ()
107107 renderChainWith' = initial >>> manipulationAction >>> chain' >>> writePage
108108
109109 chain' = chain (map render templatePaths)
@@ -113,18 +113,18 @@ renderChainWith manipulation templatePaths initial =
113113-- | Mark a certain file as static, so it will just be copied when the site is
114114-- generated.
115115static :: FilePath -> Hakyll ()
116−static source = runRenderActionIfNeeded static'
116+static source = runHakyllActionIfNeeded static'
117117 where
118− static' = createFileRenderAction source $ do
118+ static' = createFileHakyllAction source $ do
119119 destination <- toDestination source
120120 makeDirectories destination
121121 liftIO $ copyFile source destination
122122
123123-- | Render a css file, compressing it.
124124css :: FilePath -> Hakyll ()
125−css source = runRenderActionIfNeeded css'
125+css source = runHakyllActionIfNeeded css'
126126 where
127− css' = createFileRenderAction source $ do
127+ css' = createFileHakyllAction source $ do
128128 contents <- liftIO $ readFile source
129129 destination <- toDestination source
130130 makeDirectories destination
src/Text/Hakyll/Renderables.hs+10−10
@@ -14,7 +14,7 @@ import Control.Applicative ((<$>))
1414
1515import Text.Hakyll.File
1616import Text.Hakyll.Context
17−import Text.Hakyll.RenderAction
17+import Text.Hakyll.HakyllAction
1818import Text.Hakyll.Render
1919import Text.Hakyll.Internal.Page
2020
@@ -26,16 +26,16 @@ import Text.Hakyll.Internal.Page
2626-- dependency checking. A @String@ is obviously more simple to use in some
2727-- cases.
2828createCustomPage :: String
29− -> [(String, Either String (RenderAction () String))]
29+ -> [(String, Either String (HakyllAction () String))]
3030 -> Renderable
31−createCustomPage url association = RenderAction
31+createCustomPage url association = HakyllAction
3232 { actionDependencies = dataDependencies
3333 , actionUrl = Just $ return url
3434 , actionFunction = \_ -> M.fromList <$> assoc'
3535 }
3636 where
3737 mtuple (a, b) = b >>= \b' -> return (a, b')
38− toHakyllString = second (either return runRenderAction)
38+ toHakyllString = second (either return runHakyllAction)
3939 assoc' = mapM (mtuple . toHakyllString) $ ("url", Left url) : association
4040 dataDependencies = map snd association >>= getDependencies
4141 getDependencies (Left _) = []
@@ -57,7 +57,7 @@ createCustomPage url association = RenderAction
5757createListing :: String -- ^ Destination of the page.
5858 -> [FilePath] -- ^ Templates to render all items with.
5959 -> [Renderable] -- ^ Renderables in the list.
60− -> [(String, Either String (RenderAction () String))]
60+ -> [(String, Either String (HakyllAction () String))]
6161 -> Renderable
6262createListing = createListingWith id
6363
@@ -69,7 +69,7 @@ createListingWith :: ContextManipulation -- ^ Manipulation for the renderables.
6969 -> String -- ^ Destination of the page.
7070 -> [FilePath] -- ^ Templates to render all items with.
7171 -> [Renderable] -- ^ Renderables in the list.
72− -> [(String, Either String (RenderAction () String))]
72+ -> [(String, Either String (HakyllAction () String))]
7373 -> Renderable
7474createListingWith manipulation url templates renderables additional =
7575 createCustomPage url context
@@ -79,7 +79,7 @@ createListingWith manipulation url templates renderables additional =
7979
8080-- | Create a PagePath from a FilePath.
8181createPagePath :: FilePath -> Renderable
82−createPagePath path = RenderAction
82+createPagePath path = HakyllAction
8383 { actionDependencies = [path]
8484 , actionUrl = Just $ toUrl path
8585 , actionFunction = const (readPage path)
@@ -93,11 +93,11 @@ createPagePath path = RenderAction
9393-- this as a @union@ between two maps.
9494combine :: Renderable -> Renderable
9595 -> Renderable
96−combine x y = RenderAction
96+combine x y = HakyllAction
9797 { actionDependencies = actionDependencies x ++ actionDependencies y
9898 , actionUrl = actionUrl x `mplus` actionUrl y
9999 , actionFunction = \_ ->
100− liftM2 M.union (runRenderAction x) (runRenderAction y)
100+ liftM2 M.union (runHakyllAction x) (runHakyllAction y)
101101 }
102102
103103-- | Combine two renderables and set a custom URL. This behaves like @combine@,
@@ -109,7 +109,7 @@ combineWithUrl :: FilePath
109109combineWithUrl url x y = combine'
110110 { actionUrl = Just $ return url
111111 , actionFunction = \_ ->
112− M.insert "url" url <$> runRenderAction combine'
112+ M.insert "url" url <$> runHakyllAction combine'
113113 }
114114 where
115115 combine' = combine x y
src/Text/Hakyll/Tags.hs+11−11
@@ -48,7 +48,7 @@ import Text.Hakyll.Context
4848import Text.Hakyll.Hakyll (Hakyll)
4949import Text.Hakyll.Regex
5050import Text.Hakyll.Renderables
51−import Text.Hakyll.RenderAction
51+import Text.Hakyll.HakyllAction
5252import Text.Hakyll.Util
5353import Text.Hakyll.Internal.Cache
5454import Text.Hakyll.Internal.Template
@@ -65,8 +65,8 @@ type TagMap = M.Map String [Renderable]
6565readMap :: (Context -> [String]) -- ^ Function to get tags from a context.
6666 -> String -- ^ Unique identifier for the tagmap.
6767 -> [FilePath]
68− -> RenderAction () TagMap
69−readMap getTagsFunction identifier paths = RenderAction
68+ -> HakyllAction () TagMap
69+readMap getTagsFunction identifier paths = HakyllAction
7070 { actionDependencies = paths
7171 , actionUrl = Nothing
7272 , actionFunction = actionFunction'
@@ -85,7 +85,7 @@ readMap getTagsFunction identifier paths = RenderAction
8585
8686 readTagMap' = foldM addPaths M.empty paths
8787 addPaths current path = do
88− context <- runRenderAction $ createPagePath path
88+ context <- runHakyllAction $ createPagePath path
8989 let tags = getTagsFunction context
9090 addPaths' = flip (M.insertWith (++)) [path]
9191 return $ foldr addPaths' current tags
@@ -93,7 +93,7 @@ readMap getTagsFunction identifier paths = RenderAction
9393-- | Read a @TagMap@, using the @tags@ metadata field.
9494readTagMap :: String -- ^ Unique identifier for the map.
9595 -> [FilePath] -- ^ Paths to get tags from.
96− -> RenderAction () TagMap
96+ -> HakyllAction () TagMap
9797readTagMap = readMap getTagsFunction
9898 where
9999 getTagsFunction = map trim . splitRegex ","
@@ -102,22 +102,22 @@ readTagMap = readMap getTagsFunction
102102-- | Read a @TagMap@, using the subdirectories the pages are placed in.
103103readCategoryMap :: String -- ^ Unique identifier for the map.
104104 -> [FilePath] -- ^ Paths to get tags from.
105− -> RenderAction () TagMap
105+ -> HakyllAction () TagMap
106106readCategoryMap = readMap $ maybeToList . M.lookup "category"
107107
108−withTagMap :: RenderAction () TagMap
108+withTagMap :: HakyllAction () TagMap
109109 -> (String -> [Renderable] -> Hakyll ())
110110 -> Hakyll ()
111−withTagMap tagMap function = runRenderAction (tagMap >>> action)
111+withTagMap tagMap function = runHakyllAction (tagMap >>> action)
112112 where
113− action = createRenderAction (mapM_ (uncurry function) . M.toList)
113+ action = createHakyllAction (mapM_ (uncurry function) . M.toList)
114114
115115-- | Render a tag cloud.
116116renderTagCloud :: (String -> String) -- ^ Function to produce an url for a tag.
117117 -> Float -- ^ Smallest font size, in percent.
118118 -> Float -- ^ Biggest font size, in percent.
119− -> RenderAction TagMap String
120−renderTagCloud urlFunction minSize maxSize = createRenderAction renderTagCloud'
119+ -> HakyllAction TagMap String
120+renderTagCloud urlFunction minSize maxSize = createHakyllAction renderTagCloud'
121121 where
122122 renderTagCloud' tagMap =
123123 return $ intercalate " " $ map (renderTag tagMap) (tagCount tagMap)