on 5dba607 help sign in
hakyll/src/Hakyll/Core/Configuration.hs
69 lines 2.2 kB history raw
1-- | Exports a datastructure for the top-level hakyll configuration
2--
3module Hakyll.Core.Configuration
4 ( HakyllConfiguration (..)
5 , shouldIgnoreFile
6 , defaultHakyllConfiguration
7 ) where
9import System.FilePath (takeFileName)
10import Data.List (isPrefixOf, isSuffixOf)
12data HakyllConfiguration = HakyllConfiguration
13 { -- | Directory in which the output written
14 destinationDirectory :: FilePath
15 , -- | Directory where hakyll's internal store is kept
16 storeDirectory :: FilePath
17 , -- | Function to determine ignored files
18 --
19 -- In 'defaultHakyllConfiguration', the following files are ignored:
20 --
21 -- * files starting with a @.@
22 --
23 -- * files ending with a @~@
24 --
25 -- * files ending with @.swp@
26 --
27 -- Note that the files in @destinationDirectory@ and @storeDirectory@ will
28 -- also be ignored. Note that this is the configuration parameter, if you
29 -- want to use the test, you should use @shouldIgnoreFile@.
30 --
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
43 }
45-- | Default configuration for a hakyll application
46--
47defaultHakyllConfiguration :: HakyllConfiguration
48defaultHakyllConfiguration = HakyllConfiguration
49 { destinationDirectory = "_site"
50 , storeDirectory = "_cache"
51 , ignoreFile = ignoreFile'
52 , deployCommand = "echo 'No deploy command specified'"
53 }
54 where
55 ignoreFile' path
56 | "." `isPrefixOf` fileName = True
57 | "~" `isSuffixOf` fileName = True
58 | ".swp" `isSuffixOf` fileName = True
59 | otherwise = False
60 where
61 fileName = takeFileName path
63-- | Check if a file should be ignored
64--
65shouldIgnoreFile :: HakyllConfiguration -> FilePath -> Bool
66shouldIgnoreFile conf path =
67 destinationDirectory conf `isPrefixOf` path ||
68 storeDirectory conf `isPrefixOf` path ||
69 ignoreFile conf path