package DocLife::Pod; use strict; use warnings; use parent 'DocLife'; use Pod::Simple::XHTML; sub format { my ($self, $req, $res, $file) = @_; my $body = $file->slurp; if ($req->param('source')) { $res->content_type('text/plain'); $res->body($body); return; } my $home = $self->base_url; my ($title) = $body=~m|^package (.*);|; $title ||= $file->basename; my $src = qq{

Home

Source}; my $pod = Pod::Simple::XHTML->new; $pod->html_header($self->html_header($title) . $src); $pod->index(1); $pod->output_string(\my $html); $pod->parse_string_document($body); $res->body($html); } sub html_header { my ($self, $title) = @_; $title = 'Index' unless defined $title; <<"EOF" $title EOF } =head1 NAME DocLife::Pod - Pod Viewer. =head1 SYNOPSIS # app.psgi use DocLife::Pod; DocLife::Pod->new( root => "./lib" ); # one-liner plackup -MDocLife::Pod -e 'DocLife::Pod->new( root => "./lib" )->to_app' =head1 SEE ALSO L, L =cut 1;