yesod 0.6.6 → 0.6.7
raw patch · 5 files changed
+76/−97 lines, 5 filesdep ~blaze-builder
Dependency ranges changed: blaze-builder
Files
- Yesod/Form/Fields.hs +10/−0
- Yesod/Form/Jquery.hs +16/−36
- Yesod/Form/Profiles.hs +45/−57
- Yesod/Json.hs +2/−1
- yesod.cabal +3/−3
Yesod/Form/Fields.hs view
@@ -17,6 +17,7 @@ , selectField , boolField , emailField+ , searchField , urlField , fileField -- ** Optional@@ -31,6 +32,7 @@ , maybeHtmlField , maybeSelectField , maybeEmailField+ , maybeSearchField , maybeUrlField , maybeFileField -- * Inputs@@ -325,6 +327,14 @@ emailInput n = mapFormXml fieldsToInput $ requiredFieldHelper emailFieldProfile (nameSettings n) Nothing++searchField :: (IsForm f, FormType f ~ String)+ => AutoFocus -> FormFieldSettings -> Maybe String -> f+searchField = requiredFieldHelper . searchFieldProfile++maybeSearchField :: (IsForm f, FormType f ~ Maybe String)+ => AutoFocus -> FormFieldSettings -> Maybe (Maybe String) -> f+maybeSearchField = optionalFieldHelper . searchFieldProfile textareaField :: (IsForm f, FormType f ~ Textarea) => FormFieldSettings -> Maybe Textarea -> f
Yesod/Form/Jquery.hs view
@@ -27,6 +27,16 @@ import Data.Char (isSpace) import Data.Default +#if GHC7+#define HAMLET hamlet+#define CASSIUS cassius+#define JULIUS julius+#else+#define HAMLET $hamlet+#define CASSIUS $cassius+#define JULIUS $julius+#endif+ -- | Gets the Google hosted jQuery UI 1.8 CSS file with the given theme. googleHostedJqueryUiCss :: String -> String googleHostedJqueryUiCss theme = concat@@ -76,23 +86,13 @@ . readMay , fpRender = show , fpWidget = \theId name val isReq -> do- addHtml-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ addHtml [HAMLET| %input#$theId$!name=$name$!type=date!:isReq:required!value=$val$ |] addScript' urlJqueryJs addScript' urlJqueryUiJs addStylesheet' urlJqueryUiCss- addJulius-#if GHC7- [julius|-#else- [$julius|-#endif+ addJulius [JULIUS| $(function(){$("#%theId%").datepicker({ dateFormat:'yy-mm-dd', changeMonth:%jsBool.jdsChangeMonth.jds%,@@ -144,24 +144,14 @@ { fpParse = parseUTCTime , fpRender = jqueryDayTimeUTCTime , fpWidget = \theId name val isReq -> do- addHtml-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ addHtml [HAMLET| %input#$theId$!name=$name$!:isReq:required!value=$val$ |] addScript' urlJqueryJs addScript' urlJqueryUiJs addScript' urlJqueryUiDateTimePicker addStylesheet' urlJqueryUiCss- addJulius-#if GHC7- [julius|-#else- [$julius|-#endif+ addJulius [JULIUS| $(function(){$("#%theId%").datetimepicker({dateFormat : "yyyy/mm/dd h:MM TT"})}); |] }@@ -198,23 +188,13 @@ { fpParse = Right , fpRender = id , fpWidget = \theId name val isReq -> do- addHtml-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ addHtml [HAMLET| %input.autocomplete#$theId$!name=$name$!type=text!:isReq:required!value=$val$ |] addScript' urlJqueryJs addScript' urlJqueryUiJs addStylesheet' urlJqueryUiCss- addJulius-#if GHC7- [julius|-#else- [$julius|-#endif+ addJulius [JULIUS| $(function(){$("#%theId%").autocomplete({source:"@src@",minLength:2})}); |] }
Yesod/Form/Profiles.hs view
@@ -12,6 +12,8 @@ , timeFieldProfile , htmlFieldProfile , emailFieldProfile+ , searchFieldProfile+ , AutoFocus , urlFieldProfile , doubleFieldProfile , parseDate@@ -22,27 +24,36 @@ import Yesod.Form.Core import Yesod.Widget import Text.Hamlet+import Text.Cassius import Data.Time (Day, TimeOfDay(..)) import qualified Text.Email.Validate as Email import Network.URI (parseURI) import Database.Persist (PersistField) import Text.HTML.SanitizeXSS (sanitizeBalance)+import Control.Monad (when) import qualified Blaze.ByteString.Builder.Html.Utf8 as B-import Blaze.ByteString.Builder (fromWrite4List, writeByteString)+import Blaze.ByteString.Builder (writeByteString)+import Blaze.ByteString.Builder.Internal.Write (fromWriteList) import Yesod.Internal (lbsToChars) +#if GHC7+#define HAMLET hamlet+#define CASSIUS cassius+#define JULIUS julius+#else+#define HAMLET $hamlet+#define CASSIUS $cassius+#define JULIUS $julius+#endif+ intFieldProfile :: Integral i => FieldProfile sub y i intFieldProfile = FieldProfile { fpParse = maybe (Left "Invalid integer") Right . readMayI , fpRender = showI , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!type=number!:isReq:required!value=$val$ |] }@@ -57,11 +68,7 @@ { fpParse = maybe (Left "Invalid number") Right . readMay , fpRender = show , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!type=text!:isReq:required!value=$val$ |] }@@ -71,11 +78,7 @@ { fpParse = parseDate , fpRender = show , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!type=date!:isReq:required!value=$val$ |] }@@ -85,11 +88,7 @@ { fpParse = parseTime , fpRender = show , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!:isReq:required!value=$val$ |] }@@ -99,11 +98,7 @@ { fpParse = Right . preEscapedString . sanitizeBalance , fpRender = lbsToChars . renderHtml , fpWidget = \theId name val _isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %textarea.html#$theId$!name=$name$ $val$ |] }@@ -114,7 +109,7 @@ deriving (Show, Read, Eq, PersistField) instance ToHtml Textarea where toHtml =- Html . fromWrite4List writeHtmlEscapedChar . unTextarea+ Html . fromWriteList writeHtmlEscapedChar . unTextarea where -- Taken from blaze-builder and modified with newline handling. writeHtmlEscapedChar '\n' = writeByteString "<br>"@@ -125,11 +120,7 @@ { fpParse = Right . Textarea , fpRender = unTextarea , fpWidget = \theId name val _isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %textarea#$theId$!name=$name$ $val$ |] }@@ -139,11 +130,7 @@ { fpParse = Right , fpRender = id , fpWidget = \theId name val _isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input!type=hidden#$theId$!name=$name$!value=$val$ |] }@@ -153,11 +140,7 @@ { fpParse = Right , fpRender = id , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!type=text!:isReq:required!value=$val$ |] }@@ -167,11 +150,7 @@ { fpParse = Right , fpRender = id , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!type=password!:isReq:required!value=$val$ |] }@@ -221,15 +200,28 @@ else Left "Invalid e-mail address" , fpRender = id , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!type=email!:isReq:required!value=$val$ |] } +type AutoFocus = Bool+searchFieldProfile :: AutoFocus -> FieldProfile s y String+searchFieldProfile autoFocus = FieldProfile+ { fpParse = Right+ , fpRender = id+ , fpWidget = \theId name val isReq -> do+ addHtml [HAMLET|+%input#$theId$!name=$name$!type=search!:isReq:required!:autoFocus:autofocus!value=$val$+|]+ when autoFocus $ do+ addHtml $ [HAMLET| <script>if (!('autofocus' in document.createElement('input'))) {document.getElementById('$theId$').focus();}</script> |]+ addCassius [CASSIUS|+ #$theId$+ -webkit-appearance: textfield+ |]+ }+ urlFieldProfile :: FieldProfile s y String urlFieldProfile = FieldProfile { fpParse = \s -> case parseURI s of@@ -237,11 +229,7 @@ Just _ -> Right s , fpRender = id , fpWidget = \theId name val isReq -> addHamlet-#if GHC7- [hamlet|-#else- [$hamlet|-#endif+ [HAMLET| %input#$theId$!name=$name$!type=url!:isReq:required!value=$val$ |] }
Yesod/Json.hs view
@@ -25,6 +25,7 @@ import Data.Monoid (Monoid (..)) import Blaze.ByteString.Builder import Blaze.ByteString.Builder.Char.Utf8 (writeChar)+import Blaze.ByteString.Builder.Internal.Write (fromWriteList) #if TEST import Test.Framework (testGroup, Test)@@ -63,7 +64,7 @@ jsonScalar :: String -> Json jsonScalar s = Json $ mconcat [ fromByteString "\""- , fromWrite4List writeJsonChar s+ , fromWriteList writeJsonChar s , fromByteString "\"" ] where
yesod.cabal view
@@ -1,5 +1,5 @@ name: yesod-version: 0.6.6+version: 0.6.7 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -9,7 +9,7 @@ Yesod is a framework designed to foster creation of RESTful web application that have strong compile-time guarantees of correctness. It also affords space efficient code and portability to many deployment backends, from CGI to stand-alone serving. . The Yesod documentation site <http://docs.yesodweb.com/> has much more information, tutorials and information on some of the supporting packages, like Hamlet and web-routes-quasi.-category: Web+category: Web, Yesod stability: Stable cabal-version: >= 1.6 build-type: Simple@@ -37,7 +37,7 @@ , template-haskell >= 2.4 && < 2.6 , web-routes-quasi >= 0.6.2 && < 0.7 , hamlet >= 0.5.1 && < 0.7- , blaze-builder >= 0.2 && < 0.3+ , blaze-builder >= 0.2.1 && < 0.3 , transformers >= 0.2 && < 0.3 , clientsession >= 0.4.0 && < 0.5 , pureMD5 >= 1.1.0.0 && < 2.2