18 |
|
|
19 |
use File::Slurp; |
use File::Slurp; |
20 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
21 |
|
use Pod::Find qw/pod_where/; |
|
sub html { |
|
|
my ( $self, $req ) = @_; |
|
|
my $f = { $req->params }; |
|
|
my $class = delete( $f->{class} ) || $self->class; |
|
|
$req->print( $self->page( title => $class, body => $self->markup( $class ) ) ); |
|
|
} |
|
22 |
|
|
23 |
sub markup { |
sub markup { |
24 |
warn "## markup ",dump( @_ ); |
my $self = shift; |
25 |
my ( $self, $class ) = @_; |
my $class = $self->class; |
26 |
use Pod::Simple::HTML; |
use Pod::Simple::HTML; |
27 |
my $pod = read_file( $self->package_path( $class ) ); |
my $path = pod_where( { -inc => 1 }, $class ); |
28 |
|
return $self->error( "Can't find pod for $class" ) unless $path; |
29 |
|
my $pod = read_file( $path ); |
30 |
my $converter = Pod::Simple::HTML->new(); |
my $converter = Pod::Simple::HTML->new(); |
31 |
my $body; |
my $body; |
32 |
my $my_classes = join('|', $self->classes); |
my $my_classes = join('|', $self->classes); |
|
warn "my_classes: $my_classes"; |
|
33 |
$converter->output_string( \$body ); |
$converter->output_string( \$body ); |
34 |
$converter->parse_string_document($pod); |
$converter->parse_string_document($pod); |
35 |
$body =~ s{.*?<body [^>]+>}{}s; |
$body =~ s{.*?<body [^>]+>}{}s; |
36 |
$body =~ s{</body>\s*</html>\s*$}{}; |
$body =~ s{</body>\s*</html>\s*$}{}; |
37 |
$body =~ s{<a href="http://search\.cpan\.org/perldoc\?($my_classes)"([^>]*)>}{<a href="/pod/$1"$2>}g; |
$body =~ s!%3A%3A!::!g; |
38 |
|
# $body =~ s{<a href="http://search\.cpan\.org/perldoc\?($my_classes)"([^>]*)>}{<a href="/$1"$2>}g; |
39 |
|
$body =~ s{<a href="http://(search\.cpan\.org/perldoc\?)([^"]+)"([^>]*)>([^<]+)<([^>]+)>}{<a href="/$2"$3>$4<$5><sup><a target="$1" title="CPAN" style="text-decoration: none" href="http://$1$2"$3>◊<$5></sup>}g; |
40 |
$body =~ s!</li>\n\t<ul>!<ul>!; |
$body =~ s!</li>\n\t<ul>!<ul>!; |
41 |
$body =~ s!</ul>!</ul></li>!; |
$body =~ s!</ul>!</ul></li>!; |
42 |
$body =~ s!<p></p>!!; |
$body =~ s!<p></p>!!; |
|
# $body =~ s!<a name=!<a id=!g; |
|
43 |
$body =~ s!__index__!index!g; |
$body =~ s!__index__!index!g; |
44 |
return "<h1>$class</h1>$body"; |
return $body unless wantarray; |
45 |
|
return { |
46 |
|
title => $class, |
47 |
|
body => $body, |
48 |
|
}; |
49 |
|
|
50 |
} |
} |
51 |
|
|
52 |
1; |
1; |