--- loncom/interface/lonhelp.pm 2002/07/05 16:12:31 1.1 +++ loncom/interface/lonhelp.pm 2002/08/09 14:48:31 1.4 @@ -56,11 +56,18 @@ $r->print(<LON-CAPA Help +

LON-CAPA Help

+ HEADER $r->print($tex); $r->print(< +
+
About + LON-CAPA help and More Help
FOOTER @@ -70,8 +77,8 @@ FOOTER # HTML equivalent sub render { - my ($tex) = @_; - tie (my %fragmentLabels, 'GDBM_File', '/home/httpd/html/adm/help/fragmentLabels.gdbm', 0, 0); + my ($tex, $docroot, $serverroot) = @_; + tie (my %fragmentLabels, 'GDBM_File', $docroot . '/adm/help/fragmentLabels.gdbm', 0, 0); # This tells TtH what to do with captions, labels, and other # things @@ -79,21 +86,32 @@ sub render # We process these ourselves because TtH can't handle then without # LaTeX .aux files + # absolute paths for use with help.loncapa.org $tex =~ s| \\ref\{([^}]*)\} - |'\\href{' . + |'\\begin{html}' . + '\\end{html}' |gxe; + # Backslashes + $tex =~ s|\\textbackslash|###BACKSLASH###|g; + # Figures leftover without captions $tex =~ s| \\includegraphics(\[[^]]*\])*\{([^}]*)\} - | '\\begin{html}\\end{html}' |gxe; $tex = tth::tth($tex); + # Finish backslashes + $tex =~ s/###BACKSLASH###/'\\'/ge; + + # Fix the pretty quotes + $tex =~ s/('')|(``)/"/g; #" to get emacs syntax highlighter happy + # For some reason all captions come out as "Figure 0:", so # just duck the issue... @@ -104,11 +122,13 @@ sub render return $tex; } -# UNCOMMENT FOR HANDLER ONLY sub handler { my $r = shift; + my $docroot = $r->dir_config('lonDocRoot'); + my $serverroot = $ENV{'HTTP_HOST'}; + my $filename = substr ($ENV{'REQUEST_URI'} , rindex($ENV{'REQUEST_URI'}, '/') + 1, -4); @@ -118,10 +138,10 @@ sub handler return 404 if ($filename !~ /\A[-0-9a-zA-z_'',.]+\Z/); - (my $file = Apache::File->new("/home/httpd/html/adm/help/tex/".$filename.'.tex')) + (my $file = Apache::File->new($docroot . "/adm/help/tex/".$filename.'.tex')) or return 404; my $tex = join('', <$file>); - $tex = render($tex); + $tex = render($tex, $docroot, $serverroot); $r->content_type("text/html"); serveTex($tex, $r);