summaryrefslogtreecommitdiff
path: root/src/Hakyll/Main.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-10 20:05:50 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-10 20:05:50 +0100
commitc03607e08751c3ce0e7c4cb70f9168f7f0237663 (patch)
tree6788ffd972aae3bf257a898e7beb23521c82d4cf /src/Hakyll/Main.hs
parent77f37c1443293b791841538bf860e346536e306d (diff)
downloadhakyll-c03607e08751c3ce0e7c4cb70f9168f7f0237663.tar.gz
Add prototype inotify backend
Diffstat (limited to 'src/Hakyll/Main.hs')
-rw-r--r--src/Hakyll/Main.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Hakyll/Main.hs b/src/Hakyll/Main.hs
index 1d60e47..64800c2 100644
--- a/src/Hakyll/Main.hs
+++ b/src/Hakyll/Main.hs
@@ -5,6 +5,7 @@ module Hakyll.Main
, hakyllWith
) where
+import Control.Concurrent (forkIO)
import Control.Monad (when)
import System.Environment (getProgName, getArgs)
import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
@@ -12,6 +13,7 @@ import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
import Hakyll.Core.Configuration
import Hakyll.Core.Run
import Hakyll.Core.Rules
+import Hakyll.Web.Preview.INotify
import Hakyll.Web.Preview.Server
-- | This usualy is the function with which the user runs the hakyll compiler
@@ -29,8 +31,8 @@ hakyllWith configuration rules = do
["build"] -> build configuration rules
["clean"] -> clean configuration
["help"] -> help
- ["preview"] -> putStrLn "Not implemented"
- ["preview", p] -> putStrLn "Not implemented"
+ ["preview"] -> preview configuration rules 8000
+ ["preview", p] -> preview configuration rules (read p)
["rebuild"] -> rebuild configuration rules
["server"] -> server configuration 8000
["server", p] -> server configuration (read p)
@@ -74,6 +76,16 @@ help = do
, name ++ " server [port] Run a local test server"
]
+-- | Preview the site
+--
+preview :: HakyllConfiguration -> Rules -> Int -> IO ()
+preview configuration rules port = do
+ -- Fork a thread polling for changes
+ _ <- forkIO $ previewPoll configuration "." $ build configuration rules
+
+ -- Run the server in the main thread
+ server configuration port
+
-- | Rebuild the site
--
rebuild :: HakyllConfiguration -> Rules -> IO ()