Log in/log out links.
authorRobert Haas <[email protected]>
Fri, 22 May 2009 19:23:33 +0000 (15:23 -0400)
committerRobert Haas <[email protected]>
Fri, 22 May 2009 19:23:33 +0000 (15:23 -0400)
In passing, fix a wrong identifier in PgCommitFest::DB::delete, fix session
cookie path in PgCommitFest::Handler::login and remove an unnecessary trace
setting, and rip out some superfluous CSS code.

html/layout/css/blue/commitfest.css
perl-lib/PgCommitFest/DB.pm
perl-lib/PgCommitFest/Handler.pm
perl-lib/PgCommitFest/Request.pm
template/header.tt2

index 5a7df94af858ef1bbbf1810b5c5a3a37876b3eb1..e23729e82e4d3fe3861924abedf7e1573c63cd7d 100644 (file)
@@ -27,7 +27,11 @@ body {
   height: 83px;
   margin: 0px;
   padding: 0px;
-  display: block;
+  width: 100%
+}
+
+#commitfestHeader tr {
+  vertical-align: top
 }
 
 #commitfestHeaderLogo {
@@ -42,76 +46,14 @@ body {
 
 #commitfestHeaderLogo img { border: 0px; }
 
-#commitfestNavSearchContainer {
-  padding-bottom: 2px;
-}
-
 #commitfestNav {
   position: relative;
-  text-align: left;
+  text-align: right;
   margin-left: 10px;
   margin-top: 5px;
-  color: #666;
-  font-size: 0.95em;
-}
-
-#commitfestSearch {
-  position: relative;
-  text-align: right;
-  padding: 0;
-  margin: 0;
-  color: #666;
-}
-
-#commitfestTextSize {
-  text-align: right;
-  white-space: nowrap;
-  margin-top: 7px;
-  font-size: 0.95em;
-}
-
-#commitfestSearch form {
-       position: relative;
-       top: 5px;
-       right: 0;
-       margin: 0; /* need for IE Mac */
-       text-align: right; /* need for IE Mac */
-       white-space: nowrap; /* for Opera */
-}
-
-#commitfestSearch form label { color: #666; font-size: 0.95em; }
-#commitfestSearch form input { font-size: 0.95em; }
-       
-#commitfestSearch form #submit {
-       font-size: 0.95em;
-       background: #7A7A7A;
-       color: #fff;
-       border-right: 1px solid #7A7A7A;
-       border-bottom: 1px solid #7A7A7A;
-       border-top: 1px solid #7A7A7A;
-       border-left: 1px solid #7A7A7A;
-       padding: 1px 4px;
-}
-       
-#commitfestSearch form #q {
-       width: 170px;
-       font-size: 0.95em;
-       border: 1px solid #7A7A7A;
-       background: #E1E1E1;
-        color: #000000;
-       padding: 2px;
-}
-
-.frmDocSearch {
-  padding: 0;
-  margin: 0;
-  display: inline;
-}
-
-.inpDocSearch {
-  padding: 0;
-  margin: 0;
-  color: #000;
+  color: #fff;
+  font-weight: bold;
+  font-size: 0.95em
 }
 
 #commitfestContent {
@@ -130,16 +72,6 @@ body {
   margin-right: 10px;
 }
 
-#commitfestComments {
-  margin-top: 10px;
-}
-
-#commitfestClear {
-  clear: both;
-  margin: 0;
-  padding: 0;
-}
-
 /* Heading Definitions */
 
 h1 {
@@ -170,32 +102,10 @@ p, ol, ul, li {
   line-height: 1.5em;
 }
 
-.txtCommentsWrap {
-  border: 2px solid #F5F5F5; 
-  width: 100%;
-}
-
-.txtCommentsContent {
-  background: #F5F5F5;
-  padding: 3px;
-}
-
-.txtCommentsPoster {
-  float: left;
-}
-
-.txtCommentsDate {
-  float: right;
-}
-
-.txtCommentsComment {
-  padding: 3px;
-}
-
 /* Link Styles */
 
 #commitfestNav a {
-  font-weight: bold;
+  color: #ffffff
 }
 
 
