/[Frey]/branches/no-pager/lib/Frey/Pod.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /branches/no-pager/lib/Frey/Pod.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 356 - (hide annotations)
Sun Nov 16 15:49:49 2008 UTC (15 years, 5 months ago) by dpavlin
Original Path: trunk/lib/Frey/Pod.pm
File size: 1433 byte(s)
Frey::Pod now uses Pod::Find to locate all pods on system
1 dpavlin 126 package Frey::Pod;
2     use Moose;
3    
4     =head1 NAME
5    
6     Frey::Pod - display documentation
7    
8     =cut
9    
10     extends 'Frey::ClassLoader';
11     with 'Frey::Web';
12    
13     has 'class' => (
14     is => 'rw',
15     isa => 'Str',
16     required => 1,
17     );
18    
19     use File::Slurp;
20     use Data::Dump qw/dump/;
21 dpavlin 356 use Pod::Find qw/pod_where/;
22 dpavlin 126
23 dpavlin 213 sub request {
24 dpavlin 126 my ( $self, $req ) = @_;
25     my $f = { $req->params };
26     my $class = delete( $f->{class} ) || $self->class;
27     $req->print( $self->page( title => $class, body => $self->markup( $class ) ) );
28     }
29    
30     sub markup {
31 dpavlin 178 my $self = shift;
32     my $class = $self->class;
33 dpavlin 126 use Pod::Simple::HTML;
34 dpavlin 356 my $path = pod_where( { -inc => 1 }, $class );
35     return $self->error( "Can't find pod for $class" ) unless $path;
36 dpavlin 128 my $pod = read_file( $path );
37 dpavlin 126 my $converter = Pod::Simple::HTML->new();
38     my $body;
39     my $my_classes = join('|', $self->classes);
40     $converter->output_string( \$body );
41     $converter->parse_string_document($pod);
42     $body =~ s{.*?<body [^>]+>}{}s;
43     $body =~ s{</body>\s*</html>\s*$}{};
44 dpavlin 130 $body =~ s!%3A%3A!::!g;
45 dpavlin 356 # $body =~ s{<a href="http://search\.cpan\.org/perldoc\?($my_classes)"([^>]*)>}{<a href="/$1"$2>}g;
46     $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>&loz;<$5></sup>}g;
47 dpavlin 126 $body =~ s!</li>\n\t<ul>!<ul>!;
48     $body =~ s!</ul>!</ul></li>!;
49     $body =~ s!<p></p>!!;
50     $body =~ s!__index__!index!g;
51 dpavlin 128 return $body;
52 dpavlin 126 }
53    
54     1;
55    

  ViewVC Help
Powered by ViewVC 1.1.26