Works with subsites with arguments

This commit is contained in:
Michael Snoyman 2011-01-26 00:28:27 +02:00
parent ee3fc92111
commit b3ae5e6149
2 changed files with 4 additions and 4 deletions

View File

@ -93,7 +93,7 @@ type Method = String
-- to deal with it directly, as mkYesodSub creates instances appropriately.
class Eq (Route s) => YesodSubSite s y where
getSubSite :: Site (Route s) (Method -> Maybe (GHandler s y ChooseRep))
dispatchSubsite :: y -> Maybe CS.Key -> [String] -> (y -> s) -> W.Application
dispatchSubsite :: y -> Maybe CS.Key -> [String] -> s -> W.Application
dispatchSubsite _ _ _ _ _ = return $ W.responseLBS W.status200 [("Content-Type", "text/plain")] $ L8.pack "FIXME"
-- | Define settings for a Yesod applications. The only required setting is

View File

@ -188,7 +188,7 @@ mkYesodGeneral name args clazzes isSub res = do
master <- newName "master"
mkey <- newName "mkey"
just <- [|Just|]
(pat', tma', rest) <- mkPat' pieces $ just `AppE` (VarE $ mkName toSub)
(pat', tma', rest) <- mkPat' pieces $ just `AppE` (VarE (mkName toSub) `AppE` VarE master)
ds <- [|dispatchSubsite|]
let body' = ds `AppE` VarE master `AppE` VarE mkey `AppE` rest
fmap' <- [|(<$>)|]
@ -260,12 +260,12 @@ mkToMasterArg ps fname = do
let nargs = length $ filter (not.isStatic) ps
f = VarE $ mkName fname
args <- sequence $ take nargs $ repeat $ newName "x"
rsg <- [| runSubsiteGetter|]
rsg <- [|error "runSubsiteGetter"|]
let xps = map VarP args
xes = map VarE args
e' = foldl (\x y -> x `AppE` y) f xes
e = rsg `AppE` e'
return $ LamE xps e
return $ rsg -- FIXME LamE xps e
-- | Convert the given argument into a WAI application, executable with any WAI
-- handler. This is the same as 'toWaiAppPlain', except it includes three