Everything builds

This commit is contained in:
Michael Snoyman 2011-12-28 10:03:14 +02:00
parent be07e4c535
commit 50ce1da37e
10 changed files with 29 additions and 24 deletions

View File

@ -73,7 +73,7 @@ data Creds m = Creds
, credsExtra :: [(Text, Text)] , credsExtra :: [(Text, Text)]
} }
class (Yesod m, SinglePiece (AuthId m), RenderMessage m FormMessage) => YesodAuth m where class (Yesod m, PathPiece (AuthId m), RenderMessage m FormMessage) => YesodAuth m where
type AuthId m type AuthId m
-- | Default destination on successful login, if no other -- | Default destination on successful login, if no other
@ -133,7 +133,7 @@ setCreds doRedirects creds = do
Just ar -> do setMessageI Msg.InvalidLogin Just ar -> do setMessageI Msg.InvalidLogin
redirect RedirectTemporary ar redirect RedirectTemporary ar
Just aid -> do Just aid -> do
setSession credsKey $ toSinglePiece aid setSession credsKey $ toPathPiece aid
when doRedirects $ do when doRedirects $ do
setMessageI Msg.NowLoggedIn setMessageI Msg.NowLoggedIn
redirectUltDest RedirectTemporary $ loginDest y redirectUltDest RedirectTemporary $ loginDest y
@ -189,12 +189,12 @@ maybeAuthId = do
ms <- lookupSession credsKey ms <- lookupSession credsKey
case ms of case ms of
Nothing -> return Nothing Nothing -> return Nothing
Just s -> return $ fromSinglePiece s Just s -> return $ fromPathPiece s
maybeAuth :: ( YesodAuth m maybeAuth :: ( YesodAuth m
, b ~ YesodPersistBackend m , b ~ YesodPersistBackend m
, Key b val ~ AuthId m , Key b val ~ AuthId m
, PersistBackend b (GGHandler s m IO) , PersistStore b (GHandler s m)
, PersistEntity val , PersistEntity val
, YesodPersist m , YesodPersist m
) => GHandler s m (Maybe (Key b val, val)) ) => GHandler s m (Maybe (Key b val, val))
@ -209,7 +209,7 @@ requireAuthId = maybeAuthId >>= maybe redirectLogin return
requireAuth :: ( YesodAuth m requireAuth :: ( YesodAuth m
, b ~ YesodPersistBackend m , b ~ YesodPersistBackend m
, Key b val ~ AuthId m , Key b val ~ AuthId m
, PersistBackend b (GGHandler s m IO) , PersistStore b (GHandler s m)
, PersistEntity val , PersistEntity val
, YesodPersist m , YesodPersist m
) => GHandler s m (Key b val, val) ) => GHandler s m (Key b val, val)

View File

@ -60,7 +60,7 @@ data EmailCreds m = EmailCreds
, emailCredsVerkey :: Maybe VerKey , emailCredsVerkey :: Maybe VerKey
} }
class (YesodAuth m, SinglePiece (AuthEmailId m)) => YesodAuthEmail m where class (YesodAuth m, PathPiece (AuthEmailId m)) => YesodAuthEmail m where
type AuthEmailId m type AuthEmailId m
addUnverified :: Email -> VerKey -> GHandler Auth m (AuthEmailId m) addUnverified :: Email -> VerKey -> GHandler Auth m (AuthEmailId m)
@ -102,7 +102,7 @@ authEmail =
dispatch "GET" ["register"] = getRegisterR >>= sendResponse dispatch "GET" ["register"] = getRegisterR >>= sendResponse
dispatch "POST" ["register"] = postRegisterR >>= sendResponse dispatch "POST" ["register"] = postRegisterR >>= sendResponse
dispatch "GET" ["verify", eid, verkey] = dispatch "GET" ["verify", eid, verkey] =
case fromSinglePiece eid of case fromPathPiece eid of
Nothing -> notFound Nothing -> notFound
Just eid' -> getVerifyR eid' verkey >>= sendResponse Just eid' -> getVerifyR eid' verkey >>= sendResponse
dispatch "POST" ["login"] = postLoginR >>= sendResponse dispatch "POST" ["login"] = postLoginR >>= sendResponse
@ -142,7 +142,7 @@ postRegisterR = do
return (lid, key) return (lid, key)
render <- getUrlRender render <- getUrlRender
tm <- getRouteToMaster tm <- getRouteToMaster
let verUrl = render $ tm $ verify (toSinglePiece lid) verKey let verUrl = render $ tm $ verify (toPathPiece lid) verKey
sendVerifyEmail email verKey verUrl sendVerifyEmail email verKey verUrl
defaultLayout $ do defaultLayout $ do
setTitleI Msg.ConfirmationEmailSentTitle setTitleI Msg.ConfirmationEmailSentTitle

