/[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 126 - (hide annotations)
Mon Jul 14 23:12:48 2008 UTC (15 years, 9 months ago) by dpavlin
Original Path: trunk/lib/Frey/Pod.pm
File size: 1167 byte(s)
display pod documentation
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    
22     sub html {
23     my ( $self, $req ) = @_;
24     my $f = { $req->params };
25     my $class = delete( $f->{class} ) || $self->class;
26     $req->print( $self->page( title => $class, body => $self->markup( $class ) ) );
27     }
28    
29     sub markup {
30     warn "## markup ",dump( @_ );
31     my ( $self, $class ) = @_;
32     use Pod::Simple::HTML;
33     my $pod = read_file( $self->package_path( $class ) );
34     my $converter = Pod::Simple::HTML->new();
35     my $body;
36     my $my_classes = join('|', $self->classes);
37     warn "my_classes: $my_classes";
38     $converter->output_string( \$body );
39     $converter->parse_string_document($pod);
40     $body =~ s{.*?<body [^>]+>}{}s;
41     $body =~ s{</body>\s*</html>\s*$}{};
42     $body =~ s{<a href="http://search\.cpan\.org/perldoc\?($my_classes)"([^>]*)>}{<a href="/pod/$1"$2>}g;
43     $body =~ s!</li>\n\t<ul>!<ul>!;
44     $body =~ s!</ul>!</ul></li>!;
45     $body =~ s!<p></p>!!;
46     # $body =~ s!<a name=!<a id=!g;
47     $body =~ s!__index__!index!g;
48     return "<h1>$class</h1>$body";
49     }
50    
51     1;
52    

  ViewVC Help
Powered by ViewVC 1.1.26