yesod-core 1.2.0.4 → 1.2.1
raw patch · 3 files changed
+23/−3 lines, 3 filesdep ~lifted-basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: lifted-base
API changes (from Hackage documentation)
+ Yesod.Core.Json: provideJson :: (Monad m, ToJSON a) => a -> Writer (Endo [ProvidedRep m]) ()
+ Yesod.Core.Json: returnJson :: (Monad m, ToJSON a) => a -> m Value
- Yesod.Core: class RenderRoute site => Yesod site where approot = ApprootRelative errorHandler = defaultErrorHandler defaultLayout w = do { p <- widgetToPageContent w; mmsg <- getMessage; hamletToRepHtml (\ _render_aV2H -> do { id ((preEscapedText . pack) "<!DOCTYPE html>\ \<html><head><style type="text/css">#synopsis details:not([open]) > ul { visibility: hidden; }</style><title>"); id (toHtml (pageTitle p)); id ((preEscapedText . pack) "</title>"); asHtmlUrl (pageHead p) _render_aV2H; id ((preEscapedText . pack) "</head><body>"); maybeH mmsg (\ msg_aV2I -> do { id ((preEscapedText . pack) "<p class=\"message\">"); id (toHtml msg_aV2I); id ((preEscapedText . pack) "</p>") }) Nothing; asHtmlUrl (pageBody p) _render_aV2H; id ((preEscapedText . pack) "</body></html>") }) } urlRenderOverride _ _ = Nothing isAuthorized _ _ = return Authorized isWriteRequest _ = do { wai <- waiRequest; return $ requestMethod wai `notElem` ["GET", "HEAD", "OPTIONS", "TRACE"] } authRoute _ = Nothing cleanPath _ s = if corrected == s then Right $ map dropDash s else Left corrected where corrected = filter (not . null) s dropDash t | all (== '-') t = drop 1 t | otherwise = t joinPath _ ar pieces' qs' = fromText ar `mappend` encodePath pieces qs where pieces = if null pieces' then [""] else map addDash pieces' qs = map (encodeUtf8 *** go) qs' go "" = Nothing go x = Just $ encodeUtf8 x addDash t | all (== '-') t = cons '-' t | otherwise = t addStaticContent _ _ _ = return Nothing maximumContentLength _ _ = Just $ 2 * 1024 * 1024 makeLogger _ = mkLogger True stdout messageLoggerSource a logger loc source level msg = when (shouldLog a source level) $ formatLogMessage (loggerDate logger) loc source level msg >>= loggerPutStr logger jsLoader _ = BottomOfBody makeSessionBackend _ = fmap Just $ defaultClientSessionBackend 120 defaultKeyFile fileUpload _ (KnownLength size) | size <= 50000 = FileUploadMemory lbsBackEnd fileUpload _ _ = FileUploadDisk tempFileBackEnd shouldLog _ _ level = level >= LevelInfo yesodMiddleware = defaultYesodMiddleware
+ Yesod.Core: class RenderRoute site => Yesod site where approot = ApprootRelative errorHandler = defaultErrorHandler defaultLayout w = do { p <- widgetToPageContent w; mmsg <- getMessage; hamletToRepHtml (\ _render_aV2t -> do { id ((preEscapedText . pack) "<!DOCTYPE html>\ \<html><head><style type="text/css">#synopsis details:not([open]) > ul { visibility: hidden; }</style><title>"); id (toHtml (pageTitle p)); id ((preEscapedText . pack) "</title>"); asHtmlUrl (pageHead p) _render_aV2t; id ((preEscapedText . pack) "</head><body>"); maybeH mmsg (\ msg_aV2u -> do { id ((preEscapedText . pack) "<p class=\"message\">"); id (toHtml msg_aV2u); id ((preEscapedText . pack) "</p>") }) Nothing; asHtmlUrl (pageBody p) _render_aV2t; id ((preEscapedText . pack) "</body></html>") }) } urlRenderOverride _ _ = Nothing isAuthorized _ _ = return Authorized isWriteRequest _ = do { wai <- waiRequest; return $ requestMethod wai `notElem` ["GET", "HEAD", "OPTIONS", "TRACE"] } authRoute _ = Nothing cleanPath _ s = if corrected == s then Right $ map dropDash s else Left corrected where corrected = filter (not . null) s dropDash t | all (== '-') t = drop 1 t | otherwise = t joinPath _ ar pieces' qs' = fromText ar `mappend` encodePath pieces qs where pieces = if null pieces' then [""] else map addDash pieces' qs = map (encodeUtf8 *** go) qs' go "" = Nothing go x = Just $ encodeUtf8 x addDash t | all (== '-') t = cons '-' t | otherwise = t addStaticContent _ _ _ = return Nothing maximumContentLength _ _ = Just $ 2 * 1024 * 1024 makeLogger _ = mkLogger True stdout messageLoggerSource a logger loc source level msg = when (shouldLog a source level) $ formatLogMessage (loggerDate logger) loc source level msg >>= loggerPutStr logger jsLoader _ = BottomOfBody makeSessionBackend _ = fmap Just $ defaultClientSessionBackend 120 defaultKeyFile fileUpload _ (KnownLength size) | size <= 50000 = FileUploadMemory lbsBackEnd fileUpload _ _ = FileUploadDisk tempFileBackEnd shouldLog _ _ level = level >= LevelInfo yesodMiddleware = defaultYesodMiddleware
Files
- Yesod/Core/Json.hs +19/−1
- Yesod/Core/Types.hs +2/−0
- yesod-core.cabal +2/−2
Yesod/Core/Json.hs view
@@ -4,6 +4,8 @@ ( -- * Convert from a JSON value defaultLayoutJson , jsonToRepJson+ , returnJson+ , provideJson -- * Convert to a JSON value , parseJsonBody@@ -23,7 +25,9 @@ , acceptsJson ) where -import Yesod.Core.Handler (HandlerT, getRequest, invalidArgs, redirect, selectRep, provideRep, rawRequestBody)+import Yesod.Core.Handler (HandlerT, getRequest, invalidArgs, redirect, selectRep, provideRep, rawRequestBody, ProvidedRep)+import Control.Monad.Trans.Writer (Writer)+import Data.Monoid (Endo) import Yesod.Core.Content (TypedContent) import Yesod.Core.Types (reqAccept) import Yesod.Core.Class.Yesod (defaultLayout, Yesod)@@ -60,6 +64,20 @@ -- /Since: 0.3.0/ jsonToRepJson :: (Monad m, J.ToJSON a) => a -> m J.Value jsonToRepJson = return . J.toJSON+{-# DEPRECATED jsonToRepJson "Use returnJson instead" #-}++-- | Convert a value to a JSON representation via aeson\'s 'J.toJSON' function.+--+-- Since 1.2.1+returnJson :: (Monad m, J.ToJSON a) => a -> m J.Value+returnJson = return . J.toJSON++-- | Provide a JSON representation for usage with 'selectReps', using aeson\'s+-- 'J.toJSON' function to perform the conversion.+--+-- Since 1.2.1+provideJson :: (Monad m, J.ToJSON a) => a -> Writer (Endo [ProvidedRep m]) ()+provideJson = provideRep . return . J.toJSON -- | Parse the request body to a data type as a JSON value. The -- data type must support conversion from JSON via 'J.FromJSON'.
Yesod/Core/Types.hs view
@@ -300,6 +300,8 @@ data Location url = Local url | Remote Text deriving (Show, Eq) +-- | A diff list that does not directly enforce uniqueness.+-- When creating a widget Yesod will use nub to make it unique. newtype UniqueList x = UniqueList ([x] -> [x]) data Script url = Script { scriptLocation :: Location url, scriptAttributes :: [(Text, Text)] }
yesod-core.cabal view
@@ -1,5 +1,5 @@ name: yesod-core-version: 1.2.0.4+version: 1.2.1 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -58,7 +58,7 @@ , monad-logger >= 0.3.1 && < 0.4 , conduit >= 0.5 , resourcet >= 0.4.6 && < 0.5- , lifted-base >= 0.1+ , lifted-base >= 0.1.2 , attoparsec-conduit , blaze-html >= 0.5 , blaze-markup >= 0.5.1