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/yesod-core.cabal b/yesod-core/yesod-core.cabal index 8ac3de66..9e73aef9 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 diff --git a/yesod-form/Yesod/Form/Fields.hs b/yesod-form/Yesod/Form/Fields.hs index 36992998..4d5bc805 100644 --- a/yesod-form/Yesod/Form/Fields.hs +++ b/yesod-form/Yesod/Form/Fields.hs @@ -31,6 +31,15 @@ module Yesod.Form.Fields -- * File 'AForm's , fileAFormReq , fileAFormOpt + -- * Options + , selectField' + , radioField' + , Option (..) + , OptionList (..) + , mkOptionList + , optionsPersist + , optionsPairs + , optionsEnum ) where import Yesod.Form.Types @@ -48,7 +57,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 +69,17 @@ 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) +import Control.Arrow ((&&&)) + #if __GLASGOW_HASKELL__ >= 700 #define WHAMLET whamlet #define HAMLET hamlet @@ -290,10 +304,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|