changeset 25:c560ec5bf514

More flexibility in placement of login form and other similar stuff
author Adam Chlipala <adam@chlipala.net>
date Thu, 20 Jan 2011 12:23:44 -0500
parents b416b9b9dc38
children ee97bc0e08fa
files src/ur/openidUser.ur src/ur/openidUser.urs tests/utest.ur
diffstat 3 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/ur/openidUser.ur	Mon Jan 17 16:07:24 2011 -0500
+++ b/src/ur/openidUser.ur	Thu Jan 20 12:23:44 2011 -0500
@@ -261,11 +261,10 @@
             cur <- current;
             here <- currentUrl;
             case cur of
-                Some cur => return <xml>Logged in as {[cur]}. <a link={logout ()}>[Log out]</a></xml>
-              | None => return <xml>
-                <form><textbox{#User}/> <submit value="Log In" action={logon (show here)}/></form>
-                <a link={signup (show here)}>Sign up</a>
-              </xml>
+                Some cur => return {Status = <xml>Logged in as {[cur]}.</xml>,
+                                    Other = <xml><a link={logout ()}>Log out</a></xml>}
+              | None => return {Status = <xml><form><textbox{#User}/> <submit value="Log In" action={logon (show here)}/></form></xml>,
+                                Other = <xml><a link={signup (show here)}>Sign up</a></xml>}
         end
 
     task periodic 60 = fn () => dml (DELETE FROM session
--- a/src/ur/openidUser.urs	Mon Jan 17 16:07:24 2011 -0500
+++ b/src/ur/openidUser.urs	Thu Jan 20 12:23:44 2011 -0500
@@ -78,9 +78,12 @@
     val current : transaction (option user)
     (* Figure out which, if any, user is logged in on this connection. *)
 
-    val main : (string -> xbody -> transaction page) -> transaction xbody
+    val main : (string -> xbody -> transaction page) -> transaction {Status : xbody,
+                                                                     Other : xbody}
     (* Pass in your generic page template; get out the HTML snippet for user
      * management, suitable for, e.g., inclusion in your standard page
-     * header. *)
+     * header.  The output gives a "status" chunk, which will either be a login
+     * form or a message about which user is logged in; and an "other" chunk,
+     * which will be a log out or sign up link. *)
 
 end
--- a/tests/utest.ur	Mon Jan 17 16:07:24 2011 -0500
+++ b/tests/utest.ur	Thu Jan 20 12:23:44 2011 -0500
@@ -36,7 +36,8 @@
     return <xml><head>
       <title>{[title]}</title>
     </head><body>
-      {userStuff}
+      {userStuff.Status}<br/>
+      {userStuff.Other}
 
       <h1>{[title]}</h1>