From d14718cb3192765fb35f43c560e9bee5d8bba3d7 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Sun, 31 Aug 2008 20:06:53 +0200 Subject: [PATCH] Split menu to left and right part Left is for actions, right is for account --- PciIds/Html/Changes.pm | 16 ++--------- PciIds/Html/Notifications.pm | 5 +--- PciIds/Html/Users.pm | 56 ++++++++---------------------------- PciIds/Html/Util.pm | 37 ++++++++++++++++++------ static/screen.css | 14 ++++----- 5 files changed, 51 insertions(+), 77 deletions(-) diff --git a/PciIds/Html/Changes.pm b/PciIds/Html/Changes.pm index 433a91c..5747354 100644 --- a/PciIds/Html/Changes.pm +++ b/PciIds/Html/Changes.pm @@ -15,10 +15,7 @@ sub genNewItemForm( $$$$$$ ) { return NOT_FOUND unless( $ok ); my $prettyAddr = encode( $address->pretty() ); genHtmlHead( $req, "$prettyAddr - add new item", undef ); - print "
\n"; - print "

$prettyAddr - add new item

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newitem' ], [ 'ID syntax', 'help', $address->helpName() ] ] ); - print "
\n"; + genCustomHead( $req, $args, $address, "$prettyAddr - add new item", [ $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Help', 'help', 'newitem' ], [ 'ID syntax', 'help', $address->helpName() ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); print "
$error
\n" if( defined $error ); print "
hostname().$req->uri().buildExcept( 'action', $args ).'?action=newitem' : '' )."'>\n"; genFormEx( [ [ 'input', 'Id:', 'text', 'id', 'maxlength="50"' ], @@ -66,12 +63,8 @@ sub newItemSubmit( $$$$ ) { my( $result, $comName ) = $tables->submitItem( $data, $auth ); if( $result eq 'exists' ) { genHtmlHead( $req, 'ID collision', undef ); - print "
\n"; - print '

ID collision

'; my $addr = PciIds::Address::new( $req->uri() ); - genCustomMenu( $req, $addr, $args, [ logItem( $auth ), [ 'Add other item', 'newitem' ], $addr->canDiscuss() ? [ 'Discuss', 'newhistory' ] : () ] ); - genPath( $req, $data->{'address'}, 1 ); - print "
\n"; + genCustomHead( $req, $args, $addr, 'ID collision', [ [ 'Add other item', 'newitem' ], $addr->canDiscuss() ? [ 'Discuss', 'newhistory' ] : () ], [ logItem( $auth ) ] ); print '

Sorry, this ID already exists.'; genHtmlTail(); return OK; @@ -92,10 +85,7 @@ sub genNewHistoryForm( $$$$$$ ) { return NOT_FOUND unless( $ok ); my $prettyAddr = encode( $address->pretty() ); genHtmlHead( $req, "$prettyAddr - discuss", undef ); - print "

\n"; - print "

$prettyAddr - discuss

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newhistory' ] ] ); - print "
\n"; + genCustomHead( $req, $args, $address, "$prettyAddr - discuss", [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Help', 'help', 'newhistory' ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); print "
$error
\n" if( defined $error ); print "hostname().$req->uri().buildExcept( 'action', $args ).'?action=newhistory' : '' )."'>\n
"; genFormEx( [ [ 'textarea', 'Text:', undef, 'text', 'rows="5" cols="50"' ], diff --git a/PciIds/Html/Notifications.pm b/PciIds/Html/Notifications.pm index 1d2e105..4e440b7 100644 --- a/PciIds/Html/Notifications.pm +++ b/PciIds/Html/Notifications.pm @@ -11,10 +11,7 @@ sub genNotifForm( $$$$$$ ) { my( $req, $args, $tables, $auth, $error, $data ) = @_; my $addr = PciIds::Address::new( $req->uri() ); genHtmlHead( $req, $addr->pretty().' - notifications', undef ); - print "
\n"; - print "

".$addr->pretty()." - notifications

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), $addr->canAddItem() ? [ 'New item', 'newitem' ] : (), $addr->canDiscuss ? [ 'Discuss', 'newhistory' ] : (), [ 'Profile', 'profile' ], [ 'Help', 'help', 'notifications' ] ] ); - print "
\n"; + genCustomHead( $req, $args, $addr, $addr->pretty()." - notifications", [ $addr->canAddItem() ? [ 'New item', 'newitem' ] : (), $addr->canDiscuss ? [ 'Discuss', 'newhistory' ] : (), [ 'Help', 'help', 'notifications' ] ], [ logItem( $auth ), [ 'Profile', 'profile' ] ] ); print "
$error
\n" if( defined $error ); my $uri = $addr->get(); my $notifs = $tables->notificationsUser( $auth->{'authid'} ); diff --git a/PciIds/Html/Users.pm b/PciIds/Html/Users.pm index 7783f0c..377cb8b 100644 --- a/PciIds/Html/Users.pm +++ b/PciIds/Html/Users.pm @@ -19,10 +19,7 @@ our @EXPORT = qw(&checkLogin ¬LoggedComplaint); sub genRegisterForm( $$$$ ) { my( $req, $args, $error, $values ) = @_; genHtmlHead( $req, 'Register a new user', undef ); - print "
\n"; - print '

