@@ -1,25 +1,30 @@
1-- | Module providing the main hakyll function and command-line argument parsing
1-- | Module providing the main hakyll function and command-line argument parsing
3module Hakyll.Main
4module Hakyll.Main
5 , hakyllWith
6 , hakyllWith
8−import Control.Applicative ((<$>))
9−import Control.Concurrent (forkIO)
10import Control.Monad (when)
9import Control.Monad (when)
11import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
10import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
12import System.Environment (getProgName, getArgs)
11import System.Environment (getProgName, getArgs)
13import System.Process (system)
12import System.Process (system)
14−import qualified Data.Set as S
16import Hakyll.Core.Configuration
14import Hakyll.Core.Configuration
17−import Hakyll.Core.Resource
18import Hakyll.Core.Run
15import Hakyll.Core.Run
19import Hakyll.Core.Rules
16import Hakyll.Core.Rules
19+import Control.Applicative ((<$>))
20+import Control.Concurrent (forkIO)
21+import qualified Data.Set as S
23+import Hakyll.Core.Resource
20import Hakyll.Core.Rules.Internal
24import Hakyll.Core.Rules.Internal
21import Hakyll.Web.Preview.Poll
25import Hakyll.Web.Preview.Poll
22import Hakyll.Web.Preview.Server
26import Hakyll.Web.Preview.Server
24-- | This usualy is the function with which the user runs the hakyll compiler
29-- | This usualy is the function with which the user runs the hakyll compiler
@@ -83,11 +88,17 @@ help = do
83 , name ++ " rebuild Clean up and build again"
88 , name ++ " rebuild Clean up and build again"
84 , name ++ " server [port] Run a local test server"
89 , name ++ " server [port] Run a local test server"
85 , name ++ " deploy Upload/deploy your site"
90 , name ++ " deploy Upload/deploy your site"
94+#ifndef PREVIEW_SERVER
95+ previewServerDisabled
88-- | Preview the site
98-- | Preview the site
90preview :: HakyllConfiguration -> RulesM a -> Int -> IO ()
100preview :: HakyllConfiguration -> RulesM a -> Int -> IO ()
101+#ifdef PREVIEW_SERVER
91preview conf rules port = do
102preview conf rules port = do
92 -- Fork a thread polling for changes
103 -- Fork a thread polling for changes
93 _ <- forkIO $ previewPoll conf update
104 _ <- forkIO $ previewPoll conf update
@@ -96,6 +107,9 @@ preview conf rules port = do
96 server conf port
107 server conf port
98 update = map unResource . S.toList . rulesResources <$> run conf rules
109 update = map unResource . S.toList . rulesResources <$> run conf rules
111+preview _ _ _ = previewServerDisabled
100-- | Rebuild the site
114-- | Rebuild the site
@@ -107,15 +121,33 @@ rebuild conf rules = do
107-- | Start a server
121-- | Start a server
109server :: HakyllConfiguration -> Int -> IO ()
123server :: HakyllConfiguration -> Int -> IO ()
124+#ifdef PREVIEW_SERVER
110server conf port = do
125server conf port = do
111 let destination = destinationDirectory conf
126 let destination = destinationDirectory conf
112 staticServer destination preServeHook port
127 staticServer destination preServeHook port
114 preServeHook _ = return ()
129 preServeHook _ = return ()
131+server _ _ = previewServerDisabled
116−-- Upload the site
134+-- | Upload the site
118deploy :: HakyllConfiguration -> IO ()
136deploy :: HakyllConfiguration -> IO ()
119deploy conf = do
137deploy conf = do
120 _ <- system $ deployCommand conf
138 _ <- system $ deployCommand conf
121 return ()
139 return ()
141+-- | Print a warning message about the preview serving not being enabled
143+#ifndef PREVIEW_SERVER
144+previewServerDisabled :: IO ()
145+previewServerDisabled =
149+ , "The preview server is not enabled in the version of Hakyll. To"
150+ , "enable it, set the flag to True and recompile Hakyll."
151+ , "Alternatively, use an external tool to serve your site directory."