| 1 | package DocLife::Pod; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use parent 'DocLife'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use Pod::Simple::XHTML; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | sub format { | ||||||||||||||||||
|
Subroutine
format: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||
| 9 | 3 | my ($self, $req, $res, $file) = @_; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 3 | my $body = $file->slurp; | |||||||||||||||||||
| 12 | 3 | ▶ | if ($req->param('source')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 13 | 0 | $res->content_type('text/plain'); | |||||||||||||||||||
| 14 | 0 | $res->body($body); | |||||||||||||||||||
| 15 | 0 | return; | |||||||||||||||||||
| 16 | } | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 3 | my $home = $self->base_url; | |||||||||||||||||||
| 19 | 3 | my ($title) = $body=~m|^package (.*);|; | |||||||||||||||||||
| 20 | 3 | ▶ | $title ||= $file->basename; | ||||||||||||||||||
|
Condition33%1/3
$title ||= $file->basename
MC/DC0%0/2
$title ||= $file->basename
$title
$file->basename
Truth table33%1/3
A ||= B
A= $titleB= $file->basename
| |||||||||||||||||||||
| 21 | 3 | my $src = qq{<p class="home"><a href="$home">Home</a></p><a href="?source=1">Source</a>}; | |||||||||||||||||||
| 22 | 3 | my $pod = Pod::Simple::XHTML->new; | |||||||||||||||||||
| 23 | 3 | $pod->html_header($self->html_header($title) . $src); | |||||||||||||||||||
| 24 | 3 | $pod->index(1); | |||||||||||||||||||
| 25 | 3 | $pod->output_string(\my $html); | |||||||||||||||||||
| 26 | 3 | $pod->parse_string_document($body); | |||||||||||||||||||
| 27 | 3 | $res->body($html); | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 3 | ▶ | sub html_header { | ||||||||||||||||||
|
Subroutine
html_header: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 31 | 3 | my ($self, $title) = @_; | |||||||||||||||||||
| 32 | 3 | ▶ | $title = 'Index' unless defined $title; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | <<"EOF" | ||||||||||||||||||||
| 34 | <!DOCTYPE html> | ||||||||||||||||||||
| 35 | <html> | ||||||||||||||||||||
| 36 | <head> | ||||||||||||||||||||
| 37 | <title>$title</title> | ||||||||||||||||||||
| 38 | <style> | ||||||||||||||||||||
| 39 | body { | ||||||||||||||||||||
| 40 | font-family: arial,sans-serif; | ||||||||||||||||||||
| 41 | margin: 0; | ||||||||||||||||||||
| 42 | padding: 1ex; | ||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | a:link, a:visited { | ||||||||||||||||||||
| 45 | color: #069; | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | li { | ||||||||||||||||||||
| 48 | line-height: 1.2em; | ||||||||||||||||||||
| 49 | list-style-type: none; | ||||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | h1 { | ||||||||||||||||||||
| 52 | color: #006699; | ||||||||||||||||||||
| 53 | font-size: large; | ||||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | h2 { | ||||||||||||||||||||
| 56 | color: #006699; | ||||||||||||||||||||
| 57 | font-size: medium; | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | h3 { | ||||||||||||||||||||
| 60 | color: #006699; | ||||||||||||||||||||
| 61 | font-size: medium; | ||||||||||||||||||||
| 62 | font-style: italic; | ||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | h4 { | ||||||||||||||||||||
| 65 | color: #006699; | ||||||||||||||||||||
| 66 | font-size: medium; | ||||||||||||||||||||
| 67 | font-weight: normal; | ||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | pre { | ||||||||||||||||||||
| 70 | background: #eeeeee; | ||||||||||||||||||||
| 71 | border: 1px solid #888888; | ||||||||||||||||||||
| 72 | color: black; | ||||||||||||||||||||
| 73 | padding: 1em; | ||||||||||||||||||||
| 74 | white-space: pre; | ||||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | .home { | ||||||||||||||||||||
| 77 | margin: 0; | ||||||||||||||||||||
| 78 | padding: 0; | ||||||||||||||||||||
| 79 | text-align: center; | ||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | </style> | ||||||||||||||||||||
| 82 | </head> | ||||||||||||||||||||
| 83 | <body> | ||||||||||||||||||||
| 84 | EOF | ||||||||||||||||||||
| 85 | 3 | } | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =head1 NAME | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | DocLife::Pod - Pod Viewer. | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =head1 SYNOPSIS | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | # app.psgi | ||||||||||||||||||||
| 94 | use DocLife::Pod; | ||||||||||||||||||||
| 95 | DocLife::Pod->new( root => "./lib" ); | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | # one-liner | ||||||||||||||||||||
| 98 | plackup -MDocLife::Pod -e 'DocLife::Pod->new( root => "./lib" )->to_app' | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =head1 SEE ALSO | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | L<DocLife>, L<Pod::Simple::XHTML> | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 1 | 1; | |||||||||||||||||||