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