View File

@ -49,7 +49,7 @@ facebookLogout = PluginR "facebook" ["logout"]
-- @Nothing@ if it's not found (probably because the user is not -- @Nothing@ if it's not found (probably because the user is not
-- logged in via Facebook). Note that the returned access token -- logged in via Facebook). Note that the returned access token
-- may have expired. -- may have expired.
getFacebookAccessToken :: MonadIO mo => GGHandler sub master mo (Maybe Facebook.AccessToken) getFacebookAccessToken :: GHandler sub master (Maybe Facebook.AccessToken)
getFacebookAccessToken = getFacebookAccessToken =
liftM (fmap Facebook.AccessToken) (lookupSession facebookAccessTokenKey) liftM (fmap Facebook.AccessToken) (lookupSession facebookAccessTokenKey)

View File

@ -137,7 +137,8 @@ setPassword pwd u = do salt <- randomSalt
-- the database values. -- the database values.
validateUser :: ( YesodPersist yesod validateUser :: ( YesodPersist yesod
, b ~ YesodPersistBackend yesod , b ~ YesodPersistBackend yesod
, PersistBackend b (GGHandler sub yesod IO) , PersistStore b (GHandler sub yesod)
, PersistUnique b (GHandler sub yesod)
, PersistEntity user , PersistEntity user
, HashDBUser user , HashDBUser user
) => ) =>
@ -163,7 +164,8 @@ login = PluginR "hashdb" ["login"]
postLoginR :: ( YesodAuth y, YesodPersist y postLoginR :: ( YesodAuth y, YesodPersist y
, b ~ YesodPersistBackend y , b ~ YesodPersistBackend y
, HashDBUser user, PersistEntity user , HashDBUser user, PersistEntity user
, PersistBackend b (GGHandler Auth y IO)) , PersistStore b (GHandler Auth y)
, PersistUnique b (GHandler Auth y))
=> (Text -> Maybe (Unique user b)) => (Text -> Maybe (Unique user b))
-> GHandler Auth y () -> GHandler Auth y ()
postLoginR uniq = do postLoginR uniq = do
@ -186,7 +188,8 @@ getAuthIdHashDB :: ( YesodAuth master, YesodPersist master
, HashDBUser user, PersistEntity user , HashDBUser user, PersistEntity user
, Key b user ~ AuthId master , Key b user ~ AuthId master
, b ~ YesodPersistBackend master , b ~ YesodPersistBackend master
, PersistBackend b (GGHandler sub master IO)) , PersistUnique b (GHandler sub master)
, PersistStore b (GHandler sub master))
=> (AuthRoute -> Route master) -- ^ your site's Auth Route => (AuthRoute -> Route master) -- ^ your site's Auth Route
-> (Text -> Maybe (Unique user b)) -- ^ gets user ID -> (Text -> Maybe (Unique user b)) -- ^ gets user ID
-> Creds master -- ^ the creds argument -> Creds master -- ^ the creds argument
@ -213,7 +216,8 @@ authHashDB :: ( YesodAuth m, YesodPersist m
, HashDBUser user , HashDBUser user
, PersistEntity user , PersistEntity user
, b ~ YesodPersistBackend m , b ~ YesodPersistBackend m
, PersistBackend b (GGHandler Auth m IO)) , PersistStore b (GHandler Auth m)
, PersistUnique b (GHandler Auth m))
=> (Text -> Maybe (Unique user b)) -> AuthPlugin m => (Text -> Maybe (Unique user b)) -> AuthPlugin m
authHashDB uniq = AuthPlugin "hashdb" dispatch $ \tm -> addHamlet authHashDB uniq = AuthPlugin "hashdb" dispatch $ \tm -> addHamlet
[QQ(hamlet)| [QQ(hamlet)|
@ -252,8 +256,8 @@ authHashDB uniq = AuthPlugin "hashdb" dispatch $ \tm -> addHamlet
---------------------------------------------------------------- ----------------------------------------------------------------
-- | Generate data base instances for a valid user -- | Generate data base instances for a valid user
share2 (mkPersist sqlSettings) (mkMigrate "migrateUsers") share2 (mkPersist sqlMkSettings) (mkMigrate "migrateUsers")
[QQ(persist)| [QQ(persistUpperCase)|
User User
username Text Eq username Text Eq
password Text password Text

View File

@ -7,7 +7,7 @@ module Yesod.Default.Main
, defaultDevelAppWith , defaultDevelAppWith
) where ) where
import Yesod.Core hiding (AppConfig (..)) import Yesod.Core
import Yesod.Default.Config import Yesod.Default.Config
import Yesod.Logger (Logger, makeDefaultLogger, logString, flushLogger) import Yesod.Logger (Logger, makeDefaultLogger, logString, flushLogger)
import Network.Wai (Application) import Network.Wai (Application)

View File

@ -34,7 +34,7 @@ newtype RepAtom = RepAtom Content
instance HasReps RepAtom where instance HasReps RepAtom where
chooseRep (RepAtom c) _ = return (typeAtom, c) chooseRep (RepAtom c) _ = return (typeAtom, c)
atomFeed :: Monad mo => Feed (Route master) -> GGHandler sub master mo RepAtom atomFeed :: Feed (Route master) -> GHandler sub master RepAtom
atomFeed = liftM RepAtom . hamletToContent . template atomFeed = liftM RepAtom . hamletToContent . template
template :: Feed url -> HtmlUrl url template :: Feed url -> HtmlUrl url

View File

@ -25,7 +25,7 @@ import Yesod.FeedTypes
import Yesod.AtomFeed import Yesod.AtomFeed
import Yesod.RssFeed import Yesod.RssFeed
import Yesod.Content (HasReps (chooseRep), typeAtom, typeRss) import Yesod.Content (HasReps (chooseRep), typeAtom, typeRss)
import Yesod.Handler (Route, GGHandler) import Yesod.Handler (Route, GHandler)
data RepAtomRss = RepAtomRss RepAtom RepRss data RepAtomRss = RepAtomRss RepAtom RepRss
instance HasReps RepAtomRss where instance HasReps RepAtomRss where
@ -33,7 +33,7 @@ instance HasReps RepAtomRss where
[ (typeAtom, a) [ (typeAtom, a)
, (typeRss, r) , (typeRss, r)
] ]
newsFeed :: Monad mo => Feed (Route master) -> GGHandler sub master mo RepAtomRss newsFeed :: Feed (Route master) -> GHandler sub master RepAtomRss
newsFeed f = do newsFeed f = do
a <- atomFeed f a <- atomFeed f
r <- rssFeed f r <- rssFeed f

View File

@ -31,7 +31,7 @@ instance HasReps RepRss where
chooseRep (RepRss c) _ = return (typeRss, c) chooseRep (RepRss c) _ = return (typeRss, c)
-- | Generate the feed -- | Generate the feed
rssFeed :: Monad mo => Feed (Route master) -> GGHandler sub master mo RepRss rssFeed :: Feed (Route master) -> GHandler sub master RepRss
rssFeed = liftM RepRss . hamletToContent . template rssFeed = liftM RepRss . hamletToContent . template
template :: Feed url -> HtmlUrl url template :: Feed url -> HtmlUrl url

View File

@ -68,9 +68,9 @@ import qualified Data.ByteString as S
import Network.HTTP.Types (status301) import Network.HTTP.Types (status301)
import System.PosixCompat.Files (getFileStatus, modificationTime) import System.PosixCompat.Files (getFileStatus, modificationTime)
import System.Posix.Types (EpochTime) import System.Posix.Types (EpochTime)
import qualified Data.Enumerator as E import qualified Data.Conduit as C
import qualified Data.Enumerator.List as EL import qualified Data.Conduit.Binary as CB
import qualified Data.Enumerator.Binary as EB import qualified Data.Conduit.List as CL
import Network.Wai.Application.Static import Network.Wai.Application.Static
( StaticSettings (..) ( StaticSettings (..)
@ -282,7 +282,7 @@ mkStaticFilesList fp fs routeConName makeHash = do
-- descriptors -- descriptors
base64md5File :: Prelude.FilePath -> IO String base64md5File :: Prelude.FilePath -> IO String
base64md5File file = do base64md5File file = do
bss <- E.run_ $ EB.enumFile file E.$$ EL.consume bss <- C.runResourceT $ CB.sourceFile file C.$$ CL.consume
return $ base64md5 $ L.fromChunks bss return $ base64md5 $ L.fromChunks bss
-- FIXME I'd like something streaming instead -- FIXME I'd like something streaming instead
{- {-

View File

@ -40,6 +40,7 @@ library
, file-embed >= 0.0.4.1 && < 0.5 , file-embed >= 0.0.4.1 && < 0.5
, http-types >= 0.6.5 && < 0.7 , http-types >= 0.6.5 && < 0.7
, unix-compat >= 0.2 , unix-compat >= 0.2
, conduit >= 0.0
exposed-modules: Yesod.Static exposed-modules: Yesod.Static
ghc-options: -Wall ghc-options: -Wall