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.Directory (canonicalizePath)
15import System.Exit (ExitCode)
16import System.FilePath (isAbsolute, normalise, takeFileName)
17import System.IO.Error (catchIOError)
18import System.Process (system)
21--------------------------------------------------------------------------------
22data Configuration = Configuration
23 { -- | Directory in which the output written
24 destinationDirectory :: FilePath
25 , -- | Directory where hakyll's internal store is kept
26 storeDirectory :: FilePath
27 , -- | Directory in which some temporary files will be kept
28 tmpDirectory :: FilePath
29 , -- | Directory where hakyll finds the files to compile. This is @.@ by
31 providerDirectory :: FilePath
32 , -- | Function to determine ignored files
34 -- In 'defaultConfiguration', the following files are ignored:
36 -- * files starting with a @.@
38 -- * files starting with a @#@
40 -- * files ending with a @~@
42 -- * files ending with @.swp@
44 -- Note that the files in 'destinationDirectory' and 'storeDirectory' will
45 -- also be ignored. Note that this is the configuration parameter, if you
46 -- want to use the test, you should use 'shouldIgnoreFile'.
48 ignoreFile :: FilePath -> Bool
49 , -- | Here, you can plug in a system command to upload/deploy your site.
53 -- > rsync -ave 'ssh -p 2217' _site jaspervdj@jaspervdj.be:hakyll
55 -- You can execute this by using
59 deployCommand :: String
60 , -- | Function to deploy the site from Haskell.
62 -- By default, this command executes the shell command stored in
63 -- 'deployCommand'. If you override it, 'deployCommand' will not
64 -- be used implicitely.
66 -- The 'Configuration' object is passed as a parameter to this
69 deploySite :: Configuration -> IO ExitCode
70 , -- | Use an in-memory cache for items. This is faster but uses more
75--------------------------------------------------------------------------------
76instance Default Configuration where
77 def = defaultConfiguration
79--------------------------------------------------------------------------------
80-- | Default configuration for a hakyll application
81defaultConfiguration :: Configuration
82defaultConfiguration = Configuration
83 { destinationDirectory = "_site"
84 , storeDirectory = "_cache"
85 , tmpDirectory = "_cache/tmp"
86 , providerDirectory = "."
87 , ignoreFile = ignoreFile'
88 , deployCommand = "echo 'No deploy command specified' && exit 1"
89 , deploySite = system . deployCommand
90 , inMemoryCache = True
94 | "." `isPrefixOf` fileName = True
95 | "#" `isPrefixOf` fileName = True
96 | "~" `isSuffixOf` fileName = True
97 | ".swp" `isSuffixOf` fileName = True
100 fileName = takeFileName path
103--------------------------------------------------------------------------------
104-- | Check if a file should be ignored
105shouldIgnoreFile :: Configuration -> FilePath -> IO Bool
106shouldIgnoreFile conf path = orM
107 [ inDir (destinationDirectory conf)
108 , inDir (storeDirectory conf)
109 , inDir (tmpDirectory conf)
110 , return (ignoreFile conf path')
113 path' = normalise path
114 absolute = isAbsolute path
118 dir' <- catchIOError (canonicalizePath dir) (const $ return dir)
119 return $ dir' `isPrefixOf` path'
120 | otherwise = return $ dir `isPrefixOf` path'
122 orM :: [IO Bool] -> IO Bool
123 orM [] = return False
124 orM (x : xs) = x >>= \b -> if b then return True else orM xs
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