Renamed to Yesod

This commit is contained in:
Michael Snoyman 2009-12-11 00:04:00 +02:00
parent 16b854df1a
commit b4406b6a81
19 changed files with 94 additions and 96 deletions

View File

@ -20,11 +20,10 @@ module Data.Object.Instances
, Html (..) , Html (..)
) where ) where
import Data.Object
import Data.Object.Text import Data.Object.Text
import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy as B
import Web.Encodings (encodeJson) import Web.Encodings (encodeJson)
import Text.Yaml (encodeText) import Text.Yaml (encodeText')
import qualified Data.Text.Lazy as LT import qualified Data.Text.Lazy as LT
import Data.Text.Lazy (Text) import Data.Text.Lazy (Text)
import Data.Convertible.Text import Data.Convertible.Text
@ -65,7 +64,7 @@ newtype Yaml = Yaml { unYaml :: Text }
instance ConvertAttempt (Object Text Text) Yaml where instance ConvertAttempt (Object Text Text) Yaml where
convertAttempt = return . convertSuccess convertAttempt = return . convertSuccess
instance ConvertSuccess (Object Text Text) Yaml where instance ConvertSuccess (Object Text Text) Yaml where
convertSuccess = Yaml . encodeText convertSuccess = Yaml . convertSuccess . encodeText'
-- | Represents as an entire HTML 5 document by using the following: -- | Represents as an entire HTML 5 document by using the following:
-- --

View File

@ -30,7 +30,6 @@ module Data.Object.Translate
) where ) where
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Data.Object
import Control.Monad.Attempt import Control.Monad.Attempt
import Data.Object.Text import Data.Object.Text

View File

@ -1,7 +1,7 @@
The following license covers this documentation, and the source code, except The following license covers this documentation, and the source code, except
where otherwise indicated. where otherwise indicated.
Copyright 2008, Michael Snoyman. All rights reserved. Copyright 2009, Michael Snoyman. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:

12
Test.hs
View File

@ -1,12 +0,0 @@
import Test.Framework (defaultMain)
import qualified Web.Restful.Response
import qualified Web.Restful.Utils
import qualified Web.Restful.Resource
main :: IO ()
main = defaultMain
[ Web.Restful.Response.testSuite
, Web.Restful.Utils.testSuite
, Web.Restful.Resource.testSuite
]

View File

@ -1,6 +1,6 @@
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful -- Module : Yesod
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -11,23 +11,23 @@
-- Lightweight framework for designing RESTful APIs. -- Lightweight framework for designing RESTful APIs.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful module Yesod
( (
module Data.Object module Data.Object
, module Web.Restful.Request , module Yesod.Request
, module Web.Restful.Response , module Yesod.Response
, module Web.Restful.Application , module Yesod.Application
, module Web.Restful.Definitions , module Yesod.Definitions
, module Web.Restful.Handler , module Yesod.Handler
, module Web.Restful.Resource , module Yesod.Resource
, Application , Application
) where ) where
import Data.Object import Data.Object
import Web.Restful.Request import Yesod.Request
import Web.Restful.Response import Yesod.Response
import Web.Restful.Application import Yesod.Application
import Web.Restful.Definitions import Yesod.Definitions
import Web.Restful.Handler import Yesod.Handler
import Web.Restful.Resource import Yesod.Resource
import Hack (Application) import Hack (Application)

View File

