From 2f55c57773fc885b3ada6a73415f9056c64e4f9f Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Thu, 21 Aug 2008 23:56:09 +0200 Subject: [PATCH] Help system Still needs links to the help and write the help texts. --- PciIds/Html/Handler.pm | 3 ++- PciIds/Html/Help.pm | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 PciIds/Html/Help.pm diff --git a/PciIds/Html/Handler.pm b/PciIds/Html/Handler.pm index dd996ff..24f33cf 100644 --- a/PciIds/Html/Handler.pm +++ b/PciIds/Html/Handler.pm @@ -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 index 0000000..512f38e --- /dev/null +++ b/PciIds/Html/Help.pm @@ -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 = ; + chomp $head; + genHtmlHead( $req, $head, undef ); + print "

$head

\n"; + while( defined( my $line = ) ) { + print $line; + } + close HELP; + genHtmlTail(); + return OK; +} + +1; -- 2.39.5