Skip to content

Commit

Permalink
Merge remote-tracking branch 'parcs/purge-cpp'
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Apr 25, 2012
2 parents d3277ef + 1b9b19b commit 9c7b8db
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 24 deletions.
1 change: 1 addition & 0 deletions yesod/Scaffolding/Scaffolder.hs
Expand Up @@ -155,6 +155,7 @@ scaffold = do
writeFile' "Model.hs" $(codegen "Model.hs")
writeFile' "Settings.hs" $(codegen "Settings.hs")
writeFile' "Settings/StaticFiles.hs" $(codegen "Settings/StaticFiles.hs")
writeFile' "Settings/Development.hs" $(codegen "Settings/Development.hs")
writeFile' "static/css/bootstrap.css"
$(codegen "static/css/bootstrap.css")
writeFile' "templates/default-layout.hamlet"
Expand Down
17 changes: 4 additions & 13 deletions yesod/scaffold/Application.hs.cg
Expand Up @@ -11,13 +11,8 @@ import Yesod.Auth
import Yesod.Default.Config
import Yesod.Default.Main
import Yesod.Default.Handlers
#if DEVELOPMENT
import Yesod.Logger (Logger, logBS)
import Network.Wai.Middleware.RequestLogger (logCallbackDev)
#else
import Yesod.Logger (Logger, logBS, toProduction)
import Network.Wai.Middleware.RequestLogger (logCallback)
#endif
import Network.Wai.Middleware.RequestLogger (logCallback, logCallbackDev)
import qualified Database.Persist.Store~importMigration~
import Network.HTTP.Conduit (newManager, def)

Expand All @@ -40,13 +35,9 @@ makeApplication conf logger = do
app <- toWaiAppPlain foundation
return $ logWare app
where
#ifdef DEVELOPMENT
logWare = logCallbackDev (logBS setLogger)
setLogger = logger
#else
setLogger = toProduction logger -- by default the logger is set for development
logWare = logCallback (logBS setLogger)
#endif
setLogger = if development then logger else toProduction logger
logWare = if development then logCallbackDev (logBS setLogger)
else logCallback (logBS setLogger)

makeFoundation :: AppConfig DefaultEnv Extra -> Logger -> IO ~sitearg~
makeFoundation conf setLogger = do
Expand Down
2 changes: 2 additions & 0 deletions yesod/scaffold/Import.hs.cg
Expand Up @@ -3,6 +3,7 @@ module Import
, module Yesod
, module Foundation
, module Settings.StaticFiles
, module Settings.Development
, module Data.Monoid
, module Control.Applicative
, Text
Expand All @@ -18,6 +19,7 @@ import Data.Monoid (Monoid (mappend, mempty, mconcat))
import Control.Applicative ((<$>), (<*>), pure)
import Data.Text (Text)
import Settings.StaticFiles
import Settings.Development

#if __GLASGOW_HASKELL__ < 704
infixr 5 <>
Expand Down
8 changes: 3 additions & 5 deletions yesod/scaffold/Settings.hs.cg
Expand Up @@ -21,6 +21,7 @@ import qualified Yesod.Default.Util
import Data.Text (Text)
import Data.Yaml
import Control.Applicative
import Settings.Development

-- | Which Persistent backend this site is using.
type PersistConfig = ~configPersist~
Expand Down Expand Up @@ -53,11 +54,8 @@ staticRoot conf = [st|#{appRoot conf}/static|]
-- user.

widgetFile :: String -> Q Exp
#if DEVELOPMENT
widgetFile = Yesod.Default.Util.widgetFileReload
#else
widgetFile = Yesod.Default.Util.widgetFileNoReload
#endif
widgetFile = if development then Yesod.Default.Util.widgetFileReload
else Yesod.Default.Util.widgetFileNoReload

data Extra = Extra
{ extraCopyright :: Text
Expand Down
14 changes: 14 additions & 0 deletions yesod/scaffold/Settings/Development.hs.cg
@@ -0,0 +1,14 @@
module Settings.Development where

import Prelude

development :: Bool
development =
#if DEVELOPMENT
True
#else
False
#endif

production :: Bool
production = not development
9 changes: 3 additions & 6 deletions yesod/scaffold/Settings/StaticFiles.hs.cg
Expand Up @@ -4,15 +4,12 @@ import Prelude (IO)
import Yesod.Static
import qualified Yesod.Static as Static
import Settings (staticDir)
import Settings.Development

-- | use this to create your static file serving site
staticSite :: IO Static.Static
staticSite =
#ifdef DEVELOPMENT
Static.staticDevel staticDir
#else
Static.static staticDir
#endif
staticSite = if development then Static.staticDevel staticDir
else Static.static staticDir

-- | This generates easy references to files in the static directory at compile time,
-- giving you compile-time verification that referenced files exist.
Expand Down
1 change: 1 addition & 0 deletions yesod/scaffold/project.cabal.cg
Expand Up @@ -27,6 +27,7 @@ library
Model
Settings
Settings.StaticFiles
Settings.Development
Handler.Home

if flag(dev) || flag(library-only)
Expand Down
1 change: 1 addition & 0 deletions yesod/yesod.cabal
Expand Up @@ -32,6 +32,7 @@ extra-source-files:
scaffold/tests/main.hs.cg
scaffold/tests/HomeTest.hs.cg
scaffold/Settings.hs.cg
scaffold/Settings/Development.hs.cg
scaffold/Settings/StaticFiles.hs.cg
scaffold/Application.hs.cg
scaffold/deploy/Procfile.cg
Expand Down

0 comments on commit 9c7b8db

Please sign in to comment.