1-- | This is the module which binds it all together
3module Hakyll.Core.Run where
5import Control.Arrow ((&&&))
6import Control.Monad (foldM, forM_)
7import qualified Data.Map as M
8import Data.Monoid (mempty)
9import Data.Typeable (Typeable)
10import Data.Binary (Binary)
11import System.FilePath ((</>))
13import Hakyll.Core.Route
14import Hakyll.Core.Identifier
15import Hakyll.Core.Util.File
16import Hakyll.Core.Compiler
17import Hakyll.Core.Compiler.Internal
18import Hakyll.Core.ResourceProvider
19import Hakyll.Core.ResourceProvider.FileResourceProvider
20import Hakyll.Core.Rules
21import Hakyll.Core.DirectedGraph
22import Hakyll.Core.DirectedGraph.Dot
23import Hakyll.Core.DirectedGraph.DependencySolver
24import Hakyll.Core.Writable
25import Hakyll.Core.Store
26import Hakyll.Core.CompiledItem
28hakyll :: Rules -> IO ()
30 store <- makeStore "_store"
31 provider <- fileResourceProvider
32 hakyllWith rules provider store
34hakyllWith :: Rules -> ResourceProvider -> Store -> IO ()
35hakyllWith rules provider store = do
36 let -- Get the rule set
37 ruleSet = runRules rules provider
39 -- Get all identifiers and compilers
40 compilers = rulesCompilers ruleSet
42 -- Get all dependencies
43 dependencies = flip map compilers $ \(id', compiler) ->
44 let deps = runCompilerDependencies compiler provider
47 -- Create a compiler map
48 compilerMap = M.fromList compilers
50 -- Create and solve the graph, creating a compiler order
51 graph = fromList dependencies
52 ordered = solveDependencies graph
54 -- Join the order with the compilers again
55 orderedCompilers = map (id &&& (compilerMap M.!)) ordered
58 route' = rulesRoute ruleSet
60 putStrLn "Writing dependency graph to dependencies.dot..."
61 writeDot "dependencies.dot" show graph
63 -- Generate all the targets in order
64 _ <- foldM (addTarget route') M.empty orderedCompilers
68 addTarget route' map' (id', comp) = do
69 compiled <- runCompilerJob comp id' provider (dependencyLookup map')
70 putStrLn $ "Generated target: " ++ show id'
72 case runRoute route' id' of
75 putStrLn $ "Routing " ++ show id' ++ " to " ++ r
76 let path = "_site" </> r
80 return $ M.insert id' compiled map'
82 dependencyLookup map' id' = case M.lookup id' map' of
83 Nothing -> error $ "dependencyLookup: " ++ show id' ++ " not found"
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