diff --git a/scripts b/scripts index fc9feeee..f56426fa 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit fc9feeee6d330d4df7d4aab7c015387da93f0192 +Subproject commit f56426fada59012329f23c928a2d7f9c3a515d75 diff --git a/yesod-core/Yesod/Dispatch.hs b/yesod-core/Yesod/Dispatch.hs index 4421abc5..91147cb8 100644 --- a/yesod-core/Yesod/Dispatch.hs +++ b/yesod-core/Yesod/Dispatch.hs @@ -173,10 +173,10 @@ thResourceFromResource (Resource n _ _) = -- | Convert the given argument into a WAI application, executable with any WAI -- handler. This is the same as 'toWaiAppPlain', except it includes three --- middlewares: GZIP compression, JSON-P and path cleaning. This is the +-- middlewares: GZIP compression, JSON-P and autohead. This is the -- recommended approach for most users. toWaiApp :: (Yesod y, YesodDispatch y y) => y -> IO W.Application -toWaiApp y = gzip False . jsonp . autohead <$> toWaiAppPlain y +toWaiApp y = gzip (gzipCompressFiles y) . jsonp . autohead <$> toWaiAppPlain y -- | Convert the given argument into a WAI application, executable with any WAI -- handler. This differs from 'toWaiApp' in that it uses no middlewares. diff --git a/yesod-core/Yesod/Internal/Core.hs b/yesod-core/Yesod/Internal/Core.hs index 603c0231..4ba14405 100644 --- a/yesod-core/Yesod/Internal/Core.hs +++ b/yesod-core/Yesod/Internal/Core.hs @@ -205,8 +205,9 @@ class RenderRoute (Route a) => Yesod a where where corrected = filter (not . TS.null) s - -- | Join the pieces of a path together into an absolute URL. This should - -- be the inverse of 'splitPath'. + -- | Builds an absolute URL by concatenating the application root with the + -- pieces of a path and a query string, if any. + -- Note that the pieces of the path have been previously cleaned up by 'cleanPath'. joinPath :: a -> TS.Text -- ^ application root -> [TS.Text] -- ^ path pieces @@ -259,6 +260,10 @@ class RenderRoute (Route a) => Yesod a where formatLogMessage loc level msg >>= Data.Text.Lazy.IO.putStrLn + -- | Apply gzip compression to files. Default is false. + gzipCompressFiles :: a -> Bool + gzipCompressFiles _ = False + messageLoggerHandler :: (Yesod m, MonadIO mo) => Loc -> LogLevel -> Text -> GGHandler s m mo () messageLoggerHandler loc level msg = do diff --git a/yesod-core/test/Test/CleanPath.hs b/yesod-core/test/Test/CleanPath.hs index ce01a96d..656da813 100644 --- a/yesod-core/test/Test/CleanPath.hs +++ b/yesod-core/test/Test/CleanPath.hs @@ -62,7 +62,7 @@ getBarR, getPlainR :: Handler RepPlain getBarR = return $ RepPlain "bar" getPlainR = return $ RepPlain "plain" -cleanPathTest :: IO [IO Spec] +cleanPathTest :: [Spec] cleanPathTest = describe "Test.CleanPath" [ it "remove trailing slash" removeTrailingSlash diff --git a/yesod-core/test/Test/Exceptions.hs b/yesod-core/test/Test/Exceptions.hs index 639ccbd1..61bab779 100644 --- a/yesod-core/test/Test/Exceptions.hs +++ b/yesod-core/test/Test/Exceptions.hs @@ -22,7 +22,7 @@ instance Yesod Y where getRootR :: Handler () getRootR = error "FOOBAR" >> return () -exceptionsTest :: IO [IO Spec] +exceptionsTest :: [Spec] exceptionsTest = describe "Test.Exceptions" [ it "500" case500 ] diff --git a/yesod-core/test/Test/Links.hs b/yesod-core/test/Test/Links.hs index ac237f44..69679625 100644 --- a/yesod-core/test/Test/Links.hs +++ b/yesod-core/test/Test/Links.hs @@ -21,7 +21,7 @@ instance Yesod Y where getRootR :: Handler RepHtml getRootR = defaultLayout $ addHamlet [hamlet||] -linksTest :: IO [IO Spec] +linksTest :: [Spec] linksTest = describe "Test.Links" [ it "linkToHome" case_linkToHome ] diff --git a/yesod-core/test/Test/Media.hs b/yesod-core/test/Test/Media.hs index 1f86ecdb..4e863db9 100644 --- a/yesod-core/test/Test/Media.hs +++ b/yesod-core/test/Test/Media.hs @@ -52,7 +52,7 @@ caseMediaLink = runner $ do assertStatus 200 res flip assertBody res "\n" -mediaTest :: IO [IO Spec] +mediaTest :: [Spec] mediaTest = describe "Test.Media" [ it "media" caseMedia , it "media link" caseMediaLink diff --git a/yesod-core/test/Test/NoOverloadedStrings.hs b/yesod-core/test/Test/NoOverloadedStrings.hs index d0a2d6ce..f162d7f2 100644 --- a/yesod-core/test/Test/NoOverloadedStrings.hs +++ b/yesod-core/test/Test/NoOverloadedStrings.hs @@ -46,7 +46,7 @@ case_sanity = runner $ do res <- request defaultRequest assertBody mempty res -noOverloadedTest :: IO [IO Spec] +noOverloadedTest :: [Spec] noOverloadedTest = describe "Test.NoOverloadedStrings" [ it "sanity" case_sanity ] diff --git a/yesod-core/test/Test/Widget.hs b/yesod-core/test/Test/Widget.hs index 6052c51f..8de0b268 100644 --- a/yesod-core/test/Test/Widget.hs +++ b/yesod-core/test/Test/Widget.hs @@ -69,7 +69,7 @@ getWhamletR = defaultLayout [whamlet| where embed = [whamlet|

Embed|] -widgetTest :: IO [IO Spec] +widgetTest :: [Spec] widgetTest = describe "Test.Widget" [ it "addJuliusBody" case_addJuliusBody , it "whamlet" case_whamlet diff --git a/yesod-core/yesod-core.cabal b/yesod-core/yesod-core.cabal index a499a2d3..c7a7f2b3 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -1,5 +1,5 @@ name: yesod-core -version: 0.9.2 +version: 0.9.3 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -95,7 +95,7 @@ test-suite runtests build-depends: base >= 4 && < 4.3 main-is: main.hs cpp-options: -DTEST - build-depends: hspec >= 0.6.1 && < 0.7 + build-depends: hspec >= 0.8 && < 0.9 ,wai-test ,wai ,yesod-core diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index 36992998..32dfb93f 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -31,6 +31,13 @@ module Yesod.Form.Fields -- * File 'AForm's , fileAFormReq , fileAFormOpt + -- * Options + , selectField' + , radioField' + , Option (..) + , optionsPersist + , optionsPairs + , optionsEnum ) where import Yesod.Form.Types @@ -48,7 +55,7 @@ import Text.HTML.SanitizeXSS (sanitizeBalance) import Control.Monad (when, unless) import Data.List (intersect, nub) import Data.Either (rights) -import Data.Maybe (catMaybes) +import Data.Maybe (catMaybes, listToMaybe) import qualified Blaze.ByteString.Builder.Html.Utf8 as B import Blaze.ByteString.Builder (writeByteString, toLazyByteString) @@ -60,12 +67,16 @@ import qualified Data.ByteString.Lazy as L import Data.Text (Text, unpack, pack) import qualified Data.Text.Read import Control.Monad.IO.Class (liftIO) +import Control.Monad.Trans.Class (lift) import Control.Applicative ((<$>)) import qualified Data.Map as Map -import Yesod.Handler (newIdent) +import Yesod.Handler (newIdent, liftIOHandler) import Yesod.Request (FileInfo) +import Yesod.Core (toSinglePiece, GGHandler, SinglePiece) +import Yesod.Persist (selectList, runDB, Filter, SelectOpt, YesodPersistBackend, Key, YesodPersist, PersistEntity, PersistBackend) + #if __GLASGOW_HASKELL__ >= 700 #define WHAMLET whamlet #define HAMLET hamlet @@ -290,10 +301,13 @@ urlField = Field } selectField :: (Eq a, RenderMessage master FormMessage) => [(Text, a)] -> Field sub master a -selectField = selectFieldHelper - (\theId name inside -> [WHAMLET|^{inside}|]) -- outside + (\_theId _name isSel -> [WHAMLET|