From d55c78dc19557d642f450d4f4ef0cecb9eaeb395 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 2 Sep 2010 00:56:14 +0300 Subject: [PATCH] Minor bug fixes --- ChangeLog.md | 90 ++++++++++++++++++++++++++++++++++++++++++++ Yesod/Form/Fields.hs | 8 +++- scaffold.hs | 11 +++--- yesod.cabal | 2 +- 4 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 ChangeLog.md diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100644 index 00000000..d9808462 --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,90 @@ +### Yesod 0.5.0 (August 29, 2010) + +* Forms no longer have special types for special views; instead, there is a +toFormField attribute when declaring entities to specify a form rendering +function. + +* URL settings for jQuery and Nic are now in their own typeclasses. This will +be the approach used in the future when adding more widgets and forms that +require Javascript libraries. + +* You can explicitly specify the id and name attributes to be used in forms if +you like. When omitted, a unique name is automatically generated. + +* The isAuthorized function now takes a function specifying whether the +request is a write request. This should make it simpler to develop read/write +authorization systems. Bonus points: if you use HTTP request methods properly, +the isWriteRequest function will automatically determine whether a request is +a read or write request. + +* You can now specify splitPath and joinPath functions yourself. Previously, +the built-in versions had very specific URL rules, such as enforcing a +trailing slash. If you want something more flexible, you can override these +functions. + +* addStaticContent is used to serve CSS and Javascript code from widgets from +external files. This allows caching to take place as you'd normally like. + +* Static files served from the static subsite can have a hash string added to +the query string; this is done automatically when using the getStaticFiles +function. This allows you to set your expires headers far in the future. + +* A new Yesod.Mail module provides datatypes and functions for creating +multipart MIME email messages and sending them via the sendmail executable. +Since these functions generate lazy bytestrings, you can use any delivery +mechanism you want. + +* Change the type of defaultLayout to use Widgets instead of PageContent. This +makes it easier to avoid double-including scripts and stylesheets. + +* Major reworking of the Auth subsite to make it easier to use. + +* Update of the site scaffolder to include much more functionality. Also +removed the Handler type alias from the library, as the scaffolder now +provides that. + +### New in Yesod 0.4.0 + +A big thanks on this release to Simon Michael, who pointed out a number of +places where the docs were unclear, the API was unintuitive, or the names were +inconsistent. + +* Widgets. These allow you to create composable pieces of a webpage that +keep track of their own Javascript and CSS. It includes a function for +obtaining unique identifiers to avoid name collisions, and does automatic +dependency combining; in other words, if you have two widgets that depend on +jQuery, the combined widget will only include it once. + +* Combined the Yesod.Form and Yesod.Formable module into a single, consistent, +widget-based API. It includes basic input functions as well as fancier +Javascript-driven functions; for example, there is a plain day entry field, +and a day entry field which automatically loads the jQuery UI date picker. + +* Added the yesod executable which performs basic scaffolding. + +* Cleaned up a bunch of API function names for consistency. For example, +Yesod.Request now has a logical lookupGetName, lookupPostName, etc naming +scheme. + +* Changed the type of basicHandler to require less typing, and added +basicHandler' which allows you to modify the line output to STDOUT (or skip it +altogether). + +* Switched the Handler monad from ContT to MEitherT (provided by the neither +package). ContT does not have a valid MonadCatchIO instance, which is used for +the sqlite persitent backend. + +* Facebook support in the Auth helper. + +* Ensure that HTTP request methods are given in ALL CAPS. + +* Cleaned up signatures of many methods in the Yesod typeclass. In particular, +due to changes in web-routes-quasi, many of those functions can now live in +the Handler monad, making it easier to use standard functions on them. + +* The static file helper now has extensible file-extension-to-mimetype +mappings. + +* Added the sendResponse function for handler short-circuiting. + +* Renamed Routes to Route. diff --git a/Yesod/Form/Fields.hs b/Yesod/Form/Fields.hs index b1c3f229..611df896 100644 --- a/Yesod/Form/Fields.hs +++ b/Yesod/Form/Fields.hs @@ -95,6 +95,8 @@ boolField ffs orig = GForm $ do then (FormMissing, fromMaybe False orig) else case lookup name env of Nothing -> (FormSuccess False, False) + Just "" -> (FormSuccess False, False) + Just "false" -> (FormSuccess False, False) Just _ -> (FormSuccess True, True) let fi = FieldInfo { fiLabel = label @@ -214,7 +216,11 @@ maybeStringInput n = boolInput :: String -> FormInput sub master Bool boolInput n = GForm $ do env <- askParams - let res = FormSuccess $ fromMaybe "" (lookup n env) /= "" + let res = case lookup n env of + Nothing -> FormSuccess False + Just "" -> FormSuccess False + Just "false" -> FormSuccess False + Just _ -> FormSuccess True let xml = addBody [$hamlet| %input#$n$!type=checkbox!name=$n$ |] diff --git a/scaffold.hs b/scaffold.hs index 21383872..86ce7db4 100644 --- a/scaffold.hs +++ b/scaffold.hs @@ -120,7 +120,7 @@ executable simple-server directory, bytestring, persistent, - persistent-sqlite, + persistent-~lower~, template-haskell, hamlet ghc-options: -Wall @@ -313,7 +313,6 @@ sendVerifyEmail' email _ verurl = writeFile' "Controller.hs" [$codegen| {-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE PackageImports #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Controller ( with~sitearg~ @@ -401,7 +400,7 @@ import qualified Text.Hamlet as H import qualified Text.Cassius as H import qualified Text.Julius as H import Language.Haskell.TH.Syntax -import Database.Persist.Sqlite +import Database.Persist.~upper~ import Yesod (MonadCatchIO) hamletFile :: FilePath -> Q Exp @@ -427,16 +426,16 @@ juliusFile x = H.juliusFileDebug $ "julius/" ++ x ++ ".julius" connStr :: String #ifdef PRODUCTION -connStr = "production.db3" +connStr = "~connstr2~" #else -connStr = "debug.db3" +connStr = "~connstr1~" #endif connectionCount :: Int connectionCount = 10 withConnectionPool :: MonadCatchIO m => (ConnectionPool -> m a) -> m a -withConnectionPool = withSqlitePool connStr connectionCount +withConnectionPool = with~upper~Pool connStr connectionCount runConnectionPool :: MonadCatchIO m => SqlPersist m a -> ConnectionPool -> m a runConnectionPool = runSqlPool diff --git a/yesod.cabal b/yesod.cabal index a23682da..13e2b2d1 100644 --- a/yesod.cabal +++ b/yesod.cabal @@ -1,5 +1,5 @@ name: yesod -version: 0.5.0.2 +version: 0.5.0.3 license: BSD3 license-file: LICENSE author: Michael Snoyman