Register a new user

'; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Register a new user', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] ); print '
'.$error.'
' if( defined $error ); print '
'; @@ -64,9 +61,7 @@ sub registerSubmit( $$$ ) {#A registration form has been submited "\nThank you\n". "\n(This is an autogenerated email, do not respond to it)" ); genHtmlHead( $req, 'Registration email sent', undef ); - print "
\n"; - print "

Registration email sent

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Registration email sent', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] ); print "
\n"; print '

An email containing further information has been sent to you. @@ -78,10 +73,7 @@ sub registerSubmit( $$$ ) {#A registration form has been submited sub genConfirmForm( $$$$ ) { my( $req, $args, $error, $values ) = @_; genHtmlHead( $req, 'Confirm registration', undef ); - print "

\n"; - print '

Confirm registration

'; - genLocMenu( $req, $args, [ [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Confirm registration', [ [ 'Help', 'help', 'account' ] ], [ [ 'Register', 'register' ] ] ); print '
'.$error.'
' if( defined $error ); print '

Email address: '.encode( $values->{'email'} ); print ''; @@ -99,10 +91,7 @@ sub genConfirmForm( $$$$ ) { sub usedAddress( $$ ) { my( $req, $args ) = @_; genHtmlHead( $req, 'Used address', undef ); - print "

\n"; - print "

Used address

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Reset password', 'respass' ], [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Used address', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ], [ 'Reset password', 'respass' ], [ 'Register', 'register' ] ] ); print '

An account for this address is already registered. @@ -170,10 +159,7 @@ sub confirmSubmit( $$$ ) { return OK; } genHtmlHead( $req, 'Registered', undef ); - print "

\n"; - print "

Registered

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Registered', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] ); print '

You have registered successfully.'; genHtmlTail(); @@ -183,11 +169,8 @@ sub confirmSubmit( $$$ ) { sub genLoginForm( $$$$ ) { my( $req, $args, $error, $values ) = @_; $req->headers_out->add( 'Set-Cookie' => new CGI::Cookie( -name => 'cookie-test', -value => 1 ) ); - genHtmlHead( $req, 'Login', undef ); - print "

\n"; - print '

Login

'; - genLocMenu( $req, $args, [ [ 'Register', 'register' ], [ 'Reset password', 'respass' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genHtmlHead( $req, 'Log in', undef ); + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Log in', [ [ 'Help', 'help', 'account' ] ], [ [ 'Register', 'register' ], [ 'Reset password', 'respass' ] ] ); print '

'.$error.'

' if( defined $error ); print '
'; genForm( [ [ 'Login name or email:', 'text', 'login', 'maxlength="255"' ], @@ -258,10 +241,7 @@ sub notLoggedComplaint( $$$ ) { sub genResetPasswdForm( $$$$ ) { my( $req, $args, $error, $values ) = @_; genHtmlHead( $req, 'Reset password', undef ); - print "
\n"; - print "

Reset password

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ], [ 'Register', 'register' ] ] ); print "

If you forgot your password (or didn't create one yet), you can reset it to a new value here.\n"; print "Provide your email address here and further instructions will be sent to you.\n"; print '

'.$error.'
' if( defined $error ); @@ -297,10 +277,7 @@ sub resetPasswdFormSubmit( $$$ ) { "\n\nThank you\n". "\n(This is an autogenerated email, do not respond to it)" ); genHtmlHead( $req, 'Reset password', undef ); - print "
\n"; - print "

Reset password

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] ); print "

An email with information has been sent to your address.\n"; genHtmlTail(); return OK; @@ -313,10 +290,7 @@ sub resetPasswdFormSubmit( $$$ ) { sub genResetPasswdConfigForm( $$$$$$ ) { my( $req, $args, $error, $values, $email, $hash ) = @_; genHtmlHead( $req, 'Reset password', undef ); - print "

\n"; - print "

Reset password

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] ); print '
'.$error.'
' if( defined $error ); print "

