diff --git a/yesod/Scaffolding/Scaffolder.hs b/yesod/Scaffolding/Scaffolder.hs index c8fe885d..293032b6 100644 --- a/yesod/Scaffolding/Scaffolder.hs +++ b/yesod/Scaffolding/Scaffolder.hs @@ -94,10 +94,6 @@ scaffold = do MongoDB -> $(codegen $ "mongoDBConnPool") Tiny -> "" - settingsTextImport = case backend of - Postgresql -> "import Data.Text (Text, concat)\nimport Prelude hiding (concat)" - _ -> "import Data.Text (Text)" - packages = if backend == MongoDB then " , persistent-mongoDB >= 0.6.1 && < 0.7\n , mongoDB >= 1.1\n , bson >= 0.1.5\n" diff --git a/yesod/scaffold/Settings.hs.cg b/yesod/scaffold/Settings.hs.cg index fdcf3c59..36bd1576 100644 --- a/yesod/scaffold/Settings.hs.cg +++ b/yesod/scaffold/Settings.hs.cg @@ -32,10 +32,7 @@ import Yesod (liftIO, MonadControlIO, addWidget, addCassius, addJulius, addLuciu import Yesod.Settings import Data.Monoid (mempty) import System.Directory (doesFileExist) -~settingsTextImport~ -import Data.Object -import qualified Data.Object.Yaml as YAML -import Control.Monad (join) +import Data.Text (Text) -- Static setting below. Changing these requires a recompile diff --git a/yesod/scaffold/mongoDBConnPool.cg b/yesod/scaffold/mongoDBConnPool.cg index 57cb2aa0..4292d22f 100644 --- a/yesod/scaffold/mongoDBConnPool.cg +++ b/yesod/scaffold/mongoDBConnPool.cg @@ -3,14 +3,6 @@ runConnectionPool = runMongoDBConn (ConfirmWrites [u"j" =: True]) withConnectionPool :: (MonadControlIO m, Applicative m) => AppConfig -> (ConnectionPool -> m b) -> m b withConnectionPool conf f = do - (database,host) <- liftIO $ loadConnParams (appEnv conf) + (database,host) <- liftIO $ loadMongoConnParams (appEnv conf) withMongoDBPool (u database) host (connectionPoolSize conf) f - where - -- | The database connection parameters. - -- loadConnParams :: AppEnvironment -> IO (Database, HostName) - loadConnParams env = do - allSettings <- (join $ YAML.decodeFile ("config/mongoDB.yml" :: String)) >>= fromMapping - settings <- lookupMapping (show env) allSettings - database <- lookupScalar "database" settings - host <- lookupScalar "host" settings - return (database, host) + diff --git a/yesod/scaffold/postgresqlConnPool.cg b/yesod/scaffold/postgresqlConnPool.cg index 9cf1129b..e8597e4f 100644 --- a/yesod/scaffold/postgresqlConnPool.cg +++ b/yesod/scaffold/postgresqlConnPool.cg @@ -3,21 +3,8 @@ runConnectionPool = runSqlPool withConnectionPool :: MonadControlIO m => AppConfig -> (ConnectionPool -> m a) -> m a withConnectionPool conf f = do - cs <- liftIO $ loadConnStr (appEnv conf) + cs <- liftIO $ load~upper~ConnStr (appEnv conf) with~upper~Pool cs (connectionPoolSize conf) f - where - -- | The database connection string. The meaning of this string is backend- - -- specific. - loadConnStr :: AppEnvironment -> IO Text - loadConnStr env = do - allSettings <- (join $ YAML.decodeFile ("config/~backendLower~.yml" :: String)) >>= fromMapping - settings <- lookupMapping (show env) allSettings - database <- lookupScalar "database" settings :: IO Text - - connPart <- fmap concat $ (flip mapM) ["user", "password", "host", "port"] $ \key -> do - value <- lookupScalar key settings - return $ [st| #{key}=#{value} |] - return $ [st|#{connPart} dbname=#{database}|] -- Example of making a dynamic configuration static -- use /return $(mkConnStr Production)/ instead of loadConnStr diff --git a/yesod/scaffold/sqliteConnPool.cg b/yesod/scaffold/sqliteConnPool.cg index ba4981f2..e8597e4f 100644 --- a/yesod/scaffold/sqliteConnPool.cg +++ b/yesod/scaffold/sqliteConnPool.cg @@ -3,16 +3,8 @@ runConnectionPool = runSqlPool withConnectionPool :: MonadControlIO m => AppConfig -> (ConnectionPool -> m a) -> m a withConnectionPool conf f = do - cs <- liftIO $ loadConnStr (appEnv conf) + cs <- liftIO $ load~upper~ConnStr (appEnv conf) with~upper~Pool cs (connectionPoolSize conf) f - where - -- | The database connection string. The meaning of this string is backend- - -- specific. - loadConnStr :: AppEnvironment -> IO Text - loadConnStr env = do - allSettings <- (join $ YAML.decodeFile ("config/~backendLower~.yml" :: String)) >>= fromMapping - settings <- lookupMapping (show env) allSettings - lookupScalar "database" settings -- Example of making a dynamic configuration static -- use /return $(mkConnStr Production)/ instead of loadConnStr diff --git a/yesod/scaffold/tiny/Settings.hs.cg b/yesod/scaffold/tiny/Settings.hs.cg index 73e226ad..a36c764b 100644 --- a/yesod/scaffold/tiny/Settings.hs.cg +++ b/yesod/scaffold/tiny/Settings.hs.cg @@ -27,10 +27,7 @@ import Yesod.Widget (addWidget, addCassius, addJulius, addLucius, whamletFile) import Yesod.Settings import Data.Monoid (mempty) import System.Directory (doesFileExist) -~settingsTextImport~ -import Data.Object -import qualified Data.Object.Yaml as YAML -import Control.Monad (join) +import Data.Text (Text) -- | The location of static files on your system. This is a file system -- path. The default value works properly with your scaffolded site.