index c0d4e49dfa81e02c9874ac33c1f7aff0ac4de5c8..0cd3b7d483f5802e288921bcea105ec1136dc9fa 100644 (file)
@@ -26,11 +26,11 @@ sub delete {
        while (my ($k, $v) = each %$criteria) {
                if (ref $v) {
                        push @where,
-                               $self->{'dbh'}->quote_identifier($table) . ' = ' . $$v;
+                               $self->{'dbh'}->quote_identifier($k) . ' = ' . $$v;
                }
                else {
                        push @where,
-                               $self->{'dbh'}->quote_identifier($table) . ' = ?';
+                               $self->{'dbh'}->quote_identifier($k) . ' = ?';
                        push @bind, $v;
                }
        }
index 72b0c4fa430c53847b856e2bfd08b99628f3e336..b2a32ad20a4396a396dab81ba9e7744d628a0a68 100644 (file)
@@ -109,11 +109,10 @@ EOM
                        sysread(RANDOM_BITS, $random_bits, 16);
                        close(RANDOM_BITS);
                        my $session_cookie = unpack("H*", $random_bits);
-                       $r->db->{'trace'} = 1;
                        $r->db->insert('session', { 'id' => $session_cookie,
                                'username' => $u->{'username'} });
                        $r->db->commit;
-                       $r->header('Set-Cookie', "session=$session_cookie");
+                       $r->header('Set-Cookie', "session=$session_cookie; path=/");
                        $r->redirect($value{'uri'} ne '' ? $value{'uri'} : '/');
                }
                else {
@@ -125,4 +124,15 @@ EOM
        $r->render_template('login');
 }
 
+sub logout {
+       my ($r) = @_;
+       $r->header('Set-Cookie', "session=; path=/");
+       my $session = $r->cookie('session');
+       if (defined $r->cookie('session')) {
+               $r->db->delete('session', { 'id' => $r->cookie('session') });
+               $r->db->commit();
+       }
+       $r->redirect('/');
+}
+
 1;
index 7f99b2ecaba7aac5807045f75397f8dd6710a72e..7e3e87839a76a90932631593dde276609b194d00 100644 (file)
@@ -170,6 +170,7 @@ sub render_template {
        %stash = %$vars if defined $vars;
        $stash{'control'} = $self->{'control'};
        $template->process('header.tt2', {
+               'authenticate' => $self->authenticate(),
                'link' => $self->{'link'},
                'title' => $self->{'title'},
                'error_list' => $self->{'error_list'},
index aee22b4d260f7599ce3074b0e69a18f9360a99d3..561259c61f73b86b138a4d58abb98ac7a4f0285d 100644 (file)
@@ -2,16 +2,25 @@
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" dir="ltr">
 <head>
-  <title>PostgreSQL CommitFest Management[% IF title != '' %]: [% title %][% END %]</title>
+  <title>PostgreSQL CommitFest Management[% IF title != '' %]: [% title | htmlsafe %][% END %]</title>
     <style type="text/css" media="screen" title="Normal Text">@import url("/layout/css/blue/commitfest.css");</style>
     <script type="text/javascript" src="/layout/js/geckostyle.js"></script>
 </head>
 <body>
-<div id="commitfestHeader">
-       <div id="commitfestHeaderLogo">
-               <a href="/" title="PostgreSQL"><img src="/layout/images/docs/hdr_logo.png" width="206" height="80" alt="PostgreSQL" /></a>
-       </div>
-</div>
+<table id="commitfestHeader">
+  <tr>
+    <td>
+      <div id="commitfestHeaderLogo">
+        <a href="/" title="PostgreSQL"><img src="/layout/images/docs/hdr_logo.png" width="206" height="80" alt="PostgreSQL" /></a>
+      </div>
+    </td>
+    <td id="commitfestNav">
+       [% IF authenticate.username.defined %]Welcome, [% authenticate.username | htmlsafe %] - <a href='/action/logout'>Log Out</a>
+       [% ELSE %]<a href='/action/login'>Log In</a>
+       [% END %]
+    </td>
+  </tr>
+</table>
 
 <div id="commitfestContent">
        <table cellspacing='0' cellpadding='0' border='0' width='100%'>