From a60a6817d968c50d06958d4010cee84afbb58502 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 22 May 2009 15:23:33 -0400 Subject: [PATCH] Log in/log out links. 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 | 110 +++------------------------- perl-lib/PgCommitFest/DB.pm | 4 +- perl-lib/PgCommitFest/Handler.pm | 14 +++- perl-lib/PgCommitFest/Request.pm | 1 + template/header.tt2 | 21 ++++-- 5 files changed, 40 insertions(+), 110 deletions(-) diff --git a/html/layout/css/blue/commitfest.css b/html/layout/css/blue/commitfest.css index 5a7df94..e23729e 100644 --- a/html/layout/css/blue/commitfest.css +++ b/html/layout/css/blue/commitfest.css @@ -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 } diff --git a/perl-lib/PgCommitFest/DB.pm b/perl-lib/PgCommitFest/DB.pm index c0d4e49..0cd3b7d 100644 --- a/perl-lib/PgCommitFest/DB.pm +++ b/perl-lib/PgCommitFest/DB.pm @@ -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; } } diff --git a/perl-lib/PgCommitFest/Handler.pm b/perl-lib/PgCommitFest/Handler.pm index 72b0c4f..b2a32ad 100644 --- a/perl-lib/PgCommitFest/Handler.pm +++ b/perl-lib/PgCommitFest/Handler.pm @@ -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; diff --git a/perl-lib/PgCommitFest/Request.pm b/perl-lib/PgCommitFest/Request.pm index 7f99b2e..7e3e878 100644 --- a/perl-lib/PgCommitFest/Request.pm +++ b/perl-lib/PgCommitFest/Request.pm @@ -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'}, diff --git a/template/header.tt2 b/template/header.tt2 index aee22b4..561259c 100644 --- a/template/header.tt2 +++ b/template/header.tt2 @@ -2,16 +2,25 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - PostgreSQL CommitFest Management[% IF title != '' %]: [% title %][% END %] + PostgreSQL CommitFest Management[% IF title != '' %]: [% title | htmlsafe %][% END %] -
- -
+ + + + + +
+ + + [% IF authenticate.username.defined %]Welcome, [% authenticate.username | htmlsafe %] - Log Out + [% ELSE %]Log In + [% END %] +
-- 2.30.2