From 686950992da46693c05f3edc553e7f1c88d01c08 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 19 Jul 2011 09:39:05 +0300 Subject: [PATCH] hamlet 0.9 --- Yesod/Auth.hs | 10 +++++----- Yesod/Auth/Dummy.hs | 3 ++- Yesod/Auth/Email.hs | 6 +----- Yesod/Auth/HashDB.hs | 9 +++++---- Yesod/Auth/OAuth.hs | 4 ++-- yesod-auth.cabal | 7 +++---- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Yesod/Auth.hs b/Yesod/Auth.hs index 850ac194..4b6b5062 100644 --- a/Yesod/Auth.hs +++ b/Yesod/Auth.hs @@ -39,7 +39,7 @@ import qualified Data.Map as Map import Language.Haskell.TH.Syntax hiding (lift) import qualified Network.Wai as W -import Text.Hamlet (hamlet) +import Text.Hamlet (html) import Yesod.Core import Yesod.Persist @@ -119,7 +119,7 @@ setCreds doRedirects creds = do Nothing -> when doRedirects $ do case authRoute y of - Nothing -> do rh <- defaultLayout [QQ(hamlet)|

Invalid login |] + Nothing -> do rh <- defaultLayout $ addHtml [QQ(html)|

Invalid login |] sendResponse rh Just ar -> do setMessageI Msg.InvalidLogin redirect RedirectTemporary ar @@ -134,10 +134,10 @@ getCheckR = do creds <- maybeAuthId defaultLayoutJson (do setTitle "Authentication Status" - addHtml $ html creds) (json' creds) + addHtml $ html' creds) (json' creds) where - html creds = - [QQ(hamlet)| + html' creds = + [QQ(html)|

Authentication Status $maybe _ <- creds

Logged in. diff --git a/Yesod/Auth/Dummy.hs b/Yesod/Auth/Dummy.hs index 494268f1..bd42c1bc 100644 --- a/Yesod/Auth/Dummy.hs +++ b/Yesod/Auth/Dummy.hs @@ -14,6 +14,7 @@ import Yesod.Auth import Yesod.Form (runInputPost, textField, ireq) import Yesod.Handler (notFound) import Text.Hamlet (hamlet) +import Yesod.Widget (addHamlet) authDummy :: YesodAuth m => AuthPlugin m authDummy = @@ -25,7 +26,7 @@ authDummy = dispatch _ _ = notFound url = PluginR "dummy" [] login authToMaster = - [QQ(hamlet)| + addHamlet [QQ(hamlet)|

\Your new identifier is: diff --git a/Yesod/Auth/Email.hs b/Yesod/Auth/Email.hs index 9f7beb96..8e9b9b8e 100644 --- a/Yesod/Auth/Email.hs +++ b/Yesod/Auth/Email.hs @@ -35,8 +35,6 @@ import Yesod.Content import Yesod.Widget import Yesod.Core import Control.Monad.IO.Class (liftIO) -import Control.Monad.Trans.Class (lift) -import Web.Routes.Quasi (toSinglePiece, fromSinglePiece) import qualified Yesod.Auth.Message as Msg loginR, registerR, setpassR :: AuthRoute @@ -82,9 +80,7 @@ class (YesodAuth m, SinglePiece (AuthEmailId m)) => YesodAuthEmail m where authEmail :: YesodAuthEmail m => AuthPlugin m authEmail = - AuthPlugin "email" dispatch $ \tm -> do - y <- lift getYesod - l <- lift languages + AuthPlugin "email" dispatch $ \tm -> [QQ(whamlet)| diff --git a/Yesod/Auth/HashDB.hs b/Yesod/Auth/HashDB.hs index 52975c1c..acc92243 100644 --- a/Yesod/Auth/HashDB.hs +++ b/Yesod/Auth/HashDB.hs @@ -76,7 +76,8 @@ import Yesod.Persist import Yesod.Handler import Yesod.Form import Yesod.Auth -import Text.Hamlet (hamlet) +import Yesod.Widget (addHamlet) +import Text.Hamlet (hamlet, html) import Control.Applicative ((<$>), (<*>)) import Control.Monad (replicateM,liftM) @@ -163,7 +164,7 @@ postLoginR uniq = do (validateUser <$> (uniq =<< mu) <*> mp) if isValid then setCreds True $ Creds "hashdb" (fromMaybe "" mu) [] - else do setMessage [QQ(hamlet)| Invalid username/password |] + else do setMessage [QQ(html)| Invalid username/password |] toMaster <- getRouteToMaster redirect RedirectTemporary $ toMaster LoginR @@ -191,7 +192,7 @@ getAuthIdHashDB authR uniq creds = do -- user exists Just (uid, _) -> return $ Just uid Nothing -> do - setMessage [QQ(hamlet)| User not found |] + setMessage [QQ(html)| User not found |] redirect RedirectTemporary $ authR LoginR -- | Prompt for username and password, validate that against a database @@ -201,7 +202,7 @@ authHashDB :: ( YesodAuth m, YesodPersist m , PersistEntity user , PersistBackend (YesodDB m (GGHandler Auth m IO))) => (Text -> Maybe (Unique user)) -> AuthPlugin m -authHashDB uniq = AuthPlugin "hashdb" dispatch $ \tm -> +authHashDB uniq = AuthPlugin "hashdb" dispatch $ \tm -> addHamlet [QQ(hamlet)|