diff --git a/Yesod/Helpers/AtomFeed.hs b/Yesod/Helpers/AtomFeed.hs index 046e83a8..378315c2 100644 --- a/Yesod/Helpers/AtomFeed.hs +++ b/Yesod/Helpers/AtomFeed.hs @@ -52,22 +52,22 @@ xmlns _ = cs "http://www.w3.org/2005/Atom" template :: AtomFeed url -> Hamlet url IO () template = [$hamlet| -%feed!xmlns=$xmlns$ - %title $atomTitle.cs$ - %link!rel=self!href=@atomLinkSelf@ - %link!href=@atomLinkHome@ - %updated $atomUpdated.formatW3.cs$ - %id @atomLinkHome@ - $forall atomEntries entry +%feed!xmlns=$.xmlns$ + %title $.atomTitle.cs$ + %link!rel=self!href=@.atomLinkSelf@ + %link!href=@.atomLinkHome@ + %updated $.atomUpdated.formatW3.cs$ + %id @.atomLinkHome@ + $forall .atomEntries entry ^entry.entryTemplate^ |] entryTemplate :: AtomFeedEntry url -> Hamlet url IO () entryTemplate = [$hamlet| %entry - %id @atomEntryLink@ - %link!href=@atomEntryLink@ - %updated $atomEntryUpdated.formatW3.cs$ - %title $atomEntryTitle.cs$ - %content!type=html $atomEntryContent.cdata$ + %id @.atomEntryLink@ + %link!href=@.atomEntryLink@ + %updated $.atomEntryUpdated.formatW3.cs$ + %title $.atomEntryTitle.cs$ + %content!type=html $.atomEntryContent.cdata$ |] diff --git a/Yesod/Helpers/Auth.hs b/Yesod/Helpers/Auth.hs index 845b8f16..e4b9d72b 100644 --- a/Yesod/Helpers/Auth.hs +++ b/Yesod/Helpers/Auth.hs @@ -43,6 +43,7 @@ import Data.Convertible.Text import Control.Monad.Attempt import Data.Maybe +import Control.Applicative import Data.Typeable (Typeable) import Control.Exception (Exception) @@ -90,21 +91,16 @@ getOpenIdR = do [] -> return () (x:_) -> addCookie destCookieTimeout destCookieName x rtom <- getRouteToMaster - let html = template (getParams rr "message", rtom) - applyLayout "Log in via OpenID" html - where - urlForward (_, wrapper) = wrapper OpenIdForward - hasMessage = not . null . fst - message ([], _) = cs "" - message (m:_, _) = cs m - template = [$hamlet| -$if hasMessage - %p.message $message$ + let message = cs <$> (listToMaybe $ getParams rr "message") + let urlForward = rtom OpenIdForward + applyLayout "Log in via OpenID" $ [$hamlet| +$maybe message msg + %p.message $msg$ %form!method=get!action=@urlForward@ %label!for=openid OpenID: %input#openid!type=text!name=openid %input!type=submit!value=Login -|] +|] () getOpenIdForward :: GHandler Auth master () getOpenIdForward = do @@ -183,9 +179,9 @@ getCheck = do %h1 Authentication Status %dl %dt identifier - %dd $fst$ + %dd $.fst$ %dt displayName - %dd $snd$ + %dd $.snd$ |] json (ident, dn) = jsonMap [ ("ident", jsonScalar ident) diff --git a/Yesod/Helpers/EmailAuth.hs b/Yesod/Helpers/EmailAuth.hs index a32b65a2..9fc28c24 100644 --- a/Yesod/Helpers/EmailAuth.hs +++ b/Yesod/Helpers/EmailAuth.hs @@ -71,11 +71,11 @@ getRegisterR = do toMaster <- getRouteToMaster applyLayout "Register a new account" $ [$hamlet| %p Enter your e-mail address below, and a confirmation e-mail will be sent to you. -%form!method=post!action=@id@ +%form!method=post!action=@RegisterR.toMaster@ %label!for=email E-mail %input#email!type=email!name=email!width=150 %input!type=submit!value=Register -|] $ toMaster RegisterR +|] () postRegisterR :: YesodEmailAuth master => GHandler EmailAuth master RepHtml postRegisterR = do @@ -93,8 +93,8 @@ postRegisterR = do let verUrl = render $ VerifyR lid verKey liftIO $ sendVerifyEmail y email verKey verUrl applyLayout "Confirmation e-mail sent" $ [$hamlet| -%p A confirmation e-mail has been sent to $id$. -|] $ cs email +%p A confirmation e-mail has been sent to $email.cs$. +|] () checkEmail :: Form ParamValue -> Form ParamValue checkEmail = notEmpty -- FIXME @@ -132,12 +132,12 @@ getLoginR = do toMaster <- getRouteToMaster msg <- getMessage applyLayout "Login" $ [$hamlet| -$maybe snd msg - %p.message $msg$ +$maybe msg ms + %p.message $ms$ %p Please log in to your account. %p - %a!href=@fst.fst@ I don't have an account -%form!method=post!action=@fst.snd@ + %a!href=@RegisterR.toMaster@ I don't have an account +%form!method=post!action=@LoginR.toMaster@ %table %tr %th E-mail @@ -150,7 +150,7 @@ $maybe snd msg %tr %td!colspan=2 %input!type=submit!value=Login -|] ((toMaster RegisterR, toMaster LoginR), msg) +|] () postLoginR :: YesodEmailAuth master => GHandler EmailAuth master () postLoginR = do @@ -182,10 +182,10 @@ getPasswordR = do redirect RedirectTemporary $ toMaster LoginR msg <- getMessage applyLayout "Set password" $ [$hamlet| -$maybe fst msg - %p.message $msg$ +$maybe msg ms + %p.message $ms$ %h3 Set a new password -%form!method=post!action=@snd@ +%form!method=post!action=@PasswordR.toMaster@ %table %tr %th New password @@ -198,7 +198,7 @@ $maybe fst msg %tr %td!colspan=2 %input!type=submit!value=Submit -|] (msg, toMaster PasswordR) +|] () postPasswordR :: YesodEmailAuth master => GHandler EmailAuth master () postPasswordR = do diff --git a/Yesod/Helpers/Sitemap.hs b/Yesod/Helpers/Sitemap.hs index f3701b0b..3e030fc0 100644 --- a/Yesod/Helpers/Sitemap.hs +++ b/Yesod/Helpers/Sitemap.hs @@ -47,13 +47,13 @@ data SitemapUrl url = SitemapUrl , priority :: Double } -sitemapNS :: [SitemapUrl url] -> HtmlContent -sitemapNS _ = cs "http://www.sitemaps.org/schemas/sitemap/0.9" +sitemapNS :: HtmlContent +sitemapNS = cs "http://www.sitemaps.org/schemas/sitemap/0.9" template :: [SitemapUrl url] -> Hamlet url IO () template = [$hamlet| %urlset!xmlns=$sitemapNS$ - $forall id url + $forall .id url %url %loc @url.sitemapLoc@ %lastmod $url.sitemapLastMod.formatW3.cs$ diff --git a/Yesod/Yesod.hs b/Yesod/Yesod.hs index 9c61f3f7..f4ec0d51 100644 --- a/Yesod/Yesod.hs +++ b/Yesod/Yesod.hs @@ -67,11 +67,11 @@ class YesodSite a => Yesod a where !!! %html %head - %title $pageTitle$ - ^pageHead^ + %title $p.pageTitle$ + ^p.pageHead^ %body - ^pageBody^ -|] p + ^p.pageBody^ +|] () -- | Gets called at the beginning of each request. Useful for logging. onRequest :: a -> Request -> IO () @@ -126,7 +126,7 @@ defaultErrorHandler NotFound = do r <- waiRequest applyLayout' "Not Found" $ [$hamlet| %h1 Not Found -%p $helper$ +%p $.helper$ |] r where helper = Unencoded . cs . W.pathInfo @@ -146,10 +146,10 @@ defaultErrorHandler (InvalidArgs ia) = defaultErrorHandler (InternalError e) = applyLayout' "Internal Server Error" $ [$hamlet| %h1 Internal Server Error -%p $cs$ -|] e +%p $e.cs$ +|] () defaultErrorHandler (BadMethod m) = applyLayout' "Bad Method" $ [$hamlet| %h1 Method Not Supported -%p Method "$cs$" not supported -|] m +%p Method "$m.cs$" not supported +|] () diff --git a/yesod.cabal b/yesod.cabal index a7ea9626..eae3bc17 100644 --- a/yesod.cabal +++ b/yesod.cabal @@ -30,7 +30,7 @@ library template-haskell >= 2.4 && < 2.5, web-routes >= 0.22 && < 0.23, web-routes-quasi >= 0.1 && < 0.2, - hamlet >= 0.0.1 && < 0.1, + hamlet >= 0.2.0 && < 0.3, transformers >= 0.1 && < 0.3, clientsession >= 0.2 && < 0.3, MonadCatchIO-transformers >= 0.2.2 && < 0.3,