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()};
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=';
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 ) = @{$_};
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'};
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";
--- /dev/null
+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 & 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>