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