on master help sign in
Add deploy command
commitfbe95ce6ce53fee904c62d986897ad3b340429d7 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateWed 15 Jun 2011, 08:53 (15 years ago) parent7c75227
3 files changed+41−18
hakyll.cabal+16−15 src/Hakyll/Core/Configuration.hs+14−2 src/Hakyll/Main.hs+11−1
hakyll.cabal+16−15
@@ -56,28 +56,29 @@ Library
5656
5757 Build-Depends:
5858 base >= 4 && < 5,
59− filepath == 1.*,
60− directory == 1.*,
59+ binary >= 0.5,
60+ blaze-html >= 0.4,
61+ bytestring >= 0.9,
6162 containers == 0.*,
62− pandoc == 1.*,
63− regex-base >= 0.93,
64− regex-pcre >= 0.93,
63+ directory == 1.*,
64+ filepath == 1.*,
65+ hamlet >= 0.7,
66+ hopenssl >= 1.4,
67+ HTTP >= 4000,
6568 mtl >= 1,
6669 old-locale == 1.*,
6770 old-time == 1.*,
68− time >= 1.1,
69− binary >= 0.5,
70− hamlet >= 0.7,
71− blaze-html >= 0.4,
72− snap-server >= 0.4,
71+ pandoc == 1.*,
72+ process >= 1.0,
73+ regex-base >= 0.93,
74+ regex-pcre >= 0.93,
7375 snap-core >= 0.4,
74− bytestring >= 0.9,
75− utf8-string >= 0.3,
76− HTTP >= 4000,
76+ snap-server >= 0.4,
77+ strict-concurrency >= 0.2,
7778 tagsoup >= 0.12,
78− hopenssl >= 1.4,
79+ time >= 1.1,
7980 unix >= 2.4,
80− strict-concurrency >= 0.2
81+ utf8-string >= 0.3
8182
8283 Exposed-Modules:
8384 Hakyll
src/Hakyll/Core/Configuration.hs+14−2
@@ -13,7 +13,7 @@ data HakyllConfiguration = HakyllConfiguration
1313 { -- | Directory in which the output written
1414 destinationDirectory :: FilePath
1515 , -- | Directory where hakyll's internal store is kept
16− storeDirectory :: FilePath
16+ storeDirectory :: FilePath
1717 , -- | Function to determine ignored files
1818 --
1919 -- In 'defaultHakyllConfiguration', the following files are ignored:
@@ -28,7 +28,18 @@ data HakyllConfiguration = HakyllConfiguration
2828 -- also be ignored. Note that this is the configuration parameter, if you
2929 -- want to use the test, you should use @shouldIgnoreFile@.
3030 --
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
3243 }
3344
3445-- | Default configuration for a hakyll application
@@ -38,6 +49,7 @@ defaultHakyllConfiguration = HakyllConfiguration
3849 { destinationDirectory = "_site"
3950 , storeDirectory = "_cache"
4051 , ignoreFile = ignoreFile'
52+ , deployCommand = "echo 'No deploy command specified'"
4153 }
4254 where
4355 ignoreFile' path
src/Hakyll/Main.hs+11−1
@@ -8,8 +8,9 @@ module Hakyll.Main
88import Control.Applicative ((<$>))
99import Control.Concurrent (forkIO)
1010import Control.Monad (when)
11−import System.Environment (getProgName, getArgs)
1211import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
12+import System.Environment (getProgName, getArgs)
13+import System.Process (system)
1314import qualified Data.Set as S
1415
1516import Hakyll.Core.Configuration
@@ -40,6 +41,7 @@ hakyllWith conf rules = do
4041 ["rebuild"] -> rebuild conf rules
4142 ["server"] -> server conf 8000
4243 ["server", p] -> server conf (read p)
44+ ["deploy"] -> deploy conf
4345 _ -> help
4446
4547-- | Build the site
@@ -80,6 +82,7 @@ help = do
8082 , name ++ " preview [port] Run a server and autocompile"
8183 , name ++ " rebuild Clean up and build again"
8284 , name ++ " server [port] Run a local test server"
85+ , name ++ " deploy Upload/deploy your site"
8386 ]
8487
8588-- | Preview the site
@@ -109,3 +112,10 @@ server conf port = do
109112 staticServer destination preServeHook port
110113 where
111114 preServeHook _ = return ()
115+
116+-- Upload the site
117+--
118+deploy :: HakyllConfiguration -> IO ()
119+deploy conf = do
120+ _ <- system $ deployCommand conf
121+ return ()