@ -5,7 +5,7 @@
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Application -- Module : Yesod.Application
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -16,7 +16,7 @@
-- Defining the application. -- Defining the application.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Application module Yesod.Application
( (
toHackApp toHackApp
, RestfulApp (..) , RestfulApp (..)
@ -35,13 +35,13 @@ import Hack.Middleware.Gzip
import Hack.Middleware.Jsonp import Hack.Middleware.Jsonp
import Hack.Middleware.MethodOverride import Hack.Middleware.MethodOverride
import Web.Restful.Request import Yesod.Request
import Web.Restful.Response import Yesod.Response
import Web.Restful.Utils import Yesod.Utils
import Web.Restful.Handler import Yesod.Handler
import Web.Restful.Definitions import Yesod.Definitions
import Web.Restful.Constants import Yesod.Constants
import Web.Restful.Resource import Yesod.Resource
import Data.Convertible.Text import Data.Convertible.Text
import Control.Arrow ((***)) import Control.Arrow ((***))

View File

@ -1,6 +1,6 @@
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Constants -- Module : Yesod.Constants
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -11,7 +11,7 @@
-- Constants used throughout Restful. -- Constants used throughout Restful.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Constants module Yesod.Constants
( authCookieName ( authCookieName
) where ) where

View File

@ -2,7 +2,7 @@
{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE TypeSynonymInstances #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Definitions -- Module : Yesod.Definitions
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -13,7 +13,7 @@
-- Definitions throughout Restful. -- Definitions throughout Restful.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Definitions module Yesod.Definitions
( Verb (..) ( Verb (..)
, toVerb , toVerb
, Resource , Resource

View File

@ -5,7 +5,7 @@
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Handler -- Module : Yesod.Handler
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -16,7 +16,7 @@
-- Define Handler stuff. -- Define Handler stuff.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Handler module Yesod.Handler
( -- * Handler monad ( -- * Handler monad
HandlerT HandlerT
, HandlerIO , HandlerIO
@ -33,8 +33,8 @@ module Web.Restful.Handler
, header , header
) where ) where
import Web.Restful.Request import Yesod.Request
import Web.Restful.Response import Yesod.Response
import Control.Exception hiding (Handler) import Control.Exception hiding (Handler)

View File

@ -2,7 +2,7 @@
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Response.AtomFeed -- Module : Yesod.Response.AtomFeed
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -14,12 +14,12 @@
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Helpers.AtomFeed module Yesod.Helpers.AtomFeed
( AtomFeed (..) ( AtomFeed (..)
, AtomFeedEntry (..) , AtomFeedEntry (..)
) where ) where
import Web.Restful.Response import Yesod.Response
import Data.Time.Clock import Data.Time.Clock
import Web.Encodings import Web.Encodings

View File

@ -2,7 +2,7 @@
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Helpers.Auth -- Module : Yesod.Helpers.Auth
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -13,7 +13,7 @@
-- Authentication through the authentication package. -- Authentication through the authentication package.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Helpers.Auth module Yesod.Helpers.Auth
( AuthResource ( AuthResource
, authHandler , authHandler
, authResourcePattern , authResourcePattern
@ -26,8 +26,8 @@ import qualified Web.Authenticate.Rpxnow as Rpxnow
import qualified Web.Authenticate.OpenId as OpenId import qualified Web.Authenticate.OpenId as OpenId
import Data.Enumerable import Data.Enumerable
import Web.Restful import Yesod
import Web.Restful.Constants import Yesod.Constants
import Control.Applicative ((<$>), Applicative (..)) import Control.Applicative ((<$>), Applicative (..))
import Control.Monad.Reader import Control.Monad.Reader

View File

@ -2,7 +2,7 @@
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Response.AtomFeed -- Module : Yesod.Response.AtomFeed
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -14,7 +14,7 @@
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Helpers.Sitemap module Yesod.Helpers.Sitemap
( sitemap ( sitemap
, robots , robots
, SitemapUrl (..) , SitemapUrl (..)
@ -22,11 +22,11 @@ module Web.Restful.Helpers.Sitemap
, SitemapChangeFreq (..) , SitemapChangeFreq (..)
) where ) where
import Web.Restful.Handler import Yesod.Handler
import Web.Restful.Response import Yesod.Response
import Web.Encodings import Web.Encodings
import qualified Hack import qualified Hack
import Web.Restful.Request import Yesod.Request
import Data.Time (UTCTime) import Data.Time (UTCTime)
data SitemapLoc = AbsLoc String | RelLoc String data SitemapLoc = AbsLoc String | RelLoc String

View File

@ -2,7 +2,7 @@
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Helpers.Static -- Module : Yesod.Helpers.Static
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -13,7 +13,7 @@
-- Serve static files from a Restful app. -- Serve static files from a Restful app.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Helpers.Static module Yesod.Helpers.Static
( serveStatic ( serveStatic
, FileLookup , FileLookup
, fileLookupDir , fileLookupDir
@ -23,7 +23,7 @@ import qualified Data.ByteString as B
import System.Directory (doesFileExist) import System.Directory (doesFileExist)
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
import Web.Restful import Yesod
type FileLookup = FilePath -> IO (Maybe B.ByteString) type FileLookup = FilePath -> IO (Maybe B.ByteString)

View File

@ -2,7 +2,7 @@
{-# LANGUAGE OverlappingInstances #-} {-# LANGUAGE OverlappingInstances #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Request -- Module : Yesod.Request
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -13,7 +13,7 @@
-- Code for extracting parameters from requests. -- Code for extracting parameters from requests.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Request module Yesod.Request
( (
-- * Parameter -- * Parameter
-- $param_overview -- $param_overview
@ -49,8 +49,8 @@ module Web.Restful.Request
import qualified Hack import qualified Hack
import Data.Function.Predicate (equals) import Data.Function.Predicate (equals)
import Web.Restful.Constants import Yesod.Constants
import Web.Restful.Utils import Yesod.Utils
import Control.Applicative (Applicative (..)) import Control.Applicative (Applicative (..))
import Web.Encodings import Web.Encodings
import Data.Time.Calendar (Day, fromGregorian) import Data.Time.Calendar (Day, fromGregorian)

View File

@ -6,7 +6,7 @@
{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE StandaloneDeriving #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Resource -- Module : Yesod.Resource
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -17,7 +17,7 @@
-- Defines the Resource class. -- Defines the Resource class.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Resource module Yesod.Resource
( ResourceName (..) ( ResourceName (..)
, fromString , fromString
, checkPattern , checkPattern
@ -30,8 +30,8 @@ module Web.Restful.Resource
) where ) where
import Data.List.Split (splitOn) import Data.List.Split (splitOn)
import Web.Restful.Definitions import Yesod.Definitions
import Web.Restful.Handler import Yesod.Handler
import Data.List (intercalate) import Data.List (intercalate)
import Data.Enumerable import Data.Enumerable
import Data.Char (isDigit) import Data.Char (isDigit)
@ -161,7 +161,7 @@ validatePatterns (x:xs) =
#if TEST #if TEST
---- Testing ---- Testing
testSuite :: Test testSuite :: Test
testSuite = testGroup "Web.Restful.Resource" testSuite = testGroup "Yesod.Resource"
[ testCase "non-overlap" caseOverlap1 [ testCase "non-overlap" caseOverlap1
, testCase "overlap" caseOverlap2 , testCase "overlap" caseOverlap2
, testCase "overlap-slurp" caseOverlap3 , testCase "overlap-slurp" caseOverlap3

View File

@ -6,7 +6,7 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Response -- Module : Yesod.Response
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -17,7 +17,7 @@
-- Generating responses. -- Generating responses.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Response module Yesod.Response
( Response (..) ( Response (..)
-- * Representations -- * Representations
, RepT , RepT
@ -47,7 +47,6 @@ module Web.Restful.Response
) where ) where
import Data.Time.Clock import Data.Time.Clock
import Data.Object
import Data.Object.Text import Data.Object.Text
import Data.Object.Translate import Data.Object.Translate
import Data.Object.Instances import Data.Object.Instances
@ -200,7 +199,7 @@ instance HasReps (Reps m) where
#if TEST #if TEST
----- Testing ----- Testing
testSuite :: Test testSuite :: Test
testSuite = testGroup "Web.Restful.Response" testSuite = testGroup "Yesod.Response"
[ [
] ]
#endif #endif

View File

@ -1,7 +1,7 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
--------------------------------------------------------- ---------------------------------------------------------
-- --
-- Module : Web.Restful.Utils -- Module : Yesod.Utils
-- Copyright : Michael Snoyman -- Copyright : Michael Snoyman
-- License : BSD3 -- License : BSD3
-- --
@ -13,7 +13,7 @@
-- These are all functions which could be exported to another library. -- These are all functions which could be exported to another library.
-- --
--------------------------------------------------------- ---------------------------------------------------------
module Web.Restful.Utils module Yesod.Utils
( parseHttpAccept ( parseHttpAccept
, tryLookup , tryLookup
#if TEST #if TEST
@ -46,7 +46,7 @@ tryLookup def key = fromMaybe def . lookup key
#if TEST #if TEST
----- Testing ----- Testing
testSuite :: Test testSuite :: Test
testSuite = testGroup "Web.Restful.Response" testSuite = testGroup "Yesod.Response"
[ testCase "tryLookup1" caseTryLookup1 [ testCase "tryLookup1" caseTryLookup1
, testCase "tryLookup2" caseTryLookup2 , testCase "tryLookup2" caseTryLookup2
] ]

12
runtests.hs Normal file
View File

@ -0,0 +1,12 @@
import Test.Framework (defaultMain)
import qualified Yesod.Response
import qualified Yesod.Utils
import qualified Yesod.Resource
main :: IO ()
main = defaultMain
[ Yesod.Response.testSuite
, Yesod.Utils.testSuite
, Yesod.Resource.testSuite
]

View File

@ -1,15 +1,16 @@
name: restful name: yesod
version: 0.1.12 version: 0.0.0
license: BSD3 license: BSD3
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>
maintainer: Michael Snoyman <michael@snoyman.com> maintainer: Michael Snoyman <michael@snoyman.com>
synopsis: A Restful front controller built on Hack. synopsis: A Restful front controller built on Hack.
description: This package stradles the line between framework and simply a controller. It provides minimal support for model and view, mostly focusing on making a controller which adheres strictly to RESTful principles.
category: Web category: Web
stability: unstable stability: unstable
cabal-version: >= 1.2 cabal-version: >= 1.2
build-type: Simple build-type: Simple
homepage: http://github.com/snoyberg/restful/tree/master homepage: http://github.com/snoyberg/yesod
flag buildtests flag buildtests
description: Build the executable to run unit tests description: Build the executable to run unit tests
@ -42,15 +43,15 @@ library
convertible-text >= 0.0.0 && < 0.1, convertible-text >= 0.0.0 && < 0.1,
clientsession >= 0.0.1 && < 0.1, clientsession >= 0.0.1 && < 0.1,
zlib >= 0.5.2.0 && < 0.6 zlib >= 0.5.2.0 && < 0.6
exposed-modules: Web.Restful, exposed-modules: Yesod,
Web.Restful.Constants, Yesod.Constants,
Web.Restful.Request, Yesod.Request,
Web.Restful.Response, Yesod.Response,
Web.Restful.Utils, Yesod.Utils,
Web.Restful.Definitions, Yesod.Definitions,
Web.Restful.Handler, Yesod.Handler,
Web.Restful.Application, Yesod.Application,
Web.Restful.Resource, Yesod.Resource,
Data.Object.Instances, Data.Object.Instances,
Data.Object.Translate, Data.Object.Translate,
Hack.Middleware.MethodOverride, Hack.Middleware.MethodOverride,
@ -58,10 +59,10 @@ library
Hack.Middleware.Jsonp, Hack.Middleware.Jsonp,
Hack.Middleware.CleanPath, Hack.Middleware.CleanPath,
Hack.Middleware.Gzip, Hack.Middleware.Gzip,
Web.Restful.Helpers.Auth, Yesod.Helpers.Auth,
Web.Restful.Helpers.Static, Yesod.Helpers.Static,
Web.Restful.Helpers.AtomFeed, Yesod.Helpers.AtomFeed,
Web.Restful.Helpers.Sitemap Yesod.Helpers.Sitemap
ghc-options: -Wall -Werror ghc-options: -Wall -Werror
executable runtests executable runtests
@ -76,4 +77,4 @@ executable runtests
else else
Buildable: False Buildable: False
ghc-options: -Wall ghc-options: -Wall
main-is: Test.hs main-is: runtests.hs