module Web.Herringbone.Internal.Configuration where
import Data.Time.Clock (getCurrentTime)
import Filesystem.Path.CurrentOS (FilePath)
import Prelude hiding (FilePath)
import Web.Herringbone.Internal.Types
herringbone :: ConfigBuilder -> IO Herringbone
herringbone = initHerringbone . makeSettings
makeSettings :: ConfigBuilder -> HerringboneSettings
makeSettings builder = builder defaultSettings
initHerringbone :: HerringboneSettings -> IO Herringbone
initHerringbone settings = do
time <- getCurrentTime
return Herringbone
{ herringboneStartTime = time
, herringboneSettings = settings
}
setSourceDir :: FilePath -> ConfigBuilder
setSourceDir dir settings =
settings { settingsSourceDir = dir }
setDestDir :: FilePath -> ConfigBuilder
setDestDir dir settings =
settings { settingsDestDir = dir }
setPreprocessors :: [PP] -> ConfigBuilder
setPreprocessors ppList settings =
settings { settingsPPs = fromList ppList }
addPreprocessor :: PP -> ConfigBuilder
addPreprocessor pp settings =
settings { settingsPPs = insertPP pp (settingsPPs settings) }
setVerbose :: ConfigBuilder
setVerbose settings =
settings { settingsVerbose = True }
defaultSettings :: HerringboneSettings
defaultSettings = HerringboneSettings
{ settingsSourceDir = "."
, settingsDestDir = "compiled_assets"
, settingsPPs = emptyPPs
, settingsVerbose = False
}