1-- | This is the module which binds it all together
3module Hakyll.Core.Run where
5import Control.Arrow ((&&&))
6import Control.Monad (msum, foldM, forM, forM_)
7import qualified Data.Map as M
9import Hakyll.Core.Route
10import Hakyll.Core.Compiler
11import Hakyll.Core.ResourceProvider
12import Hakyll.Core.ResourceProvider.FileResourceProvider
13import Hakyll.Core.Rules
14import Hakyll.Core.Target
15import Hakyll.Core.Identifier
16import Hakyll.Core.DirectedGraph
17import Hakyll.Core.DirectedGraph.DependencySolver
18import Hakyll.Core.Writable
20hakyll :: Writable a => Rules a -> IO ()
22 provider <- fileResourceProvider
23 hakyllWith rules provider
25hakyllWith :: Writable a => Rules a -> ResourceProvider -> IO ()
26hakyllWith rules provider = do
27 let -- Get the rule set
28 ruleSet = runRules rules provider
30 -- Get all identifiers and compilers
31 compilers = rulesCompilers ruleSet
34 targets = flip map compilers $ \(id', compiler) ->
35 let (targ, deps) = runCompiler compiler id'
38 -- Map mapping every identifier to it's target
39 targetMap = M.fromList $ map (\(i, t, _) -> (i, t)) targets
41 -- Create a dependency graph
42 graph = fromList $ map (\(i, _, d) -> (i, d)) targets
44 -- Solve the graph, creating a target order
45 ordered = solveDependencies graph
47 -- Join the order with the targets again
48 orderedTargets = map (id &&& (targetMap M.!)) ordered
50 -- Generate all the targets in order
51 map' <- foldM addTarget M.empty orderedTargets
53 let -- Fetch the routes
54 route' = rulesRoute ruleSet
56 forM_ (M.toList map') $ \(id', result) ->
57 case runRoute route' id' of
60 putStrLn $ "Routing " ++ show id' ++ " to " ++ r
65 addTarget map' (id', targ) = do
66 result <- runTarget targ id' (map' M.!) provider
67 putStrLn $ "Generated target: " ++ show id'
68 return $ M.insert id' result map'
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list