Added head to applyLayout(Json)
This commit is contained in:
parent
32465f4e97
commit
2067d5d687
@ -92,7 +92,7 @@ getOpenIdR = do
|
|||||||
(x:_) -> addCookie destCookieTimeout destCookieName x
|
(x:_) -> addCookie destCookieTimeout destCookieName x
|
||||||
rtom <- getRouteToMaster
|
rtom <- getRouteToMaster
|
||||||
let message = cs <$> (listToMaybe $ getParams rr "message")
|
let message = cs <$> (listToMaybe $ getParams rr "message")
|
||||||
applyLayout "Log in via OpenID" $ [$hamlet|
|
applyLayout "Log in via OpenID" (return ()) [$hamlet|
|
||||||
$maybe message msg
|
$maybe message msg
|
||||||
%p.message $msg$
|
%p.message $msg$
|
||||||
%form!method=get!action=@rtom.OpenIdForward@
|
%form!method=get!action=@rtom.OpenIdForward@
|
||||||
@ -174,7 +174,7 @@ getCheck = do
|
|||||||
ident <- maybeIdentifier
|
ident <- maybeIdentifier
|
||||||
dn <- displayName
|
dn <- displayName
|
||||||
let arg = (cs $ fromMaybe "" ident, cs $ fromMaybe "" dn)
|
let arg = (cs $ fromMaybe "" ident, cs $ fromMaybe "" dn)
|
||||||
applyLayoutJson "Authentication Status" arg html json
|
applyLayoutJson "Authentication Status" (return ()) arg html json
|
||||||
where
|
where
|
||||||
html (x, y) = [$hamlet|
|
html (x, y) = [$hamlet|
|
||||||
%h1 Authentication Status
|
%h1 Authentication Status
|
||||||
|
|||||||
@ -69,7 +69,7 @@ mkYesodSub "EmailAuth" [''YesodEmailAuth] [$parseRoutes|
|
|||||||
getRegisterR :: Yesod master => GHandler EmailAuth master RepHtml
|
getRegisterR :: Yesod master => GHandler EmailAuth master RepHtml
|
||||||
getRegisterR = do
|
getRegisterR = do
|
||||||
toMaster <- getRouteToMaster
|
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.
|
%p Enter your e-mail address below, and a confirmation e-mail will be sent to you.
|
||||||
%form!method=post!action=@toMaster.RegisterR@
|
%form!method=post!action=@toMaster.RegisterR@
|
||||||
%label!for=email E-mail
|
%label!for=email E-mail
|
||||||
@ -93,7 +93,7 @@ postRegisterR = do
|
|||||||
tm <- getRouteToMaster
|
tm <- getRouteToMaster
|
||||||
let verUrl = render $ tm $ VerifyR lid verKey
|
let verUrl = render $ tm $ VerifyR lid verKey
|
||||||
liftIO $ sendVerifyEmail y email verKey verUrl
|
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$.
|
%p A confirmation e-mail has been sent to $cs.email$.
|
||||||
|]
|
|]
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ getVerifyR lid key = do
|
|||||||
setLoginSession email lid
|
setLoginSession email lid
|
||||||
toMaster <- getRouteToMaster
|
toMaster <- getRouteToMaster
|
||||||
redirect RedirectTemporary $ toMaster PasswordR
|
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.
|
%p I'm sorry, but that was an invalid verification key.
|
||||||
|]
|
|]
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ getLoginR :: Yesod master => GHandler EmailAuth master RepHtml
|
|||||||
getLoginR = do
|
getLoginR = do
|
||||||
toMaster <- getRouteToMaster
|
toMaster <- getRouteToMaster
|
||||||
msg <- getMessage
|
msg <- getMessage
|
||||||
applyLayout "Login" $ [$hamlet|
|
applyLayout "Login" (return ()) [$hamlet|
|
||||||
$maybe msg ms
|
$maybe msg ms
|
||||||
%p.message $ms$
|
%p.message $ms$
|
||||||
%p Please log in to your account.
|
%p Please log in to your account.
|
||||||
@ -182,7 +182,7 @@ getPasswordR = do
|
|||||||
setMessage "You must be logged in to set a password"
|
setMessage "You must be logged in to set a password"
|
||||||
redirect RedirectTemporary $ toMaster LoginR
|
redirect RedirectTemporary $ toMaster LoginR
|
||||||
msg <- getMessage
|
msg <- getMessage
|
||||||
applyLayout "Set password" [$hamlet|
|
applyLayout "Set password" (return ()) [$hamlet|
|
||||||
$maybe msg ms
|
$maybe msg ms
|
||||||
%p.message $ms$
|
%p.message $ms$
|
||||||
%h3 Set a new password
|
%h3 Set a new password
|
||||||
|
|||||||
@ -85,12 +85,13 @@ class YesodSite a => Yesod a where
|
|||||||
-- | Apply the default layout ('defaultLayout') to the given title and body.
|
-- | Apply the default layout ('defaultLayout') to the given title and body.
|
||||||
applyLayout :: Yesod master
|
applyLayout :: Yesod master
|
||||||
=> String -- ^ title
|
=> String -- ^ title
|
||||||
|
-> Hamlet (Routes master) IO () -- ^ head
|
||||||
-> Hamlet (Routes master) IO () -- ^ body
|
-> Hamlet (Routes master) IO () -- ^ body
|
||||||
-> GHandler sub master RepHtml
|
-> GHandler sub master RepHtml
|
||||||
applyLayout t b =
|
applyLayout t h b =
|
||||||
RepHtml `fmap` defaultLayout PageContent
|
RepHtml `fmap` defaultLayout PageContent
|
||||||
{ pageTitle = cs t
|
{ pageTitle = cs t
|
||||||
, pageHead = return ()
|
, pageHead = h
|
||||||
, pageBody = b
|
, pageBody = b
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,14 +99,15 @@ applyLayout t b =
|
|||||||
-- the default layout for the HTML output ('defaultLayout').
|
-- the default layout for the HTML output ('defaultLayout').
|
||||||
applyLayoutJson :: Yesod master
|
applyLayoutJson :: Yesod master
|
||||||
=> String -- ^ title
|
=> String -- ^ title
|
||||||
|
-> Hamlet (Routes master) IO () -- ^ head
|
||||||
-> x
|
-> x
|
||||||
-> (x -> Hamlet (Routes master) IO ())
|
-> (x -> Hamlet (Routes master) IO ())
|
||||||
-> (x -> Json (Routes master) ())
|
-> (x -> Json (Routes master) ())
|
||||||
-> GHandler sub master RepHtmlJson
|
-> GHandler sub master RepHtmlJson
|
||||||
applyLayoutJson t x toH toJ = do
|
applyLayoutJson t h x toH toJ = do
|
||||||
html <- defaultLayout PageContent
|
html <- defaultLayout PageContent
|
||||||
{ pageTitle = cs t
|
{ pageTitle = cs t
|
||||||
, pageHead = return ()
|
, pageHead = h
|
||||||
, pageBody = toH x
|
, pageBody = toH x
|
||||||
}
|
}
|
||||||
json <- jsonToContent $ toJ x
|
json <- jsonToContent $ toJ x
|
||||||
@ -115,7 +117,7 @@ applyLayout' :: Yesod master
|
|||||||
=> String -- ^ title
|
=> String -- ^ title
|
||||||
-> Hamlet (Routes master) IO () -- ^ body
|
-> Hamlet (Routes master) IO () -- ^ body
|
||||||
-> GHandler sub master ChooseRep
|
-> GHandler sub master ChooseRep
|
||||||
applyLayout' s = fmap chooseRep . applyLayout s
|
applyLayout' s = fmap chooseRep . applyLayout s (return ())
|
||||||
|
|
||||||
-- | The default error handler for 'errorHandler'.
|
-- | The default error handler for 'errorHandler'.
|
||||||
defaultErrorHandler :: Yesod y
|
defaultErrorHandler :: Yesod y
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user