From bd617a846ebe8f50b65f2500147f1f5271320852 Mon Sep 17 00:00:00 2001 From: Oscar Picasso Date: Sun, 11 Sep 2011 17:47:21 -0400 Subject: [PATCH 1/6] reworded 'joinPath' comments --- yesod-core/Yesod/Internal/Core.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yesod-core/Yesod/Internal/Core.hs b/yesod-core/Yesod/Internal/Core.hs index 603c0231..ce0c4910 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 From be372022ec6cee4c2994ab3b73cf022c65a2aaec Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 14 Sep 2011 07:11:44 +0300 Subject: [PATCH 2/6] GHC 6.12 fixes --- yesod/Devel.hs | 9 ++++++++- yesod/yesod.cabal | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/yesod/Devel.hs b/yesod/Devel.hs index 88e214bd..03d8795f 100755 --- a/yesod/Devel.hs +++ b/yesod/Devel.hs @@ -2,6 +2,7 @@ {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE CPP #-} module Devel ( devel ) where @@ -35,6 +36,12 @@ import Text.Shakespeare.Text (st) import Build (recompDeps, getDeps,findHaskellFiles) +#if __GLASGOW_HASKELL__ >= 700 +#define ST st +#else +#define ST $st +#endif + lockFile :: FilePath lockFile = "dist/devel-terminate" @@ -137,7 +144,7 @@ showPkgName :: D.PackageId -> String showPkgName = (\(D.PackageName n) -> n) . D.pkgName develFile :: D.PackageId -> T.Text -develFile pid = [st| +develFile pid = [ST| {-# LANGUAGE PackageImports #-} import "#{showPkgName pid}" Application (withDevelAppPort) import Data.Dynamic (fromDynamic) diff --git a/yesod/yesod.cabal b/yesod/yesod.cabal index 94a340d4..9b13dcdf 100644 --- a/yesod/yesod.cabal +++ b/yesod/yesod.cabal @@ -1,5 +1,5 @@ name: yesod -version: 0.9.2.1 +version: 0.9.2.2 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -100,7 +100,7 @@ executable yesod , attoparsec-text >= 0.8.5 && < 0.9 , http-types >= 0.6.1 && < 0.7 , blaze-builder >= 0.2 && < 0.4 - , filepath >= 1.2 && < 1.3 + , filepath >= 1.1 && < 1.3 , process ghc-options: -Wall -threaded main-is: main.hs From 4bcfe8758221316b9af8d88273a024171e989fe6 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Thu, 15 Sep 2011 09:37:55 -0700 Subject: [PATCH 3/6] bump hspec dependency --- yesod-core/test/Test/CleanPath.hs | 2 +- yesod-core/test/Test/Exceptions.hs | 2 +- yesod-core/test/Test/Links.hs | 2 +- yesod-core/test/Test/Media.hs | 2 +- yesod-core/test/Test/NoOverloadedStrings.hs | 2 +- yesod-core/test/Test/Widget.hs | 2 +- yesod-core/yesod-core.cabal | 2 +- yesod-static/tests/runtests.hs | 3 ++- yesod-static/tests/unicode/wai-app-static.cabal | 2 +- yesod-static/yesod-static.cabal | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) 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 1b520dc4..233b95c6 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -91,7 +91,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-static/tests/runtests.hs b/yesod-static/tests/runtests.hs index a1dcb983..20ce829a 100644 --- a/yesod-static/tests/runtests.hs +++ b/yesod-static/tests/runtests.hs @@ -6,7 +6,8 @@ import Test.Hspec.HUnit () -- import Test.Hspec.QuickCheck (prop) main :: IO () -main = hspecX $ return [] {- FIXME specs +main = return () -- hspecX $ return [] +{- FIXME specs specs :: IO [Spec] specs = runSpecM $ do diff --git a/yesod-static/tests/unicode/wai-app-static.cabal b/yesod-static/tests/unicode/wai-app-static.cabal index 6c89fb4e..066d54e3 100644 --- a/yesod-static/tests/unicode/wai-app-static.cabal +++ b/yesod-static/tests/unicode/wai-app-static.cabal @@ -48,7 +48,7 @@ test-suite runtests type: exitcode-stdio-1.0 build-depends: base >= 4 && < 5 - , hspec >= 0.6.1 && < 0.7 + , hspec >= 0.8 && < 0.9 , HUnit , unix-compat >= 0.2 && < 0.3 , time >= 1.1.4 && < 1.3 diff --git a/yesod-static/yesod-static.cabal b/yesod-static/yesod-static.cabal index 5c11f79c..e503db0c 100644 --- a/yesod-static/yesod-static.cabal +++ b/yesod-static/yesod-static.cabal @@ -44,7 +44,7 @@ test-suite runtests cpp-options: -DTEST build-depends: yesod-static , base >= 4 && < 5 - , hspec >= 0.6.1 && < 0.7 + , hspec >= 0.8 && < 0.9 , HUnit ghc-options: -Wall main-is: runtests.hs From 3a36c4e68529f523feae75c77dc766f839865d88 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Thu, 15 Sep 2011 11:50:51 -0700 Subject: [PATCH 4/6] update submodule --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index fc9feeee..f56426fa 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit fc9feeee6d330d4df7d4aab7c015387da93f0192 +Subproject commit f56426fada59012329f23c928a2d7f9c3a515d75 From fe2e0176809469d7af206f177dca253c22c915f3 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 19 Sep 2011 12:50:01 +0300 Subject: [PATCH 5/6] gzipCompressFiles --- yesod-core/Yesod/Dispatch.hs | 4 ++-- yesod-core/Yesod/Internal/Core.hs | 4 ++++ yesod-core/yesod-core.cabal | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) 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 ce0c4910..4ba14405 100644 --- a/yesod-core/Yesod/Internal/Core.hs +++ b/yesod-core/Yesod/Internal/Core.hs @@ -260,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 233b95c6..b2b9bbe3 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 From 74fbfee1c9886a0cc562f4662dae0c900134a6d8 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 19 Sep 2011 15:52:15 +0300 Subject: [PATCH 6/6] Option (for selectField) --- yesod-form/Yesod/Form/Fields.hs | 99 +++++++++++++++++++++++---------- yesod-form/yesod-form.cabal | 3 +- 2 files changed, 73 insertions(+), 29 deletions(-) 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|