@@ -1,39 +1,47 @@
1+--------------------------------------------------------------------------------
1-- | Module providing the main hakyll function and command-line argument parsing
2-- | Module providing the main hakyll function and command-line argument parsing
3{-# LANGUAGE CPP #-}
3{-# LANGUAGE CPP #-}
4module Hakyll.Main
4module Hakyll.Main
6 , hakyllWith
6 , hakyllWith
9−import Control.Monad (when)
10−import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
11−import System.Environment (getProgName, getArgs)
12−import System.Process (system)
14−import Hakyll.Core.Configuration
10+--------------------------------------------------------------------------------
15−import Hakyll.Core.Identifier
11+import Control.Monad (when)
16−import Hakyll.Core.Runtime
12+import System.Directory (doesDirectoryExist,
17−import Hakyll.Core.Rules
13+ removeDirectoryRecursive)
14+import System.Environment (getArgs, getProgName)
15+import System.Process (system)
20−import Control.Applicative ((<$>))
21−import Control.Concurrent (forkIO)
22−import qualified Data.Set as S
18+--------------------------------------------------------------------------------
19+import Hakyll.Core.Configuration
20+import Hakyll.Core.Rules
21+import Hakyll.Core.Runtime
24+--------------------------------------------------------------------------------
26+import Control.Applicative ((<$>))
27+import Control.Concurrent (forkIO)
28+import qualified Data.Set as S
29+import Hakyll.Core.Identifier
24−import Hakyll.Core.Rules.Internal
30+import Hakyll.Core.Rules.Internal
25−import Hakyll.Web.Preview.Poll
31+import Hakyll.Web.Preview.Poll
26−import Hakyll.Web.Preview.Server
32+import Hakyll.Web.Preview.Server
36+--------------------------------------------------------------------------------
29-- | This usualy is the function with which the user runs the hakyll compiler
37-- | This usualy is the function with which the user runs the hakyll compiler
31hakyll :: Rules a -> IO ()
38hakyll :: Rules a -> IO ()
32hakyll = hakyllWith defaultConfiguration
39hakyll = hakyllWith defaultConfiguration
42+--------------------------------------------------------------------------------
34-- | A variant of 'hakyll' which allows the user to specify a custom
43-- | A variant of 'hakyll' which allows the user to specify a custom
35-- configuration
44-- configuration
37hakyllWith :: Configuration -> Rules a -> IO ()
45hakyllWith :: Configuration -> Rules a -> IO ()
38hakyllWith conf rules = do
46hakyllWith conf rules = do
39 args <- getArgs
47 args <- getArgs
@@ -49,15 +57,17 @@ hakyllWith conf rules = do
49 ["deploy"] -> deploy conf
57 ["deploy"] -> deploy conf
61+--------------------------------------------------------------------------------
52-- | Build the site
62-- | Build the site
54build :: Configuration -> Rules a -> IO ()
63build :: Configuration -> Rules a -> IO ()
55build conf rules = do
64build conf rules = do
56 _ <- run conf rules
65 _ <- run conf rules
69+--------------------------------------------------------------------------------
59-- | Remove the output directories
70-- | Remove the output directories
61clean :: Configuration -> IO ()
71clean :: Configuration -> IO ()
62clean conf = do
72clean conf = do
63 remove $ destinationDirectory conf
73 remove $ destinationDirectory conf
@@ -68,8 +78,9 @@ clean conf = do
68 exists <- doesDirectoryExist dir
78 exists <- doesDirectoryExist dir
69 when exists $ removeDirectoryRecursive dir
79 when exists $ removeDirectoryRecursive dir
82+--------------------------------------------------------------------------------
71-- | Show usage information.
83-- | Show usage information.
73help :: IO ()
84help :: IO ()
75 name <- getProgName
86 name <- getProgName
@@ -95,8 +106,9 @@ help = do
95 previewServerDisabled
106 previewServerDisabled
110+--------------------------------------------------------------------------------
98-- | Preview the site
111-- | Preview the site
100preview :: Configuration -> Rules a -> Int -> IO ()
112preview :: Configuration -> Rules a -> Int -> IO ()
101#ifdef PREVIEW_SERVER
113#ifdef PREVIEW_SERVER
102preview conf rules port = do
114preview conf rules port = do
@@ -111,15 +123,17 @@ preview conf rules port = do
111preview _ _ _ = previewServerDisabled
123preview _ _ _ = previewServerDisabled
127+--------------------------------------------------------------------------------
114-- | Rebuild the site
128-- | Rebuild the site
116rebuild :: Configuration -> Rules a -> IO ()
129rebuild :: Configuration -> Rules a -> IO ()
117rebuild conf rules = do
130rebuild conf rules = do
118 clean conf
131 clean conf
119 build conf rules
132 build conf rules
135+--------------------------------------------------------------------------------
121-- | Start a server
136-- | Start a server
123server :: Configuration -> Int -> IO ()
137server :: Configuration -> Int -> IO ()
124#ifdef PREVIEW_SERVER
138#ifdef PREVIEW_SERVER
125server conf port = do
139server conf port = do
@@ -131,15 +145,17 @@ server conf port = do
131server _ _ = previewServerDisabled
145server _ _ = previewServerDisabled
149+--------------------------------------------------------------------------------
134-- | Upload the site
150-- | Upload the site
136deploy :: Configuration -> IO ()
151deploy :: Configuration -> IO ()
137deploy conf = do
152deploy conf = do
138 _ <- system $ deployCommand conf
153 _ <- system $ deployCommand conf
139 return ()
154 return ()
157+--------------------------------------------------------------------------------
141-- | Print a warning message about the preview serving not being enabled
158-- | Print a warning message about the preview serving not being enabled
143#ifndef PREVIEW_SERVER
159#ifndef PREVIEW_SERVER
144previewServerDisabled :: IO ()
160previewServerDisabled :: IO ()
145previewServerDisabled =
161previewServerDisabled =