#!/usr/bin/env perl
## $Id$
####################################################################
# Copyright @ 1995-1998 University of Rochester
# All Rights Reserved
####################################################################
use strict;
use lib '.'; use webworkInit; # WeBWorKInitLine
# this is the home directory. (change to system)
use Global;
use Pod::Html;
use Carp;
use CGI qw(:standard);
#eval {
$| = 1; #force command buffering
print "Content-type: text/html\n\n";
$| = 0;
# augment the paths to search for documentation.
# e.g. '/webwork/experimental/courseScripts', '/webwork/experimental/scripts',
# This is not fool proof, but it will work if the webwork system has been set up as at U. of Rochester.
#my $dir3 = "/ww/webwork/development/"; #kludge for the summer so that the latest docs make it to the web.
my $dir3 = $Global::mainDirectory;
unshift(@INC,$dir3);
unshift(@INC, $dir3.'courseScripts/',$dir3.'scripts/',$dir3.'cgi/cgi-scripts/');
my $dir4 = "/u/gage/webwork-modperl/lib/";
unshift( @INC, $dir4.'Apache/', $dir4.'WeBWorK/', $dir4.'WeBWorK/PG/', $dir4.'WeBWorK/ContentGenerator/' );
# End defining search paths.
open( LOG, ">pod2webwork.log" ) or warn "Can't open pod2webwork.log for writing";
#print LOG "";
#close( LOG );
#open( LOG, ">>pod2webwork.log" );
my $path = param('path');
my $HTMLpre = 0; #for use with clipline(); must be global to this file
#because it's used over multiple calls of clipline()
my $up_path = referer(); #This is the URL that the "up" button will point to.
if (defined $up_path) {
# point to the index of the directory
$up_path =~ s|/[^/]*$|/index.html|g;
} else {
$up_path = "${Global::webworkDocsURL}";
}
# Now find the path to the file
my $p;
foreach $p ("",@INC) {
if (-r "$p$path") {
$path = "$p$path";
#print "found $path
\n";
last;
}
#print "looking for $p$path
\n";
}
output_filter(); # install output filter
pod2html($path, "--title= "); # produces a blank title, eliminating error message.
# real title is produced in output_filter
close(STDOUT);
close( LOG );
#}; # end eval
print "Content-type: text/html\n\n
$@" if $@; ########### # This will print to STDOUT which will then be filtered. sub output_filter{ # use command buffering; my $pid; return if $pid = open(STDOUT, "|-") ; #I'm not sure why this works -- see Perl cookbook. print <
EOT unless (-r $path) { print "Missing documentation
"; print "Can't find file$pathafter searching in the following directories:
"; print join("
",@INC); } unless ( defined($pid) ) { print "Can't find the file $path
"; return; } # get rid of the html header while () { last if //; } while ( ) { my $line = $_; last if $line =~ m{}i; chomp($line); print clipline($line); } print < File path = $path