Added head to applyLayout(Json)

This commit is contained in:
Michael Snoyman 2010-05-09 14:30:24 +03:00
parent 32465f4e97
commit 2067d5d687
3 changed files with 14 additions and 12 deletions

View File

@ -92,7 +92,7 @@ getOpenIdR = do
(x:_) -> addCookie destCookieTimeout destCookieName x
rtom <- getRouteToMaster
let message = cs <$> (listToMaybe $ getParams rr "message")
applyLayout "Log in via OpenID" $ [$hamlet|
applyLayout "Log in via OpenID" (return ()) [$hamlet|
$maybe message msg
%p.message $msg$
%form!method=get!action=@rtom.OpenIdForward@
@ -174,7 +174,7 @@ getCheck = do
ident <- maybeIdentifier
dn <- displayName
let arg = (cs $ fromMaybe "" ident, cs $ fromMaybe "" dn)
applyLayoutJson "Authentication Status" arg html json
applyLayoutJson "Authentication Status" (return ()) arg html json
where
html (x, y) = [$hamlet|
%h1 Authentication Status

View File

@ -69,7 +69,7 @@ mkYesodSub "EmailAuth" [''YesodEmailAuth] [$parseRoutes|
getRegisterR :: Yesod master => GHandler EmailAuth master RepHtml
getRegisterR = do
toMaster <- getRouteToMaster
applyLayout "Register a new account" $ [$hamlet|
applyLayout "Register a new account" (return ()) [$hamlet|
%p Enter your e-mail address below, and a confirmation e-mail will be sent to you.
%form!method=post!action=@toMaster.RegisterR@
%label!for=email E-mail
@ -93,7 +93,7 @@ postRegisterR = do
tm <- getRouteToMaster
let verUrl = render $ tm $ VerifyR lid verKey
liftIO $ sendVerifyEmail y email verKey verUrl
applyLayout "Confirmation e-mail sent" $ [$hamlet|
applyLayout "Confirmation e-mail sent" (return ()) [$hamlet|
%p A confirmation e-mail has been sent to $cs.email$.
|]
@ -112,7 +112,7 @@ getVerifyR lid key = do
setLoginSession email lid
toMaster <- getRouteToMaster
redirect RedirectTemporary $ toMaster PasswordR
_ -> applyLayout "Invalid verification key" $ [$hamlet|
_ -> applyLayout "Invalid verification key" (return ()) [$hamlet|
%p I'm sorry, but that was an invalid verification key.
|]
@ -132,7 +132,7 @@ getLoginR :: Yesod master => GHandler EmailAuth master RepHtml
getLoginR = do
toMaster <- getRouteToMaster
msg <- getMessage
applyLayout "Login" $ [$hamlet|
applyLayout "Login" (return ()) [$hamlet|
$maybe msg ms
%p.message $ms$
%p Please log in to your account.
@ -182,7 +182,7 @@ getPasswordR = do
setMessage "You must be logged in to set a password"
redirect RedirectTemporary $ toMaster LoginR
msg <- getMessage
applyLayout "Set password" [$hamlet|
applyLayout "Set password" (return ()) [$hamlet|
$maybe msg ms
%p.message $ms$
%h3 Set a new password

View File

@ -85,12 +85,13 @@ class YesodSite a => Yesod a where
-- | Apply the default layout ('defaultLayout') to the given title and body.
applyLayout :: Yesod master
=> String -- ^ title
-> Hamlet (Routes master) IO () -- ^ head
-> Hamlet (Routes master) IO () -- ^ body
-> GHandler sub master RepHtml
applyLayout t b =
applyLayout t h b =
RepHtml `fmap` defaultLayout PageContent
{ pageTitle = cs t
, pageHead = return ()
, pageHead = h
, pageBody = b
}
@ -98,14 +99,15 @@ applyLayout t b =
-- the default layout for the HTML output ('defaultLayout').
applyLayoutJson :: Yesod master
=> String -- ^ title
-> Hamlet (Routes master) IO () -- ^ head
-> x
-> (x -> Hamlet (Routes master) IO ())
-> (x -> Json (Routes master) ())
-> GHandler sub master RepHtmlJson
applyLayoutJson t x toH toJ = do
applyLayoutJson t h x toH toJ = do
html <- defaultLayout PageContent
{ pageTitle = cs t
, pageHead = return ()
, pageHead = h
, pageBody = toH x
}
json <- jsonToContent $ toJ x
@ -115,7 +117,7 @@ applyLayout' :: Yesod master
=> String -- ^ title
-> Hamlet (Routes master) IO () -- ^ body
-> GHandler sub master ChooseRep
applyLayout' s = fmap chooseRep . applyLayout s
applyLayout' s = fmap chooseRep . applyLayout s (return ())
-- | The default error handler for 'errorHandler'.
defaultErrorHandler :: Yesod y