You can enter new password here:\n"; print ' @@ -368,10 +342,7 @@ sub resetPasswdConfirmFormSubmit( $$$ ) { if( defined( $myHash ) && ( $myHash eq $hash ) ) { changePasswd( $tables, $id, $data->{'password'}, $email ); genHtmlHead( $req, 'Reset password', undef ); - print "

\n"; - print "

Reset password

\n"; - genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] ); print "

Your password was successfuly changed.\n"; genHtmlTail(); return OK; @@ -387,10 +358,7 @@ sub genProfileForm( $$$$$$ ) { delete $data->{'current_password'}; delete $data->{'confirm_password'}; delete $data->{'password'}; - print "

\n"; - print "

User profile

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'profile' ] ] ); - print "
\n"; + genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'User profile', [ [ 'Help', 'help', 'profile' ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); print '

'.$error.'

' if defined $error; print "

$info

\n" if defined $info; print '
'; diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index 5c3b2a4..ec6de57 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -7,7 +7,7 @@ use PciIds::Users; use Apache2::Const qw(:common :http); use APR::Table; -our @EXPORT = qw(&genHtmlHead &htmlDiv &genHtmlTail &genTableHead &genTableTail &parseArgs &buildExcept &buildArgs &genMenu &genCustomMenu &encode &setAddrPrefix &HTTPRedirect &genPath &logItem &genLocMenu); +our @EXPORT = qw(&genHtmlHead &htmlDiv &genHtmlTail &genTableHead &genTableTail &parseArgs &buildExcept &buildArgs &genMenu &genCustomMenu &encode &setAddrPrefix &HTTPRedirect &genPath &logItem &genLocMenu &genCustomHead); sub encode( $ ) { return encode_entities( shift, "\"'&<>" ); @@ -47,7 +47,7 @@ sub genCustomMenu( $$$$ ) { } else { $url = '/read/?action='; } - print "\n"; + print "\n"; } sub logItem( $ ) { @@ -70,16 +70,24 @@ sub logItem( $ ) { sub genMenu( $$$$$ ) { my( $req, $address, $args, $auth, $append ) = @_; - my @list = ( logItem( $auth ) ); + my @list; if( defined $address ) { push @list, [ 'Add item', 'newitem' ] if( $address->canAddItem() ); push @list, [ 'Discuss', 'newhistory' ] if( $address->canDiscuss() ); } push @list, [ 'Administrate', 'admin' ] if( hasRight( $auth->{'accrights'}, 'validate' ) ); + push @list, @{$append} if defined $append; + if( @list ) { + print "\n"; + } + @list = ( logItem( $auth ) ); push @list, [ 'Profile', 'profile' ] if defined $auth->{'authid'}; push @list, [ 'Notifications', 'notifications' ] if defined $auth->{'authid'}; - push @list, @{$append} if defined $append; + print "
\n"; genCustomMenu( $req, $address, $args, \@list ); + print "
\n"; } sub genTableHead( $$$ ) { @@ -152,10 +160,21 @@ sub genPath( $$$ ) { print "\n"; } -sub genLocMenu( $$$ ) { - my( $req, $args, $actions ) = @_; - my $addr = PciIds::Address::new( $req->uri() ); - genCustomMenu( $req, $addr, $args, $actions ); +sub genLocMenu( $$$$$ ) { + my( $req, $args, $addr, $lactions, $ractions ) = @_; + print "\n
\n"; + genCustomMenu( $req, $addr, $args, $ractions ); + print "
\n"; +} + +sub genCustomHead( $$$$$$ ) { + my( $req, $args, $addr, $caption, $lactions, $ractions ) = @_; + print "
\n"; + print "

$caption

\n"; + genLocMenu( $req, $args, $addr, $lactions, $ractions ); + print "
\n"; genPath( $req, $addr, 1 ); } diff --git a/static/screen.css b/static/screen.css index 0aa45b0..15595ef 100644 --- a/static/screen.css +++ b/static/screen.css @@ -44,19 +44,19 @@ body padding-left: 5px; padding-right: 5px; } -div.menu +div.lmenu { position: relative; float: left; width: 20%; } -div.navigation-menu +div.rmenu { position: relative; float: right; text-align: right; width: 20%; - margin-right: 1em; + padding-right: 1em; } div.top h1 { @@ -68,15 +68,15 @@ div.clear { clear: both; /* Hack. Wait for all menus to end first. */ } -.menu ul, +.lmenu ul, +.rmenu ul, .navigation ul, -.navigation-menu ul, ul.navigation { list-style-type: none; } -.menu li, -.navigation li +.lmenu li, +.rmenu li { margin-left: -1em; /* Hack. Move the place the bullets would take if they were there back left. */ } -- 2.39.2