on master help sign in
Add deploy command
fbe95ceJasper Van der Jeugt
hakyll.cabal+16−15
@@ -56,28 +56,29 @@ Library
56
56
57 Build-Depends:
57 Build-Depends:
58 base >= 4 && < 5,
58 base >= 4 && < 5,
59− filepath == 1.*,
59+ binary >= 0.5,
60− directory == 1.*,
60+ blaze-html >= 0.4,
61+ bytestring >= 0.9,
61 containers == 0.*,
62 containers == 0.*,
62− pandoc == 1.*,
63+ directory == 1.*,
63− regex-base >= 0.93,
64+ filepath == 1.*,
64− regex-pcre >= 0.93,
65+ hamlet >= 0.7,
66+ hopenssl >= 1.4,
67+ HTTP >= 4000,
65 mtl >= 1,
68 mtl >= 1,
66 old-locale == 1.*,
69 old-locale == 1.*,
67 old-time == 1.*,
70 old-time == 1.*,
68− time >= 1.1,
71+ pandoc == 1.*,
69− binary >= 0.5,
72+ process >= 1.0,
70− hamlet >= 0.7,
73+ regex-base >= 0.93,
71− blaze-html >= 0.4,
74+ regex-pcre >= 0.93,
72− snap-server >= 0.4,
73 snap-core >= 0.4,
75 snap-core >= 0.4,
74− bytestring >= 0.9,
76+ snap-server >= 0.4,
75− utf8-string >= 0.3,
77+ strict-concurrency >= 0.2,
76− HTTP >= 4000,
77 tagsoup >= 0.12,
78 tagsoup >= 0.12,
78− hopenssl >= 1.4,
79+ time >= 1.1,
79 unix >= 2.4,
80 unix >= 2.4,
80− strict-concurrency >= 0.2
81+ utf8-string >= 0.3
81
82
82 Exposed-Modules:
83 Exposed-Modules:
83 Hakyll
84 Hakyll
src/Hakyll/Core/Configuration.hs+14−2
@@ -13,7 +13,7 @@ data HakyllConfiguration = HakyllConfiguration
13 { -- | Directory in which the output written
13 { -- | Directory in which the output written
14 destinationDirectory :: FilePath
14 destinationDirectory :: FilePath
15 , -- | Directory where hakyll's internal store is kept
15 , -- | Directory where hakyll's internal store is kept
16− storeDirectory :: FilePath
16+ storeDirectory :: FilePath
17 , -- | Function to determine ignored files
17 , -- | Function to determine ignored files
18 --
18 --
19 -- In 'defaultHakyllConfiguration', the following files are ignored:
19 -- In 'defaultHakyllConfiguration', the following files are ignored:
@@ -28,7 +28,18 @@ data HakyllConfiguration = HakyllConfiguration
28 -- also be ignored. Note that this is the configuration parameter, if you
28 -- also be ignored. Note that this is the configuration parameter, if you
29 -- want to use the test, you should use @shouldIgnoreFile@.
29 -- want to use the test, you should use @shouldIgnoreFile@.
30 --
30 --
31− ignoreFile :: FilePath -> Bool
31+ ignoreFile :: FilePath -> Bool
32+ , -- | Here, you can plug in a system command to upload/deploy your site.
33+ --
34+ -- Example:
35+ --
36+ -- > rsync -ave 'ssh -p 2217' _site jaspervdj@jaspervdj.be:hakyll
37+ --
38+ -- You can execute this by using
39+ --
40+ -- > ./hakyll deploy
41+ --
42+ deployCommand :: String
32 }
43 }
33
44
34-- | Default configuration for a hakyll application
45-- | Default configuration for a hakyll application
@@ -38,6 +49,7 @@ defaultHakyllConfiguration = HakyllConfiguration
38 { destinationDirectory = "_site"
49 { destinationDirectory = "_site"
39 , storeDirectory = "_cache"
50 , storeDirectory = "_cache"
40 , ignoreFile = ignoreFile'
51 , ignoreFile = ignoreFile'
52+ , deployCommand = "echo 'No deploy command specified'"
41 }
53 }
42 where
54 where
43 ignoreFile' path
55 ignoreFile' path
src/Hakyll/Main.hs+11−1
@@ -8,8 +8,9 @@ module Hakyll.Main
8import Control.Applicative ((<$>))
8import Control.Applicative ((<$>))
9import Control.Concurrent (forkIO)
9import Control.Concurrent (forkIO)
10import Control.Monad (when)
10import Control.Monad (when)
11−import System.Environment (getProgName, getArgs)
12import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
11import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
12+import System.Environment (getProgName, getArgs)
13+import System.Process (system)
13import qualified Data.Set as S
14import qualified Data.Set as S
14
15
15import Hakyll.Core.Configuration
16import Hakyll.Core.Configuration
@@ -40,6 +41,7 @@ hakyllWith conf rules = do
40 ["rebuild"] -> rebuild conf rules
41 ["rebuild"] -> rebuild conf rules
41 ["server"] -> server conf 8000
42 ["server"] -> server conf 8000
42 ["server", p] -> server conf (read p)
43 ["server", p] -> server conf (read p)
44+ ["deploy"] -> deploy conf
43 _ -> help
45 _ -> help
44
46
45-- | Build the site
47-- | Build the site
@@ -80,6 +82,7 @@ help = do
80 , name ++ " preview [port] Run a server and autocompile"
82 , name ++ " preview [port] Run a server and autocompile"
81 , name ++ " rebuild Clean up and build again"
83 , name ++ " rebuild Clean up and build again"
82 , name ++ " server [port] Run a local test server"
84 , name ++ " server [port] Run a local test server"
85+ , name ++ " deploy Upload/deploy your site"
83 ]
86 ]
84
87
85-- | Preview the site
88-- | Preview the site
@@ -109,3 +112,10 @@ server conf port = do
109 staticServer destination preServeHook port
112 staticServer destination preServeHook port
110 where
113 where
111 preServeHook _ = return ()
114 preServeHook _ = return ()
115+
116+-- Upload the site
117+--
118+deploy :: HakyllConfiguration -> IO ()
119+deploy conf = do
120+ _ <- system $ deployCommand conf
121+ return ()