yesod 0.5.2 → 0.5.3
raw patch · 7 files changed
+58/−15 lines, 7 files
Files
- Yesod/Content.hs +5/−0
- Yesod/Form/Core.hs +0/−3
- Yesod/Form/Fields.hs +6/−3
- Yesod/Form/Jquery.hs +15/−6
- Yesod/Form/Profiles.hs +1/−1
- Yesod/Handler.hs +30/−1
- yesod.cabal +1/−1
Yesod/Content.hs view
@@ -44,6 +44,7 @@ , RepXml (..) -- * Utilities , formatW3+ , formatRFC1123 #if TEST , testSuite #endif@@ -252,3 +253,7 @@ -- | Format a 'UTCTime' in W3 format; useful for setting cookies. formatW3 :: UTCTime -> String formatW3 = formatTime defaultTimeLocale "%FT%X-00:00"++-- | Format as per RFC 1123.+formatRFC1123 :: UTCTime -> String+formatRFC1123 = formatTime defaultTimeLocale "%a, %d %b %Y %X %Z"
Yesod/Form/Core.hs view
@@ -156,7 +156,6 @@ { fiLabel = label , fiTooltip = tooltip , fiIdent = theId- , fiName = name , fiInput = mkWidget theId name val True , fiErrors = case res of FormFailure [x] -> Just $ string x@@ -188,7 +187,6 @@ { fiLabel = label , fiTooltip = tooltip , fiIdent = theId- , fiName = name , fiInput = mkWidget theId name val False , fiErrors = case res of FormFailure x -> Just $ string $ unlines x@@ -212,7 +210,6 @@ { fiLabel :: Html , fiTooltip :: Html , fiIdent :: String- , fiName :: String , fiInput :: GWidget sub y () , fiErrors :: Maybe Html }
Yesod/Form/Fields.hs view
@@ -37,6 +37,7 @@ -- ** Optional , maybeStringInput , maybeDayInput+ , maybeIntInput ) where import Yesod.Form.Core@@ -59,6 +60,11 @@ mapFormXml fieldsToInput $ requiredFieldHelper intFieldProfile (nameSettings n) Nothing +maybeIntInput :: Integral i => String -> FormInput sub master (Maybe i)+maybeIntInput n =+ mapFormXml fieldsToInput $+ optionalFieldHelper intFieldProfile (nameSettings n) Nothing+ intField :: Integral i => FormFieldSettings -> FormletField sub y i intField = requiredFieldHelper intFieldProfile @@ -102,7 +108,6 @@ { fiLabel = label , fiTooltip = tooltip , fiIdent = theId- , fiName = name , fiInput = addBody [$hamlet| %input#$theId$!type=checkbox!name=$name$!:val:checked |]@@ -152,7 +157,6 @@ { fiLabel = label , fiTooltip = tooltip , fiIdent = theId- , fiName = name , fiInput = addBody input , fiErrors = case res of FormFailure [x] -> Just $ string x@@ -195,7 +199,6 @@ { fiLabel = label , fiTooltip = tooltip , fiIdent = theId- , fiName = name , fiInput = addBody input , fiErrors = case res of FormFailure [x] -> Just $ string x
Yesod/Form/Jquery.hs view
@@ -8,6 +8,7 @@ , jqueryAutocompleteField , maybeJqueryAutocompleteField , jqueryDayFieldProfile+ , googleHostedJqueryUiCss ) where import Yesod.Handler@@ -19,18 +20,26 @@ import Yesod.Hamlet import Data.Char (isSpace) +-- | Gets the Google hosted jQuery UI 1.8 CSS file with the given theme.+googleHostedJqueryUiCss :: String -> String+googleHostedJqueryUiCss theme = concat+ [ "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/"+ , theme+ , "/jquery-ui.css"+ ]+ class YesodJquery a where- -- | The jQuery Javascript file.+ -- | The jQuery 1.4 Javascript file. urlJqueryJs :: a -> Either (Route a) String- urlJqueryJs _ = Right "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"+ urlJqueryJs _ = Right "http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" - -- | The jQuery UI 1.8.1 Javascript file.+ -- | The jQuery UI 1.8 Javascript file. urlJqueryUiJs :: a -> Either (Route a) String- urlJqueryUiJs _ = Right "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"+ urlJqueryUiJs _ = Right "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" - -- | The jQuery UI 1.8.1 CSS file; defaults to cupertino theme.+ -- | The jQuery UI 1.8 CSS file; defaults to cupertino theme. urlJqueryUiCss :: a -> Either (Route a) String- urlJqueryUiCss _ = Right "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/cupertino/jquery-ui.css"+ urlJqueryUiCss _ = Right $ googleHostedJqueryUiCss "cupertino" -- | jQuery UI time picker add-on. urlJqueryUiDateTimePicker :: a -> Either (Route a) String
Yesod/Form/Profiles.hs view
@@ -49,7 +49,7 @@ { fpParse = maybe (Left "Invalid number") Right . readMay , fpRender = show , fpWidget = \theId name val isReq -> addBody [$hamlet|-%input#$theId$!name=$name$!type=number!:isReq:required!value=$val$+%input#$theId$!name=$name$!type=text!:isReq:required!value=$val$ |] }
Yesod/Handler.hs view
@@ -51,6 +51,11 @@ , deleteCookie , setHeader , setLanguage+ -- ** Content caching and expiration+ , cacheSeconds+ , neverExpires+ , alreadyExpired+ , expiresAt -- * Session , setSession , deleteSession@@ -75,6 +80,7 @@ import Yesod.Internal import Data.List (foldl') import Data.Neither+import Data.Time (UTCTime) import Control.Exception hiding (Handler, catch) import qualified Control.Exception as E@@ -383,9 +389,32 @@ setLanguage :: String -> GHandler sub master () setLanguage = setSession langKey --- | Set an arbitrary header on the client.+-- | Set an arbitrary response header. setHeader :: String -> String -> GHandler sub master () setHeader a = addHeader . Header a++-- | Set the Cache-Control header to indicate this response should be cached+-- for the given number of seconds.+cacheSeconds :: Int -> GHandler s m ()+cacheSeconds i = setHeader "Cache-Control" $ concat+ [ "max-age="+ , show i+ , ", public"+ ]++-- | Set the Expires header to some date in 2037. In other words, this content+-- is never (realistically) expired.+neverExpires :: GHandler s m ()+neverExpires = setHeader "Expires" "Thu, 31 Dec 2037 23:55:55 GMT"++-- | Set an Expires header in the past, meaning this content should not be+-- cached.+alreadyExpired :: GHandler s m ()+alreadyExpired = setHeader "Expires" "Thu, 01 Jan 1970 05:05:05 GMT"++-- | Set an Expires header to the given date.+expiresAt :: UTCTime -> GHandler s m ()+expiresAt = setHeader "Expires" . formatRFC1123 -- | Set a variable in the user's session. --
yesod.cabal view
@@ -1,5 +1,5 @@ name: yesod-version: 0.5.2+version: 0.5.3 license: BSD3 license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>