Toader/Render/Entry.pm

filter: Statementstmt 7.9% 29 / 367 Branchbran 0.0% 0 / 126 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 9 / 18 Podpod 100% 9 / 9 totaltotal 9.0% 47 / 520 CC 64 SCAR 46.7
CC
64
Cov
6%
render
210.0
new
182.0
content
90.0
CRAP 107.0
« Toader/Render/Page.pm ↑ Summary Toader/findToaderDirs.pm »
1 package Toader::Render::Entry;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use base 'Error::Helper';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Toader::Render::General;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Toader::Templates;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Date::Parse;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Toader::pathHelper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use File::Path qw(make_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Toader::Render::Entry::Cleanup;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 Toader::Render::Entry - This renders a Toader::Entry object.
16  
17 =head1 VERSION
18  
19 Version 0.1.1
20  
21 =cut
22  
23 3 our $VERSION = '0.1.1';
24  
25 =head1 SYNOPSIS
26  
27 =head1 METHODS
28  
29 =head2 new
30  
31 This initiates the object.
32  
33 =head3 args hash ref
34  
35 =head4 obj
36  
37 This is the L<Toader::Entry> object to render.
38  
39 =head4 toader
40  
41 This is the L<Toader> object to use.
42  
43 =head2 toDir
44  
45 This is the value used to get from the directory it is being
46 rendered in back to directory storing stuff for that directory. By
47 default this is '../../' as it needs to get from '.entries/'.$entryID
48 back to the directory. Or we are creating a listing of the last
49 several in the '.entries/' directory, it should be set it to '../'.
50  
51  
52 my $foo=Toader::Render::Entry->new(\%args);
53 if($foo->error){
54 warn('error: '.$foo->error.":".$foo->errorString);
55 }
56  
57 =cut
58  
59 0 ▶sub new{
Subroutine new: not called CC=13 SCAR=52.0
Pod documented
60 0 my %args;
61 0 ▶ if(defined($_[1])){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 0 0 0
62 0 %args= %{$_[1]};
63 };
64  
65 0 my $self={
66 error=>undef,
67 errorString=>'',
68 perror=>undef,
69 toDir=>'../../',
70 errorExtra=>{
71 flags=>{
72 1=>'noObj',
73 2=>'noToaderObj',
74 3=>'objPerror',
75 4=>'toaderObjPerror',
76 5=>'noDirSet',
77 6=>'cleanupInitErrored',
78 7=>'cleanupErrored',
79 8=>'backendInitErrored',
80 9=>'pathhelperInitErrored',
81 11=>'noOutputDirSet',
82 12=>'outputDirDoesNotExist',
83 13=>'outputEntryDirCreationFailed',
84 14=>'outputFileDirCreationFailed',
85 15=>'generalInitErrored',
86 },
87 },
88 };
89 0 bless $self;
90  
91 0 ▶ if ( defined( $args{toDir} ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"toDir"}) 0 0 0
92 0 $self->{toDir}=$args{toDir};
93 }
94  
95 #make sure we have a Toader::Entry object.
96 0 ▶ if ( ! defined( $args{obj} ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"obj"}) 0 0 0
97 0 $self->{perror}=1;
98 0 $self->{error}=1;
99 0 $self->{errorString}='Nothing defined for the Toader::Entry object';
100 0 $self->warn;
101 0 return $self;
102 }
103 0 ▶ if ( ref( $args{obj} ) ne 'Toader::Entry' ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args{"obj"} ne "Toader::Entry") 0 0 0
104 0 $self->{perror}=1;
105 0 $self->{error}=1;
106 $self->{errorString}='The specified object is not a Toader::Entry object, but a "'.
107 0 ref( $args{obj} ).'"';
108 0 $self->warn;
109 0 return $self;
110 }
111 0 $self->{obj}=$args{obj};
112  
113 #make sure the object does not have a permanent error set
114 0 ▶ if( ! $self->{obj}->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"obj"}->errorblank) 0 0 0
115 0 $self->{perror}=1;
116 0 $self->{error}=3;
117 0 $self->{errorString}='The Toader::Entry object has a permanent error set';
118 0 $self->warn;
119 0 return $self;
120 }
121  
122 #make sure a Toader object is given
123 0 ▶ if ( ! defined( $args{toader} ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"toader"}) 0 0 0
124 0 $self->{perror}=1;
125 0 $self->{error}=2;
126 0 $self->{errorString}='Nothing defined for the Toader object';
127 0 $self->warn;
128 0 return $self;
129 }
130 0 ▶ if ( ref( $args{toader} ) ne 'Toader' ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args{"toader"} ne "Toader") 0 0 0
131 0 $self->{perror}=1;
132 0 $self->{error}=2;
133 $self->{errorString}='The specified object is not a Toader object, but a "'.
134 0 ref( $args{toader} ).'"';
135 0 $self->warn;
136 0 return $self;
137 }
138 0 $self->{toader}=$args{toader};
139  
140 #make sure the object does not have a permanent error set
141 0 ▶ if( ! $self->{toader}->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"toader"}->errorblank) 0 0 0
142 0 $self->{perror}=1;
143 0 $self->{error}=4;
144 0 $self->{errorString}='The Toader object has a permanent error set';
145 0 $self->warn;
146 0 return $self;
147 }
148  
149 #make sure a directory is set
150 0 ▶ if( ! defined( $self->{obj}->dirGet ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"obj"}->dirGet) 0 0 0
151 0 $self->{perror}=1;
152 0 $self->{error}=5;
153 0 $self->{errorString}='The Toader::Entry object does not have a directory set';
154 0 $self->warn;
155 0 return $self;
156 }
157 0 $self->{dir}=$self->{obj}->dirGet;
158  
159 #initialize this here for simplicity
160 $self->{t}=Toader::Templates->new({
161 dir=>$self->{obj}->dirGet,
162 toader=>$args{toader},
163 0 });
164  
165 #initialize the general object here for simplicity
166 $self->{g}=Toader::Render::General->new(
167 {
168 toader=>$self->{toader},
169 self=>\$self,
170 obj=>$self->{obj},
171 toDir=>$self->{toDir},
172 }
173 0 );
174 0 ▶ if ( $self->{g}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"g"}->error) 0 0 0
175 0 $self->{perror}=1;
176 0 $self->{error}=15;
177 $self->{errorString}='Failed to initialize Toader::Render::General. error="'
178 0 .$self->{g}->error.'" errorString="'.$self->{g}->errorString.'"';
179 0 $self->warn;
180 0 return $self;
181 }
182  
183 #initialize the Toader::pathHelper
184 0 $self->{ph}=Toader::pathHelper->new( $self->{dir} );
185 0 ▶ if ( $self->{ph}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ph"}->error) 0 0 0
186 0 $self->{perror}=1;
187 0 $self->{error}=6;
188 $self->{errorString}='Failed to initiate pathHelper. error="'.
189 0 $self->{ph}->error.'" errorString="'.$self->{ph}->errorString.'"';
190 0 $self->warn;
191 0 return $self;
192 }
193  
194 #gets the r2r for the object
195 0 $self->{r2r}=$self->{ph}->relative2root( $self->{dir} );
196 0 ▶ if ( $self->{ph}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ph"}->error) 0 0 0
197 0 $self->{perror}=1;
198 0 $self->{error}=19;
199 $self->{errorString}='pathHelper failed to find the relative2root path for "'.
200 0 $self->{odir}.'"';
201 0 $self->warn;
202 0 return $self;
203 }
204  
205 0 return $self;
206 }
207  
208 =head2 content
209  
210 This renders the content to be included in a static
211 entry page.
212  
213 my $content=$foo->content;
214  
215 =cut
216  
217 0 ▶sub content{
Subroutine content: not called CC=9 SCAR=45.0
Pod documented
218 0 my $self=$_[0];
219  
220 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
221 0 return undef;
222 }
223  
224 #puts together the date stuff
225 0 my $date=$self->{obj}->{mime}->header("Date");
226 0 my ($sec,$min,$hour,$day,$month,$year,$zone) = strptime($date);
227 0 $year=1900+$year;
228  
229 0 ▶ if( $day < 10 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($day < 10) 0 0 0
230 0 $day='0'.$day;
231 }
232 0 $month++;
233 0 ▶ if( $month < 10 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($month < 10) 0 0 0
234 0 $month='0'.$month;
235 }
236  
237 my $body=$self->{t}->fill_in_string( $self->{obj}->bodyGet,
238 {
239 title=>$self->{obj}->titleGet,
240 from=>$self->{obj}->fromGet,
241 date=>$self->{obj}->entryNameGet,
242 g=>\$self->{g},
243 toader=>\$self->{toader},
244 sec=>$sec,
245 min=>$min,
246 hour=>$hour,
247 day=>$day,
248 month=>$month,
249 year=>$year,
250 zone=>$zone,
251 obj=>\$self->{obj},
252 self=>\$self,
253 c=>\$self->{toader}->getConfig,
254 0 });
255 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
256 0 $self->{error}=8;
257 $self->{errorString}='Filling in the template failed. error="'.
258 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
259 0 $self->warn;
260 0 return undef;
261 }
262  
263 #this prepares to run it through the specified renderer
264 0 my $renderer;
265 my $torun='use Toader::Render::Entry::backends::'.$self->{obj}->rendererGet.'; '.
266 0 '$renderer=Toader::Render::Entry::backends::'.$self->{obj}->rendererGet.'->new({'.
267 'obj=>$self->{obj}, toader=>$self->{toader}, });';
268 0 eval( $torun );
269 0 ▶ if ( ! defined( $renderer ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $renderer) 0 0 0
270 0 $self->{error}=8;
271 $self->{errorString}='Failed to initialize the backend. It returned undef. '.
272 0 'renderer="'.$self->{obj}->rendererGet.'"';
273 0 $self->warn;
274 0 return undef;
275 }
276 0 ▶ if ( $renderer->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($renderer->error) 0 0 0
277 0 $self->{error}=8;
278 0 $self->{errorString}='Failed to initialize the backend. It returned with an error. '.
279 'error="'.$renderer->error.'" errorString="'.$renderer->errorString.'"';
280 0 $self->warn;
281 0 return undef;
282 }
283  
284 #render it
285 0 my $content=$renderer->render( $body );
286 0 ▶ if ( $renderer->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($renderer->error) 0 0 0
287 0 $self->{error}=9;
288 0 $self->{errorString}='Failed to render the content. It returned an error. '.
289 'error="'.$renderer->error.'" errorString="'.$renderer->errorString.'"';
290 0 $self->warn;
291 0 return undef;
292 }
293  
294 $content=$self->{t}->fill_in( 'entryContent',
295 {
296 body=>$content,
297 title=>$self->{obj}->titleGet,
298 from=>$self->{obj}->fromGet,
299 date=>$self->{obj}->entryNameGet,
300 g=>\$self->{g},
301 toader=>\$self->{toader},
302 sec=>$sec,
303 min=>$min,
304 hour=>$hour,
305 day=>$day,
306 month=>$month,
307 year=>$year,
308 zone=>$zone,
309 self=>\$self,
310 obj=>\$self->{obj},
311 c=>\$self->{toader}->getConfig,
312 0 });
313 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
314 0 $self->{error}=8;
315 $self->{errorString}='Filling in the template failed. error="'.
316 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
317 0 $self->warn;
318 0 return undef;
319 }
320  
321 0 return $content;
322 }
323  
324 =head2 archive
325  
326 This renders the '.entries/archive.html' file.
327  
328 =cut
329  
330 0 ▶sub archive{
Subroutine archive: not called CC=9 SCAR=45.0
Pod documented
331 0 my $self=$_[0];
332
333 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
334 0 return undef;
335 }
336  
337 #makes sure we have a output directory set...
338 #while we don't care about this for rendering the content, we do need to
339 #know this for actually fully rendering it
340 0 my $output=$self->{toader}->getOutputDir;
341 0 ▶ if ( ! defined( $output ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $output) 0 0 0
342 0 $self->{error}=11;
343 0 $self->{errorString}='No output directory has been set for the Toader object';
344 0 $self->warn;
345 0 return undef;
346 }
347  
348 #makes sure the output directory exists
349 0 ▶ if ( ! -d $output ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $output) 0 0 0
350 0 $self->{error}=12;
351 0 $self->{errorString}='The output directory, "'.$output.'", does not exist';
352 0 $self->warn;
353 0 return undef;
354 }
355  
356 #this renders the content of it
357 0 my $content=$self->archiveContent;
358 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
359 0 $self->warnString('Failed to render the content to include');
360 0 return undef;
361 }
362  
363 my $page=$self->{t}->fill_in( 'page',
364 {
365 toader=>\$self->{toader},
366 g=>\$self->{g},
367 self=>\$self,
368 obj=>\$self->{obj},
369 c=>\$self->{toader}->getConfig,
370 0 locationID=>'Entries Archive',
371 content=>$content,
372 });
373 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
374 0 $self->{error}=8;
375 $self->{errorString}='Filling in the template failed. error="'.
376 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
377 0 $self->warn;
378 0 return undef;
379 }
380  
381 #the paths that will be used
382 0 my $dir=$output.'/'.$self->{r2r}.'/.entries/';
383 0 my $index=$dir.'archive.html';
384  
385 #make sure the files and entry directory exist
386 0 ▶ if ( ! -d $dir ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
387 0 ▶ if ( ! make_path( $dir ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (make_path($dir)) 0 0 0
388 0 $self->{error}=13;
389 0 $self->{errorString}='The output entry directry, "'.$dir.'", could not be created';
390 0 $self->warn;
391 0 return undef;
392 }
393 }
394  
395 #write the index out
396 0 my $fh;
397 0 ▶ if ( ! open( $fh, '>', $index ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, ">", $index) 0 0 0
398 0 $self->{error}=15;
399 0 $self->{errorString}='Failed to open the index, "'.$index.'", for writing';
400 0 $self->warn;
401 0 return undef;
402 }
403 0 print $fh $page;
404 0 close( $fh );
405  
406 0 return 1;
407 }
408  
409 =head2 archiveContent
410  
411 This renders the content for the index.html page for the entries.
412  
413 =cut
414  
415 0 ▶sub archiveContent{
Subroutine archiveContent: not called CC=3 SCAR=24.8
Pod documented
416 0 my $self=$_[0];
417
418 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
419 0 return undef;
420 }
421  
422 my $content=$self->{t}->fill_in( 'entryArchive',
423 {
424 toader=>\$self->{toader},
425 g=>\$self->{g},
426 self=>\$self,
427 obj=>\$self->{obj},
428 c=>\$self->{toader}->getConfig,
429 0 });
430 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
431 0 $self->{error}=8;
432 $self->{errorString}='Filling in the template failed. error="'.
433 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
434 0 $self->warn;
435 0 return undef;
436 }
437  
438 0 return $content;
439 }
440  
441 =head2 index
442  
443 This renders the '.entries/index.html' file.
444  
445 =cut
446  
447 0 ▶sub index{
Subroutine index: not called CC=9 SCAR=45.0
Pod documented
448 0 my $self=$_[0];
449
450 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
451 0 return undef;
452 }
453  
454 #makes sure we have a output directory set...
455 #while we don't care about this for rendering the content, we do need to
456 #know this for actually fully rendering it
457 0 my $output=$self->{toader}->getOutputDir;
458 0 ▶ if ( ! defined( $output ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $output) 0 0 0
459 0 $self->{error}=11;
460 0 $self->{errorString}='No output directory has been set for the Toader object';
461 0 $self->warn;
462 0 return undef;
463 }
464  
465 #makes sure the output directory exists
466 0 ▶ if ( ! -d $output ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $output) 0 0 0
467 0 $self->{error}=12;
468 0 $self->{errorString}='The output directory, "'.$output.'", does not exist';
469 0 $self->warn;
470 0 return undef;
471 }
472  
473 #this renders the content of it
474 0 my $content=$self->indexContent;
475 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
476 0 $self->warnString('Failed to render the content to include');
477 0 return undef;
478 }
479  
480 my $page=$self->{t}->fill_in( 'page',
481 {
482 toader=>\$self->{toader},
483 g=>\$self->{g},
484 self=>\$self,
485 obj=>\$self->{obj},
486 c=>\$self->{toader}->getConfig,
487 0 locationID=>'Latest Entries',
488 content=>$content,
489 });
490 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
491 0 $self->{error}=8;
492 $self->{errorString}='Filling in the template failed. error="'.
493 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
494 0 $self->warn;
495 0 return undef;
496 }
497  
498 #the paths that will be used
499 0 my $dir=$output.'/'.$self->{r2r}.'/.entries/';
500 0 my $index=$dir.'index.html';
501  
502 #make sure the files and entry directory exist
503 0 ▶ if ( ! -d $dir ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
504 0 ▶ if ( ! make_path( $dir ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (make_path($dir)) 0 0 0
505 0 $self->{error}=13;
506 0 $self->{errorString}='The output entry directry, "'.$dir.'", could not be created';
507 0 $self->warn;
508 0 return undef;
509 }
510 }
511  
512 #write the index out
513 0 my $fh;
514 0 ▶ if ( ! open( $fh, '>', $index ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, ">", $index) 0 0 0
515 0 $self->{error}=15;
516 0 $self->{errorString}='Failed to open the index, "'.$index.'", for writing';
517 0 $self->warn;
518 0 return undef;
519 }
520 0 print $fh $page;
521 0 close( $fh );
522  
523 0 return 1;
524 }
525  
526 =head2 indexContent
527  
528 This renders the content for the index.html page for the entries.
529  
530 =cut
531  
532 0 ▶sub indexContent{
Subroutine indexContent: not called CC=3 SCAR=24.8
Pod documented
533 0 my $self=$_[0];
534
535 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
536 0 return undef;
537 }
538  
539 my $content=$self->{t}->fill_in( 'entryIndex',
540 {
541 toader=>\$self->{toader},
542 g=>\$self->{g},
543 self=>\$self,
544 obj=>\$self->{obj},
545 c=>\$self->{toader}->getConfig,
546 0 });
547 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
548 0 $self->{error}=8;
549 $self->{errorString}='Filling in the template failed. error="'.
550 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
551 0 $self->warn;
552 0 return undef;
553 }
554  
555 0 return $content;
556 }
557  
558 =head2 render
559  
560 This renders the object.
561  
562 No arguments are taken.
563  
564 =cut
565  
566 0 ▶sub render{
Subroutine render: not called CC=14 SCAR=53.5
Pod documented
567 0 my $self=$_[0];
568
569 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
570 0 return undef;
571 }
572  
573 #makes sure we have a output directory set...
574 #while we don't care about this for rendering the content, we do need to
575 #know this for actually fully rendering it
576 0 my $output=$self->{toader}->getOutputDir;
577 0 ▶ if ( ! defined( $output ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $output) 0 0 0
578 0 $self->{error}=11;
579 0 $self->{errorString}='No output directory has been set for the Toader object';
580 0 $self->warn;
581 0 return undef;
582 }
583  
584 #makes sure the output directory exists
585 0 ▶ if ( ! -d $output ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $output) 0 0 0
586 0 $self->{error}=12;
587 0 $self->{errorString}='The output directory, "'.$output.'", does not exist';
588 0 $self->warn;
589 0 return undef;
590 }
591  
592 #clean up the old entry
593 0 my $cleanup=Toader::Render::Entry::Cleanup->new( $self->{toader} );
594 0 ▶ if ( $cleanup->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cleanup->error) 0 0 0
595 0 $self->{error}=6;
596 0 $self->{errorString}='Initialing the cleanup module failed. error="'.
597 $cleanup->error.'" errorString="'.$cleanup->errorString.'"';
598 0 $self->warn;
599 0 return undef;
600 }
601 0 $cleanup->cleanup( $self->{obj} );
602 0 ▶ if ( $cleanup->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($cleanup->error) 0 0 0
603 0 $self->{error}=7;
604 0 $self->{errorString}='Cleanup failed. error="'.$cleanup->error.
605 '" errorString="'.$cleanup->errorString.'"';
606 0 $self->warn;
607 0 return undef;
608 }
609  
610 #this renders the content of it
611 0 my $content=$self->content;
612 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
613 0 $self->warnString('Failed to render the content to include');
614 0 return undef;
615 }
616  
617 my $page=$self->{t}->fill_in( 'page',
618 {
619 toader=>\$self->{toader},
620 g=>\$self->{g},
621 self=>\$self,
622 obj=>\$self->{obj},
623 c=>\$self->{toader}->getConfig,
624 0 content=>$content,
625 });
626 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
627 0 $self->{error}=8;
628 $self->{errorString}='Filling in the template failed. error="'.
629 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
630 0 $self->warn;
631 0 return undef;
632 }
633  
634 #put together some paths for later use
635 0 my $entryDir=$output.'/'.$self->{r2r}.'/.entries/'.$self->{obj}->entryNameGet;
636 0 my $index=$entryDir.'/index.html';
637 0 my $fileDir=$entryDir.'/.files';
638  
639 #make sure the files and entry directory exist
640 0 ▶ if ( ! -d $entryDir ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $entryDir) 0 0 0
641 0 ▶ if ( ! make_path( $entryDir ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (make_path($entryDir)) 0 0 0
642 0 $self->{error}=13;
643 0 $self->{errorString}='The output entry directry, "'.$entryDir.'", could not be created';
644 0 $self->warn;
645 0 return undef;
646 }
647 }
648 0 ▶ if ( ! -d $fileDir ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $fileDir) 0 0 0
649 0 ▶ if ( ! make_path( $fileDir ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (make_path($fileDir)) 0 0 0
650 0 $self->{error}=14;
651 0 $self->{errorString}='The output file directry, "'.$fileDir.'", could not be created';
652 0 $self->warn;
653 0 return undef;
654 }
655 }
656  
657 #write the index out
658 0 my $fh;
659 0 ▶ if ( ! open( $fh, '>', $index ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, ">", $index) 0 0 0
660 0 $self->{error}=15;
661 0 $self->{errorString}='Failed to open the index, "'.$index.'", for writing';
662 0 $self->warn;
663 0 return undef;
664 }
665 0 print $fh $page;
666 0 close( $fh );
667  
668 #extract the files
669 0 $self->{obj}->subpartsExtract( $fileDir );
670 0 ▶ if ( $self->{obj}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"obj"}->error) 0 0 0
671 0 $self->{error}=16;
672 $self->{errorString}='Failed to extract the subparts. error="'.
673 0 $self->{obj}->error.'" errorString="'.$self->{obj}->errorString.'"';
674 0 $self->warn;
675 0 return undef;
676 }
677  
678 0 return 1;
679 }
680  
681 =head2 tags
682  
683 This renders the '.entries/tags.html' file.
684  
685 =cut
686  
687 0 ▶sub tags{
Subroutine tags: not called CC=9 SCAR=45.0
Pod documented
688 0 my $self=$_[0];
689
690 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
691 0 return undef;
692 }
693  
694 #makes sure we have a output directory set...
695 #while we don't care about this for rendering the content, we do need to
696 #know this for actually fully rendering it
697 0 my $output=$self->{toader}->getOutputDir;
698 0 ▶ if ( ! defined( $output ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $output) 0 0 0
699 0 $self->{error}=11;
700 0 $self->{errorString}='No output directory has been set for the Toader object';
701 0 $self->warn;
702 0 return undef;
703 }
704  
705 #makes sure the output directory exists
706 0 ▶ if ( ! -d $output ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $output) 0 0 0
707 0 $self->{error}=12;
708 0 $self->{errorString}='The output directory, "'.$output.'", does not exist';
709 0 $self->warn;
710 0 return undef;
711 }
712  
713 #this renders the content of it
714 0 my $content=$self->tagsContent;
715 0 ▶ if ( $self->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->error) 0 0 0
716 0 $self->warnString('Failed to render the content to include');
717 0 return undef;
718 }
719  
720 my $page=$self->{t}->fill_in( 'page',
721 {
722 toader=>\$self->{toader},
723 g=>\$self->{g},
724 self=>\$self,
725 obj=>\$self->{obj},
726 c=>\$self->{toader}->getConfig,
727 0 locationID=>'Entry Tags',
728 content=>$content,
729 });
730 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
731 0 $self->{error}=8;
732 $self->{errorString}='Filling in the template failed. error="'.
733 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
734 0 $self->warn;
735 0 return undef;
736 }
737  
738 #the paths that will be used
739 0 my $dir=$output.'/'.$self->{r2r}.'/.entries/';
740 0 my $index=$dir.'tags.html';
741  
742 #make sure the files and entry directory exist
743 0 ▶ if ( ! -d $dir ){
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
744 0 ▶ if ( ! make_path( $dir ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (make_path($dir)) 0 0 0
745 0 $self->{error}=13;
746 0 $self->{errorString}='The output entry directry, "'.$dir.'", could not be created';
747 0 $self->warn;
748 0 return undef;
749 }
750 }
751  
752 #write the index out
753 0 my $fh;
754 0 ▶ if ( ! open( $fh, '>', $index ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, ">", $index) 0 0 0
755 0 $self->{error}=15;
756 0 $self->{errorString}='Failed to open the index, "'.$index.'", for writing';
757 0 $self->warn;
758 0 return undef;
759 }
760 0 print $fh $page;
761 0 close( $fh );
762  
763 0 return 1;
764 }
765  
766 =head2 tagsContent
767  
768 This renders the content for the index.html page for the entries.
769  
770 =cut
771  
772 0 ▶sub tagsContent{
Subroutine tagsContent: not called CC=3 SCAR=24.8
Pod documented
773 0 my $self=$_[0];
774
775 0 ▶ if ( ! $self->errorblank ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->errorblank) 0 0 0
776 0 return undef;
777 }
778  
779 my $content=$self->{t}->fill_in( 'entryTags',
780 {
781 toader=>\$self->{toader},
782 g=>\$self->{g},
783 self=>\$self,
784 obj=>\$self->{obj},
785 c=>\$self->{toader}->getConfig,
786 0 });
787 0 ▶ if ( $self->{t}->error ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"t"}->error) 0 0 0
788 0 $self->{error}=8;
789 $self->{errorString}='Filling in the template failed. error="'.
790 0 $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"';
791 0 $self->warn;
792 0 return undef;
793 }
794  
795 0 return $content;
796 }
797  
798 =head1 ERROR CODES
799  
800 =head2 1, noObj
801  
802 No L<Toader::Entry> object specified.
803  
804 =head2 2, noToaderObj
805  
806 No L<Toader> object specified.
807  
808 =head2 3, objPerror
809  
810 The L<Toader::Entry> object has a permanent error set.
811  
812 =head2 4, toaderObjPerror
813  
814 The L<Toader> object has a permanent error set.
815  
816 =head2 5, noDirSet
817  
818 The L<Toader::Entry> object does not have a directory set
819  
820 =head2 6, cleanupInitErrored
821  
822 Failed to initialize the cleanup module.
823  
824 =head2 7, cleanupErrored
825  
826 Failed to cleanup.
827  
828 =head2 8, backendInitErrored
829  
830 Failed to initialize the backend.
831  
832 =head2 9, pathhelperInitErrored
833  
834 Failed to initialize the path helper.
835  
836 =head2 11, noOutputDirSet
837  
838 The L<Toader> object does not have a output directory set.
839  
840 =head2 12, outputDirDoesNotExist
841  
842 The output directory does not exist.
843  
844 =head2 13, outputEntryDirCreationFailed
845  
846 The output entry directory could not be created.
847  
848 =head2 14, outputFileDirCreationFailed
849  
850 The output file directory could not be created.
851  
852 =head2 15, generalInitErrored
853  
854 Failed to initialize the L<Toader::Render::General> object.
855  
856 =head1 AUTHOR
857  
858 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
859  
860 =head1 BUGS
861  
862 Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through
863 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll
864 automatically be notified of progress on your bug as I make changes.
865  
866  
867  
868  
869 =head1 SUPPORT
870  
871 You can find documentation for this module with the perldoc command.
872  
873 perldoc Toader::Render
874  
875  
876 You can also look for information at:
877  
878 =over 4
879  
880 =item * RT: CPAN's request tracker
881  
882 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader>
883  
884 =item * AnnoCPAN: Annotated CPAN documentation
885  
886 L<http://annocpan.org/dist/Toader>
887  
888 =item * CPAN Ratings
889  
890 L<http://cpanratings.perl.org/d/Toader>
891  
892 =item * Search CPAN
893  
894 L<http://search.cpan.org/dist/Toader/>
895  
896 =back
897  
898  
899 =head1 ACKNOWLEDGEMENTS
900  
901  
902 =head1 LICENSE AND COPYRIGHT
903  
904 Copyright 2011. Zane C. Bowers-Hadley.
905  
906 This program is free software; you can redistribute it and/or modify it
907 under the terms of either: the GNU General Public License as published
908 by the Free Software Foundation; or the Artistic License.
909  
910 See http://dev.perl.org/licenses/ for more information.
911  
912  
913 =cut
914  
915 3 1; # End of Toader::Render::Entry
« Toader/Render/Page.pm ↑ Summary Toader/findToaderDirs.pm »