From 439847eb6f002f61bdc7a37a07989ab26540ab67 Mon Sep 17 00:00:00 2001 From: Piyush P Kurur Date: Thu, 7 Mar 2013 16:43:53 +0530 Subject: added a default instance for Configuration --- hakyll.cabal | 1 + src/Hakyll/Core/Configuration.hs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/hakyll.cabal b/hakyll.cabal index 4649c8c..b952da6 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -92,6 +92,7 @@ Library citeproc-hs >= 0.3.2 && < 0.4, containers >= 0.3 && < 0.6, cryptohash >= 0.7 && < 0.9, + data-default >= 0.4 && < 0.5, deepseq >= 1.3 && < 1.4, directory >= 1.0 && < 1.3, filepath >= 1.0 && < 1.4, diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs index fdca879..be9a460 100644 --- a/src/Hakyll/Core/Configuration.hs +++ b/src/Hakyll/Core/Configuration.hs @@ -8,6 +8,7 @@ module Hakyll.Core.Configuration -------------------------------------------------------------------------------- +import Data.Default import Data.List (isPrefixOf, isSuffixOf) import System.FilePath (normalise, takeFileName) @@ -56,8 +57,28 @@ data Configuration = Configuration inMemoryCache :: Bool } +instance Default Configuration where + def = Configuration + { destinationDirectory = "_site" + , storeDirectory = "_cache" + , tmpDirectory = "_cache/tmp" + , providerDirectory = "." + , ignoreFile = ignoreFile' + , deployCommand = "echo 'No deploy command specified'" + , inMemoryCache = True + } + where + ignoreFile' path + | "." `isPrefixOf` fileName = True + | "#" `isPrefixOf` fileName = True + | "~" `isSuffixOf` fileName = True + | ".swp" `isSuffixOf` fileName = True + | otherwise = False + where + fileName = takeFileName path -------------------------------------------------------------------------------- + -- | Default configuration for a hakyll application defaultConfiguration :: Configuration defaultConfiguration = Configuration -- cgit v1.2.3 From 1c50baff7a752d6dedd3cf9ec5efc819f08f1d3c Mon Sep 17 00:00:00 2001 From: Piyush P Kurur Date: Thu, 7 Mar 2013 17:38:49 +0530 Subject: fixing the dependency on data.default 1. Added it to the dependency of hakyll-tests 2. Bumped the upper bound to < 0.6 --- hakyll.cabal | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hakyll.cabal b/hakyll.cabal index b952da6..a5c4d37 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -92,7 +92,7 @@ Library citeproc-hs >= 0.3.2 && < 0.4, containers >= 0.3 && < 0.6, cryptohash >= 0.7 && < 0.9, - data-default >= 0.4 && < 0.5, + data-default >= 0.4 && < 0.6, deepseq >= 1.3 && < 1.4, directory >= 1.0 && < 1.3, filepath >= 1.0 && < 1.4, @@ -191,6 +191,7 @@ Test-suite hakyll-tests citeproc-hs >= 0.3.2 && < 0.4, containers >= 0.3 && < 0.6, cryptohash >= 0.7 && < 0.9, + data-default >= 0.4 && < 0.6, deepseq >= 1.3 && < 1.4, directory >= 1.0 && < 1.3, filepath >= 1.0 && < 1.4, -- cgit v1.2.3 From 7fc2f677d9e4b4267059275d4e6451410893fc04 Mon Sep 17 00:00:00 2001 From: Piyush P Kurur Date: Thu, 7 Mar 2013 17:56:56 +0530 Subject: fixing the coding style --- src/Hakyll/Core/Configuration.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs index be9a460..8cbbff0 100644 --- a/src/Hakyll/Core/Configuration.hs +++ b/src/Hakyll/Core/Configuration.hs @@ -8,7 +8,7 @@ module Hakyll.Core.Configuration -------------------------------------------------------------------------------- -import Data.Default +import Data.Default (Default(..)) import Data.List (isPrefixOf, isSuffixOf) import System.FilePath (normalise, takeFileName) @@ -57,8 +57,9 @@ data Configuration = Configuration inMemoryCache :: Bool } +-------------------------------------------------------------------------------- instance Default Configuration where - def = Configuration + def = Configuration { destinationDirectory = "_site" , storeDirectory = "_cache" , tmpDirectory = "_cache/tmp" @@ -67,18 +68,17 @@ instance Default Configuration where , deployCommand = "echo 'No deploy command specified'" , inMemoryCache = True } - where - ignoreFile' path - | "." `isPrefixOf` fileName = True - | "#" `isPrefixOf` fileName = True - | "~" `isSuffixOf` fileName = True - | ".swp" `isSuffixOf` fileName = True - | otherwise = False - where - fileName = takeFileName path + where + ignoreFile' path + | "." `isPrefixOf` fileName = True + | "#" `isPrefixOf` fileName = True + | "~" `isSuffixOf` fileName = True + | ".swp" `isSuffixOf` fileName = True + | otherwise = False + where + fileName = takeFileName path -------------------------------------------------------------------------------- - -- | Default configuration for a hakyll application defaultConfiguration :: Configuration defaultConfiguration = Configuration -- cgit v1.2.3 From d6f6657c28f0ae4f82a249db0f6ce01482319713 Mon Sep 17 00:00:00 2001 From: Piyush P Kurur Date: Thu, 7 Mar 2013 18:04:21 +0530 Subject: refactored the Default instance of Configuration --- src/Hakyll/Core/Configuration.hs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs index 8cbbff0..5382b6d 100644 --- a/src/Hakyll/Core/Configuration.hs +++ b/src/Hakyll/Core/Configuration.hs @@ -59,24 +59,7 @@ data Configuration = Configuration -------------------------------------------------------------------------------- instance Default Configuration where - def = Configuration - { destinationDirectory = "_site" - , storeDirectory = "_cache" - , tmpDirectory = "_cache/tmp" - , providerDirectory = "." - , ignoreFile = ignoreFile' - , deployCommand = "echo 'No deploy command specified'" - , inMemoryCache = True - } - where - ignoreFile' path - | "." `isPrefixOf` fileName = True - | "#" `isPrefixOf` fileName = True - | "~" `isSuffixOf` fileName = True - | ".swp" `isSuffixOf` fileName = True - | otherwise = False - where - fileName = takeFileName path + def = defaultConfiguration -------------------------------------------------------------------------------- -- | Default configuration for a hakyll application -- cgit v1.2.3