diff --git a/sources.txt b/sources.txt index 3830938b..ef9a273b 100644 --- a/sources.txt +++ b/sources.txt @@ -1,6 +1,5 @@ ./yesod-routes ./yesod-core -./yesod-json ./yesod-static ./yesod-persistent ./yesod-newsfeed diff --git a/yesod-core/Yesod/Core.hs b/yesod-core/Yesod/Core.hs index 7268d6cb..e8f65d6a 100644 --- a/yesod-core/Yesod/Core.hs +++ b/yesod-core/Yesod/Core.hs @@ -55,6 +55,7 @@ module Yesod.Core , module Yesod.Request , module Yesod.Widget , module Yesod.Message + , module Yesod.Core.Json ) where import Yesod.Internal.Core @@ -65,6 +66,7 @@ import Yesod.Handler import Yesod.Request import Yesod.Widget import Yesod.Message +import Yesod.Core.Json import Control.Monad.Logger diff --git a/yesod-json/Yesod/Json.hs b/yesod-core/Yesod/Core/Json.hs similarity index 92% rename from yesod-json/Yesod/Json.hs rename to yesod-core/Yesod/Core/Json.hs index eb46612a..64cb7cc5 100644 --- a/yesod-json/Yesod/Json.hs +++ b/yesod-core/Yesod/Core/Json.hs @@ -1,7 +1,7 @@ {-# LANGUAGE TypeSynonymInstances, OverloadedStrings #-} {-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -module Yesod.Json +module Yesod.Core.Json ( -- * Convert from a JSON value defaultLayoutJson , jsonToRepJson @@ -26,7 +26,7 @@ import Yesod.Content ( ToContent (toContent), RepHtmlJson (RepHtmlJson), RepHtml (RepHtml) , RepJson (RepJson), Content (ContentBuilder) ) -import Yesod.Core (defaultLayout, Yesod) +import Yesod.Internal.Core (defaultLayout, Yesod) import Yesod.Widget (GWidget) import Yesod.Routes.Class import Control.Arrow (second) @@ -49,15 +49,7 @@ import Data.Conduit (($$)) import Network.Wai (requestBody, requestHeaders) import Network.Wai.Parse (parseHttpAccept) import qualified Data.ByteString.Char8 as B8 -import Safe (headMay) - -#if !MIN_VERSION_yesod_core(1, 1, 5) -instance ToContent J.Value where - toContent = flip ContentBuilder Nothing - . Blaze.fromLazyText - . toLazyText - . fromValue -#endif +import Data.Maybe (listToMaybe) -- | Provide both an HTML and JSON representation for a piece of -- data, using the default layout for the HTML output @@ -133,6 +125,6 @@ jsonOrRedirect r j = do acceptsJson :: Yesod master => GHandler sub master Bool acceptsJson = maybe False ((== "application/json") . B8.takeWhile (/= ';')) . join - . fmap (headMay . parseHttpAccept) + . fmap (listToMaybe . parseHttpAccept) . lookup "Accept" . requestHeaders <$> waiRequest diff --git a/yesod-core/yesod-core.cabal b/yesod-core/yesod-core.cabal index 1a2e86cf..250e1ef8 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -85,9 +85,11 @@ library , lifted-base >= 0.1 , blaze-html >= 0.5 && < 0.6 , blaze-markup >= 0.5.1 && < 0.6 + , attoparsec-conduit exposed-modules: Yesod.Content Yesod.Core + Yesod.Core.Json Yesod.Dispatch Yesod.Handler Yesod.Request diff --git a/yesod-json/LICENSE b/yesod-json/LICENSE deleted file mode 100644 index d9f04179..00000000 --- a/yesod-json/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/ - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/yesod-json/README b/yesod-json/README deleted file mode 100644 index e69de29b..00000000 diff --git a/yesod-json/Setup.lhs b/yesod-json/Setup.lhs deleted file mode 100755 index 06e2708f..00000000 --- a/yesod-json/Setup.lhs +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env runhaskell - -> module Main where -> import Distribution.Simple - -> main :: IO () -> main = defaultMain diff --git a/yesod-json/yesod-json.cabal b/yesod-json/yesod-json.cabal deleted file mode 100644 index c9115f04..00000000 --- a/yesod-json/yesod-json.cabal +++ /dev/null @@ -1,37 +0,0 @@ -name: yesod-json -version: 1.1.2 -license: MIT -license-file: LICENSE -author: Michael Snoyman -maintainer: Michael Snoyman -synopsis: Generate content for Yesod using the aeson package. -category: Web, Yesod -stability: Stable -cabal-version: >= 1.6 -build-type: Simple -homepage: http://www.yesodweb.com/ -description: Generate content for Yesod using the aeson package. - -library - build-depends: base >= 4 && < 5 - , yesod-core >= 1.1 && < 1.2 - , yesod-routes >= 1.1 && < 1.2 - , aeson >= 0.5 - , text >= 0.8 && < 1.0 - , shakespeare-js >= 1.0 && < 1.2 - , vector >= 0.9 - , containers >= 0.2 - , blaze-builder - , attoparsec-conduit >= 0.5 && < 0.6 - , conduit >= 0.5 && < 0.6 - , transformers >= 0.2.2 && < 0.4 - , wai >= 1.3 && < 1.4 - , wai-extra >= 1.3 && < 1.4 - , bytestring >= 0.9 - , safe >= 0.2 && < 0.4 - exposed-modules: Yesod.Json - ghc-options: -Wall - -source-repository head - type: git - location: https://github.com/yesodweb/yesod