Merge yesod-json functionality into yesod-core (closes #487)

This commit is contained in:
Michael Snoyman 2013-02-12 15:42:45 +02:00
parent f78559d7ed
commit ed53b20308
8 changed files with 8 additions and 77 deletions

View File

@ -1,6 +1,5 @@
./yesod-routes
./yesod-core
./yesod-json
./yesod-static
./yesod-persistent
./yesod-newsfeed

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

View File

@ -1,7 +0,0 @@
#!/usr/bin/env runhaskell
> module Main where
> import Distribution.Simple
> main :: IO ()
> main = defaultMain

View File

@ -1,37 +0,0 @@
name: yesod-json
version: 1.1.2
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
maintainer: Michael Snoyman <michael@snoyman.com>
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