production -> dev, devel -> library-only, debug -> reload
This commit is contained in:
parent
7e643d6848
commit
4ed96e82ac
@ -54,8 +54,8 @@ library
|
|||||||
, path-pieces >= 0.0 && < 0.1
|
, path-pieces >= 0.0 && < 0.1
|
||||||
, hamlet >= 0.10 && < 0.11
|
, hamlet >= 0.10 && < 0.11
|
||||||
, shakespeare >= 0.10 && < 0.11
|
, shakespeare >= 0.10 && < 0.11
|
||||||
, shakespeare-js >= 0.10 && < 0.11
|
, shakespeare-js >= 0.10.4 && < 0.11
|
||||||
, shakespeare-css >= 0.10 && < 0.11
|
, shakespeare-css >= 0.10.5 && < 0.11
|
||||||
, shakespeare-i18n >= 0.0 && < 0.1
|
, shakespeare-i18n >= 0.0 && < 0.1
|
||||||
, blaze-builder >= 0.2.1.4 && < 0.4
|
, blaze-builder >= 0.2.1.4 && < 0.4
|
||||||
, transformers >= 0.2.2 && < 0.3
|
, transformers >= 0.2.2 && < 0.3
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
module Yesod.Default.Util
|
module Yesod.Default.Util
|
||||||
( addStaticContentExternal
|
( addStaticContentExternal
|
||||||
, globFile
|
, globFile
|
||||||
, widgetFileProduction
|
, widgetFileNoReload
|
||||||
, widgetFileDebug
|
, widgetFileReload
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
@ -16,9 +16,9 @@ import Yesod.Core -- purposely using complete import so that Haddock will see ad
|
|||||||
import Control.Monad (unless)
|
import Control.Monad (unless)
|
||||||
import System.Directory (doesFileExist, createDirectoryIfMissing)
|
import System.Directory (doesFileExist, createDirectoryIfMissing)
|
||||||
import Language.Haskell.TH.Syntax
|
import Language.Haskell.TH.Syntax
|
||||||
import Text.Lucius (luciusFile, luciusFileDebug)
|
import Text.Lucius (luciusFile, luciusFileReload)
|
||||||
import Text.Julius (juliusFile, juliusFileDebug)
|
import Text.Julius (juliusFile, juliusFileReload)
|
||||||
import Text.Cassius (cassiusFile, cassiusFileDebug)
|
import Text.Cassius (cassiusFile, cassiusFileReload)
|
||||||
import Data.Monoid (mempty)
|
import Data.Monoid (mempty)
|
||||||
|
|
||||||
-- | An implementation of 'addStaticContent' which stores the contents in an
|
-- | An implementation of 'addStaticContent' which stores the contents in an
|
||||||
@ -56,20 +56,20 @@ addStaticContentExternal minify hash staticDir toRoute ext' _ content = do
|
|||||||
globFile :: String -> String -> FilePath
|
globFile :: String -> String -> FilePath
|
||||||
globFile kind x = "templates/" ++ x ++ "." ++ kind
|
globFile kind x = "templates/" ++ x ++ "." ++ kind
|
||||||
|
|
||||||
widgetFileProduction :: FilePath -> Q Exp
|
widgetFileNoReload :: FilePath -> Q Exp
|
||||||
widgetFileProduction x = do
|
widgetFileNoReload x = do
|
||||||
let h = whenExists x "hamlet" whamletFile
|
let h = whenExists x "hamlet" whamletFile
|
||||||
let c = whenExists x "cassius" cassiusFile
|
let c = whenExists x "cassius" cassiusFile
|
||||||
let j = whenExists x "julius" juliusFile
|
let j = whenExists x "julius" juliusFile
|
||||||
let l = whenExists x "lucius" luciusFile
|
let l = whenExists x "lucius" luciusFile
|
||||||
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
|
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
|
||||||
|
|
||||||
widgetFileDebug :: FilePath -> Q Exp
|
widgetFileReload :: FilePath -> Q Exp
|
||||||
widgetFileDebug x = do
|
widgetFileReload x = do
|
||||||
let h = whenExists x "hamlet" whamletFile
|
let h = whenExists x "hamlet" whamletFile
|
||||||
let c = whenExists x "cassius" cassiusFileDebug
|
let c = whenExists x "cassius" cassiusFileReload
|
||||||
let j = whenExists x "julius" juliusFileDebug
|
let j = whenExists x "julius" juliusFileReload
|
||||||
let l = whenExists x "lucius" luciusFileDebug
|
let l = whenExists x "lucius" luciusFileReload
|
||||||
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
|
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
|
||||||
|
|
||||||
whenExists :: String -> String -> (FilePath -> Q Exp) -> Q Exp
|
whenExists :: String -> String -> (FilePath -> Q Exp) -> Q Exp
|
||||||
|
|||||||
@ -27,8 +27,8 @@ library
|
|||||||
, transformers >= 0.2.2 && < 0.3
|
, transformers >= 0.2.2 && < 0.3
|
||||||
, text >= 0.9
|
, text >= 0.9
|
||||||
, directory >= 1.0
|
, directory >= 1.0
|
||||||
, shakespeare-css >= 0.10 && < 0.11
|
, shakespeare-css >= 0.10.5 && < 0.11
|
||||||
, shakespeare-js >= 0.10 && < 0.11
|
, shakespeare-js >= 0.10.4 && < 0.11
|
||||||
, template-haskell
|
, template-haskell
|
||||||
, data-object >= 0.3 && < 0.4
|
, data-object >= 0.3 && < 0.4
|
||||||
, data-object-yaml >= 0.3 && < 0.4
|
, data-object-yaml >= 0.3 && < 0.4
|
||||||
|
|||||||
14
yesod/Devel.hs
Executable file → Normal file
14
yesod/Devel.hs
Executable file → Normal file
@ -66,8 +66,18 @@ devel isDevel = do
|
|||||||
checkCabalFile gpd
|
checkCabalFile gpd
|
||||||
|
|
||||||
_ <- if isDevel
|
_ <- if isDevel
|
||||||
then rawSystem "cabal-dev" ["configure", "--cabal-install-arg=-fdevel", "--disable-library-profiling"]
|
then rawSystem "cabal-dev"
|
||||||
else rawSystem "cabal" ["configure", "-fdevel", "--disable-library-profiling"]
|
[ "configure"
|
||||||
|
, "--cabal-install-arg=-fdevel" -- legacy
|
||||||
|
, "--cabal-install-arg=-flibrary-only"
|
||||||
|
, "--disable-library-profiling"
|
||||||
|
]
|
||||||
|
else rawSystem "cabal"
|
||||||
|
[ "configure"
|
||||||
|
, "-fdevel" -- legacy
|
||||||
|
, "-flibrary-only"
|
||||||
|
, "--disable-library-profiling"
|
||||||
|
]
|
||||||
|
|
||||||
T.writeFile "dist/devel.hs" (develFile pid)
|
T.writeFile "dist/devel.hs" (develFile pid)
|
||||||
|
|
||||||
|
|||||||
@ -29,10 +29,10 @@ mkYesodDispatch "~sitearg~" resources~sitearg~
|
|||||||
-- migrations handled by Yesod.
|
-- migrations handled by Yesod.
|
||||||
with~sitearg~ :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO ()
|
with~sitearg~ :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO ()
|
||||||
with~sitearg~ conf logger f = do
|
with~sitearg~ conf logger f = do
|
||||||
#ifdef PRODUCTION
|
#ifdef DEV
|
||||||
s <- static Settings.staticDir
|
|
||||||
#else
|
|
||||||
s <- staticDevel Settings.staticDir
|
s <- staticDevel Settings.staticDir
|
||||||
|
#else
|
||||||
|
s <- static Settings.staticDir
|
||||||
#endif
|
#endif
|
||||||
dbconf <- withYamlEnvironment "config/~dbConfigFile~.yml" (appEnv conf)
|
dbconf <- withYamlEnvironment "config/~dbConfigFile~.yml" (appEnv conf)
|
||||||
$ either error return . Database.Persist.Base.loadConfig
|
$ either error return . Database.Persist.Base.loadConfig
|
||||||
|
|||||||
@ -33,10 +33,10 @@ import Model
|
|||||||
import Text.Jasmine (minifym)
|
import Text.Jasmine (minifym)
|
||||||
import Web.ClientSession (getKey)
|
import Web.ClientSession (getKey)
|
||||||
import Text.Hamlet (hamletFile)
|
import Text.Hamlet (hamletFile)
|
||||||
#if PRODUCTION
|
#if DEV
|
||||||
import Network.Mail.Mime (sendmail)
|
|
||||||
#else
|
|
||||||
import qualified Data.Text.Lazy.Encoding
|
import qualified Data.Text.Lazy.Encoding
|
||||||
|
#else
|
||||||
|
import Network.Mail.Mime (sendmail)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- | The site argument for your application. This can be a good place to
|
-- | The site argument for your application. This can be a good place to
|
||||||
@ -145,10 +145,10 @@ instance YesodAuth ~sitearg~ where
|
|||||||
|
|
||||||
-- Sends off your mail. Requires sendmail in production!
|
-- Sends off your mail. Requires sendmail in production!
|
||||||
deliver :: ~sitearg~ -> L.ByteString -> IO ()
|
deliver :: ~sitearg~ -> L.ByteString -> IO ()
|
||||||
#ifdef PRODUCTION
|
#ifdef DEV
|
||||||
deliver _ = sendmail
|
|
||||||
#else
|
|
||||||
deliver y = logLazyText (getLogger y) . Data.Text.Lazy.Encoding.decodeUtf8
|
deliver y = logLazyText (getLogger y) . Data.Text.Lazy.Encoding.decodeUtf8
|
||||||
|
#else
|
||||||
|
deliver _ = sendmail
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- This instance is required to use forms. You can modify renderMessage to
|
-- This instance is required to use forms. You can modify renderMessage to
|
||||||
|
|||||||
@ -49,8 +49,8 @@ staticRoot conf = [~qq~st|#{appRoot conf}/static|]
|
|||||||
-- user.
|
-- user.
|
||||||
|
|
||||||
widgetFile :: String -> Q Exp
|
widgetFile :: String -> Q Exp
|
||||||
#if PRODUCTION
|
#if DEV
|
||||||
widgetFile = Yesod.Default.Util.widgetFileProduction
|
widgetFile = Yesod.Default.Util.widgetFileReload
|
||||||
#else
|
#else
|
||||||
widgetFile = Yesod.Default.Util.widgetFileDebug
|
widgetFile = Yesod.Default.Util.widgetFileNoReload
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -27,12 +27,12 @@
|
|||||||
#
|
#
|
||||||
# * add code in Settings.hs to turn that url into connection parameters. The below works for Postgresql.
|
# * add code in Settings.hs to turn that url into connection parameters. The below works for Postgresql.
|
||||||
#
|
#
|
||||||
# #ifdef PRODUCTION
|
# #ifdef !DEV
|
||||||
# import qualified Web.Heroku
|
# import qualified Web.Heroku
|
||||||
# #endif
|
# #endif
|
||||||
#
|
#
|
||||||
# dbConnParams :: AppEnvironment -> IO [(Text, Text)]
|
# dbConnParams :: AppEnvironment -> IO [(Text, Text)]
|
||||||
# #ifdef PRODUCTION
|
# #ifdef !DEV
|
||||||
# dbConnParams _ = Web.Heroku.dbConnParams
|
# dbConnParams _ = Web.Heroku.dbConnParams
|
||||||
# #else
|
# #else
|
||||||
# dbConnParams env = do
|
# dbConnParams env = do
|
||||||
|
|||||||
@ -21,7 +21,7 @@ Flag devel
|
|||||||
Default: False
|
Default: False
|
||||||
|
|
||||||
library
|
library
|
||||||
if flag(devel)
|
if flag(library-only)
|
||||||
Buildable: True
|
Buildable: True
|
||||||
else
|
else
|
||||||
Buildable: False
|
Buildable: False
|
||||||
@ -35,6 +35,7 @@ library
|
|||||||
Handler.Root
|
Handler.Root
|
||||||
|
|
||||||
ghc-options: -Wall -threaded -O0
|
ghc-options: -Wall -threaded -O0
|
||||||
|
cpp-options: -DDEV
|
||||||
|
|
||||||
extensions: TemplateHaskell
|
extensions: TemplateHaskell
|
||||||
QuasiQuotes
|
QuasiQuotes
|
||||||
@ -49,14 +50,14 @@ library
|
|||||||
FlexibleContexts
|
FlexibleContexts
|
||||||
|
|
||||||
executable ~project~
|
executable ~project~
|
||||||
if flag(devel)
|
if flag(library-only)
|
||||||
Buildable: False
|
Buildable: False
|
||||||
|
|
||||||
if flag(production)
|
if flag(dev)
|
||||||
cpp-options: -DPRODUCTION
|
cpp-options: -DDEV
|
||||||
ghc-options: -Wall -threaded -O2
|
|
||||||
else
|
|
||||||
ghc-options: -Wall -threaded -O0
|
ghc-options: -Wall -threaded -O0
|
||||||
|
else
|
||||||
|
ghc-options: -Wall -threaded
|
||||||
|
|
||||||
main-is: main.hs
|
main-is: main.hs
|
||||||
|
|
||||||
|
|||||||
@ -28,10 +28,10 @@ mkYesodDispatch "~sitearg~" resources~sitearg~
|
|||||||
-- migrations handled by Yesod.
|
-- migrations handled by Yesod.
|
||||||
with~sitearg~ :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO ()
|
with~sitearg~ :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO ()
|
||||||
with~sitearg~ conf logger f = do
|
with~sitearg~ conf logger f = do
|
||||||
#ifdef PRODUCTION
|
#ifdef DEV
|
||||||
s <- static Settings.staticDir
|
|
||||||
#else
|
|
||||||
s <- staticDevel Settings.staticDir
|
s <- staticDevel Settings.staticDir
|
||||||
|
#else
|
||||||
|
s <- static Settings.staticDir
|
||||||
#endif
|
#endif
|
||||||
let h = ~sitearg~ conf logger s
|
let h = ~sitearg~ conf logger s
|
||||||
defaultRunner f h
|
defaultRunner f h
|
||||||
|
|||||||
@ -38,8 +38,8 @@ staticRoot :: AppConfig DefaultEnv a -> Text
|
|||||||
staticRoot conf = [~qq~st|#{appRoot conf}/static|]
|
staticRoot conf = [~qq~st|#{appRoot conf}/static|]
|
||||||
|
|
||||||
widgetFile :: String -> Q Exp
|
widgetFile :: String -> Q Exp
|
||||||
#if PRODUCTION
|
#if DEV
|
||||||
widgetFile = Yesod.Default.Util.widgetFileProduction
|
widgetFile = Yesod.Default.Util.widgetFileReload
|
||||||
#else
|
#else
|
||||||
widgetFile = Yesod.Default.Util.widgetFileDebug
|
widgetFile = Yesod.Default.Util.widgetFileNoReload
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -12,16 +12,16 @@ cabal-version: >= 1.6
|
|||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://~project~.yesodweb.com/
|
homepage: http://~project~.yesodweb.com/
|
||||||
|
|
||||||
Flag production
|
Flag dev
|
||||||
Description: Build the production executable.
|
Description: Turn on development settings, like auto-reload templates.
|
||||||
Default: False
|
Default: False
|
||||||
|
|
||||||
Flag devel
|
Flag library-only
|
||||||
Description: Build for use with "yesod devel"
|
Description: Build for use with "yesod devel"
|
||||||
Default: False
|
Default: False
|
||||||
|
|
||||||
library
|
library
|
||||||
if flag(devel)
|
if flag(library-only)
|
||||||
Buildable: True
|
Buildable: True
|
||||||
else
|
else
|
||||||
Buildable: False
|
Buildable: False
|
||||||
@ -33,6 +33,7 @@ library
|
|||||||
Handler.Root
|
Handler.Root
|
||||||
|
|
||||||
ghc-options: -Wall -threaded -O0
|
ghc-options: -Wall -threaded -O0
|
||||||
|
cpp-options: -DDEV
|
||||||
|
|
||||||
extensions: TemplateHaskell
|
extensions: TemplateHaskell
|
||||||
QuasiQuotes
|
QuasiQuotes
|
||||||
@ -44,14 +45,14 @@ library
|
|||||||
TypeFamilies
|
TypeFamilies
|
||||||
|
|
||||||
executable ~project~
|
executable ~project~
|
||||||
if flag(devel)
|
if flag(library-only)
|
||||||
Buildable: False
|
Buildable: False
|
||||||
|
|
||||||
if flag(production)
|
if flag(dev)
|
||||||
cpp-options: -DPRODUCTION
|
cpp-options: -DDEV
|
||||||
ghc-options: -Wall -threaded -O2
|
|
||||||
else
|
|
||||||
ghc-options: -Wall -threaded -O0
|
ghc-options: -Wall -threaded -O0
|
||||||
|
else
|
||||||
|
ghc-options: -Wall -threaded
|
||||||
|
|
||||||
main-is: main.hs
|
main-is: main.hs
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user