Anonymous avatar Anonymous committed 4f37a01

Displaying proper Login/Logout links in the top-right menu.
* * *
Changing effect for displaying openid box.

Comments (0)

Files changed (3)

src/redhot2_common.erl

 -include_lib ("nitrogen/include/wf.hrl").
 
 -export([title/0
+         , event/1
          , header/0
          , header/1
          , footer/0
 title() ->
     "RedHotErlang".
 
+event(login) ->
+    wf:wire(openid_box_id(), #appear { speed=5000 });
+event(Event) ->
+    io:format("~p: Event=~p~n",[?MODULE,Event]),
+    ok.
 
 right() ->
     #panel { class=right, body=[] }.
     header(none).
 
 header(Selected) ->
-    lists:member(Selected,[home,twitter,logout,new,about]) andalso
+    lists:member(Selected,[home,twitter,login,logout,new,about]) andalso
         wf:wire(Selected, #add_class { class=selected }),
     #panel { body = [#image{image="/images/chili-small.png", 
                             class="chili_logo"},                     
     #panel { class=menu, 
              body=[#link { id=home,    url='/',           text="Home" },
                    #link { id=projects,url='/projects',   text="Projects" },
-                   #link { id=logout,  url="/logout?"++P, text="Logout" },
+                   login_logout(P),
                    #link { id=new,     url='/new',        text="New" },
                    #link { id=about,   url='/about',      text="About" }
                   ]}.
 
+
+login_logout(Path) ->
+    login_logout(Path, wf:session(authenticated)).
+
+login_logout(Path, true) ->
+    #link { id=logout, url="/logout?"++Path, text="Logout" };
+login_logout(_,_) ->
+    #link { id=login, url="#", text="Login", postback=login, delegate=?MODULE }.
+
+
+openid_box_id() ->
+    openid_box_id.
+
 openid_box() ->
     case wf:session(authenticated) of
         true ->
-            #panel { class = "openid_box",
-                     body = [wf:user()]};
+            #panel { class = "show_openid_box",
+                     id    = openid_box_id(),
+                     body  = [wf:user()]};
         _ ->
             Id = claimed_id,
-            #panel { class = "openid_box",
-                     body = [#textbox{ class    = "openid_login", 
-                                       id       = Id,
-                                       postback = {Id,raw_path()},
-                                       delegate = ?INDEX_PAGE}]}
+            #panel { class = "hide_openid_box",
+                     id    = openid_box_id(),
+                     body  = [#textbox{ class    = "openid_login", 
+                                        id       = Id,
+                                        postback = {Id,raw_path()},
+                                        delegate = ?INDEX_PAGE}]}
     end.
 
+
 logo_text() ->
     "<span class='big'>R</span>ed<span class='big'>H</span>ot<span class='big'>E</span>rlang".
 

www/css/digitalchili.css

 /*
  * OpenID box
  */
-.openid_box {margin:25px 0px -25px 0px; padding-left:5px;}
+.hide_openid_box {display:none; margin:25px 0px -25px 0px; padding-left:5px;}
+.show_openid_box {margin:25px 0px -25px 0px; padding-left:5px;}
 input.openid_login {
    background: url(http://openid.net/login-bg.gif) no-repeat;
    background-color: #fff;

www/css/redhot2.css

-/***** CSS RESET *****/
-html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outline:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}
-
-/***** GRID *****/
-
-div.header {
-    margin: 0px;
-    padding: 0px;
-    margin-bottom: 1.0em;
-}
-
-.grid {
-    font-size: 1em; /* 13px */
-    line-height: 2em; /* 26px */
-    margin: 1em 0em;
-}
-
-.pad_right {
-    padding-right: 20px;
-}
-
-/***** STYLE *****/
-
-body { 
-    font-family: "Lucida Grande","Segoe UI","Trebuchet MS",Tahoma,Helvetica,Arial,sans-serif; 
-    font-size: 13px;
-    line-height: 1.5385em;
-    color: #222;
-}
-
-/***** MENU *****/
-
-
-.menu { 
-    color: #888;
-    background-color: #dfe2ea;
-    text-align: center;
-    font-size: 12px;
-    line-height: 12px;
-    padding: 8px;
-}
-
-.menu a {
-    color: #888;
-    padding: 3px 0px;
-    margin: 0px 10px;
-}
-
-.menu a:HOVER {
-    color: #FC2752;
-    text-decoration: none;
-}
-
-.menu a.selected {
-    color: #000;
-    background-color: #dfe2ea;
-    border-bottom: solid 3px #FC2752;
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.