Proper render function; removed YesodApproot

This commit is contained in:
Michael Snoyman 2010-04-11 12:54:19 -07:00
parent a19751622a
commit 5d14ac5e1e
4 changed files with 13 additions and 13 deletions

View File

@ -27,7 +27,7 @@ import Web.Encodings (formatW3)
data AtomFeedResponse = AtomFeedResponse AtomFeed Approot data AtomFeedResponse = AtomFeedResponse AtomFeed Approot
atomFeed :: YesodApproot y => AtomFeed -> Handler y AtomFeedResponse atomFeed :: Yesod y => AtomFeed -> Handler y AtomFeedResponse
atomFeed f = do atomFeed f = do
y <- getYesod y <- getYesod
return $ AtomFeedResponse f $ approot y return $ AtomFeedResponse f $ approot y

View File

@ -40,7 +40,7 @@ import Control.Applicative ((<$>))
-- FIXME check referer header to determine destination -- FIXME check referer header to determine destination
class YesodApproot a => YesodAuth a where class Yesod a => YesodAuth a where
-- | The following breaks DRY, but I cannot think of a better solution -- | The following breaks DRY, but I cannot think of a better solution
-- right now. -- right now.
-- --
@ -134,7 +134,7 @@ authOpenidForward = do
(redirect RedirectTemporary) (redirect RedirectTemporary)
res res
authOpenidComplete :: YesodApproot y => Handler y () authOpenidComplete :: Yesod y => Handler y ()
authOpenidComplete = do authOpenidComplete = do
rr <- getRequest rr <- getRequest
let gets' = reqGetParams rr let gets' = reqGetParams rr
@ -239,7 +239,7 @@ requestPath = do
-- | Redirect to the given URL, and set a cookie with the current URL so the -- | Redirect to the given URL, and set a cookie with the current URL so the
-- user will ultimately be sent back here. -- user will ultimately be sent back here.
redirectSetDest :: YesodApproot y => RedirectType -> String -> Handler y a redirectSetDest :: Yesod y => RedirectType -> String -> Handler y a
redirectSetDest rt dest = do redirectSetDest rt dest = do
ar <- getApproot ar <- getApproot
rp <- requestPath rp <- requestPath

View File

@ -73,12 +73,12 @@ instance HasReps SitemapResponse where
[ (TypeXml, return . cs) [ (TypeXml, return . cs)
] ]
sitemap :: YesodApproot y => [SitemapUrl] -> Handler y SitemapResponse sitemap :: Yesod y => [SitemapUrl] -> Handler y SitemapResponse
sitemap urls = do sitemap urls = do
yesod <- getYesod yesod <- getYesod
return $ SitemapResponse urls $ approot yesod return $ SitemapResponse urls $ approot yesod
robots :: YesodApproot yesod => Handler yesod [(ContentType, Content)] robots :: Yesod yesod => Handler yesod [(ContentType, Content)]
robots = do robots = do
yesod <- getYesod yesod <- getYesod
return $ staticRep TypePlain $ "Sitemap: " ++ showLocation return $ staticRep TypePlain $ "Sitemap: " ++ showLocation

View File

@ -2,7 +2,6 @@
module Yesod.Yesod module Yesod.Yesod
( Yesod (..) ( Yesod (..)
, YesodSite (..) , YesodSite (..)
, YesodApproot (..)
, applyLayout' , applyLayout'
, applyLayoutJson , applyLayoutJson
, getApproot , getApproot
@ -21,7 +20,7 @@ import qualified Data.ByteString as B
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Web.Mime import Web.Mime
import Web.Encodings (parseHttpAccept) import Web.Encodings (parseHttpAccept)
import Web.Routes (Site (..)) import Web.Routes (Site (..), encodePathInfo)
import qualified Network.Wai as W import qualified Network.Wai as W
import Network.Wai.Middleware.CleanPath import Network.Wai.Middleware.CleanPath
@ -66,10 +65,10 @@ class YesodSite a => Yesod a where
onRequest :: a -> Request -> IO () onRequest :: a -> Request -> IO ()
onRequest _ _ = return () onRequest _ _ = return ()
badMethod :: a -> YesodApp a badMethod :: a -> YesodApp a -- FIXME include in errorHandler
class Yesod a => YesodApproot a where -- | An absolute URL to the root of the application. Do not include
-- | An absolute URL to the root of the application. -- trailing slash.
approot :: a -> Approot approot :: a -> Approot
-- | A convenience wrapper around 'applyLayout'. -- | A convenience wrapper around 'applyLayout'.
@ -98,7 +97,7 @@ applyLayoutJson t b = do
, (TypeJson, cs $ unJsonDoc $ cs b) , (TypeJson, cs $ unJsonDoc $ cs b)
] ]
getApproot :: YesodApproot y => Handler y Approot getApproot :: Yesod y => Handler y Approot
getApproot = approot `fmap` getYesod getApproot = approot `fmap` getYesod
defaultErrorHandler :: Yesod y defaultErrorHandler :: Yesod y
@ -148,7 +147,8 @@ toWaiApp' y resource session env = do
Right url -> do Right url -> do
rr <- parseWaiRequest env session rr <- parseWaiRequest env session
onRequest y rr onRequest y rr
let render = error "FIXME: render" -- use formatPathSegments let render u = approot y ++ '/'
: encodePathInfo (formatPathSegments site u)
res <- handleSite site render url errorHandler rr types res <- handleSite site render url errorHandler rr types
responseToWaiResponse res responseToWaiResponse res