Builds properly with stricter rules
This commit is contained in:
parent
86acf25523
commit
d1bb17304a
@ -11,6 +11,7 @@ cabal-version: >= 1.6.0
|
|||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://www.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
extra-source-files: include/qq.h
|
extra-source-files: include/qq.h
|
||||||
|
description: Authentication for Yesod.
|
||||||
|
|
||||||
flag ghc7
|
flag ghc7
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE DeriveDataTypeable #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
|
{-# OPTIONS_GHC -fno-warn-missing-fields #-} -- QuasiQuoter
|
||||||
module Yesod.Internal.RouteParsing
|
module Yesod.Internal.RouteParsing
|
||||||
( createRoutes
|
( createRoutes
|
||||||
, createRender
|
, createRender
|
||||||
@ -22,10 +23,8 @@ import Data.Either
|
|||||||
import Data.List
|
import Data.List
|
||||||
import Data.Char (toLower)
|
import Data.Char (toLower)
|
||||||
import qualified Data.Text
|
import qualified Data.Text
|
||||||
import Language.Haskell.TH.Syntax
|
|
||||||
import Language.Haskell.TH.Quote
|
import Language.Haskell.TH.Quote
|
||||||
import Data.Data
|
import Data.Data
|
||||||
import Data.Maybe
|
|
||||||
import qualified System.IO as SIO
|
import qualified System.IO as SIO
|
||||||
|
|
||||||
data Pieces =
|
data Pieces =
|
||||||
|
|||||||
@ -1,15 +1,12 @@
|
|||||||
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
module Test.CleanPath (cleanPathTest) where
|
module Test.CleanPath (cleanPathTest, Widget) where
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.HUnit
|
import Test.Hspec.HUnit()
|
||||||
|
|
||||||
import Yesod.Core hiding (Request)
|
import Yesod.Core hiding (Request)
|
||||||
import Yesod.Content
|
|
||||||
import Yesod.Dispatch
|
|
||||||
import Yesod.Handler (Route)
|
|
||||||
|
|
||||||
import Network.Wai
|
import Network.Wai
|
||||||
import Network.Wai.Test
|
import Network.Wai.Test
|
||||||
@ -19,7 +16,10 @@ import qualified Data.ByteString.Lazy.Char8 as L8
|
|||||||
import qualified Data.Text as TS
|
import qualified Data.Text as TS
|
||||||
|
|
||||||
data Subsite = Subsite
|
data Subsite = Subsite
|
||||||
|
|
||||||
|
getSubsite :: a -> Subsite
|
||||||
getSubsite = const Subsite
|
getSubsite = const Subsite
|
||||||
|
|
||||||
data SubsiteRoute = SubsiteRoute [TS.Text]
|
data SubsiteRoute = SubsiteRoute [TS.Text]
|
||||||
deriving (Eq, Show, Read)
|
deriving (Eq, Show, Read)
|
||||||
type instance Route Subsite = SubsiteRoute
|
type instance Route Subsite = SubsiteRoute
|
||||||
@ -33,7 +33,7 @@ instance YesodDispatch Subsite master where
|
|||||||
] $ L8.pack $ show pieces
|
] $ L8.pack $ show pieces
|
||||||
|
|
||||||
data Y = Y
|
data Y = Y
|
||||||
mkYesod "Y" [$parseRoutes|
|
mkYesod "Y" [parseRoutes|
|
||||||
/foo FooR GET
|
/foo FooR GET
|
||||||
/foo/#String FooStringR GET
|
/foo/#String FooStringR GET
|
||||||
/bar BarR GET
|
/bar BarR GET
|
||||||
@ -52,8 +52,13 @@ instance Yesod Y where
|
|||||||
where
|
where
|
||||||
corrected = filter (not . TS.null) s
|
corrected = filter (not . TS.null) s
|
||||||
|
|
||||||
|
getFooR :: Handler RepPlain
|
||||||
getFooR = return $ RepPlain "foo"
|
getFooR = return $ RepPlain "foo"
|
||||||
|
|
||||||
|
getFooStringR :: String -> Handler RepPlain
|
||||||
getFooStringR = return . RepPlain . toContent
|
getFooStringR = return . RepPlain . toContent
|
||||||
|
|
||||||
|
getBarR, getPlainR :: Handler RepPlain
|
||||||
getBarR = return $ RepPlain "bar"
|
getBarR = return $ RepPlain "bar"
|
||||||
getPlainR = return $ RepPlain "plain"
|
getPlainR = return $ RepPlain "plain"
|
||||||
|
|
||||||
@ -69,8 +74,10 @@ cleanPathTest =
|
|||||||
, it "redirect with query string" redQueryString
|
, it "redirect with query string" redQueryString
|
||||||
]
|
]
|
||||||
|
|
||||||
|
runner :: Session () -> IO ()
|
||||||
runner f = toWaiApp Y >>= runSession f
|
runner f = toWaiApp Y >>= runSession f
|
||||||
|
|
||||||
|
removeTrailingSlash :: IO ()
|
||||||
removeTrailingSlash = runner $ do
|
removeTrailingSlash = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = decodePathSegments "/foo/"
|
{ pathInfo = decodePathSegments "/foo/"
|
||||||
@ -78,6 +85,7 @@ removeTrailingSlash = runner $ do
|
|||||||
assertStatus 301 res
|
assertStatus 301 res
|
||||||
assertHeader "Location" "http://test/foo" res
|
assertHeader "Location" "http://test/foo" res
|
||||||
|
|
||||||
|
noTrailingSlash :: IO ()
|
||||||
noTrailingSlash = runner $ do
|
noTrailingSlash = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = decodePathSegments "/foo"
|
{ pathInfo = decodePathSegments "/foo"
|
||||||
@ -86,6 +94,7 @@ noTrailingSlash = runner $ do
|
|||||||
assertContentType "text/plain; charset=utf-8" res
|
assertContentType "text/plain; charset=utf-8" res
|
||||||
assertBody "foo" res
|
assertBody "foo" res
|
||||||
|
|
||||||
|
addTrailingSlash :: IO ()
|
||||||
addTrailingSlash = runner $ do
|
addTrailingSlash = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = decodePathSegments "/bar"
|
{ pathInfo = decodePathSegments "/bar"
|
||||||
@ -93,6 +102,7 @@ addTrailingSlash = runner $ do
|
|||||||
assertStatus 301 res
|
assertStatus 301 res
|
||||||
assertHeader "Location" "http://test/bar/" res
|
assertHeader "Location" "http://test/bar/" res
|
||||||
|
|
||||||
|
hasTrailingSlash :: IO ()
|
||||||
hasTrailingSlash = runner $ do
|
hasTrailingSlash = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = decodePathSegments "/bar/"
|
{ pathInfo = decodePathSegments "/bar/"
|
||||||
@ -101,6 +111,7 @@ hasTrailingSlash = runner $ do
|
|||||||
assertContentType "text/plain; charset=utf-8" res
|
assertContentType "text/plain; charset=utf-8" res
|
||||||
assertBody "bar" res
|
assertBody "bar" res
|
||||||
|
|
||||||
|
fooSomething :: IO ()
|
||||||
fooSomething = runner $ do
|
fooSomething = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = decodePathSegments "/foo/something"
|
{ pathInfo = decodePathSegments "/foo/something"
|
||||||
@ -109,6 +120,7 @@ fooSomething = runner $ do
|
|||||||
assertContentType "text/plain; charset=utf-8" res
|
assertContentType "text/plain; charset=utf-8" res
|
||||||
assertBody "something" res
|
assertBody "something" res
|
||||||
|
|
||||||
|
subsiteDispatch :: IO ()
|
||||||
subsiteDispatch = runner $ do
|
subsiteDispatch = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = decodePathSegments "/subsite/1/2/3/"
|
{ pathInfo = decodePathSegments "/subsite/1/2/3/"
|
||||||
@ -117,6 +129,7 @@ subsiteDispatch = runner $ do
|
|||||||
assertContentType "SUBSITE" res
|
assertContentType "SUBSITE" res
|
||||||
assertBody "[\"1\",\"2\",\"3\",\"\"]" res
|
assertBody "[\"1\",\"2\",\"3\",\"\"]" res
|
||||||
|
|
||||||
|
redQueryString :: IO ()
|
||||||
redQueryString = runner $ do
|
redQueryString = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = decodePathSegments "/plain/"
|
{ pathInfo = decodePathSegments "/plain/"
|
||||||
@ -1,23 +1,16 @@
|
|||||||
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
module Test.Exceptions (exceptionsTest) where
|
module Test.Exceptions (exceptionsTest, Widget) where
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.HUnit
|
import Test.Hspec.HUnit ()
|
||||||
|
|
||||||
import Yesod.Core hiding (Request)
|
import Yesod.Core hiding (Request)
|
||||||
import Yesod.Content
|
|
||||||
import Yesod.Dispatch
|
|
||||||
import Yesod.Handler (Route, ErrorResponse (InternalError))
|
|
||||||
|
|
||||||
import Network.Wai
|
|
||||||
import Network.Wai.Test
|
import Network.Wai.Test
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L8
|
|
||||||
|
|
||||||
data Y = Y
|
data Y = Y
|
||||||
mkYesod "Y" [$parseRoutes|
|
mkYesod "Y" [parseRoutes|
|
||||||
/ RootR GET
|
/ RootR GET
|
||||||
|]
|
|]
|
||||||
|
|
||||||
@ -26,6 +19,7 @@ instance Yesod Y where
|
|||||||
errorHandler (InternalError e) = return $ chooseRep $ RepPlain $ toContent e
|
errorHandler (InternalError e) = return $ chooseRep $ RepPlain $ toContent e
|
||||||
errorHandler x = defaultErrorHandler x
|
errorHandler x = defaultErrorHandler x
|
||||||
|
|
||||||
|
getRootR :: Handler ()
|
||||||
getRootR = error "FOOBAR" >> return ()
|
getRootR = error "FOOBAR" >> return ()
|
||||||
|
|
||||||
exceptionsTest :: IO [IO Spec]
|
exceptionsTest :: IO [IO Spec]
|
||||||
@ -33,8 +27,10 @@ exceptionsTest = describe "Test.Exceptions"
|
|||||||
[ it "500" case500
|
[ it "500" case500
|
||||||
]
|
]
|
||||||
|
|
||||||
|
runner :: Session () -> IO ()
|
||||||
runner f = toWaiApp Y >>= runSession f
|
runner f = toWaiApp Y >>= runSession f
|
||||||
|
|
||||||
|
case500 :: IO ()
|
||||||
case500 = runner $ do
|
case500 = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
assertStatus 500 res
|
assertStatus 500 res
|
||||||
@ -1,36 +1,35 @@
|
|||||||
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
module Test.Links (linksTest) where
|
module Test.Links (linksTest, Widget) where
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.HUnit
|
import Test.Hspec.HUnit ()
|
||||||
|
|
||||||
import Yesod.Core hiding (Request)
|
import Yesod.Core hiding (Request)
|
||||||
import Text.Hamlet
|
import Text.Hamlet
|
||||||
|
|
||||||
import Network.Wai
|
|
||||||
import Network.Wai.Test
|
import Network.Wai.Test
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L8
|
|
||||||
|
|
||||||
data Y = Y
|
data Y = Y
|
||||||
mkYesod "Y" [$parseRoutes|
|
mkYesod "Y" [parseRoutes|
|
||||||
/ RootR GET
|
/ RootR GET
|
||||||
|]
|
|]
|
||||||
|
|
||||||
instance Yesod Y where
|
instance Yesod Y where
|
||||||
approot _ = ""
|
approot _ = ""
|
||||||
|
|
||||||
getRootR = defaultLayout $ addHamlet [$hamlet|<a href=@{RootR}>|]
|
getRootR :: Handler RepHtml
|
||||||
|
getRootR = defaultLayout $ addHamlet [hamlet|<a href=@{RootR}>|]
|
||||||
|
|
||||||
linksTest :: IO [IO Spec]
|
linksTest :: IO [IO Spec]
|
||||||
linksTest = describe "Test.Links"
|
linksTest = describe "Test.Links"
|
||||||
[ it "linkToHome" case_linkToHome
|
[ it "linkToHome" case_linkToHome
|
||||||
]
|
]
|
||||||
|
|
||||||
|
runner :: Session () -> IO ()
|
||||||
runner f = toWaiApp Y >>= runSession f
|
runner f = toWaiApp Y >>= runSession f
|
||||||
|
|
||||||
|
case_linkToHome :: IO ()
|
||||||
case_linkToHome = runner $ do
|
case_linkToHome = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
assertBody "<!DOCTYPE html>\n<html><head><title></title></head><body><a href=\"/\"></a></body></html>" res
|
assertBody "<!DOCTYPE html>\n<html><head><title></title></head><body><a href=\"/\"></a></body></html>" res
|
||||||
@ -1,23 +1,17 @@
|
|||||||
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
module Test.Media (mediaTest) where
|
module Test.Media (mediaTest, Widget) where
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.HUnit
|
import Test.Hspec.HUnit ()
|
||||||
|
|
||||||
import Yesod.Core hiding (Request)
|
import Yesod.Core hiding (Request)
|
||||||
|
|
||||||
import Network.Wai
|
import Network.Wai
|
||||||
import Network.Wai.Test
|
import Network.Wai.Test
|
||||||
import Network.HTTP.Types (status200, decodePathSegments)
|
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L8
|
|
||||||
import qualified Data.Text as TS
|
|
||||||
import Text.Lucius
|
import Text.Lucius
|
||||||
|
|
||||||
data Y = Y
|
data Y = Y
|
||||||
mkYesod "Y" [$parseRoutes|
|
mkYesod "Y" [parseRoutes|
|
||||||
/ RootR GET
|
/ RootR GET
|
||||||
/static StaticR GET
|
/static StaticR GET
|
||||||
|]
|
|]
|
||||||
@ -34,19 +28,25 @@ instance Yesod Y where
|
|||||||
else "all.css"
|
else "all.css"
|
||||||
_ -> return Nothing
|
_ -> return Nothing
|
||||||
|
|
||||||
|
getRootR :: Handler RepHtml
|
||||||
getRootR = defaultLayout $ do
|
getRootR = defaultLayout $ do
|
||||||
addCassius [$lucius|foo1{bar:baz}|]
|
addCassius [lucius|foo1{bar:baz}|]
|
||||||
addCassiusMedia "screen" [$lucius|foo2{bar:baz}|]
|
addCassiusMedia "screen" [lucius|foo2{bar:baz}|]
|
||||||
addCassius [$lucius|foo3{bar:baz}|]
|
addCassius [lucius|foo3{bar:baz}|]
|
||||||
|
|
||||||
|
getStaticR :: Handler RepHtml
|
||||||
getStaticR = getRootR
|
getStaticR = getRootR
|
||||||
|
|
||||||
|
runner :: Session () -> IO ()
|
||||||
runner f = toWaiApp Y >>= runSession f
|
runner f = toWaiApp Y >>= runSession f
|
||||||
|
|
||||||
|
caseMedia :: IO ()
|
||||||
caseMedia = runner $ do
|
caseMedia = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
assertStatus 200 res
|
assertStatus 200 res
|
||||||
flip assertBody res "<!DOCTYPE html>\n<html><head><title></title><style>foo1{bar:baz}foo3{bar:baz}</style><style media=\"screen\">foo2{bar:baz}</style></head><body></body></html>"
|
flip assertBody res "<!DOCTYPE html>\n<html><head><title></title><style>foo1{bar:baz}foo3{bar:baz}</style><style media=\"screen\">foo2{bar:baz}</style></head><body></body></html>"
|
||||||
|
|
||||||
|
caseMediaLink :: IO ()
|
||||||
caseMediaLink = runner $ do
|
caseMediaLink = runner $ do
|
||||||
res <- request defaultRequest { pathInfo = ["static"] }
|
res <- request defaultRequest { pathInfo = ["static"] }
|
||||||
assertStatus 200 res
|
assertStatus 200 res
|
||||||
@ -1,18 +1,20 @@
|
|||||||
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
module Test.NoOverloadedStrings (noOverloadedTest) where
|
module Test.NoOverloadedStrings (noOverloadedTest, Widget) where
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.HUnit
|
import Test.Hspec.HUnit ()
|
||||||
|
|
||||||
import Yesod.Core hiding (Request)
|
import Yesod.Core hiding (Request)
|
||||||
import Network.Wai.Test
|
import Network.Wai.Test
|
||||||
import Network.Wai
|
|
||||||
import Data.Monoid (mempty)
|
import Data.Monoid (mempty)
|
||||||
import Data.String (fromString)
|
import Data.String (fromString)
|
||||||
|
|
||||||
data Subsite = Subsite
|
data Subsite = Subsite
|
||||||
|
|
||||||
|
getSubsite :: a -> Subsite
|
||||||
getSubsite = const Subsite
|
getSubsite = const Subsite
|
||||||
|
|
||||||
mkYesodSub "Subsite" [] [parseRoutes|
|
mkYesodSub "Subsite" [] [parseRoutes|
|
||||||
/bar BarR GET
|
/bar BarR GET
|
||||||
|]
|
|]
|
||||||
@ -30,11 +32,16 @@ mkYesod "Y" [parseRoutes|
|
|||||||
instance Yesod Y where
|
instance Yesod Y where
|
||||||
approot _ = fromString ""
|
approot _ = fromString ""
|
||||||
|
|
||||||
|
getRootR :: Handler ()
|
||||||
getRootR = return ()
|
getRootR = return ()
|
||||||
|
|
||||||
|
getFooR :: Handler ()
|
||||||
getFooR = return ()
|
getFooR = return ()
|
||||||
|
|
||||||
|
runner :: Session () -> IO ()
|
||||||
runner f = toWaiApp Y >>= runSession f
|
runner f = toWaiApp Y >>= runSession f
|
||||||
|
|
||||||
|
case_sanity :: IO ()
|
||||||
case_sanity = runner $ do
|
case_sanity = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
assertBody mempty res
|
assertBody mempty res
|
||||||
@ -4,12 +4,9 @@
|
|||||||
module Test.Widget (widgetTest) where
|
module Test.Widget (widgetTest) where
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.HUnit
|
import Test.Hspec.HUnit ()
|
||||||
|
|
||||||
import Yesod.Core hiding (Request)
|
import Yesod.Core hiding (Request)
|
||||||
import Yesod.Content
|
|
||||||
import Yesod.Dispatch
|
|
||||||
import Yesod.Widget
|
|
||||||
import Text.Julius
|
import Text.Julius
|
||||||
import Text.Lucius
|
import Text.Lucius
|
||||||
import Text.Hamlet
|
import Text.Hamlet
|
||||||
@ -17,15 +14,13 @@ import Text.Hamlet
|
|||||||
import Network.Wai
|
import Network.Wai
|
||||||
import Network.Wai.Test
|
import Network.Wai.Test
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L8
|
|
||||||
|
|
||||||
data Y = Y
|
data Y = Y
|
||||||
|
|
||||||
mkMessage "Y" "test" "en"
|
mkMessage "Y" "test" "en"
|
||||||
|
|
||||||
type Strings = [String]
|
type Strings = [String]
|
||||||
|
|
||||||
mkYesod "Y" [$parseRoutes|
|
mkYesod "Y" [parseRoutes|
|
||||||
/ RootR GET
|
/ RootR GET
|
||||||
/foo/*Strings MultiR GET
|
/foo/*Strings MultiR GET
|
||||||
/whamlet WhamletR GET
|
/whamlet WhamletR GET
|
||||||
@ -35,7 +30,10 @@ mkYesod "Y" [$parseRoutes|
|
|||||||
instance Yesod Y where
|
instance Yesod Y where
|
||||||
approot _ = "http://test"
|
approot _ = "http://test"
|
||||||
|
|
||||||
getRootR = defaultLayout $ toWidgetBody [$julius|<not escaped>|]
|
getRootR :: Handler RepHtml
|
||||||
|
getRootR = defaultLayout $ toWidgetBody [julius|<not escaped>|]
|
||||||
|
|
||||||
|
getMultiR :: [String] -> Handler ()
|
||||||
getMultiR _ = return ()
|
getMultiR _ = return ()
|
||||||
|
|
||||||
data Msg = Hello | Goodbye
|
data Msg = Hello | Goodbye
|
||||||
@ -49,7 +47,7 @@ instance RenderMessage Y Msg where
|
|||||||
|
|
||||||
getTowidgetR :: Handler RepHtml
|
getTowidgetR :: Handler RepHtml
|
||||||
getTowidgetR = defaultLayout $ do
|
getTowidgetR = defaultLayout $ do
|
||||||
toWidget [julius|foo|]
|
toWidget [julius|foo|] :: Widget
|
||||||
toWidgetHead [julius|foo|]
|
toWidgetHead [julius|foo|]
|
||||||
toWidgetBody [julius|foo|]
|
toWidgetBody [julius|foo|]
|
||||||
|
|
||||||
@ -60,7 +58,8 @@ getTowidgetR = defaultLayout $ do
|
|||||||
toWidgetHead [hamlet|<foo>|]
|
toWidgetHead [hamlet|<foo>|]
|
||||||
toWidgetBody [hamlet|<foo>|]
|
toWidgetBody [hamlet|<foo>|]
|
||||||
|
|
||||||
getWhamletR = defaultLayout [$whamlet|
|
getWhamletR :: Handler RepHtml
|
||||||
|
getWhamletR = defaultLayout [whamlet|
|
||||||
<h1>Test
|
<h1>Test
|
||||||
<h2>@{WhamletR}
|
<h2>@{WhamletR}
|
||||||
<h3>_{Goodbye}
|
<h3>_{Goodbye}
|
||||||
@ -68,7 +67,7 @@ getWhamletR = defaultLayout [$whamlet|
|
|||||||
^{embed}
|
^{embed}
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
embed = [$whamlet|<h4>Embed|]
|
embed = [whamlet|<h4>Embed|]
|
||||||
|
|
||||||
widgetTest :: IO [IO Spec]
|
widgetTest :: IO [IO Spec]
|
||||||
widgetTest = describe "Test.Widget"
|
widgetTest = describe "Test.Widget"
|
||||||
@ -76,12 +75,15 @@ widgetTest = describe "Test.Widget"
|
|||||||
, it "whamlet" case_whamlet
|
, it "whamlet" case_whamlet
|
||||||
]
|
]
|
||||||
|
|
||||||
|
runner :: Session () -> IO ()
|
||||||
runner f = toWaiApp Y >>= runSession f
|
runner f = toWaiApp Y >>= runSession f
|
||||||
|
|
||||||
|
case_addJuliusBody :: IO ()
|
||||||
case_addJuliusBody = runner $ do
|
case_addJuliusBody = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
assertBody "<!DOCTYPE html>\n<html><head><title></title></head><body><script><not escaped></script></body></html>" res
|
assertBody "<!DOCTYPE html>\n<html><head><title></title></head><body><script><not escaped></script></body></html>" res
|
||||||
|
|
||||||
|
case_whamlet :: IO ()
|
||||||
case_whamlet = runner $ do
|
case_whamlet = runner $ do
|
||||||
res <- request defaultRequest
|
res <- request defaultRequest
|
||||||
{ pathInfo = ["whamlet"]
|
{ pathInfo = ["whamlet"]
|
||||||
@ -11,7 +11,7 @@ description:
|
|||||||
The Yesod documentation site <http://www.yesodweb.com/> has much more information, tutorials and information on some of the supporting packages, like Hamlet and Persistent.
|
The Yesod documentation site <http://www.yesodweb.com/> has much more information, tutorials and information on some of the supporting packages, like Hamlet and Persistent.
|
||||||
category: Web, Yesod
|
category: Web, Yesod
|
||||||
stability: Stable
|
stability: Stable
|
||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.8
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://www.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
|
|
||||||
@ -78,7 +78,8 @@ library
|
|||||||
|
|
||||||
test-suite runtests
|
test-suite runtests
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
main-is: test/main.hs
|
main-is: main.hs
|
||||||
|
hs-source-dirs: test
|
||||||
|
|
||||||
if flag(ghc7)
|
if flag(ghc7)
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
@ -92,10 +93,17 @@ test-suite runtests
|
|||||||
cpp-options: -DTEST
|
cpp-options: -DTEST
|
||||||
build-depends: hspec >= 0.6.1 && < 0.7
|
build-depends: hspec >= 0.6.1 && < 0.7
|
||||||
,wai-test
|
,wai-test
|
||||||
|
,wai
|
||||||
|
,yesod-core
|
||||||
|
,bytestring
|
||||||
|
,hamlet
|
||||||
|
,shakespeare-css
|
||||||
|
,shakespeare-js
|
||||||
|
,text
|
||||||
|
,http-types
|
||||||
,HUnit
|
,HUnit
|
||||||
,QuickCheck >= 2 && < 3
|
,QuickCheck >= 2 && < 3
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
main-is: runtests.hs
|
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
|
|||||||
@ -10,6 +10,7 @@ stability: Stable
|
|||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.6
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://www.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
|
description: Form handling support for Yesod Web Framework
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: base >= 4 && < 5
|
build-depends: base >= 4 && < 5
|
||||||
|
|||||||
@ -10,6 +10,7 @@ stability: Stable
|
|||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.6
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://www.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
|
description: Generate content for Yesod using the aeson package.
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: base >= 4 && < 5
|
build-depends: base >= 4 && < 5
|
||||||
|
|||||||
@ -9,7 +9,8 @@ category: Web, Yesod
|
|||||||
stability: Stable
|
stability: Stable
|
||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.6
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://docs.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
|
description: Helper functions and data types for producing News feeds.
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: base >= 4 && < 5
|
build-depends: base >= 4 && < 5
|
||||||
@ -26,4 +27,4 @@ library
|
|||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: git://github.com/snoyberg/yesod-newsfeed.git
|
location: git://github.com/yesodweb/yesod.git
|
||||||
|
|||||||
@ -10,6 +10,7 @@ stability: Stable
|
|||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.6
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://www.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
|
description: Some helpers for using Persistent from Yesod.
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: base >= 4 && < 5
|
build-depends: base >= 4 && < 5
|
||||||
|
|||||||
@ -9,7 +9,8 @@ category: Web, Yesod
|
|||||||
stability: Stable
|
stability: Stable
|
||||||
cabal-version: >= 1.6
|
cabal-version: >= 1.6
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://docs.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
|
description: Generate XML sitemaps.
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: base >= 4 && < 5
|
build-depends: base >= 4 && < 5
|
||||||
@ -21,4 +22,4 @@ library
|
|||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: git://github.com/snoyberg/yesod-sitemap.git
|
location: git://github.com/yesodweb/yesod.git
|
||||||
|
|||||||
@ -128,9 +128,11 @@ instance Yesod master => YesodDispatch Static master where
|
|||||||
\req -> staticApp set req { pathInfo = textPieces }
|
\req -> staticApp set req { pathInfo = textPieces }
|
||||||
|
|
||||||
notHidden :: Prelude.FilePath -> Bool
|
notHidden :: Prelude.FilePath -> Bool
|
||||||
notHidden ('.':_) = False
|
|
||||||
notHidden "tmp" = False
|
notHidden "tmp" = False
|
||||||
notHidden _ = True
|
notHidden s =
|
||||||
|
case s of
|
||||||
|
'.':_ -> False
|
||||||
|
_ -> True
|
||||||
|
|
||||||
getFileListPieces :: Prelude.FilePath -> IO [[String]]
|
getFileListPieces :: Prelude.FilePath -> IO [[String]]
|
||||||
getFileListPieces = flip go id
|
getFileListPieces = flip go id
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
import Yesod.Static
|
import Yesod.Static ()
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.HUnit ()
|
import Test.Hspec.HUnit ()
|
||||||
-- import Test.Hspec.QuickCheck (prop)
|
-- import Test.Hspec.QuickCheck (prop)
|
||||||
import Test.HUnit ((@?=))
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = hspecX $ return [] {- FIXME specs
|
main = hspecX $ return [] {- FIXME specs
|
||||||
|
|||||||
@ -10,6 +10,7 @@ stability: Stable
|
|||||||
cabal-version: >= 1.8
|
cabal-version: >= 1.8
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
homepage: http://www.yesodweb.com/
|
homepage: http://www.yesodweb.com/
|
||||||
|
description: Static file serving subsite for Yesod Web Framework.
|
||||||
|
|
||||||
flag test
|
flag test
|
||||||
description: Build the executable to run unit tests
|
description: Build the executable to run unit tests
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user