Hello,<br>I'm doing it like that now, it works fine.<br>What was confusing me was whether I should pass the data of the form on the URL at some point or not (my knowledge of HTML is very low ;)<br><br>Now turning to digestive functors, I don't see where do goes the "A.action actionURL" part that was in traditionnal forms?<br>
It seems I need it for routing the result of the form.<br>I'm doing it like that:<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">type NomicServer = ServerPartT IO</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">type RoutedNomicServer = RouteT PlayerCommand NomicServer</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">type NomicForm a = HappstackForm IO String BlazeFormHtml a</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">data LoginPass = LoginPass { login :: PlayerName,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> password :: PlayerPassword}</span><br>
<br><span style="font-family: courier new,monospace;">loginForm' :: NomicForm LoginPass</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">loginForm' = </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> LoginPass <$> (TDB.label "Login: " *> inputText Nothing)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <*> (TDB.label "Password: " *> inputText Nothing)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <* (submit "Enter Nomic!")<br><br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">loginPage :: RoutedNomicServer Html</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">loginPage = do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> (l, _) <- liftRouteT $ runForm loginForm' "prefix" NoEnvironment</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> let html = formHtml (unView l []) defaultHtmlConfig</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ok $ H.html $ do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> H.head $ do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> H.title (H.string "Login to Nomic")</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> H.link ! rel "stylesheet" ! type_ "text/css" ! href "/static/css/nomic.css"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> H.meta ! A.httpEquiv "Content-Type" ! content "text/html;charset=utf-8"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> H.meta ! A.name "keywords" ! A.content "Nomic, game, rules, Haskell, auto-reference"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> H.body $ do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> H.div ! A.id "container" $ do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> H.div ! A.id "header" $ "Login to Nomic"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> H.div ! A.id "login" $ html</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> H.div ! A.id "footer" $ "footer"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><br>Also, I don't see how with digestive functors you can set all the HTML properties like id, tabindex, length etc...<br>
<br>Thanks,<br>Corentin<br><br><div class="gmail_quote">On Tue, Jan 25, 2011 at 5:42 AM, Jeremy Shaw <span dir="ltr"><<a href="mailto:jeremy@n-heptane.com">jeremy@n-heptane.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>
<br>
I think you should just be able to use showURL to convert the url type<br>
into a String that you can use with blaze-html:<br>
<br>
data SiteURL = Post_Login | etc<br>
<div class="im"><br>
loginForm :: RoutedNomicServer Html<br>
loginForm = do<br>
</div> actionURL <- showURL Post_Login<br>
ok $ H.form ! A.method "POST" ! A.action actionURL ! enctype<br>
<div class="im">"multipart/form-data;charset=UTF-8" $ do<br>
H.label ! for "login" $ "Login"<br>
input ! type_ "text" ! name "login" ! A.id "login" ! tabindex<br>
"1" ! accesskey "L"<br>
H.label ! for "password" $ "Password"<br>
input ! type_ "text" ! name "password" ! A.id "password" !<br>
tabindex "2" ! accesskey "P"<br>
input ! type_ "submit" ! tabindex "3" ! accesskey "S" ! value<br>
"Enter Nomic!"<br>
<br>
</div>Using the HSP stuff you can avoid the explicit call to showURL and do:<br>
<br>
<form method=Post_Login enctype="multipart/form-data;charset=utf-8"><br>
... </form><br>
<br>
But HSP is a fair bit more complex than blaze-html.<br>
<br>
If blaze-html provide an HtmlT monad that was a real monad transformer<br>
then you could do something similar using blaze. But they decided to<br>
trade-off functionality for speed.<br>
<br>
- jeremy<br>
<br>
On Sat, Jan 22, 2011 at 3:19 PM, Corentin Dupont<br>
<div><div></div><div class="h5"><<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>> wrote:<br>
> Hello Jeremy,<br>
> Yes it would be fine to use solution 1, but I just don't figured how to mix<br>
> web routes and forms.<br>
><br>
> My forms are like that:<br>
> loginForm :: RoutedNomicServer Html<br>
> loginForm = do<br>
> ok $ H.form ! A.method "POST" ! A.action "/postLogin" ! enctype<br>
> "multipart/form-data;charset=UTF-8" $ do<br>
> H.label ! for "login" $ "Login"<br>
> input ! type_ "text" ! name "login" ! A.id "login" ! tabindex "1" !<br>
> accesskey "L"<br>
> H.label ! for "password" $ "Password"<br>
> input ! type_ "text" ! name "password" ! A.id "password" ! tabindex<br>
> "2" ! accesskey "P"<br>
> input ! type_ "submit" ! tabindex "3" ! accesskey "S" ! value "Enter<br>
> Nomic!"<br>
><br>
> And are decoded using a FromData:<br>
><br>
> instance FromData LoginPass where<br>
> fromData = do<br>
> login <- look "login" `mplus` (error "need login")<br>
> password <- look "password" `mplus` (error "need password")<br>
> return $ LoginPass login password<br>
><br>
> How this can go inside web routes? I cannot pass the parameters in the URL<br>
> (here login and password), can I?<br>
><br>
> Thanks,<br>
> Corentin<br>
><br>
> On Sat, Jan 22, 2011 at 9:49 PM, Jeremy Shaw <<a href="mailto:jeremy@n-heptane.com">jeremy@n-heptane.com</a>> wrote:<br>
>><br>
>> Hello,<br>
>><br>
>> I believe you problem is because you are trying to use 'dir' inside<br>
>> RouteT after you have already consumed and decode the path info using<br>
>> implSite.<br>
>><br>
>> There are two solutions here:<br>
>><br>
>> 1. just use web-routes for all your URLs instead of using a mixture<br>
>> of type-safe routes and 'dir'.<br>
>> 2. put the calls to dir outside the call to implSite.<br>
>><br>
>> For example, something like,<br>
>><br>
>> simpleHTTP nullConf $ msum [ dir "Login" $ loginPage,<br>
>> , dir "postLogin" $<br>
>> postLogin<br>
>> , implSite<br>
>> "<a href="http://localhost:8000/" target="_blank">http://localhost:8000/</a>" "" (nomicSite sh)<br>
>> ]<br>
>><br>
>> You to do that, you would also need to modified loginPage and<br>
>> postLogin to not be in the RoutedNomicServer monad. Since they do not<br>
>> appear to use the RouteT stuff anyway, that should not be hard ?<br>
>><br>
>> But, personally, I would just choose option #1. Can you explain why<br>
>> you thought it was better to mix the web-routes stuff with the 'dir'<br>
>> style guards? Maybe there is a short coming in web-routes that needs<br>
>> to be addressed ?<br>
>><br>
>> - jeremy<br>
>><br>
>> On Fri, Jan 21, 2011 at 2:33 PM, Corentin Dupont<br>
>> <<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>> wrote:<br>
>> > Hello Jeremy,<br>
>> > I'm still trying to integrate web routes, but there is one thing I don't<br>
>> > understand:<br>
>> > how to deal with multiple forms?<br>
>> ><br>
>> > In my former application, each forms used to redirect to a subdirectory<br>
>> > of<br>
>> > the web site, and an appropriate handler was waiting there.<br>
>> > But now with web routes I don't see how to do that.<br>
>> > I've tried to push down the decision over subdirectories (with the guard<br>
>> > "dir") inside the RouteT monad:<br>
>> ><br>
>> > type NomicServer = ServerPartT IO<br>
>> > type RoutedNomicServer = RouteT PlayerCommand NomicServer<br>
>> ><br>
>> > nomicSite :: ServerHandle -> Site PlayerCommand (NomicServer Html)<br>
>> > nomicSite sh = setDefault (Noop 0) Site {<br>
>> > handleSite = \f url -> unRouteT (routedNomicHandle sh url)<br>
>> > f<br>
>> > , formatPathSegments = \u -> (toPathSegments u, [])<br>
>> > , parsePathSegments = parseSegments fromPathSegments<br>
>> > }<br>
>> ><br>
>> > routedNomicHandle :: ServerHandle -> PlayerCommand -> RoutedNomicServer<br>
>> > Html<br>
>> > routedNomicHandle sh pc = do<br>
>> > d <- liftRouteT $ liftIO getDataDir<br>
>> > msum [dir "Login" $ loginPage,<br>
>> > dir "postLogin" $ postLogin,<br>
>> > --nullDir >> fileServe [] d,<br>
>> > dir "NewRule" $ newRule sh,<br>
>> > dir "NewGame" $ newGameWeb sh,<br>
>> > dir "Nomic" $ routedNomicCommands sh pc]<br>
>> ><br>
>> ><br>
>> > routedNomicCommands :: ServerHandle -> PlayerCommand -><br>
>> > RoutedNomicServer<br>
>> > Html<br>
>> > routedNomicCommands sh (Noop pn) = nomicPageComm pn sh<br>
>> > (return ())<br>
>> > routedNomicCommands sh (JoinGame pn game) = nomicPageComm pn sh<br>
>> > (joinGame game pn)<br>
>> > routedNomicCommands sh (LeaveGame pn) = nomicPageComm pn sh<br>
>> > (leaveGame pn)<br>
>> > routedNomicCommands sh (SubscribeGame pn game) = nomicPageComm pn sh<br>
>> > (subscribeGame game pn)<br>
>> > routedNomicCommands sh (UnsubscribeGame pn game) = nomicPageComm pn sh<br>
>> > (unsubscribeGame game pn)<br>
>> > routedNomicCommands sh (Amend pn) = nomicPageComm pn sh<br>
>> > (amendConstitution pn)<br>
>> > routedNomicCommands sh (DoAction pn an ar) = nomicPageComm pn sh<br>
>> > (doAction' an ar pn)<br>
>> > routedNomicCommands sh (NewRule pn name text code) = nomicPageComm pn sh<br>
>> > (submitRule name text code pn)<br>
>> > routedNomicCommands sh (NewGame pn game) = nomicPageComm pn sh<br>
>> > (newGame game pn)<br>
>> ><br>
>> ><br>
>> > loginPage :: RoutedNomicServer Html<br>
>> > loginPage = do<br>
>> > l <- loginForm<br>
>> > ok $ H.html $ do<br>
>> > H.head $ do<br>
>> > H.title (H.string "Login to Nomic")<br>
>> > H.link ! rel "stylesheet" ! type_ "text/css" ! href<br>
>> > "/static/css/nomic.css"<br>
>> > H.meta ! A.httpEquiv "Content-Type" ! content<br>
>> > "text/html;charset=utf-8"<br>
>> > H.meta ! A.name "keywords" ! A.content "Nomic, game, rules,<br>
>> > Haskell,<br>
>> > auto-reference"<br>
>> > H.body $ do<br>
>> > H.div ! A.id "container" $ do<br>
>> > H.div ! A.id "header" $ "Login to Nomic"<br>
>> > H.div ! A.id "login" $ l<br>
>> > H.div ! A.id "footer" $ "footer"<br>
>> ><br>
>> > loginForm :: RoutedNomicServer Html<br>
>> > loginForm = do<br>
>> > ok $ H.form ! A.method "POST" ! A.action "/postLogin" ! enctype<br>
>> > "multipart/form-data;charset=UTF-8" $ do<br>
>> > H.label ! for "login" $ "Login"<br>
>> > input ! type_ "text" ! name "login" ! A.id "login" ! tabindex "1"<br>
>> > !<br>
>> > accesskey "L"<br>
>> > H.label ! for "password" $ "Password"<br>
>> > input ! type_ "text" ! name "password" ! A.id "password" !<br>
>> > tabindex<br>
>> > "2" ! accesskey "P"<br>
>> > input ! type_ "submit" ! tabindex "3" ! accesskey "S" ! value<br>
>> > "Enter<br>
>> > Nomic!"<br>
>> ><br>
>> > postLogin :: RoutedNomicServer Html<br>
>> > postLogin = do<br>
>> > methodM POST -- only accept a post method<br>
>> > mbEntry <- getData -- get the data<br>
>> > case mbEntry of<br>
>> > Nothing -> error $ "error: postLogin"<br>
>> > Just (LoginPass login password) -> do<br>
>> > mpn <- liftRouteT $ liftIO $ newPlayerWeb login password<br>
>> > case mpn of<br>
>> > Just pn -> do<br>
>> > link <- showURL $ Noop pn<br>
>> > seeOther link $ string "Redirecting..."<br>
>> > Nothing -> seeOther ("/Login?status=fail" :: String) $ string<br>
>> > "Redirecting..."<br>
>> ><br>
>> > launchWebServer :: ServerHandle -> IO ()<br>
>> > launchWebServer sh = do<br>
>> > putStrLn "Starting web server...\nTo connect, drive your browser to<br>
>> > \"<a href="http://localhost:8000/Login%5C" target="_blank">http://localhost:8000/Login\</a>""<br>
>> > simpleHTTP nullConf $ implSite "<a href="http://localhost:8000/" target="_blank">http://localhost:8000/</a>" "" (nomicSite<br>
>> > sh)<br>
>> ><br>
>> ><br>
>> > But when I drive my browser to "<a href="http://localhost:8000/Login/" target="_blank">http://localhost:8000/Login/</a>", happstack<br>
>> > tell me there is nothing here.<br>
>> > Am I doing it right? If yes, I must have made a mistake.<br>
>> > (as you can see I'm still far from putting in disgestive functors ;)<br>
>> ><br>
>> > If you need, the complete application can be found here (see file<br>
>> > Web.hs):<br>
>> > <a href="https://github.com/cdupont/Nomic" target="_blank">https://github.com/cdupont/Nomic</a><br>
>> ><br>
>> > Thanks,<br>
>> > Corentin<br>
>> ><br>
>> > On Wed, Jan 19, 2011 at 5:12 PM, Corentin Dupont<br>
>> > <<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Thanks Jeremy.<br>
>> >> I had it to work now ;)<br>
>> >><br>
>> >> Corentin<br>
>> >><br>
>> >> On Tue, Jan 18, 2011 at 6:01 PM, Jeremy Shaw <<a href="mailto:jeremy@n-heptane.com">jeremy@n-heptane.com</a>><br>
>> >> wrote:<br>
>> >>><br>
>> >>> Hello,<br>
>> >>><br>
>> >>> trhsx will be installed in ~/.cabal/bin, so you will need to add that<br>
>> >>> to your PATH.<br>
>> >>><br>
>> >>> In order to use the demo code I provided you would need the latest<br>
>> >>> happstack from darcs because it contains a few differences in the API.<br>
>> >>> The code can be made to work with what is on hackage though.<br>
>> >>><br>
>> >>> The submit issue is actually a bug in digestive-functors-blaze. The<br>
>> >>> return type should be, Form m i e BlazeFormHtml (). jaspervdj is going<br>
>> >>> to patch it and upload a new version.<br>
>> >>><br>
>> >>> - jeremy<br>
>> >>><br>
>> >>><br>
>> >>> On Thu, Jan 13, 2011 at 2:40 PM, Corentin Dupont<br>
>> >>> <<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>> wrote:<br>
>> >>> > Hello,<br>
>> >>> ><br>
>> >>> > I'm using the combination happstack + digestive-functors +<br>
>> >>> > web-routes +<br>
>> >>> > blazeHTML.<br>
>> >>> > I'm not finding any examples on the net...<br>
>> >>> ><br>
>> >>> > I've tried to adapt your example (thanks):<br>
>> >>> ><br>
>> >>> > type NomicForm a = HappstackForm IO String BlazeFormHtml a<br>
>> >>> ><br>
>> >>> > demoForm :: NomicForm (Text, Text)<br>
>> >>> > demoForm =<br>
>> >>> > (,) <$> ((TDB.label "greeting: " ++> inputNonEmpty Nothing) <*<br>
>> >>> > br)<br>
>> >>> > <*> ((TDB.label "noun: " ++> inputNonEmpty Nothing) <*<br>
>> >>> > br)<br>
>> >>> > <* (submit "submit")<br>
>> >>> > where<br>
>> >>> > br :: NomicForm ()<br>
>> >>> > br = view H.br<br>
>> >>> > -- make sure the fields are not blank, show errors in line if<br>
>> >>> > they are<br>
>> >>> > inputNonEmpty :: Maybe Text -> NomicForm Text<br>
>> >>> > inputNonEmpty v =<br>
>> >>> > (inputText v `validate` (TD.check "You can not leave this<br>
>> >>> > field<br>
>> >>> > blank." (not . T.null)) <++ errors)<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > But I've got a problem on submit and inputText. I don't see how they<br>
>> >>> > are<br>
>> >>> > compatible with HappstackForm.<br>
>> >>> > NomicForm a reduces to:<br>
>> >>> > Form (ServerPartT IO) Input String BlazeFormHtml a<br>
>> >>> ><br>
>> >>> > whereas the type of submit is:<br>
>> >>> ><br>
>> >>> > submit :: Monad m<br>
>> >>> ><br>
>> >>> > => String -- ^ Text on the submit<br>
>> >>> > button<br>
>> >>> ><br>
>> >>> > -> Form m String e BlazeFormHtml () -- ^ Submit button<br>
>> >>> ><br>
>> >>> ><br>
>> >>> > Maybe I miss some instance?<br>
>> >>> ><br>
>> >>> > BTW, I also tried to execute your exemple, but I can't install some<br>
>> >>> > packages.<br>
>> >>> ><br>
>> >>> >> cabal install digestive-functors-hsp<br>
>> >>> ><br>
>> >>> > cabal: Unknown build tool trhsx<br>
>> >>> ><br>
>> >>> > Whereas trhsx is in my PATH (under linux).<br>
>> >>> ><br>
>> >>> > You said I need the latest happstack from darcs, why?<br>
>> >>> ><br>
>> >>> > Cheers,<br>
>> >>> > Corentin<br>
>> >>> ><br>
>> >>> > On Sun, Jan 9, 2011 at 8:36 PM, Jeremy Shaw <<a href="mailto:jeremy@n-heptane.com">jeremy@n-heptane.com</a>><br>
>> >>> > wrote:<br>
>> >>> >><br>
>> >>> >> Hello,<br>
>> >>> >><br>
>> >>> >> newRule also needs to have the type, RoutedNomicServer. The<br>
>> >>> >> transformation of RoutedNomicServer into NomicServer is done in the<br>
>> >>> >> handleSite function. Something like this:<br>
>> >>> >><br>
>> >>> >><br>
>> >>> >> nomicSpec :: ServerHandle -> Site Route (ServerPartT IO Response)<br>
>> >>> >> nomicSpec sh =<br>
>> >>> >> Site { handleSite = \f url -> unRouteT (nomicSite sh<br>
>> >>> >> url) f<br>
>> >>> >> ...<br>
>> >>> >><br>
>> >>> >> main =<br>
>> >>> >> do ...<br>
>> >>> >> simpleHTTP nullConf $ siteImpl (nomicSpec sh)<br>
>> >>> >><br>
>> >>> >> Or something like that -- it's hard to tell exactly what is going<br>
>> >>> >> on<br>
>> >>> >> in your app based on the snippets you provided.<br>
>> >>> >><br>
>> >>> >> Also, I highly recommend using digestive functors instead of<br>
>> >>> >> formlets.<br>
>> >>> >> It is the successor to formlets. Same core idea, better<br>
>> >>> >> implementation<br>
>> >>> >> and actively maintained.<br>
>> >>> >><br>
>> >>> >> I have attached a quick demo of using:<br>
>> >>> >><br>
>> >>> >> happstack+digestive-functors+web-routes+HSP<br>
>> >>> >><br>
>> >>> >> To use it you will need the latest happstack from darcs plus:<br>
>> >>> >><br>
>> >>> >> hsp<br>
>> >>> >> web-routes<br>
>> >>> >> web-routes-hsp<br>
>> >>> >> web-routes-happstack<br>
>> >>> >> web-routes-mtl<br>
>> >>> >> digestive-functors<br>
>> >>> >> digestive-functors-hsp<br>
>> >>> >><br>
>> >>> >> I plan to clean up this example and document it better in the crash<br>
>> >>> >> course for the upcoming release. Clearly things like the FormInput<br>
>> >>> >> instance and the formPart function belong a library.<br>
>> >>> >><br>
>> >>> >> let me know if you have more questions.<br>
>> >>> >> - jeremy<br>
>> >>> >><br>
>> >>> >> On Sat, Jan 8, 2011 at 6:44 PM, Corentin Dupont<br>
>> >>> >> <<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>> wrote:<br>
>> >>> >> > Hello,<br>
>> >>> >> ><br>
>> >>> >> > I have difficulties mixing web-routes and forms:<br>
>> >>> >> > I have put routes in all my site, except for forms which remains<br>
>> >>> >> > with<br>
>> >>> >> > the<br>
>> >>> >> > type ServerPartT IO Response.<br>
>> >>> >> > How to make them work together?<br>
>> >>> >> ><br>
>> >>> >> > I have:<br>
>> >>> >> > type NomicServer = ServerPartT IO<br>
>> >>> >> > type RoutedNomicServer = RouteT PlayerCommand NomicServer<br>
>> >>> >> ><br>
>> >>> >> > newRule :: ServerHandle -> NomicServer Response<br>
>> >>> >> > newRule sh = do<br>
>> >>> >> > methodM POST -- only accept a post method<br>
>> >>> >> > mbEntry <- getData -- get the data<br>
>> >>> >> > case mbEntry of<br>
>> >>> >> > Nothing -> error $ "error: newRule"<br>
>> >>> >> > Just (NewRule name text code pn) -> do<br>
>> >>> >> > html <- nomicPageComm pn sh (submitRule name text code<br>
>> >>> >> > pn))<br>
>> >>> >> > ok $ toResponse html<br>
>> >>> >> ><br>
>> >>> >> ><br>
>> >>> >> > nomicPageComm :: PlayerNumber -> ServerHandle -> Comm () -><br>
>> >>> >> > RoutedNomicServer Html<br>
>> >>> >> > nomicPageComm pn sh comm =<br>
>> >>> >> > (..)<br>
>> >>> >> ><br>
>> >>> >> ><br>
>> >>> >> > launchWebServer :: ServerHandle -> IO ()<br>
>> >>> >> > launchWebServer sh = do<br>
>> >>> >> > putStrLn "Starting web server...\nTo connect, drive your<br>
>> >>> >> > browser<br>
>> >>> >> > to<br>
>> >>> >> > \"<a href="http://localhost:8000/Login%5C" target="_blank">http://localhost:8000/Login\</a>""<br>
>> >>> >> > d <- liftIO getDataDir<br>
>> >>> >> > simpleHTTP nullConf $ mconcat [dir "postLogin" $ postLogin,<br>
>> >>> >> > fileServe [] d,<br>
>> >>> >> > dir "Login" $ ok $ toResponse $<br>
>> >>> >> > loginPage,<br>
>> >>> >> > dir "NewRule" $ newRule sh,<br>
>> >>> >> > dir "NewGame" $ newGameWeb sh,<br>
>> >>> >> > dir "Nomic" $ do<br>
>> >>> >> > html <- implSite<br>
>> >>> >> > "<a href="http://localhost:8000/Nomic/" target="_blank">http://localhost:8000/Nomic/</a>" "" (nomicSite sh)<br>
>> >>> >> > ok $ toResponse html<br>
>> >>> >> > ]<br>
>> >>> >> ><br>
>> >>> >> ><br>
>> >>> >> > The red line doesn't compile. I don't know how to transform a<br>
>> >>> >> > RoutedNomicServer into a NomicServer.<br>
>> >>> >> ><br>
>> >>> >> > For the future I intend to use formlets: is these some examples<br>
>> >>> >> > of<br>
>> >>> >> > programs<br>
>> >>> >> > using happstack + web-routes + formlets?<br>
>> >>> >> ><br>
>> >>> >> > Thanks,<br>
>> >>> >> > Corentin<br>
>> >>> >> ><br>
>> >>> >> ><br>
>> >>> >> ><br>
>> >>> >> ><br>
>> >>> >> > On Fri, Jan 7, 2011 at 5:10 PM, Jeremy Shaw<br>
>> >>> >> > <<a href="mailto:jeremy@n-heptane.com">jeremy@n-heptane.com</a>><br>
>> >>> >> > wrote:<br>
>> >>> >> >><br>
>> >>> >> >> Hello,<br>
>> >>> >> >><br>
>> >>> >> >> The [(String, String)] argument is for adding query parameters.<br>
>> >>> >> >><br>
>> >>> >> >> > encodePathInfo ["foo", "bar", "baz"] [("key","value")]<br>
>> >>> >> >><br>
>> >>> >> >> "foo/bar/baz?key=value"<br>
>> >>> >> >><br>
>> >>> >> >> Instead of showURL you would use showURLParams.<br>
>> >>> >> >><br>
>> >>> >> >> hope this helps!d<br>
>> >>> >> >> - jeremy<br>
>> >>> >> >><br>
>> >>> >> >> On Fri, Jan 7, 2011 at 8:12 AM, Corentin Dupont<br>
>> >>> >> >> <<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>> wrote:<br>
>> >>> >> >> > Hello Jeremy,<br>
>> >>> >> >> > I'm using Web routes with happstack.<br>
>> >>> >> >> > I'm following this tutorial:<br>
>> >>> >> >> ><br>
>> >>> >> >> > <a href="http://tutorialpedia.org/tutorials/Happstack+type+safe+URLs.html" target="_blank">http://tutorialpedia.org/tutorials/Happstack+type+safe+URLs.html</a><br>
>> >>> >> >> ><br>
>> >>> >> >> > But It seems out of synch with the latest version of<br>
>> >>> >> >> > web-routes:<br>
>> >>> >> >> > 0.23.2.<br>
>> >>> >> >> > The haddock documentation seems out of date also:<br>
>> >>> >> >> ><br>
>> >>> >> >> > encodePathInfo :: [String] -> [(String, String)] -> String<br>
>> >>> >> >> ><br>
>> >>> >> >> > For example:<br>
>> >>> >> >> ><br>
>> >>> >> >> > encodePathInfo [\"foo\", \"bar\", \"baz\"]<br>
>> >>> >> >> ><br>
>> >>> >> >> > "foo/bar/baz"<br>
>> >>> >> >> ><br>
>> >>> >> >> > And I can't figure out what this [(String, String)] is for ;)<br>
>> >>> >> >> ><br>
>> >>> >> >> > Thanks,<br>
>> >>> >> >> ><br>
>> >>> >> >> > Corentin<br>
>> >>> >> >> ><br>
>> >>> >> ><br>
>> >>> >> ><br>
>> >>> ><br>
>> >>> ><br>
>> >><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br>