summaryrefslogtreecommitdiff
path: root/Settings.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Settings.hs')
-rw-r--r--Settings.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/Settings.hs b/Settings.hs
index 8a98c7a..a79f6f8 100644
--- a/Settings.hs
+++ b/Settings.hs
@@ -1,4 +1,3 @@
1{-# Language CPP #-}
2-- | Settings are centralized, as much as possible, into this file. This 1-- | Settings are centralized, as much as possible, into this file. This
3-- includes database connection settings, static file locations, etc. 2-- includes database connection settings, static file locations, etc.
4-- In addition, you can configure a number of different aspects of Yesod 3-- In addition, you can configure a number of different aspects of Yesod
@@ -19,7 +18,9 @@ import Yesod.Default.Config2 (applyEnvValue, configSettingsYml)
19import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload, 18import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload,
20 widgetFileReload) 19 widgetFileReload)
21 20
21#ifdef THERMOPRINT
22import Thermoprint.Client (BaseUrl(..), parseBaseUrl) 22import Thermoprint.Client (BaseUrl(..), parseBaseUrl)
23#endif
23 24
24#ifdef DEVELOPMENT 25#ifdef DEVELOPMENT
25#define DEV_BOOL True 26#define DEV_BOOL True
@@ -51,13 +52,14 @@ data AppSettings = AppSettings
51 , appReloadTemplates :: Bool 52 , appReloadTemplates :: Bool
52 -- ^ Use the reload version of templates 53 -- ^ Use the reload version of templates
53 54
55#ifdef THERMORPINT
54 , appThermoprintBase :: BaseUrl 56 , appThermoprintBase :: BaseUrl
57#endif
55 } 58 }
56 59
57instance FromJSON AppSettings where 60instance FromJSON AppSettings where
58 parseJSON = withObject "AppSettings" $ \o -> do 61 parseJSON = withObject "AppSettings" $ \o -> do
59 let defaultDev = DEV_BOOL 62 let defaultDev = DEV_BOOL
60 parseUrl' = either (fail . show) return . parseBaseUrl
61 appStaticDir <- o .: "static-dir" 63 appStaticDir <- o .: "static-dir"
62 appDatabaseConf <- o .: "database" 64 appDatabaseConf <- o .: "database"
63 appRoot' <- o .:? "approot" 65 appRoot' <- o .:? "approot"
@@ -73,7 +75,10 @@ instance FromJSON AppSettings where
73 appShouldLogAll <- o .:? "should-log-all" .!= defaultDev 75 appShouldLogAll <- o .:? "should-log-all" .!= defaultDev
74 appReloadTemplates <- o .:? "reload-templates" .!= defaultDev 76 appReloadTemplates <- o .:? "reload-templates" .!= defaultDev
75 77
78#ifdef THERMOPRINT
79 let parseUrl' = either (fail . show) return . parseBaseUrl
76 appThermoprintBase <- parseUrl' =<< o .: "thermoprint-url" 80 appThermoprintBase <- parseUrl' =<< o .: "thermoprint-url"
81#endif
77 82
78 return AppSettings {..} 83 return AppSettings {..}
79 84