]> mj.ucw.cz Git - pciids.git/commitdiff
Help system
authorMichal Vaner <vorner@ucw.cz>
Thu, 21 Aug 2008 21:56:09 +0000 (23:56 +0200)
committerMichal Vaner <vorner@ucw.cz>
Thu, 21 Aug 2008 21:56:09 +0000 (23:56 +0200)
Still needs links to the help and write the help texts.

PciIds/Html/Handler.pm
PciIds/Html/Help.pm [new file with mode: 0644]

index dd996ffd5b27ee674ec6e6bbdb525c8fd941e090..24f33cfc053dfd80596f7c2631d3df3220be1e00 100644 (file)
@@ -10,7 +10,7 @@ use PciIds::Html::Debug;
 use PciIds::Html::Changes;
 use PciIds::Html::Admin;
 use PciIds::Html::Notifications;
-use PciIds::Notifications;
+use PciIds::Html::Help;
 use Apache2::Const qw(:common :http);
 
 $ENV{'PATH'} = '';
@@ -59,6 +59,7 @@ 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 );
diff --git a/PciIds/Html/Help.pm b/PciIds/Html/Help.pm
new file mode 100644 (file)
index 0000000..512f38e
--- /dev/null
@@ -0,0 +1,28 @@
+package PciIds::Html::Help;
+use strict;
+use warnings;
+use PciIds::Startup;
+use PciIds::Html::Util;
+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 '' );
+       open HELP, "$directory/help/$helpname" or return NOT_FOUND;
+       my $head = <HELP>;
+       chomp $head;
+       genHtmlHead( $req, $head, undef );
+       print "<h1>$head</h1>\n";
+       while( defined( my $line = <HELP> ) ) {
+               print $line;
+       }
+       close HELP;
+       genHtmlTail();
+       return OK;
+}
+
+1;