Apache-Pod
view release on metacpan or search on metacpan
lib/Apache/Pod/HTML.pm view on Meta::CPAN
=cut
sub handler {
my $r = shift;
if ( $r->path_info eq '/auto.css' ) {
$r->content_type( 'text/css' );
$r->send_http_header;
$r->print( _css() );
return OK;
}
my $body;
my $file = Apache::Pod::getpodfile( $r );
if ( $file ) {
my $parser = Pod::Simple::HTML->new;
$parser->no_errata_section(1);
$parser->complain_stderr(1);
$parser->output_string( \$body );
$parser->index( $r->dir_config('INDEX') );
if ( my $prefix = $r->dir_config('LINKBASE') ) {
if ( $prefix eq 'LOCAL' ) {
$prefix = $r->location . '/';
}
$parser->perldoc_url_prefix( $prefix );
}
$parser->parse_file( $file );
# TODO: Send the timestamp of the file in the header
my $stylesheet = $r->dir_config('STYLESHEET') || '';
$stylesheet = $r->location . '/auto.css' if $stylesheet =~ /^auto/i;
if ( $stylesheet ) {
# Stick in a link to our stylesheet
$stylesheet = qq(<LINK REL="stylesheet" HREF="$stylesheet" TYPE="text/css">);
$body =~ s{(?=</head)}{$stylesheet\n}i;
}
if ( $r->dir_config('GZIP') && ($r->header_in('Accept-Encoding') =~ /gzip/) ) {
local $@;
eval {
require Compress::Zlib;
$body = Compress::Zlib::memGzip( $body );
$r->header_out('Content-Encoding','gzip');
};
}
} else {
$body = "<HTML><HEAD><TITLE>Not found</TITLE></HEAD><BODY>That module doesn't exist</BODY></HTML>";
}
$r->content_type('text/html');
$r->send_http_header;
$r->print( $body );
return OK;
}
sub _css {
return <<'EOF';
BODY {
background: white;
color: black;
font-family: times,serif;
margin: 0;
padding: 1ex;
}
TABLE {
border-collapse: collapse;
border-spacing: 0;
border-width: 0;
color: inherit;
}
A:link, A:visited {
background: transparent;
color: #006699;
}
PRE {
background: #eeeeee;
border: 1px solid #888888;
color: black;
padding-top: 1em;
padding-bottom: 1em;
white-space: pre;
}
H1 {
background: transparent;
color: #006699;
font-size: x-large;
font-family: tahoma,sans-serif;
}
H2 {
background: transparent;
color: #006699;
font-size: large;
font-family: tahoma,sans-serif;
}
.block {
background: transparent;
}
TD .block {
color: #006699;
background: #dddddd;
padding: 0.2em;
font-size: large;
}
HR {
display: none;
}
EOF
}
package My::Pod::Simple::HTML;
use Pod::Simple::HTML;
our @ISA = qw( Pod::Simple::HTML );
*VERSION = *Pod::Simple::HTML::VERSION;
sub resolve_pod_page_link {
my $self = shift;
my $to = shift;
my $section = shift;
my $link = $to;
return uri_escape( $link );
}
=head1 AUTHOR
Andy Lester C<< <andy@petdance.com> >>, adapted from Apache::Perldoc by
Rich Bowen C<< <rbowen@ApacheAdmin.com> >>
=head1 LICENSE
This package is licensed under the same terms as Perl itself.
=cut
1;
( run in 1.459 second using v1.01-cache-2.11-cpan-d8267643d1d )