]> mj.ucw.cz Git - pciids.git/commitdiff
Split menu to left and right part
authorMichal Vaner <vorner@ucw.cz>
Sun, 31 Aug 2008 18:06:53 +0000 (20:06 +0200)
committerMichal Vaner <vorner@ucw.cz>
Sun, 31 Aug 2008 18:06:53 +0000 (20:06 +0200)
Left is for actions, right is for account

PciIds/Html/Changes.pm
PciIds/Html/Notifications.pm
PciIds/Html/Users.pm
PciIds/Html/Util.pm
static/screen.css

index 433a91c9390563391d444eead4af37f8558ff8ba..57473544d65015e33f36402dbb3d2d146a8173dd 100644 (file)
@@ -15,10 +15,7 @@ sub genNewItemForm( $$$$$$ ) {
        return NOT_FOUND unless( $ok );
        my $prettyAddr = encode( $address->pretty() );
        genHtmlHead( $req, "$prettyAddr - add new item", undef );
-       print "<div class='top'>\n";
-       print "<h1>$prettyAddr - add new item</h1>\n";
-       genLocMenu( $req, $args, [ logItem( $auth ), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newitem' ], [ 'ID syntax', 'help', $address->helpName() ] ] );
-       print "<div class='clear'></div></div>\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 "<div class='error'>$error</div>\n" if( defined $error );
        print "<form name='newitem' id='newitem' method='POST' action='".( $args->{'full_links'} ? 'http://'.$req->hostname().$req->uri().buildExcept( 'action', $args ).'?action=newitem' : '' )."'>\n<table>";
        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 "<div class='top'>\n";
-                       print '<h1>ID collision</h1>';
                        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 "<div class='clear'></div></div>\n";
+                       genCustomHead( $req, $args, $addr, 'ID collision', [ [ 'Add other item', 'newitem' ], $addr->canDiscuss() ? [ 'Discuss', 'newhistory' ] : () ], [ logItem( $auth ) ] );
                        print '<p>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 "<div class='top'>\n";
-       print "<h1>$prettyAddr - discuss</h1>\n";
-       genLocMenu( $req, $args, [ logItem( $auth ), $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newhistory' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, $address, "$prettyAddr - discuss", [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Help', 'help', 'newhistory' ] ], [ logItem( $auth ),  [ 'Notifications', 'notifications' ] ] );
        print "<div class='error'>$error</div>\n" if( defined $error );
        print "<form name='newhistory' id='newhistory' method='POST' action='".( $args->{'full_links'} ? 'http://'.$req->hostname().$req->uri().buildExcept( 'action', $args ).'?action=newhistory' : '' )."'>\n<table>";
        genFormEx( [ [ 'textarea', 'Text:', undef, 'text', 'rows="5" cols="50"' ],
index 1d2e105ef1bf25c19c374165a07a67bef8433481..4e440b7ea208b76f104d70a62afb052cbdac579a 100644 (file)
@@ -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 "<div class='top'>\n";
-       print "<h1>".$addr->pretty()." - notifications</h1>\n";
-       genLocMenu( $req, $args, [ logItem( $auth ), $addr->canAddItem() ? [ 'New item', 'newitem' ] : (), $addr->canDiscuss ? [ 'Discuss', 'newhistory' ] : (), [ 'Profile', 'profile' ], [ 'Help', 'help', 'notifications' ] ] );
-       print "<div class='clear'></div></div>\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 "<div class='error'>$error</div>\n" if( defined $error );
        my $uri = $addr->get();
        my $notifs = $tables->notificationsUser( $auth->{'authid'} );
index 7783f0c04ab2e988a4893356c9a8c844975b22a1..377cb8b601e47b5be005b8ba59f5a5d5131d549d 100644 (file)
@@ -19,10 +19,7 @@ our @EXPORT = qw(&checkLogin &notLoggedComplaint);
 sub genRegisterForm( $$$$ ) {
        my( $req, $args, $error, $values ) = @_;
        genHtmlHead( $req, 'Register a new user', undef );
-       print "<div class='top'>\n";
-       print '<h1>Register a new user</h1>';
-       genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Register a new user', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] );
        print '<div class="error">'.$error.'</div>' if( defined $error );
        print '<form name="register" id="register" method="POST" action="">
                <table>';
@@ -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 "<div class='top'>\n";
-       print "<h1>Registration email sent</h1>\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 "<div class='clear'></div></div>\n";
        print '<p>
                        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 "<div class='top'>\n";
-       print '<h1>Confirm registration</h1>';
-       genLocMenu( $req, $args, [ [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Confirm registration', [ [ 'Help', 'help', 'account' ] ], [ [ 'Register', 'register' ] ] );
        print '<div class="error">'.$error.'</div>' if( defined $error );
        print '<p>Email address: '.encode( $values->{'email'} );
        print '<form name="register-confirm" id="register-confirm" method="POST" action="">';
@@ -99,10 +91,7 @@ sub genConfirmForm( $$$$ ) {
 sub usedAddress( $$ ) {
        my( $req, $args ) = @_;
        genHtmlHead( $req, 'Used address', undef );
-       print "<div class='top'>\n";
-       print "<h1>Used address</h1>\n";
-       genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Reset password', 'respass' ], [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Used address', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ], [ 'Reset password', 'respass' ], [ 'Register', 'register' ] ] );
        print '<div class="error">
                <p>
                        An account for this address is already registered.
@@ -170,10 +159,7 @@ sub confirmSubmit( $$$ ) {
                return OK;
        }
        genHtmlHead( $req, 'Registered', undef );
-       print "<div class='top'>\n";
-       print "<h1>Registered</h1>\n";
-       genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Registered', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] );
        print '<p>
                        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 "<div class='top'>\n";
-       print '<h1>Login</h1>';
-       genLocMenu( $req, $args, [ [ 'Register', 'register' ], [ 'Reset password', 'respass' ], [ 'Help', 'help', 'account' ] ] );
-       print "<div class='clear'></div></div>\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 '<div class="error"><p>'.$error.'</div>' if( defined $error );
        print '<form name="login" id="login" method="POST" action="'.setAddrPrefix( $req->uri(), 'mods' ).buildExcept( 'action', $args ).'?action=login"><table>';
        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 "<div class='top'>\n";
-       print "<h1>Reset password</h1>\n";
-       genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Register', 'register' ], [ 'Help', 'help', 'account' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ], [ 'Register', 'register' ] ] );
        print "<p>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 '<div class="error">'.$error.'</div>' 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 "<div class='top'>\n";
-               print "<h1>Reset password</h1>\n";
-               genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] );
-               print "<div class='clear'></div></div>\n";
+               genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] );
                print "<p>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 "<div class='top'>\n";
-       print "<h1>Reset password</h1>\n";
-       genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] );
        print '<div class="error">'.$error.'</div>' if( defined $error );
        print "<p>You can enter new password here:\n";
        print '<form name="respass-confirm" id="respass-confirm" method="POST" action="">
@@ -368,10 +342,7 @@ sub resetPasswdConfirmFormSubmit( $$$ ) {
                if( defined( $myHash ) && ( $myHash eq $hash ) ) {
                        changePasswd( $tables, $id, $data->{'password'}, $email );
                        genHtmlHead( $req, 'Reset password', undef );
-                       print "<div class='top'>\n";
-                       print "<h1>Reset password</h1>\n";
-                       genLocMenu( $req, $args, [ [ 'Log in', 'login' ], [ 'Help', 'help', 'account' ] ] );
-                       print "<div class='clear'></div></div>\n";
+                       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'Reset password', [ [ 'Help', 'help', 'account' ] ], [ [ 'Log in', 'login' ] ] );
                        print "<p>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 "<div class='top'>\n";
-       print "<h1>User profile</h1>\n";
-       genLocMenu( $req, $args, [ logItem( $auth ), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'profile' ] ] );
-       print "<div class='clear'></div></div>\n";
+       genCustomHead( $req, $args, PciIds::Address::new( $req->uri() ), 'User profile', [ [ 'Help', 'help', 'profile' ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] );
        print '<div class="error"><p>'.$error.'</div>' if defined $error;
        print "<div class='info'><p>$info</div>\n" if defined $info;
        print '<form name="profile" id="profile" method="POST" action=""><table>';
index 5c3b2a4ecd123bafc708e60ac0495274f7a1f112..ec6de57650f3ce50dd40c91f50375410dce652da 100644 (file)
@@ -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 "<div class='menu'>\n<ul>\n";
+       print "<ul>\n";
        foreach( @{$list} ) {
                my( $label, $action, $param ) = @{$_};
                my $prefix = '/mods';
@@ -56,7 +56,7 @@ sub genCustomMenu( $$$$ ) {
                $suffix = '?help='.$param if( $action eq 'help' );
                item( 'http://'.$req->hostname().$prefix.$url.$action.$suffix, $label );
        }
-       print "</ul></div>\n";
+       print "</ul>\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 "<div class='lmenu'>\n";
+               genCustomMenu( $req, $address, $args, \@list );
+               print "</div>\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 "<div class='rmenu'>\n";
        genCustomMenu( $req, $address, $args, \@list );
+       print "</div>\n";
 }
 
 sub genTableHead( $$$ ) {
@@ -152,10 +160,21 @@ sub genPath( $$$ ) {
        print "</div>\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 "<div class='lmenu'>\n";
+       genCustomMenu( $req, $addr, $args, $lactions );
+       print "</div>\n<div class='rmenu'>\n";
+       genCustomMenu( $req, $addr, $args, $ractions );
+       print "</div>\n";
+}
+
+sub genCustomHead( $$$$$$ ) {
+       my( $req, $args, $addr, $caption, $lactions, $ractions ) = @_;
+       print "<div class='top'>\n";
+       print "<h1>$caption</h1>\n";
+       genLocMenu( $req, $args, $addr, $lactions, $ractions );
+       print "<div class='clear'></div></div>\n";
        genPath( $req, $addr, 1 );
 }
 
index 0aa45b0e1243461f026f8c9f34fb63fb2806f1c6..15595ef9d0d08e95d79bea15c410fd7df00a34dd 100644 (file)
@@ -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. */
 }