| blib/lib/App/Pods2Site/SiteBuilder/AbstractBasicFrames.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % | 
| statement | 97 | 99 | 97.9 | 
| branch | 7 | 12 | 58.3 | 
| condition | 3 | 4 | 75.0 | 
| subroutine | 12 | 13 | 92.3 | 
| pod | 0 | 1 | 0.0 | 
| total | 119 | 129 | 92.2 | 
| line | stmt | bran | cond | sub | pod | time | code | 
|---|---|---|---|---|---|---|---|
| 1 | package App::Pods2Site::SiteBuilder::AbstractBasicFrames; | ||||||
| 2 | |||||||
| 3 | 2 | 2 | 14 | use strict; | |||
| 2 | 5 | ||||||
| 2 | 55 | ||||||
| 4 | 2 | 2 | 10 | use warnings; | |||
| 2 | 4 | ||||||
| 2 | 157 | ||||||
| 5 | |||||||
| 6 | our $VERSION = '1.001'; | ||||||
| 7 | my $version = $VERSION; | ||||||
| 8 | $VERSION = eval $VERSION; | ||||||
| 9 | |||||||
| 10 | 2 | 2 | 24 | use base qw(App::Pods2Site::AbstractSiteBuilder); | |||
| 2 | 4 | ||||||
| 2 | 310 | ||||||
| 11 | |||||||
| 12 | 2 | 2 | 14 | use App::Pods2Site::Util qw(slashify readData writeData writeUTF8File); | |||
| 2 | 4 | ||||||
| 2 | 112 | ||||||
| 13 | |||||||
| 14 | 2 | 2 | 1010 | use HTML::Entities; | |||
| 2 | 11347 | ||||||
| 2 | 2232 | ||||||
| 15 | |||||||
| 16 | sub _getCssContent | ||||||
| 17 | { | ||||||
| 18 | 3 | 3 | 25 |  	return < | |||
| 19 | \@charset "UTF-8"; | ||||||
| 20 | |||||||
| 21 | html | ||||||
| 22 | { | ||||||
| 23 | font-family: sans-serif; | ||||||
| 24 | font-size: small; | ||||||
| 25 | } | ||||||
| 26 | |||||||
| 27 | MYCSS | ||||||
| 28 | } | ||||||
| 29 | |||||||
| 30 | sub makeSite | ||||||
| 31 | { | ||||||
| 32 | 3 | 3 | 0 | 12 | my $self = shift; | ||
| 33 | 3 | 8 | my $args = shift; | ||||
| 34 | 3 | 6 | my $workGroups = shift; | ||||
| 35 | 3 | 27 | my $partCounts = shift; | ||||
| 36 | |||||||
| 37 | 3 | 51 | $self->__updateMain($args, $partCounts); | ||||
| 38 | 3 | 43 | $self->__updateHeader($args); | ||||
| 39 | 3 | 24 | $self->__updateTOC($args, $workGroups); | ||||
| 40 | 3 | 24 | $self->__updateIndex($args); | ||||
| 41 | } | ||||||
| 42 | |||||||
| 43 | # PRIVATE | ||||||
| 44 | # | ||||||
| 45 | |||||||
| 46 | sub __updateMain | ||||||
| 47 | { | ||||||
| 48 | 3 | 3 | 10 | my $self = shift; | |||
| 49 | 3 | 7 | my $args = shift; | ||||
| 50 | 3 | 10 | my $partCounts = shift; | ||||
| 51 | |||||||
| 52 | 3 | 13 | my $z = encode_entities(slashify($0)); | ||||
| 53 | 3 | 86 | my $zv = encode_entities($App::Pods2Site::VERSION); | ||||
| 54 | 3 | 80 | my $x = encode_entities($^X); | ||||
| 55 | 3 | 51 | my $xv = encode_entities($]); | ||||
| 56 | 3 | 61 |  	my $builtBy = " This site built using:  | 
||||
| 57 | 3 | 33 |  	$builtBy .= " $z ($zv) ";  | 
||||
| 58 | 3 | 15 |  	$builtBy .= " $x ($xv) \n";  | 
||||
| 59 | 3 | 9 | $builtBy .= "\n"; | ||||
| 60 | |||||||
| 61 | 3 | 10 | my $scannedLocations = ''; | ||||
| 62 | 3 | 40 | foreach my $loc ($args->getBinDirs(), $args->getLibDirs()) | ||||
| 63 | { | ||||||
| 64 | 6 | 22 | $loc = encode_entities($loc); | ||||
| 65 | 6 | 97 |  		$scannedLocations .= " $loc "  | 
||||
| 66 | } | ||||||
| 67 | 3 | 13 |  	$scannedLocations = " Scanned locations:  | 
||||
| 68 | |||||||
| 69 | 3 | 15 |  	my $style = " Style:  | 
||||
| 70 | 3 | 37 |  	$style .= " " . encode_entities($self->getStyleName()) . " ";  | 
||||
| 71 | 3 | 49 | $style .= "\n"; | ||||
| 72 | |||||||
| 73 | 3 | 50 | 28 | my $actualCSS = encode_entities($args->getCSS() || '(default css)'); | |||
| 74 | 3 | 55 |  	$actualCSS = " CSS:  | 
||||
| 75 | |||||||
| 76 | 3 | 11 | my $groupDefs = ''; | ||||
| 77 | 3 | 9 | foreach my $groupDef (@{$args->getGroupDefs()}) | ||||
| 3 | 19 | ||||||
| 78 | { | ||||||
| 79 | 6 | 100 | 22 |  		$groupDefs .= ' ' if $groupDefs;  | 
|||
| 80 | 6 | 27 | my $name = encode_entities($groupDef->{name}); | ||||
| 81 | 6 | 95 |  		$groupDefs .= " $name ($partCounts->{$groupDef->{name}} pods) ";  | 
||||
| 82 | 6 | 54 | my $query = encode_entities($groupDef->{query}->getQuery()); | ||||
| 83 | 6 | 50 | 151 |  		if ($query =~ s#\n# #g)  | 
|||
| 84 | { | ||||||
| 85 | 0 | 0 | $query =~ s#\t# #g; | ||||
| 86 | } | ||||||
| 87 | 6 | 28 |  		$groupDefs .= "  $query ";  | 
||||
| 88 | } | ||||||
| 89 | 3 | 15 |  	$groupDefs = " Groups:  | 
||||
| 90 | |||||||
| 91 | 3 | 11 | my $sitedir = $args->getSiteDir(); | ||||
| 92 | 3 | 100 | 27 | my $savedTS = readData($sitedir, 'timestamps') || []; | |||
| 93 | 3 | 22 | push(@$savedTS, time()); | ||||
| 94 | 3 | 19 | writeData($sitedir, 'timestamps', $savedTS); | ||||
| 95 | |||||||
| 96 | 3 | 26 | my $createdUpdated = ''; | ||||
| 97 | 3 | 166 |  	$createdUpdated .= (' ' . encode_entities(scalar(localtime($_))) . " \n") foreach (@$savedTS);  | 
||||
| 98 | 3 | 93 |  	$createdUpdated = " Created/Updated:  | 
||||
| 99 | |||||||
| 100 | 3 | 20 | my $sysCssName = $self->getSystemCssName(); | ||||
| 101 | |||||||
| 102 | 3 | 25 |  	my $mainContent = < | ||||
| 103 | |||||||
| 104 | |||||||
| 105 | |||||||
| 106 | |||||||
| 107 |  		 | 
||||||
| 108 | |||||||
| 109 | |||||||
| 110 | |||||||
| 111 | |||||||
| 112 | |||||||
| 113 | $builtBy | ||||||
| 114 | $scannedLocations | ||||||
| 115 | $style | ||||||
| 116 | $actualCSS | ||||||
| 117 | $groupDefs | ||||||
| 118 | $createdUpdated | ||||||
| 119 | |||||||
| 120 | |||||||
| 121 | |||||||
| 122 | MAIN | ||||||
| 123 | |||||||
| 124 | 3 | 14 | my $mainFile = slashify("$sitedir/main.html"); | ||||
| 125 | 3 | 28 | writeUTF8File($mainFile, $mainContent); | ||||
| 126 | |||||||
| 127 | 3 | 50 | 20 | print "Wrote main as '$mainFile'\n" if $args->isVerboseLevel(2); | |||
| 128 | } | ||||||
| 129 | |||||||
| 130 | sub __updateHeader | ||||||
| 131 | { | ||||||
| 132 | 3 | 3 | 13 | my $self = shift; | |||
| 133 | 3 | 9 | my $args = shift; | ||||
| 134 | |||||||
| 135 | 3 | 12 | my $sysCssName = $self->getSystemCssName(); | ||||
| 136 | |||||||
| 137 | 3 | 35 |  	my $headerContent = < | ||||
| 138 | |||||||
| 139 | |||||||
| 140 | |||||||
| 141 | |||||||
| 142 |  		 | 
||||||
| 143 | |||||||
| 144 | |||||||
| 145 | |||||||
| 146 | |||||||
| 147 | |||||||
| 148 |  		Pods2Site - Perl documentation from pods to html | 
||||||
| 149 | |||||||
| 150 | |||||||
| 151 | |||||||
| 152 | MAIN | ||||||
| 153 | |||||||
| 154 | 3 | 14 | my $sitedir = $args->getSiteDir(); | ||||
| 155 | 3 | 24 | my $headerFile = slashify("$sitedir/header.html"); | ||||
| 156 | 3 | 17 | writeUTF8File($headerFile, $headerContent); | ||||
| 157 | |||||||
| 158 | 3 | 50 | 20 | print "Wrote header as '$headerFile'\n" if $args->isVerboseLevel(2); | |||
| 159 | } | ||||||
| 160 | |||||||
| 161 | sub __updateTOC | ||||||
| 162 | { | ||||||
| 163 | 3 | 3 | 10 | my $self = shift; | |||
| 164 | 3 | 13 | my $args = shift; | ||||
| 165 | 3 | 8 | my $workGroups = shift; | ||||
| 166 | |||||||
| 167 | 3 | 10 | my $sitedir = $args->getSiteDir(); | ||||
| 168 | |||||||
| 169 | 3 | 14 | my $sections = ''; | ||||
| 170 | 3 | 20 | foreach my $workGroup (@$workGroups) | ||||
| 171 | { | ||||||
| 172 | 6 | 53 | $sections .= $self->_getCategoryTOC($workGroup->{group}, $workGroup->{podinfo}, $sitedir); | ||||
| 173 | } | ||||||
| 174 | |||||||
| 175 | 3 | 26 | $self->_rewriteCss($args); | ||||
| 176 | |||||||
| 177 | 3 | 14 | my $sysCssName = $self->getSystemCssName(); | ||||
| 178 | |||||||
| 179 | 3 | 26 |  	my $tocContent = < | ||||
| 180 | |||||||
| 181 | |||||||
| 182 | |||||||
| 183 | |||||||
| 184 |  		 | 
||||||
| 185 | |||||||
| 186 | |||||||
| 187 | |||||||
| 188 | |||||||
| 189 | |||||||
| 190 | $sections | ||||||
| 191 | |||||||
| 192 | |||||||
| 193 | |||||||
| 194 | TOC | ||||||
| 195 | |||||||
| 196 | 3 | 21 | my $tocFile = slashify("$sitedir/toc.html"); | ||||
| 197 | 3 | 21 | writeUTF8File($tocFile, $tocContent); | ||||
| 198 | |||||||
| 199 | 3 | 50 | 20 | print "Wrote TOC as '$tocFile'\n" if $args->isVerboseLevel(2); | |||
| 200 | } | ||||||
| 201 | |||||||
| 202 | sub __updateIndex | ||||||
| 203 | { | ||||||
| 204 | 3 | 3 | 12 | my $self = shift; | |||
| 205 | 3 | 7 | my $args = shift; | ||||
| 206 | |||||||
| 207 | 3 | 11 | my $sysCssName = $self->getSystemCssName(); | ||||
| 208 | 3 | 17 | my $title = encode_entities($args->getTitle()); | ||||
| 209 | |||||||
| 210 | 3 | 79 |  	my $indexContent = < | ||||
| 211 | |||||||
| 212 | |||||||
| 213 | |||||||
| 214 | |||||||
| 215 |  		 | 
||||||
| 216 | |||||||
| 217 | |||||||
| 218 | |||||||
| 219 | |||||||
| 220 | |||||||
| 221 | |||||||
| 222 | |||||||
| 223 | |||||||
| 224 | |||||||
| 225 | |||||||
| 226 | |||||||
| 227 | |||||||
| 228 | |||||||
| 229 | INDEX | ||||||
| 230 | |||||||
| 231 | 3 | 14 | my $sitedir = $args->getSiteDir(); | ||||
| 232 | 3 | 18 | my $indexFile = slashify("$sitedir/index.html"); | ||||
| 233 | 3 | 14 | writeUTF8File($indexFile, $indexContent); | ||||
| 234 | |||||||
| 235 | 3 | 50 | 23 | print "Wrote index as '$indexFile'\n" if $args->isVerboseLevel(2); | |||
| 236 | } | ||||||
| 237 | |||||||
| 238 | sub _getCategoryTOC | ||||||
| 239 | { | ||||||
| 240 | 0 | 0 | die("Missing override: _getCategoryTOC()"); | ||||
| 241 | } | ||||||
| 242 | |||||||
| 243 | sub _rewriteCss | ||||||
| 244 | 3 | { | |||||
| 245 | # noop | ||||||
| 246 | } | ||||||
| 247 | |||||||
| 248 | 1; |