| 1 | # | ||||||||||
| 2 | # This file is part of Catalyst-Controller-POD | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is Copyright (c) 2011 by Moritz Onken. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software, licensed under: | ||||||||||
| 7 | # | ||||||||||
| 8 | # The (three-clause) BSD License | ||||||||||
| 9 | # | ||||||||||
| 10 | package Catalyst::Controller::POD::POM::View; | ||||||||||
| 11 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | $Catalyst::Controller::POD::POM::View::VERSION = '1.0.0'; | |||||||||
| 13 | } | ||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | use base "Pod::POM::View::HTML"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 1 | my $HTML_PROTECT = 1; | |||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | sub _root { | ||||||||
|
Subroutine
_root: not called CC=2 SCAR=11.6
| |||||||||||
| 22 | 1 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 0 | my $self = shift; | |||||||||
| 24 | 0 | ▶ | if(@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | $self->{_root} = $_[0]; | |||||||||
| 26 | } | ||||||||||
| 27 | 0 | return $self->{_root}; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub _module { | ||||||||
|
Subroutine
_module: not called CC=2 SCAR=11.6
| |||||||||||
| 32 | 1 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | 0 | my $self = shift; | |||||||||
| 34 | 0 | ▶ | if(@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | $self->{_module} = $_[0]; | |||||||||
| 36 | } | ||||||||||
| 37 | 0 | return $self->{_module}; | |||||||||
| 38 | } | ||||||||||
| 39 | 0 | ▶ | sub _toc { | ||||||||
|
Subroutine
_toc: not called CC=2 SCAR=11.6
| |||||||||||
| 40 | 1 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | 0 | my $self = shift; | |||||||||
| 42 | 0 | ▶ | if(@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | $self->{_toc} = $_[0]; | |||||||||
| 44 | } | ||||||||||
| 45 | 0 | return $self->{_toc}; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | sub view_begin { | ||||||||
|
Subroutine
view_begin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 49 | 0 | my ($self, $begin) = @_; | |||||||||
| 50 | 0 | ▶ | return '' unless $begin->format() =~ /\bhtml\b/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | $HTML_PROTECT = 1; | |||||||||
| 52 | 0 | my $output = $begin->content(); | |||||||||
| 53 | 0 | return $output; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub view_pod { | ||||||||
|
Subroutine
view_pod: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 58 | 0 | my ($self, $pod) = @_; | |||||||||
| 59 | 0 | my $toc = $self->_toc; | |||||||||
| 60 | 0 | my $permalink = $self->_root . "?permalink=" . $self->_module; # There has to be a better way | |||||||||
| 61 | 0 | return qq~ | |||||||||
| 62 | <html> | ||||||||||
| 63 | <head> | ||||||||||
| 64 | <link rel="stylesheet" href="http://search.cpan.org/s/style.css" type="text/css" /> | ||||||||||
| 65 | |||||||||||
| 66 | </head> | ||||||||||
| 67 | <body bgcolor=\"#ffffff\"> | ||||||||||
| 68 | <script type="text/javascript">POD.setTOC($toc);</script> | ||||||||||
| 69 | <div id="permalink"><a href="$permalink">Permalink</a></div> | ||||||||||
| 70 | <div class="pod"> | ||||||||||
| 71 | ~ | ||||||||||
| 72 | . $pod->content->present($self) | ||||||||||
| 73 | . "<script>prettyPrint()</script></div></body></html>\n"; | ||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub view_verbatim { | ||||||||
|
Subroutine
view_verbatim: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||
| 77 | 0 | my ($self, $text) = @_; | |||||||||
| 78 | |||||||||||
| 79 | 0 | for ($text) { | |||||||||
| 80 | 0 | s/&/&/g; | |||||||||
| 81 | 0 | s/</</g; | |||||||||
| 82 | 0 | s/>/>/g; | |||||||||
| 83 | } | ||||||||||
| 84 | 0 | foreach my $i (1..10) { | |||||||||
| 85 | 0 | my $t; | |||||||||
| 86 | 0 | my $last = 0; | |||||||||
| 87 | 0 | for(split(/\n/, $text)) { | |||||||||
| 88 | 0 | $_ =~ s/^(.)//; | |||||||||
| 89 | 0 | ▶ | if($1 ne " ") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 0 | $last = 1; | |||||||||
| 91 | 0 | last; | |||||||||
| 92 | } | ||||||||||
| 93 | 0 | $t .= $_.$/; | |||||||||
| 94 | } | ||||||||||
| 95 | 0 | ▶ | $text = $t unless($last); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | 0 | ▶ | last if($last); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 0 | return "<pre class=\"prettyprint lang-perl\">$text</pre>\n\n"; | |||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | 0 | ▶ | sub view_seq_link_transform_path { | ||||||||
|
Subroutine
view_seq_link_transform_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 103 | 0 | my($self,$page) = @_; | |||||||||
| 104 | 0 | return $self->_root."/module/$page"; | |||||||||
| 105 | } | ||||||||||
| 106 | { | ||||||||||
| 107 | 1 | ▶ | no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 108 | 0 | ▶ | sub Pod::POM::View::HTML::make_href { | ||||||||
|
Subroutine
make_href: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 109 | 0 | my($url, $title) = @_; | |||||||||
| 110 | 0 | ▶ | if (!defined $url) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 111 | 0 | $url = "$title"; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | $title = $url unless defined $title; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | 0 | return qq{<a href="$url" onclick="return POD.proxyLink(this)">$title</a>}; | |||||||||
| 116 | } | ||||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | 1 | ▶ | sub view_head1 { | ||||||||
|
Subroutine
view_head1: not called CC=1 SCAR=4.9
Pod
documented
| |||||||||||
| 120 | 0 | my ($self, $head1) = @_; | |||||||||
| 121 | 0 | my $title = $head1->title->present($self); | |||||||||
| 122 | 0 | my $id = "section-".$self->_module."-".$title; | |||||||||
| 123 | 0 | $id =~ s/<.*?>//g; | |||||||||
| 124 | 0 | $id =~ s/'/\\'/g; | |||||||||
| 125 | 0 | return "<h1 id='$id'>$title</h1>\n\n" | |||||||||
| 126 | . $head1->content->present($self); | ||||||||||
| 127 | } | ||||||||||
| 128 | |||||||||||
| 129 | |||||||||||
| 130 | 0 | ▶ | sub view_head2 { | ||||||||
|
Subroutine
view_head2: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 131 | 0 | my ($self, $head2) = @_; | |||||||||
| 132 | 0 | my $title = $head2->title->present($self); | |||||||||
| 133 | 0 | my $id = "section-".$self->_module."-".$title; | |||||||||
| 134 | 0 | $id =~ s/<.*?>//g; | |||||||||
| 135 | 0 | $id =~ s/'/\\'/g; | |||||||||
| 136 | 0 | return "<h2 id='$id'>$title</h2>\n\n" | |||||||||
| 137 | . $head2->content->present($self); | ||||||||||
| 138 | } | ||||||||||
| 139 | |||||||||||
| 140 | |||||||||||
| 141 | 0 | ▶ | sub view_head3 { | ||||||||
|
Subroutine
view_head3: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 142 | 0 | my ($self, $head3) = @_; | |||||||||
| 143 | 0 | my $title = $head3->title->present($self); | |||||||||
| 144 | 0 | my $id = "section-".$self->_module."-".$title; | |||||||||
| 145 | 0 | $id =~ s/<.*?>//g; | |||||||||
| 146 | 0 | $id =~ s/'/\\'/g; | |||||||||
| 147 | 0 | return "<h3 id='$id'>$title</h3>\n\n" | |||||||||
| 148 | . $head3->content->present($self); | ||||||||||
| 149 | } | ||||||||||
| 150 | |||||||||||
| 151 | |||||||||||
| 152 | 0 | ▶ | sub view_head4 { | ||||||||
|
Subroutine
view_head4: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 153 | 0 | my ($self, $head4) = @_; | |||||||||
| 154 | 0 | my $title = $head4->title->present($self); | |||||||||
| 155 | 0 | my $id = "section-".$self->_module."-".$title; | |||||||||
| 156 | 0 | $id =~ s/<.*?>//g; | |||||||||
| 157 | 0 | $id =~ s/'/\\'/g; | |||||||||
| 158 | 0 | return "<h4 id='$id'>$title</h4>\n\n" | |||||||||
| 159 | . $head4->content->present($self); | ||||||||||
| 160 | } | ||||||||||
| 161 | |||||||||||
| 162 | 1 | 1; | |||||||||
| 163 | |||||||||||
| 164 | __END__ | ||||||||||