yesod 0.9.2 → 0.9.2.1
raw patch · 4 files changed
+45/−32 lines, 4 files
Files
- input/database.cg +5/−3
- scaffold/config/models.cg +3/−3
- scaffold/main.hs.cg +36/−25
- yesod.cabal +1/−1
input/database.cg view
@@ -1,7 +1,9 @@ Yesod uses Persistent for its (you guessed it) persistence layer.-This tool will build in either SQLite or PostgreSQL support for you.+This tool will build in either SQLite or PostgreSQL or MongoDB support for you. We recommend starting with SQLite: it has no dependencies. -We have another option: a tiny project with minimal dependencies. In particular: no database and no authentication.+We have another option: a tiny project with minimal dependencies.+Mostly this means no database and no authentication. -So, what'll it be? s for sqlite, p for postgresql, t for tiny: +So, what'll it be?+s for sqlite, p for postgresql, m for mongodb, or t for tiny:
scaffold/config/models.cg view
@@ -1,10 +1,10 @@ User ident Text- password Text Maybe Update+ password Text Maybe UniqueUser ident Email email Text- user UserId Maybe Update- verkey Text Maybe Update+ user UserId Maybe+ verkey Text Maybe UniqueEmail email
scaffold/main.hs.cg view
@@ -1,57 +1,68 @@ {-# LANGUAGE CPP, DeriveDataTypeable #-}-import qualified Settings as Settings-import Settings (AppConfig(..))+import Settings (AppEnvironment(..), AppConfig(..), loadConfig) import Application (with~sitearg~) import Network.Wai.Handler.Warp (run) import System.Console.CmdArgs hiding (args) import Data.Char (toUpper, toLower)-import Yesod.Logger (logString, logLazyText, flushLogger, makeLogger) #ifndef PRODUCTION import Network.Wai.Middleware.Debug (debugHandle)+import Yesod.Logger (logString, logLazyText, flushLogger, makeLogger)+#else+import Yesod.Logger (makeLogger) #endif main :: IO () main = do logger <- makeLogger- args <- cmdArgs argConfig- env <- getAppEnv args- config <- Settings.loadConfig env- let c = if (port args) /= 0 then config {appPort = (port args) } else config+ args <- cmdArgs argConfig+ env <- getAppEnv args+ config <- loadConfig env+ let c = if port args /= 0+ then config { appPort = port args }+ else config+ #if PRODUCTION- with~sitearg~ c $ run (appPort c)+ with~sitearg~ c logger $ run (appPort c) #else logString logger $ (show env) ++ " application launched, listening on port " ++ show (appPort c) with~sitearg~ c logger $ run (appPort c) . debugHandle (logHandle logger) flushLogger logger++ where+ logHandle logger msg = logLazyText logger msg >> flushLogger logger #endif- where- logHandle logger msg = logLazyText logger msg >> flushLogger logger -data ArgConfig = ArgConfig {environment :: String, port :: Int}- deriving (Show, Data, Typeable)+data ArgConfig = ArgConfig+ { environment :: String+ , port :: Int+ } deriving (Show, Data, Typeable) argConfig :: ArgConfig-argConfig = ArgConfig{ environment = def - &= help ("application environment, one of: " ++ (foldl1 (\a b -> a ++ ", " ++ b) environments))- &= typ "ENVIRONMENT"- ,port = def &= typ "PORT"-}+argConfig = ArgConfig+ { environment = def + &= help ("application environment, one of: " ++ (foldl1 (\a b -> a ++ ", " ++ b) environments))+ &= typ "ENVIRONMENT"+ , port = def+ &= typ "PORT"+ } environments :: [String]-environments = map ((map toLower) . show) ([minBound..maxBound] :: [Settings.AppEnvironment])+environments = map ((map toLower) . show) ([minBound..maxBound] :: [AppEnvironment]) -- | retrieve the -e environment option-getAppEnv :: ArgConfig -> IO Settings.AppEnvironment+getAppEnv :: ArgConfig -> IO AppEnvironment getAppEnv cfg = do- let e = if (environment cfg) /= "" then (environment cfg)+ let e = if environment cfg /= ""+ then environment cfg else #if PRODUCTION- "production"+ "production" #else- "development"+ "development" #endif return $ read $ capitalize e- where- capitalize [] = []- capitalize (x:xs) = toUpper x : map toLower xs++ where+ capitalize [] = []+ capitalize (x:xs) = toUpper x : map toLower xs
yesod.cabal view
@@ -1,5 +1,5 @@ name: yesod-version: 0.9.2+version: 0.9.2.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>