1--------------------------------------------------------------------------------
2-- | Exports a datastructure for the top-level hakyll configuration
3module Hakyll.Core.Configuration
10--------------------------------------------------------------------------------
11import Control.Monad (void)
12import Data.Default (Default(..))
13import Data.List (isPrefixOf, isSuffixOf)
14import System.FilePath (normalise, takeFileName)
15import System.Process (system)
18--------------------------------------------------------------------------------
19data Configuration = Configuration
20 { -- | Directory in which the output written
21 destinationDirectory :: FilePath
22 , -- | Directory where hakyll's internal store is kept
23 storeDirectory :: FilePath
24 , -- | Directory in which some temporary files will be kept
25 tmpDirectory :: FilePath
26 , -- | Directory where hakyll finds the files to compile. This is @.@ by
28 providerDirectory :: FilePath
29 , -- | Function to determine ignored files
31 -- In 'defaultConfiguration', the following files are ignored:
33 -- * files starting with a @.@
35 -- * files starting with a @#@
37 -- * files ending with a @~@
39 -- * files ending with @.swp@
41 -- Note that the files in 'destinationDirectory' and 'storeDirectory' will
42 -- also be ignored. Note that this is the configuration parameter, if you
43 -- want to use the test, you should use 'shouldIgnoreFile'.
45 ignoreFile :: FilePath -> Bool
46 , -- | Here, you can plug in a system command to upload/deploy your site.
50 -- > rsync -ave 'ssh -p 2217' _site jaspervdj@jaspervdj.be:hakyll
52 -- You can execute this by using
56 deployCommand :: String
57 , -- | Function to deploy the site from Haskell.
59 -- By default, this command executes the shell command stored in
60 -- 'deployCommand'. If you override it, 'deployCommand' will not
61 -- be used implicitely.
63 -- The 'Configuration' object is passed as a parameter to this
66 deploySite :: Configuration -> IO ()
67 , -- | Use an in-memory cache for items. This is faster but uses more
72--------------------------------------------------------------------------------
73instance Default Configuration where
74 def = defaultConfiguration
76--------------------------------------------------------------------------------
77-- | Default configuration for a hakyll application
78defaultConfiguration :: Configuration
79defaultConfiguration = Configuration
80 { destinationDirectory = "_site"
81 , storeDirectory = "_cache"
82 , tmpDirectory = "_cache/tmp"
83 , providerDirectory = "."
84 , ignoreFile = ignoreFile'
85 , deployCommand = "echo 'No deploy command specified'"
86 , deploySite = void . system . deployCommand
87 , inMemoryCache = True
91 | "." `isPrefixOf` fileName = True
92 | "#" `isPrefixOf` fileName = True
93 | "~" `isSuffixOf` fileName = True
94 | ".swp" `isSuffixOf` fileName = True
97 fileName = takeFileName path
100--------------------------------------------------------------------------------
101-- | Check if a file should be ignored
102shouldIgnoreFile :: Configuration -> FilePath -> Bool
103shouldIgnoreFile conf path =
104 destinationDirectory conf `isPrefixOf` path' ||
105 storeDirectory conf `isPrefixOf` path' ||
106 tmpDirectory conf `isPrefixOf` path' ||
107 ignoreFile conf path'
109 path' = normalise path
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list