]> mj.ucw.cz Git - pciids.git/commitdiff
Help index
authorMichal Vaner <vorner@ucw.cz>
Sat, 30 Aug 2008 15:07:24 +0000 (17:07 +0200)
committerMichal Vaner <vorner@ucw.cz>
Sat, 30 Aug 2008 15:07:24 +0000 (17:07 +0200)
PciIds/Html/Handler.pm
PciIds/Html/Help.pm
PciIds/Html/Util.pm
help/index [new file with mode: 0644]
index.html

index f490f08b53883004f9cc80b732f841e3bbc37945..879086a26c4632175eb5127fc8eab119edbff926 100644 (file)
@@ -58,9 +58,9 @@ my %handlers = (
 
 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)/ );
        my $args = parseArgs( $req->args() );
+       return HTTPRedirect( $req, $req->uri()."index.html" ) if( $req->uri() eq '/' && ( !defined $args->{'action'} || $args->{'action'} ne 'help' ) );
+       return DECLINED if( $req->uri() =~ /^\/((static)\/|robots.txt|index.html)/ );
        my $action = $args->{'action'};
        $action = '' unless( defined $action );
        my $method = $handlers{$req->method()};
index 8c65bad4ba759f86d2a0cf089ed11534bbdff345..3f869c33c459efd2eaf7e2cd5bf67660bed86ff4 100644 (file)
@@ -18,7 +18,7 @@ sub getHelp( $$ ) {
        chomp $head;
        genHtmlHead( $req, $head, undef );
        my $addr = PciIds::Address::new( $req->uri() );
-       print "<h1>$head (".$addr->pretty().")</h1>\n";
+       print "<h1>$head".( defined $addr ? "(".$addr->pretty().")" : "" )."</h1>\n";
        genMenu( $req, $addr, $args, $auth, undef );
        genPath( $req, $addr, 1 );
        my $url = setAddrPrefix( $req->uri(), 'read' ).buildExcept( 'help', $args ).'?help=';
index 02f1a42db54eb72d475baba4a130cecbb38189f1..37538f3151eb590e3ebf62e38bc3166cea0f9941 100644 (file)
@@ -41,7 +41,12 @@ sub item( $$ ) {
 
 sub genCustomMenu( $$$$ ) {
        my( $req, $address, $args, $list ) = @_;
-       my $url = '/'.$address->get().buildExcept( 'action', $args ).'?action=';
+       my $url;
+       if( defined $address ) {
+               $url = '/'.$address->get().buildExcept( 'action', $args ).'?action=';
+       } else {
+               $url = '/read/?action=';
+       }
        print "<div class='menu'>\n<ul>\n";
        foreach( @{$list} ) {
                my( $label, $action, $param ) = @{$_};
@@ -66,8 +71,10 @@ sub logItem( $ ) {
 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() );
+       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, [ 'Profile', 'profile' ] if defined $auth->{'authid'};
        push @list, [ 'Notifications', 'notifications' ] if defined $auth->{'authid'};
@@ -129,8 +136,13 @@ sub HTTPRedirect( $$ ) {
 
 sub genPath( $$$ ) {
        my( $req, $address, $printAddr ) = @_;
-       my $path = $address->path();
-       unshift @{$path}, $address if( $printAddr );
+       my $path;
+       if( defined $address ) {
+               $path = $address->path();
+               unshift @{$path}, $address if( $printAddr );
+       } else {
+               $path = [];
+       }
        print "<div class='navigation'><ul>\n";
        foreach my $addr ( @{$path} ) {
                print "  <li><a href='http://".$req->hostname()."/read/".$addr->get()."/'>".encode( $addr->pretty() )."</a>\n";
diff --git a/help/index b/help/index
new file mode 100644 (file)
index 0000000..069d669
--- /dev/null
@@ -0,0 +1,21 @@
+Help index
+<h2>Read only operations<h2>
+<ul class='navigation'>
+       <li><a href='$HELP_URL$list'>Browsing</a>
+</ul>
+<h2>Account based operations</h2>
+<ul class='navigation'>
+       <li><a href='$HELP_URL$account'>Account creation &amp; login</a>
+       <li><a href='$HELP_URL$notifications'>Notifications</a>
+       <li><a href='$HELP_URL$profile'>Profile</a>
+</ul>
+<h2>Editing database</h2>
+<ul class='navigation'>
+       <li><a href='$HELP_URL$newitem'>Submitting new item</a>
+       <li><a href='$HELP_URL$newhistory'>Discussion</a>
+</ul>
+<h2>Information about ID types</h2>
+<ul class='navigation'>
+       <li><a href='$HELP_URL$pci'>PCI devices</a>
+       <li><a href='$HELP_URL$pci_class'>PCI device classes</a>
+</ul>
index 411eb608cce85d85b1fca7e02cfa52d19e7c18d0..a44d6eda8ae0a23990467f173b055f3254299eb4 100644 (file)
@@ -10,4 +10,5 @@
                <li><a href='/PD/'>PCI device classes</a>
        </ul>
        <p>You can download the PCI database in <a href='/static/pci.ids'>pci.ids</a> format or its compressed version (<a href='/static/pci.ids.gz'>gz</a>, <a href='/static/pci.ids.bz2'>bz2</a>). They are regenerated every 24 hours.
+       <p>You may want to read <a href='/?action=help?help=index'>help</a> before you start using this site.
 </body></html>