1--------------------------------------------------------------------------------
2-- | Exports a datastructure for the top-level hakyll configuration
3module Hakyll.Core.Configuration
10--------------------------------------------------------------------------------
11import Data.Default (Default (..))
12import Data.List (isPrefixOf, isSuffixOf)
13import System.Directory (canonicalizePath)
14import System.Exit (ExitCode)
15import System.FilePath (isAbsolute, normalise, takeFileName)
16import System.IO.Error (catchIOError)
17import System.Process (system)
20--------------------------------------------------------------------------------
21data Configuration = Configuration
22 { -- | Directory in which the output written
23 destinationDirectory :: FilePath
24 , -- | Directory where hakyll's internal store is kept
25 storeDirectory :: FilePath
26 , -- | Directory in which some temporary files will be kept
27 tmpDirectory :: FilePath
28 , -- | Directory where hakyll finds the files to compile. This is @.@ by
30 providerDirectory :: FilePath
31 , -- | Function to determine ignored files
33 -- In 'defaultConfiguration', the following files are ignored:
35 -- * files starting with a @.@
37 -- * files starting with a @#@
39 -- * files ending with a @~@
41 -- * files ending with @.swp@
43 -- Note that the files in 'destinationDirectory' and 'storeDirectory' will
44 -- also be ignored. Note that this is the configuration parameter, if you
45 -- want to use the test, you should use 'shouldIgnoreFile'.
47 ignoreFile :: FilePath -> Bool
48 , -- | Here, you can plug in a system command to upload/deploy your site.
52 -- > rsync -ave 'ssh -p 2217' _site jaspervdj@jaspervdj.be:hakyll
54 -- You can execute this by using
58 deployCommand :: String
59 , -- | Function to deploy the site from Haskell.
61 -- By default, this command executes the shell command stored in
62 -- 'deployCommand'. If you override it, 'deployCommand' will not
63 -- be used implicitely.
65 -- The 'Configuration' object is passed as a parameter to this
68 deploySite :: Configuration -> IO ExitCode
69 , -- | Use an in-memory cache for items. This is faster but uses more
72 , -- | Override default host for preview server. Default is "127.0.0.1",
73 -- which binds only on the loopback address.
74 -- One can also override the host as a command line argument:
75 -- ./site preview -h "0.0.0.0"
77 , -- | Override default port for preview server. Default is 8000.
78 -- One can also override the port as a command line argument:
79 -- ./site preview -p 1234
83--------------------------------------------------------------------------------
84instance Default Configuration where
85 def = defaultConfiguration
87--------------------------------------------------------------------------------
88-- | Default configuration for a hakyll application
89defaultConfiguration :: Configuration
90defaultConfiguration = Configuration
91 { destinationDirectory = "_site"
92 , storeDirectory = "_cache"
93 , tmpDirectory = "_cache/tmp"
94 , providerDirectory = "."
95 , ignoreFile = ignoreFile'
96 , deployCommand = "echo 'No deploy command specified' && exit 1"
97 , deploySite = system . deployCommand
98 , inMemoryCache = True
99 , previewHost = "127.0.0.1"
104 | "." `isPrefixOf` fileName = True
105 | "#" `isPrefixOf` fileName = True
106 | "~" `isSuffixOf` fileName = True
107 | ".swp" `isSuffixOf` fileName = True
110 fileName = takeFileName path
113--------------------------------------------------------------------------------
114-- | Check if a file should be ignored
115shouldIgnoreFile :: Configuration -> FilePath -> IO Bool
116shouldIgnoreFile conf path = orM
117 [ inDir (destinationDirectory conf)
118 , inDir (storeDirectory conf)
119 , inDir (tmpDirectory conf)
120 , return (ignoreFile conf path')
123 path' = normalise path
124 absolute = isAbsolute path
128 dir' <- catchIOError (canonicalizePath dir) (const $ return dir)
129 return $ dir' `isPrefixOf` path'
130 | otherwise = return $ dir `isPrefixOf` path'
132 orM :: [IO Bool] -> IO Bool
133 orM [] = return False
134 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