hamlet 0.9

This commit is contained in:
Michael Snoyman 2011-07-19 09:39:05 +03:00
parent c566eafb34
commit 686950992d
6 changed files with 18 additions and 21 deletions

View File

@ -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)| <h1>Invalid login |]
Nothing -> do rh <- defaultLayout $ addHtml [QQ(html)| <h1>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)|
<h1>Authentication Status
$maybe _ <- creds
<p>Logged in.

View File

@ -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)|
<form method="post" action="@{authToMaster url}">
\Your new identifier is:
<input type="text" name="ident">

View File

@ -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)|
<form method="post" action="@{tm loginR}">
<table>

View File

@ -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)|
<div id="header">
<h1>Login

View File

@ -13,7 +13,7 @@ import Yesod.Auth
import Yesod.Form
import Yesod.Handler
import Yesod.Widget
import Text.Hamlet (hamlet)
import Text.Hamlet (html)
import Web.Authenticate.OAuth
import Data.Maybe
import Data.String
@ -69,7 +69,7 @@ authOAuth name ident reqUrl accUrl authUrl key sec = AuthPlugin name dispatch lo
render <- lift getUrlRender
let oaUrl = render $ tm $ oauthUrl name
addHtml
[QQ(hamlet)| <a href=#{oaUrl}>Login with #{name} |]
[QQ(html)| <a href=#{oaUrl}>Login with #{name} |]
authTwitter :: YesodAuth m =>
String -- ^ Consumer Key

View File

@ -22,7 +22,7 @@ library
build-depends: base >= 4 && < 4.3
build-depends: authenticate >= 0.9 && < 0.10
, bytestring >= 0.9.1.4 && < 0.10
, yesod-core >= 0.8.3 && < 0.9
, yesod-core >= 0.9 && < 0.10
, wai >= 0.4 && < 0.5
, template-haskell
, pureMD5 >= 1.1 && < 2.2
@ -32,8 +32,8 @@ library
, mime-mail >= 0.3 && < 0.4
, blaze-html >= 0.4 && < 0.5
, yesod-persistent >= 0.2 && < 0.3
, hamlet >= 0.8.1 && < 0.9
, yesod-json >= 0.1 && < 0.2
, hamlet >= 0.9 && < 0.10
, yesod-json >= 0.2 && < 0.3
, containers >= 0.2 && < 0.5
, yesod-form >= 0.3 && < 0.4
, transformers >= 0.2 && < 0.3
@ -42,7 +42,6 @@ library
, SHA >= 1.4.1.3 && < 1.5
, http-enumerator >= 0.6 && < 0.7
, aeson >= 0.3.2.2 && < 0.4
, web-routes-quasi >= 0.7 && < 0.8
, pwstore-fast >= 2.1 && < 2.2
exposed-modules: Yesod.Auth