packages feed

yesod 0.9.3.4 → 0.9.4

raw patch · 19 files changed

+123/−83 lines, 19 files

Files

Devel.hs view
@@ -25,6 +25,7 @@ import qualified Data.Text.IO as T  import           System.Directory (createDirectoryIfMissing, removeFile,+                                           doesFileExist,                                            getDirectoryContents) import           System.Exit (exitFailure, exitSuccess) import           System.Posix.Types (EpochTime)@@ -35,6 +36,7 @@ import Text.Shakespeare.Text (st)  import Build (recompDeps, getDeps,findHaskellFiles)+import Control.Monad (unless)  #if __GLASGOW_HASKELL__ >= 700 #define ST st@@ -66,10 +68,21 @@       checkCabalFile gpd        _ <- if isDevel-        then rawSystem "cabal-dev" ["configure", "--cabal-install-arg=-fdevel", "--disable-library-profiling"]-        else rawSystem "cabal"     ["configure", "-fdevel", "--disable-library-profiling"]+        then rawSystem "cabal-dev"+            [ "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)+      exists <- doesFileExist "dist/devel.hs"+      unless exists $ T.writeFile "dist/devel.hs" (develFile pid)        mainLoop isDevel @@ -148,7 +161,8 @@ {-# LANGUAGE PackageImports #-} import "#{showPkgName pid}" Application (withDevelAppPort) import Data.Dynamic (fromDynamic)-import Network.Wai.Handler.Warp (run)+import Network.Wai.Handler.Warp+    (runSettings, defaultSettings, settingsPort, settingsHost) import Data.Maybe (fromJust) import Control.Concurrent (forkIO) import System.Directory (doesFileExist, removeFile)@@ -159,7 +173,10 @@ main = do   putStrLn "Starting devel application"   wdap <- (return . fromJust . fromDynamic) withDevelAppPort-  forkIO . wdap $ \(port, app) -> run port app+  forkIO . wdap $ \(port, app) -> runSettings defaultSettings+    { settingsPort = port+    , settingsHost = "0.0.0.0"+    } app   loop  loop :: IO ()@@ -194,7 +211,7 @@ lookupDevelLib ct = listToMaybe . map (\(_,x,_) -> D.condTreeData x) .                     filter isDevelLib . D.condTreeComponents  $ ct   where-    isDevelLib ((D.Var (D.Flag (D.FlagName "devel"))), _, _) = True-    isDevelLib _                                             = False+    isDevelLib ((D.Var (D.Flag (D.FlagName f))), _, _) = f `elem` ["library-only", "devel"]+    isDevelLib _                                       = False  
Yesod.hs view
@@ -51,7 +51,7 @@ import Yesod.Json import Yesod.Persist import Network.Wai (Application)-import Network.Wai.Middleware.Debug+import Network.Wai.Middleware.RequestLogger import Control.Monad.Trans.Class (lift) import Control.Monad.IO.Class (liftIO) #if MIN_VERSION_monad_control(0, 3, 0)@@ -78,12 +78,12 @@ warp :: (Yesod a, YesodDispatch a a) => Int -> a -> IO () warp port a = toWaiApp a >>= run port --- | Same as 'warp', but also sends a message to stderr for each request, and+-- | Same as 'warp', but also sends a message to stdout for each request, and -- an \"application launched\" message as well. Can be useful for development. warpDebug :: (Yesod a, YesodDispatch a a) => Int -> a -> IO () warpDebug port a = do     hPutStrLn stderr $ "Application launched, listening on port " ++ show port-    toWaiApp a >>= run port . debug+    toWaiApp a >>= run port . logStdout  -- | Run a development server, where your code changes are automatically -- reloaded.
input/done.cg view
@@ -14,7 +14,7 @@  --------------------------------------- -The foundation for your site has been laid.+The foundation for your web application has been built.   There are a lot of resources to help you use Yesod.
main.hs view
@@ -4,6 +4,7 @@ import System.Environment (getArgs) import System.Exit (exitWith) import System.Process (rawSystem)+import Yesod.Core(yesodVersion)  #ifndef WINDOWS import Build (touch)@@ -35,7 +36,7 @@         ["touch"] -> touch #endif         ["devel"] -> devel isDev-        ["version"] -> putStrLn "0.9.3"+        ["version"] -> putStrLn yesodVersion         "configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith         _ -> do             putStrLn "Usage: yesod <command>"
scaffold/Application.hs.cg view
@@ -6,13 +6,19 @@  import Import import Settings-import Yesod.Static+import Settings.StaticFiles (staticSite) import Yesod.Auth import Yesod.Default.Config import Yesod.Default.Main import Yesod.Default.Handlers-import Yesod.Logger (Logger) import Data.Dynamic (Dynamic, toDyn)+#if DEVELOPMENT+import Yesod.Logger (Logger, logBS, flushLogger)+import Network.Wai.Middleware.RequestLogger (logHandleDev)+#else+import Yesod.Logger (Logger)+import Network.Wai.Middleware.RequestLogger (logStdout)+#endif import qualified Database.Persist.Base~importMigration~  -- Import all relevant handler modules here.@@ -27,18 +33,20 @@ -- performs initialization and creates a WAI application. This is also the -- place to put your migrate statements to have automatic database -- 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-#ifdef PRODUCTION-    s <- static Settings.staticDir-#else-    s <- staticDevel Settings.staticDir-#endif+    s <- staticSite     dbconf <- withYamlEnvironment "config/~dbConfigFile~.yml" (appEnv conf)             $ either error return . Database.Persist.Base.loadConfig     Database.Persist.Base.withPool (dbconf :: Settings.PersistConfig) $ \p -> do~runMigration~         let h = ~sitearg~ conf logger s p-        defaultRunner f h+        defaultRunner (f . logWare) h+  where+#ifdef DEVELOPMENT+    logWare = logHandleDev (\msg -> logBS logger msg >> flushLogger logger)+#else+    logWare = logStdout+#endif  -- for yesod devel withDevelAppPort :: Dynamic
scaffold/Foundation.hs.cg view
@@ -16,14 +16,17 @@     ) where  import Prelude-import Yesod hiding (Form)+import Yesod hiding (Form, AppConfig (..), withYamlEnvironment) import Yesod.Static (Static, base64md5, StaticRoute(..)) import Settings.StaticFiles import Yesod.Auth import Yesod.Auth.OpenId import Yesod.Default.Config import Yesod.Default.Util (addStaticContentExternal)-import Yesod.Logger (Logger, logLazyText)+import Yesod.Logger (Logger, logMsg, formatLogText)+#ifdef DEVELOPMENT+import Yesod.Logger (logLazyText)+#endif import qualified Settings import qualified Data.ByteString.Lazy as L import qualified Database.Persist.Base@@ -33,10 +36,10 @@ import Text.Jasmine (minifym) import Web.ClientSession (getKey) import Text.Hamlet (hamletFile)-#if PRODUCTION-import Network.Mail.Mime (sendmail)-#else+#if DEVELOPMENT import qualified Data.Text.Lazy.Encoding+#else+import Network.Mail.Mime (sendmail) #endif  -- | The site argument for your application. This can be a good place to@@ -44,7 +47,7 @@ -- starts running, such as database connections. Every handler will have -- access to the data present here. data ~sitearg~ = ~sitearg~-    { settings :: AppConfig DefaultEnv+    { settings :: AppConfig DefaultEnv ()     , getLogger :: Logger     , getStatic :: Static -- ^ Settings for static file serving.     , connPool :: Database.Persist.Base.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.@@ -108,7 +111,7 @@     authRoute _ = Just $ AuthR LoginR      messageLogger y loc level msg =-      formatLogMessage loc level msg >>= logLazyText (getLogger y)+      formatLogText (getLogger y) loc level msg >>= logMsg (getLogger y)      -- This function creates static content files in the static folder     -- and names them based on a hash of their content. This allows@@ -145,10 +148,10 @@  -- Sends off your mail. Requires sendmail in production! deliver :: ~sitearg~ -> L.ByteString -> IO ()-#ifdef PRODUCTION-deliver _ = sendmail-#else+#ifdef DEVELOPMENT deliver y = logLazyText (getLogger y) . Data.Text.Lazy.Encoding.decodeUtf8+#else+deliver _ = sendmail #endif  -- This instance is required to use forms. You can modify renderMessage to
scaffold/Settings.hs.cg view
@@ -41,7 +41,7 @@ -- have to make a corresponding change here. -- -- To see how this value is used, see urlRenderOverride in Foundation.hs-staticRoot :: AppConfig DefaultEnv ->  Text+staticRoot :: AppConfig DefaultEnv x ->  Text staticRoot conf = [~qq~st|#{appRoot conf}/static|]  @@ -49,8 +49,8 @@ -- user.  widgetFile :: String -> Q Exp-#if PRODUCTION-widgetFile = Yesod.Default.Util.widgetFileProduction+#if DEVELOPMENT+widgetFile = Yesod.Default.Util.widgetFileReload #else-widgetFile = Yesod.Default.Util.widgetFileDebug+widgetFile = Yesod.Default.Util.widgetFileNoReload #endif
scaffold/Settings/StaticFiles.hs.cg view
@@ -1,10 +1,22 @@ module Settings.StaticFiles where +import Prelude (IO) import Yesod.Static (staticFiles, StaticRoute (StaticRoute))+import qualified Yesod.Static as Static+import Settings (staticDir) --- | This generates easy references to files in the static directory at compile time.---   The upside to this is that you have compile-time verification that referenced files---   exist. However, any files added to your static directory during run-time can't be+-- | use this to create your static file serving site+staticSite :: IO Static.Static+staticSite =+#ifdef DEVELOPMENT+  Static.staticDevel staticDir+#else+  Static.static staticDir+#endif++-- | This generates easy references to files in the static directory at compile time,+--   giving you compile-time verification that referenced files exist.+--   Warning: any files added to your static directory during run-time can't be --   accessed this way. You'll have to use their FilePath or URL to access them.-$(staticFiles "static")+$(staticFiles Settings.staticDir) 
scaffold/config/mongoDB.yml.cg view
@@ -9,7 +9,7 @@ Development:   <<: *defaults -Testing:+Test:   database: ~project~_test   <<: *defaults 
scaffold/config/postgresql.yml.cg view
@@ -9,7 +9,7 @@ Development:   <<: *defaults -Testing:+Test:   database: ~project~_test   <<: *defaults 
scaffold/config/settings.yml.cg view
@@ -5,7 +5,7 @@ Development:   <<: *defaults -Testing:+Test:   <<: *defaults  Staging:
scaffold/config/sqlite.yml.cg view
@@ -5,7 +5,7 @@ Development:   <<: *defaults -Testing:+Test:   database: ~project~_test.sqlite3   <<: *defaults 
scaffold/deploy/Procfile.cg view
@@ -27,12 +27,12 @@ #      # * add code in Settings.hs to turn that url into connection parameters. The below works for Postgresql. #-#     #ifdef PRODUCTION+#     #ifdef !DEVELOPMENT #     import qualified Web.Heroku #     #endif # #     dbConnParams :: AppEnvironment -> IO [(Text, Text)]-#     #ifdef PRODUCTION+#     #ifdef !DEVELOPMENT #     dbConnParams _ = Web.Heroku.dbConnParams #     #else #     dbConnParams env = do
scaffold/project.cabal.cg view
@@ -12,16 +12,16 @@ build-type:        Simple homepage:          http://~project~.yesodweb.com/ -Flag production-    Description:   Build the production executable.+Flag dev+    Description:   Turn on development settings, like auto-reload templates.     Default:       False -Flag devel+Flag library-only     Description:   Build for use with "yesod devel"     Default:       False  library-    if flag(devel)+    if flag(library-only)         Buildable: True     else         Buildable: False@@ -35,6 +35,7 @@                      Handler.Root      ghc-options:   -Wall -threaded -O0+    cpp-options:   -DDEVELOPMENT      extensions: TemplateHaskell                 QuasiQuotes@@ -49,14 +50,14 @@                 FlexibleContexts  executable         ~project~-    if flag(devel)+    if flag(library-only)         Buildable: False -    if flag(production)-        cpp-options:   -DPRODUCTION-        ghc-options:   -Wall -threaded -O2-    else+    if flag(dev)+        cpp-options:   -DDEVELOPMENT         ghc-options:   -Wall -threaded -O0+    else+        ghc-options:   -Wall -threaded      main-is:       main.hs @@ -77,9 +78,9 @@                  , yesod-core                    >= 0.9.3      && < 0.10                  , yesod-auth                    >= 0.7.3      && < 0.8                  , yesod-static                  >= 0.3.1      && < 0.4-                 , yesod-default                 >= 0.4        && < 0.5+                 , yesod-default                 >= 0.5        && < 0.6                  , yesod-form                    >= 0.3.4      && < 0.4-                 , mime-mail                     >= 0.3.0.3    && < 0.4+                 , mime-mail                     >= 0.3.0.3    && < 0.5                  , clientsession                 >= 0.7.3      && < 0.8                  , bytestring                    >= 0.9        && < 0.10                  , text                          >= 0.11       && < 0.12@@ -92,3 +93,5 @@                  , shakespeare-text              >= 0.10       && < 0.11                  , hjsmin                        >= 0.0.14     && < 0.1                  , monad-control                 ~monadControlVersion~+                 , wai-extra                     >= 0.4.6      && < 0.5+
scaffold/tiny/Application.hs.cg view
@@ -5,8 +5,7 @@     ) where  import Import-import Settings-import Yesod.Static+import Settings.StaticFiles (staticSite) import Yesod.Default.Config import Yesod.Default.Main (defaultDevelApp, defaultRunner) import Yesod.Default.Handlers (getFaviconR, getRobotsR)@@ -26,13 +25,9 @@ -- performs initialization and creates a WAI application. This is also the -- place to put your migrate statements to have automatic database -- 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-#ifdef PRODUCTION-    s <- static Settings.staticDir-#else-    s <- staticDevel Settings.staticDir-#endif+    s <- staticSite     let h = ~sitearg~ conf logger s     defaultRunner f h 
scaffold/tiny/Foundation.hs.cg view
@@ -13,12 +13,12 @@     ) where  import Prelude-import Yesod.Core+import Yesod.Core hiding (AppConfig (..)) import Yesod.Default.Config import Yesod.Default.Util (addStaticContentExternal) import Yesod.Static (Static, base64md5, StaticRoute(..)) import Settings.StaticFiles-import Yesod.Logger (Logger, logLazyText)+import Yesod.Logger (Logger, logMsg, formatLogText) import qualified Settings import Settings (widgetFile) import Control.Monad.Trans.Class (lift)@@ -31,7 +31,7 @@ -- starts running, such as database connections. Every handler will have -- access to the data present here. data ~sitearg~ = ~sitearg~-    { settings :: AppConfig DefaultEnv+    { settings :: AppConfig DefaultEnv ()     , getLogger :: Logger     , getStatic :: Static -- ^ Settings for static file serving.     }@@ -89,7 +89,7 @@     urlRenderOverride _ _ = Nothing      messageLogger y loc level msg =-      formatLogMessage loc level msg >>= logLazyText (getLogger y)+      formatLogText (getLogger y) loc level msg >>= logMsg (getLogger y)      -- This function creates static content files in the static folder     -- and names them based on a hash of their content. This allows
scaffold/tiny/Settings.hs.cg view
@@ -34,12 +34,12 @@ -- have to make a corresponding change here. -- -- To see how this value is used, see urlRenderOverride in ~project~.hs-staticRoot :: AppConfig DefaultEnv ->  Text+staticRoot :: AppConfig DefaultEnv a ->  Text staticRoot conf = [~qq~st|#{appRoot conf}/static|]  widgetFile :: String -> Q Exp-#if PRODUCTION-widgetFile = Yesod.Default.Util.widgetFileProduction+#if DEVELOPMENT+widgetFile = Yesod.Default.Util.widgetFileReload #else-widgetFile = Yesod.Default.Util.widgetFileDebug+widgetFile = Yesod.Default.Util.widgetFileNoReload #endif
scaffold/tiny/project.cabal.cg view
@@ -12,16 +12,16 @@ build-type:        Simple homepage:          http://~project~.yesodweb.com/ -Flag production-    Description:   Build the production executable.+Flag dev+    Description:   Turn on development settings, like auto-reload templates.     Default:       False -Flag devel+Flag library-only     Description:   Build for use with "yesod devel"     Default:       False  library-    if flag(devel)+    if flag(library-only)         Buildable: True     else         Buildable: False@@ -33,6 +33,7 @@                      Handler.Root      ghc-options:   -Wall -threaded -O0+    cpp-options:   -DDEVELOPMENT      extensions: TemplateHaskell                 QuasiQuotes@@ -44,14 +45,14 @@                 TypeFamilies  executable         ~project~-    if flag(devel)+    if flag(library-only)         Buildable: False -    if flag(production)-        cpp-options:   -DPRODUCTION-        ghc-options:   -Wall -threaded -O2-    else+    if flag(dev)+        cpp-options:   -DDEVELOPMENT         ghc-options:   -Wall -threaded -O0+    else+        ghc-options:   -Wall -threaded      main-is:       main.hs @@ -67,7 +68,7 @@     build-depends: base                          >= 4          && < 5                  , yesod-core                    >= 0.9.3      && < 0.10                  , yesod-static                  >= 0.3.1      && < 0.4-                 , yesod-default                 >= 0.4        && < 0.5+                 , yesod-default                 >= 0.5        && < 0.6                  , clientsession                 >= 0.7.3      && < 0.8                  , bytestring                    >= 0.9        && < 0.10                  , text                          >= 0.11       && < 0.12
yesod.cabal view
@@ -1,5 +1,5 @@ name:            yesod-version:         0.9.3.4+version:         0.9.4 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>