yesod-default 0.3.1 → 0.4.0
raw patch · 4 files changed
+27/−16 lines, 4 filesdep ~wai-extra
Dependency ranges changed: wai-extra
Files
- Yesod/Default/Handlers.hs +2/−2
- Yesod/Default/Main.hs +21/−10
- Yesod/Default/Util.hs +2/−2
- yesod-default.cabal +2/−2
Yesod/Default/Handlers.hs view
@@ -5,10 +5,10 @@ ) where import Yesod.Handler (GHandler, sendFile)-import Yesod.Content (RepPlain(..), ToContent(..))+import Yesod.Content (RepPlain(..)) getFaviconR :: GHandler s m () getFaviconR = sendFile "image/x-icon" "config/favicon.ico" getRobotsR :: GHandler s m RepPlain-getRobotsR = return $ RepPlain $ toContent ("User-agent: *" :: String)+getRobotsR = sendFile "text/plain" "config/robots.txt"
Yesod/Default/Main.hs view
@@ -13,6 +13,11 @@ import Network.Wai (Application) import Network.Wai.Handler.Warp (run) import Network.Wai.Middleware.Debug (debugHandle)+import System.Directory (doesDirectoryExist, removeDirectoryRecursive)+import Network.Wai.Middleware.Gzip (gzip', GzipFiles (GzipCacheFolder), gzipFiles, def)+import Network.Wai.Middleware.Autohead (autohead)+import Network.Wai.Middleware.Jsonp (jsonp)+import Control.Monad (when) #ifndef WINDOWS import qualified System.Posix.Signals as Signal@@ -55,19 +60,25 @@ => (Application -> IO a) -> y -- ^ your foundation type -> IO ()-defaultRunner f h =+defaultRunner f h = do+ -- clear the .static-cache so we don't have stale content+ exists <- doesDirectoryExist staticCache+ when exists $ removeDirectoryRecursive staticCache #ifdef WINDOWS- toWaiApp h >>= f >> return ()+ toWaiAppPlain h >>= f . middlewares >> return () #else- do- tid <- forkIO $ toWaiApp h >>= f >> return ()- flag <- newEmptyMVar- _ <- Signal.installHandler Signal.sigINT (Signal.CatchOnce $ do- putStrLn "Caught an interrupt"- killThread tid- putMVar flag ()) Nothing- takeMVar flag+ tid <- forkIO $ toWaiAppPlain h >>= f . middlewares >> return ()+ flag <- newEmptyMVar+ _ <- Signal.installHandler Signal.sigINT (Signal.CatchOnce $ do+ putStrLn "Caught an interrupt"+ killThread tid+ putMVar flag ()) Nothing+ takeMVar flag #endif+ where+ middlewares = gzip' gset . jsonp . autohead+ gset = def { gzipFiles = GzipCacheFolder staticCache }+ staticCache = ".static-cache" -- | Run your development app using the provided @'DefaultEnv'@ type --
Yesod/Default/Util.hs view
@@ -52,9 +52,9 @@ | ext' == "js" = either (const content) id $ minify content | otherwise = content --- | expects a root folder for each type, e.g: hamlet/ lucius/ julius/+-- | expects a file extension for each type, e.g: hamlet lucius julius globFile :: String -> String -> FilePath-globFile kind x = kind ++ "/" ++ x ++ "." ++ kind+globFile kind x = "templates/" ++ x ++ "." ++ kind widgetFileProduction :: FilePath -> Q Exp widgetFileProduction x = do
yesod-default.cabal view
@@ -1,5 +1,5 @@ name: yesod-default-version: 0.3.1+version: 0.4.0 license: BSD3 license-file: LICENSE author: Patrick Brisbin@@ -22,7 +22,7 @@ , cmdargs >= 0.8 && < 0.9 , warp >= 0.4 && < 0.5 , wai >= 0.4 && < 0.5- , wai-extra >= 0.4 && < 0.5+ , wai-extra >= 0.4.4 && < 0.5 , bytestring >= 0.9 && < 0.10 , transformers >= 0.2 && < 0.3 , text >= 0.9 && < 1.0