]> mj.ucw.cz Git - pciids.git/commitdiff
Help works
authorMichal Vaner <vorner@ucw.cz>
Sat, 30 Aug 2008 12:18:41 +0000 (14:18 +0200)
committerMichal Vaner <vorner@ucw.cz>
Sat, 30 Aug 2008 12:18:41 +0000 (14:18 +0200)
PciIds/Html/Handler.pm
PciIds/Html/Help.pm
PciIds/Html/List.pm
PciIds/Html/Notifications.pm
PciIds/Html/Util.pm
help/list [new file with mode: 0644]
static/screen.css

index 4392baf2a74d5c2c672075ecd7f820e3d67ff8a0..f490f08b53883004f9cc80b732f841e3bbc37945 100644 (file)
@@ -39,7 +39,8 @@ my %handlers = (
                #Some debug
                'test' => \&PciIds::Html::Debug::test,
                #Notifications
-               'notifications' => \&PciIds::Html::Notifications::notifForm
+               'notifications' => \&PciIds::Html::Notifications::notifForm,
+               'help' => \&PciIds::Html::Help::getHelp
        },
        'POST' => {
                'newitem' => \&PciIds::Html::Changes::newItemSubmit,
@@ -59,7 +60,6 @@ sub handler( $$ ) {
        my( $req, $hasSSL ) = @_;
        return HTTPRedirect( $req, $req->uri()."index.html" ) if( $req->uri() eq '/' );
        return DECLINED if( $req->uri() =~ /^\/((static)\/|robots.txt|index.html)/ );
-       return getHelp( $req ) if( $req->uri() =~ /^\/help/ );
        my $args = parseArgs( $req->args() );
        my $action = $args->{'action'};
        $action = '' unless( defined $action );
index 512f38ed6262cf1e332e615b3ed9a39d46f03f57..803d922ce23eb20c0f5714511e209a44eeb9383e 100644 (file)
@@ -3,21 +3,28 @@ use strict;
 use warnings;
 use PciIds::Startup;
 use PciIds::Html::Util;
+use PciIds::Address;
 use Apache2::Const qw(:common :http);
 use base 'Exporter';
 
 our @EXPORT=qw(getHelp);
 
-sub getHelp($) {
-       my( $req ) = @_;
-       my( $helpname ) = ( $req->uri() =~ /^\/help\/(.*)/ );
-       return NOT_FOUND if( $helpname =~ /[\/.]/ || $helpname eq '' );
+sub getHelp( $$ ) {
+       my( $req, $args, $tables, $auth ) = @_;
+       my $helpname = $args->{'help'};
+       return NOT_FOUND if( !defined $helpname || $helpname =~ /[\/.]/ || $helpname eq '' );
        open HELP, "$directory/help/$helpname" or return NOT_FOUND;
        my $head = <HELP>;
        chomp $head;
        genHtmlHead( $req, $head, undef );
-       print "<h1>$head</h1>\n";
+       my $addr = PciIds::Address::new( $req->uri() );
+       print "<h1>$head (".$addr->pretty().")</h1>\n";
+       genMenu( $req, $addr, $args, $auth, undef );
+       genPath( $req, $addr, 1 );
+       my $url = '/read'.$req->uri().buildExcept( 'help', $args ).'?help=';
+       print "<div class='navigation'><ul><li><a href='$url=index'>Help index</a></ul></div>\n" if( $helpname ne 'index' );
        while( defined( my $line = <HELP> ) ) {
+               $line =~ s/\$CUR_LINK\$/$url/g;
                print $line;
        }
        close HELP;
index 875640b1501a0100ad03df71b9212758ff953f32..02c62c9d23bb6b8fc1e97c4da3316e1683c0257f 100644 (file)
@@ -25,10 +25,10 @@ sub list( $$$$ ) {
        my $id = $address->pretty();
        genHtmlHead( $req, $id, undef );
        print '<h1>'.encode( $id ).'</h1>';
-       genMenu( $req, $address, $args, $auth );
+       genMenu( $req, $address, $args, $auth, 'list' );
+       genPath( $req, $address, 0 );
        print htmlDiv( 'name', '<p>'.encode( $name ) ) if( defined( $name ) );
        print htmlDiv( 'note', '<p>'.encode( $note ) ) if( defined( $note ) );
-       genPath( $req, $address, 0 );
        my $diss = 0;
        my $history;
        foreach $history ( @{$tables->history( $address->get() )} ) {
@@ -53,7 +53,7 @@ sub list( $$$$ ) {
        }
        print "</div>\n" if( $diss );
        unless( $address->leaf() ) {
-               print "<h2>Subitems</h2>\n";
+               print "<h2>Sub-items</h2>\n";
                my $restricts = $address->defaultRestrictList();
                if( scalar @{$restricts} ) {
                        print "<p>";
index 1d5523a3c05d2dac32905d13d3d835d4f3a2e147..b39bc07542d4d132b0ca7e3e8d9765c2a329e1d5 100644 (file)
@@ -29,18 +29,18 @@ sub genNotifForm( $$$$$$ ) {
        }
        print "</ul></div>\n" if( $started );
        print "<form name='notifications' id='notifications' method='POST' action=''>\n";
-       print "<h3>Effect range</h3>\n";
+       print "<h2>Effect range</h2>\n";
        print "<p><input type='checkbox' value='recursive' name='recursive'".( $data->{'recursive'} ? " checked='checked'" : "" )."> Recursive\n";
-       print "<h3>Notification level</h3>\n";
+       print "<h2>Notification level</h2>\n";
        print "<p>\n";
        genRadios( [ [ 'None', '3' ], [ 'Main comment &amp; new subitem', '2' ], [ 'Description', '1' ], [ 'Comment', '0' ] ], 'notification', ( defined $data->{'notification'} ) ? $data->{'notification'} : '3' );
-       print "<h3>Notification way</h3>\n";
+       print "<h2>Notification way</h2>\n";
        print "<p>\n";
        genRadios( [ [ 'Email', '0' ], [ 'Xmpp', '1' ], [ 'Both', '2' ] ], 'way', ( defined $data->{'way'} ) ? $data->{'way'} : '0' );
        print "<p><input type='submit' value='Submit' name='submit'>\n";
        print "</form>\n";
        if( @{$notifs} ) {
-               print "<div class='navigation'><h3>All notifications</h3><ul>\n";
+               print "<div class='navigation'><h2>All notifications</h2><ul>\n";
                foreach( @{$notifs} ) {
                        my( $location ) = @{$_};
                        print "<li><a href='/$location".buildArgs( $args )."'>".PciIds::Address::new( $location )->pretty()."</a>\n";
index a21d38363a451d77afc5d4d1b4a8a27842a28343..02f1a42db54eb72d475baba4a130cecbb38189f1 100644 (file)
@@ -34,9 +34,9 @@ sub htmlDiv( $$ ) {
        return '<div class="'.$class.'">'.$text.'</div>';
 }
 
-sub item( $$$ ) {
-       my( $url, $label, $action ) = @_;
-       print "  <li><a href='".$url.$action."'>$label</a>\n";
+sub item( $$ ) {
+       my( $url, $label ) = @_;
+       print "  <li><a href='".$url."'>$label</a>\n";
 }
 
 sub genCustomMenu( $$$$ ) {
@@ -44,10 +44,12 @@ sub genCustomMenu( $$$$ ) {
        my $url = '/'.$address->get().buildExcept( 'action', $args ).'?action=';
        print "<div class='menu'>\n<ul>\n";
        foreach( @{$list} ) {
-               my( $label, $action ) = @{$_};
+               my( $label, $action, $param ) = @{$_};
                my $prefix = '/mods';
-               $prefix = '/read' if( !defined( $action ) or ( $action eq 'list' ) or ( $action eq '' ) );
-               item( 'http://'.$req->hostname().$prefix.$url, $label, $action );
+               $prefix = '/read' if( !defined( $action ) or ( $action eq 'list' ) or ( $action eq '' ) or ( $action eq 'help' ) );
+               my $suffix = '';
+               $suffix = '?help='.$param if( $action eq 'help' );
+               item( 'http://'.$req->hostname().$prefix.$url.$action.$suffix, $label );
        }
        print "</ul></div>\n";
 }
@@ -61,14 +63,15 @@ sub logItem( $ ) {
        }
 }
 
-sub genMenu( $$$$ ) {
-       my( $req, $address, $args, $auth ) = @_;
+sub genMenu( $$$$$ ) {
+       my( $req, $address, $args, $auth, $help ) = @_;
        my @list = ( logItem( $auth ) );
        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, [ 'Profile', 'profile' ] if defined $auth->{'authid'};
        push @list, [ 'Notifications', 'notifications' ] if defined $auth->{'authid'};
+       push @list, [ 'Help', 'help', $help ] if defined $help;
        genCustomMenu( $req, $address, $args, \@list );
 }
 
diff --git a/help/list b/help/list
new file mode 100644 (file)
index 0000000..b09d02c
--- /dev/null
+++ b/help/list
@@ -0,0 +1,48 @@
+Browsing ID list
+<p>
+You can examine the current list of IDs.
+The IDs are organized into a tree.
+<h2>Page anatomy</h2>
+<p>
+Page is divided into parts:
+<ul>
+       <li><strong>Menu</strong> ‒ you can perform actions, both in connection with current item (like <a href='$CUR_LINK$newitem'>adding a new sub-item</a>) and global (<a href='$CUR_LINK$profile'>editing your profile</a>).
+       <li><strong>Hierarchy</strong> ‒ lists all parental items.
+       <li><strong>Discussion</strong> ‒ contains history of suggested names, notes and general talk about current item.
+       <li><strong>List of sub-items</strong> ‒ all direct sub-items are listed here and you can browse into them.
+</ul>
+
+You can find menu and hierarchy in most other pages and they have the same function.
+
+<h2>Colors</h2>
+Colors are used both in discussion and list of sub-items to mark status of discussion comments and sub-items respectively.
+<span class='main-history'>Green entries</span> are discussion comments which provide current item name.
+<span class='unseen-history'>Grey ones</span> are entries with some problem. They are either items without any assigned name (discussion about non-existing item, new item which was not yet approved by an admin) or discussion comments not yet seen by an admin.
+<span class='history'>White ones</span> are the rest, usual discussion and valid items.
+
+<h2>Example</h2>
+<div class='help-example'>
+<h1>ID 0000</h1>
+<div class='menu'><ul>
+       <li><a href='$CUR_LINK$account'>Log in</a>
+       <li><a href='$CUR_LINK$newitem'>Add item</a>
+       <li><a href='$CUR_LINK$newhistory'>Discuss</a>
+</ul></div>
+<div class='navigation'><ul>
+       <li><a href='$CUR_LINK$index'>Parent</a>
+</div>
+<div class='name'><p>ID name</div>
+<div class='discussion'><h2>Discussion</h2>
+<div class='main-history'>
+       <p class='itemname'>Name: ID name
+       <p class='discussion-text'>This item is here just as an example.
+       <p class='author'>Author
+       <p class='time'>1900-01-01 00:00
+</div>
+</div>
+<h2>Sub-items</h2>
+<table class='subnodes'><col class='id-col'><col class='name-col'><col class='note-col'>
+<th>Id<th>Name<th>Note
+<tr class='item'><td>1234<td>Sub-item<td>This is just example
+</table>
+</div>
index aba046a3d3d2fe99f84c5dd5c15fc134a79b7c1c..56018c6cc3ba44a8e6d60594a4898e3ad17dad27 100644 (file)
@@ -15,6 +15,11 @@ body
 {
        background: #DDFFDD;
 }
+.help-example
+{
+       background: #BBBBFF;
+       padding: 0.3em;
+}
 .itemname, .name
 {
        font-weight: bold;