This page best viewed by IE 5.0+ or NS 6.0+
|
|
February 06, 2012 - 06:46
|
|
This index is provided as a courtesy to help new and old players alike
read up on the current commands and topics available without having to be
logged in.
#!/usr/bin/perl
# Created by Neal Haggard - July 20, 1999
$help_dir = "/home/dhorizon/Aldara/lib/helps";
print "Content-type: text/html\n\n";
# Grab their input
$topic = ;
@topics = split (/=/, $topic);
$topic = $topics[1];
# Replace all the whitespaces
$topic =~ s/\s/_/g;
if( $topic eq "" )
{
$topic = $ARGV[0];
}
$topic = uc $topic;
# Make sure the file exists
if( !( -r "$help_dir/$topic" ) )
{
print( "There is no help file on $topic\n" );
exit;
}
open( HELPFILE, "$help_dir/$topic") or die "Can't open $topic\n";
$line = ; # Grab the level
if( $line > 0 )
{
print( "There is no help file on $topic\n" );
exit;
}
$line = ; # first real line
chop( $line );
if( $line =~ /\./ )
{
$line = ;
}
$line = fix_line( $line );
@larray = split( / /, $line );
# Prepare the first line of the help entry
print( "\n" );
while( $line = )
{
interp_line( $line );
}
$last_blank = 0;
$was_blank = 0;
sub interp_line( $ )
{
my( $line ) = @_;
$line = fix_line( $line );
$last_blank = $is_blank;
if( $line eq "\n" )
{
print( "" );
$is_blank = 1;
}
else
{
$is_blank = 0;
if( $line =~ /Syntax\:/ || $line =~ /Example(s?)\:/
|| $line =~ /Note(s?)\:/ || $line =~ /Roleplaying\:/ )
{
print( " $line\n \n" );
while( $line = )
{
$line = fix_line( $line );
if( $line eq "\n" )
{
$is_blank = 1;
print( "" );
$line = ;
$line = fix_line( $line );
if( !( $line =~ /^\s/ ) )
{
interp_line( $line );
return;
}
$is_blank = 0;
print( "$line" );
}
elsif( $line =~ /^\s+$/ )
{
print( " " );
}
elsif( $line =~ /^\s*o / ) # unorder list ie. o This is the first item
{
$line =~ s/o //;
print( "\n - $line" );
while( $line = )
{
$line = fix_line( $line );
if( $line =~ /^\s+$/ ) # blank line?
{
$is_blank = 1;
print( "
\n\n" );
$line = ;
if( $line =~ /^\s*o / ) # more list items?
{
$is_blank = 0;
$line = fix_line( $line );
$line =~ s/o //;
print( " - $line" );
next;
}
else
{
print( "
\n" );
interp_line( $line );
return;
}
}
elsif( $line =~ /^\s*o / ) #more list items without a blank line
{
$line =~ s/o //;
print( " \n\n $line" );
next;
}
print( " $line" );
}
}
else
{
$is_blank = 0;
print( "$line" );
}
}
}
elsif ($line =~ /See [aA]lso\:/)
{
@larray = split (/:/, $line);
print( "@larray[0]: \n" );
while( $line = )
{
$line = fix_line( $line );
if( $line eq "\n" )
{
$is_blank = 1;
print( "$line" );
last;
}
$is_blank = 0;
@larray = split (/,/, $line );
foreach $filename (@larray)
{
if( $filename ne @larray[0] )
{
print( ", " );
}
$show = $filename;
$filename =~ s/(\w)\s(\w)/$1_$2/g;
$filename =~ s/\s//g;
$ucfilename = uc $filename;
if( -r "$help_dir/$ucfilename"
&& $filename !~ /\W/ && $filename !~ /spell_desc/i )
{
print( "$show" );
}
else
{
print( "$show" );
}
}
}
}
elsif( $line =~ /Delay\:/ )
{
@larray = split( /\s+/, $line );
print( " $larray[0]\n \n" );
shift( @larray );
print( "" );
foreach $telem (@larray)
{
print( "$telem " );
}
print( "\n" );
while( $line = )
{
$line = fix_line( $line );
if( $line eq "\n" )
{
$is_blank = 1;
print( "" );
last;
}
elsif( $line =~ /^\s+$/ )
{
print( " " );
}
$is_blank = 0;
print( " $line\n" );
}
}
elsif( $line =~ /^\s{10,}\S/ ) # enough space just use a pre
{
print( "\n$line" );
while( $line = )
{
$line = fix_line( $line );
if( $line eq "\n" )
{
$is_blank = 1;
print( "\n" );
last;
}
else
{
$is_blank = 0;
print( "$line" );
}
}
}
elsif( $last_blank == 1 # was the last line a blank?
&& $line =~ /^\s*(\S+\s?){1,}\:\n/ ) # (word )+:
{
chop( $line );
print( "$line \n" );
while( $line = )
{
$line = fix_line( $line );
if( $line eq "\n" )
{
$is_blank = 1;
print( "" );
$line = ;
$line = fix_line( $line );
if( !( $line =~ /^\s/ ) )
{
interp_line( $line );
return;
}
$is_blank = 0;
print( "$line" );
}
elsif( $line =~ /^\s+$/ )
{
print( " " );
}
elsif( $line =~ /^\s*o / ) # unorder list ie. o This is the first item
{
$line =~ s/o //;
print( "\n - $line" );
while( $line = )
{
$line = fix_line( $line );
if( $line =~ /^\s+$/ ) # blank line?
{
$is_blank = 1;
print( "
\n\n" );
$line = ;
if( $line =~ /^\s*o / ) # more list items?
{
$is_blank = 0;
$line = fix_line( $line );
$line =~ s/o //;
print( " - $line" );
next;
}
else
{
print( "
\n" );
interp_line( $line );
return;
}
}
elsif( $line =~ /^\s*o / ) #more list items without a blank line
{
$line =~ s/o //;
print( " \n\n $line" );
next;
}
print( " $line" );
}
}
else
{
$is_blank = 0;
print( "$line" );
}
}
}
elsif( $line =~ /^\s*o / ) # unorder list ie. o This is the first item
{
$line =~ s/o //;
print( "\n - $line" );
while( $line = )
{
$line = fix_line( $line );
if( $line =~ /^\s+$/ ) # blank line?
{
$is_blank = 1;
print( "
\n\n" );
$line = ;
if( $line =~ /^\s*o / ) # more list items?
{
$is_blank = 0;
$line = fix_line( $line );
$line =~ s/o //;
print( " - $line" );
next;
}
else
{
print( "
\n" );
interp_line( $line );
return;
}
}
elsif( $line =~ /^\s*o / ) #more list items without a blank line
{
$line =~ s/o //;
print( " \n\n $line" );
next;
}
print( " $line" );
}
}
elsif( $line =~ /^\s*\d+[\.|)]\D/ ) # ie. 1.
{
$line =~ s/\d+[\.|)]//;
print( "\n - $line" );
while( $line = )
{
$line = fix_line( $line );
if( $line =~ /^\s+$/ ) # blank line?
{
$is_blank = 1;
print( "
\n\n" );
$line = ;
if( $line =~ /^\s*\d+[\.|)]\D/ ) # more numbers?
{
$is_blank = 0;
$line = fix_line( $line );
$line =~ s/\d+[\.|)]//;
print( " - $line" );
next;
}
else
{
print( "
\n" );
interp_line( $line );
return;
}
}
elsif( $line =~ /^\s*\d+[\.|)]/ ) #more numbers w/out a blank line?
{
$line =~ s/\d+\.//;
print( " \n\n $line" );
next;
}
print( " $line" );
}
}
elsif( $line =~ /(?:\S+[^\.|\?|\!]\s)+(?:\s+(?:\S+[^\.|\?|\!]\s?)+)+/ )
{ # tables
print( "\n" );
@larray = split( /\s{2,}/, $line );
if( $larray[0] =~ /^\s+$/ )
{
shift( @larray );
}
print( "\n" );
foreach $telem (@larray)
{
print( " | " );
$show = $telem;
$telem =~ s/(\w)\s(\w)/$1_$2/g;
$telem =~ s/\s//g;
$uctelem = uc $telem;
if( -r "$help_dir/$uctelem"
&& $telem !~ /spell_desc/i )
{
print( " $show" );
}
else
{
print( " $show" );
}
print( " | \n" );
}
print( " \n" );
while( ( $line = ) && $line ne "\n" )
{
chop $line;
$line = fix_line( $line );
@larray = split( /\s{2,}/, $line );
if( $larray[0] =~ /^\s+$/ )
{
shift( @larray );
}
print( "\n" );
foreach $telem (@larray)
{
print( " | " );
$show = $telem;
$telem =~ s/(\w)\s(\w)/$1_$2/g;
$telem =~ s/\s//g;
$uctelem = uc $telem;
if( -r "$help_dir/$uctelem"
&& $telem !~ /spell_desc/i )
{
print( " $show" );
}
else
{
print( " $show" );
}
print( " | \n" );
}
print( " \n" );
}
$is_blank = 1;
print( " \n$line\n" );
}
elsif( $line =~ /^\s{4}/ )
{
print( " $line" );
}
elsif( $line =~ /^\s{3}/ )
{
print( "$line" );
}
elsif( $line =~ /^\s{2}/ )
{
chop( $line );
print( " $line\n" );
}
elsif( $line =~ /^-{2,}/ || $line =~ /^_{2,}/ )
{
print( " \n" );
}
else
{
print( $line );
}
}
}
sub fix_line( $ )
{
my( $l ) = @_;
$l =~ s/^\~//g;
$l =~ s/&/&\;/g;
$l =~ s/<\;/g;
$l =~ s/>/>\;/g;
# convert http into links
$l =~ s/(http:\/\/\S*)/$1<\/A>/g;
# convert mail addresses into mailto:
$l =~ s/(\b\w+@(?:\w+\.?)+)/$1<\/A>/g;
# convert telnet addresses into links
$l =~ s/(\b(?:\w+\.)(?:\w+\.?)+)\s(\d+)\s/$1 $2<\/A>/g;
$l =~ s/\b_(\w+)_\b/$1<\/u>/g;
$l =~ s/([sS])ee \"?help (\w+)\"?/\1ee help \2<\/A>/g;
$l =~ s/\"help (\w+)\"/\"help \1<\/A>\"/g;
return $l;
}
|
|