version 1.1, 2002/07/05 16:12:31
|
version 1.3, 2002/07/26 19:58:52
|
Line 56 $r->print(<<HEADER);
|
Line 56 $r->print(<<HEADER);
|
<title>LON-CAPA Help</title> |
<title>LON-CAPA Help</title> |
</head> |
</head> |
<body bgcolor="#FFFFFF"> |
<body bgcolor="#FFFFFF"> |
|
<!-- BEGIN --> |
HEADER |
HEADER |
|
|
$r->print($tex); |
$r->print($tex); |
|
|
$r->print(<<FOOTER); |
$r->print(<<FOOTER); |
|
<!-- END --> |
</body> |
</body> |
</html> |
</html> |
FOOTER |
FOOTER |
Line 70 FOOTER
|
Line 72 FOOTER
|
# HTML equivalent |
# HTML equivalent |
sub render |
sub render |
{ |
{ |
my ($tex) = @_; |
my ($tex, $docroot, $serverroot) = @_; |
tie (my %fragmentLabels, 'GDBM_File', '/home/httpd/html/adm/help/fragmentLabels.gdbm', 0, 0); |
tie (my %fragmentLabels, 'GDBM_File', $docroot . '/adm/help/fragmentLabels.gdbm', 0, 0); |
|
|
# This tells TtH what to do with captions, labels, and other |
# This tells TtH what to do with captions, labels, and other |
# things |
# things |
Line 79 sub render
|
Line 81 sub render
|
|
|
# We process these ourselves because TtH can't handle then without |
# We process these ourselves because TtH can't handle then without |
# LaTeX .aux files |
# LaTeX .aux files |
|
# absolute paths for use with help.loncapa.org |
$tex =~ s| \\ref\{([^}]*)\} |
$tex =~ s| \\ref\{([^}]*)\} |
|'\\href{' . |
|'\\begin{html}<a href="http://' . $serverroot ."/adm/help/". |
substr($fragmentLabels{$1}, 0, -4) . |
substr($fragmentLabels{$1}, 0, -4) . |
'#' . processLabelName($1) . |
'.hlp#' . processLabelName($1) . |
'}{graphic}' |
'"><img src="http://' . $serverroot . '/adm/help/gif/smallHelp.gif" border="0" /></a>' . |
|
'\\end{html}' |
|gxe; |
|gxe; |
|
|
|
# Backslashes |
|
$tex =~ s|\\textbackslash|###BACKSLASH###|g; |
|
|
# Figures leftover without captions |
# Figures leftover without captions |
$tex =~ s| \\includegraphics(\[[^]]*\])*\{([^}]*)\} |
$tex =~ s| \\includegraphics(\[[^]]*\])*\{([^}]*)\} |
| '\\begin{html}<img src="gif/' . $2 . '.gif" border="2"'. |
| '\\begin{html}<img src="http://' . $serverroot . '/adm/help/gif/' . $2 . '.gif" border="2"'. |
' bordercolor="#000000"/>\\end{html}' |
' bordercolor="#000000"/>\\end{html}' |
|gxe; |
|gxe; |
|
|
$tex = tth::tth($tex); |
$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 |
# For some reason all captions come out as "Figure 0:", so |
# just duck the issue... |
# just duck the issue... |
|
|
Line 104 sub render
|
Line 117 sub render
|
return $tex; |
return $tex; |
} |
} |
|
|
# UNCOMMENT FOR HANDLER ONLY |
|
sub handler |
sub handler |
{ |
{ |
my $r = shift; |
my $r = shift; |
|
|
|
my $docroot = $r->dir_config('lonDocRoot'); |
|
my $serverroot = $ENV{'HTTP_HOST'}; |
|
|
my $filename = substr ($ENV{'REQUEST_URI'} , |
my $filename = substr ($ENV{'REQUEST_URI'} , |
rindex($ENV{'REQUEST_URI'}, '/') + 1, -4); |
rindex($ENV{'REQUEST_URI'}, '/') + 1, -4); |
|
|
Line 118 sub handler
|
Line 133 sub handler
|
|
|
return 404 if ($filename !~ /\A[-0-9a-zA-z_'',.]+\Z/); |
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; |
or return 404; |
my $tex = join('', <$file>); |
my $tex = join('', <$file>); |
$tex = render($tex); |
$tex = render($tex, $docroot, $serverroot); |
$r->content_type("text/html"); |
$r->content_type("text/html"); |
serveTex($tex, $r); |
serveTex($tex, $r); |
|
|