| 1 | package Toader::Render::General; | ||
| 2 | |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use base 'Error::Helper'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Toader::Templates; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 7 | use Toader::Entry::Helper; | ||
| 8 | use Toader::Entry::Manage; | ||
| 9 | use Toader::Page::Helper; | ||
| 10 | use Toader::Page::Manage; | ||
| 11 | use Toader::Render::CSS; | ||
| 12 | use Toader::Render::Entry; | ||
| 13 | use Toader::Render::supportedObjects; | ||
| 14 | use Toader::pathHelper; | ||
| 15 | use Toader::Gallery; | ||
| 16 | use File::Spec; | ||
| 17 | use Toader::Directory; | ||
| 18 | use Email::Address; | ||
| 19 | use Toader::AutoDoc; | ||
| 20 | use Image::ExifTool; | ||
| 21 | use Script::isAperlScript; | ||
| 22 | |||
| 23 | =head1 NAME | ||
| 24 | |||
| 25 | Toader::Render::General - Renders various general stuff for Toader as well as some other stuff. | ||
| 26 | |||
| 27 | =head1 VERSION | ||
| 28 | |||
| 29 | Version 0.5.0 | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | our $VERSION = '0.5.0'; | ||
| 34 | |||
| 35 | =head1 METHODS | ||
| 36 | |||
| 37 | =head2 new | ||
| 38 | |||
| 39 | This initiates the object. | ||
| 40 | |||
| 41 | =head3 args hash ref | ||
| 42 | |||
| 43 | =head4 toader | ||
| 44 | |||
| 45 | This is the L<Toader> object. | ||
| 46 | |||
| 47 | =head4 obj | ||
| 48 | |||
| 49 | This is the L<Toader> object being worked with. | ||
| 50 | |||
| 51 | =head4 toDir | ||
| 52 | |||
| 53 | This is the path to use for getting back down to the directory. | ||
| 54 | |||
| 55 | Lets say we have rendered a single entry to it's page, then it would | ||
| 56 | be "../../", were as if we rendered a page of multiple entries it | ||
| 57 | would be "../". | ||
| 58 | |||
| 59 | The default is "../../". | ||
| 60 | |||
| 61 | This is set to '' if fullURL is set to true. | ||
| 62 | |||
| 63 | =head4 fullURL | ||
| 64 | |||
| 65 | This is if it should make a non-relative link for when generating links. If set to 1, | ||
| 66 | it makes links non-relative. If not defined/false it uses relative links. | ||
| 67 | |||
| 68 | =head4 dir | ||
| 69 | |||
| 70 | This is the directory that it is currently in. This can differ from the object directory | ||
| 71 | and if not defined will be set to the object directory, which is found via $args{obj}->dirGet. | ||
| 72 | |||
| 73 | my $g=Toader::Render::General->new(\%args); | ||
| 74 | if($g->error){ | ||
| 75 | warn('error: '.$g->error.":".$g->errorString); | ||
| 76 | } | ||
| 77 | |||
| 78 | =cut | ||
| 79 | |||
| 80 | sub new{ | ||
| 81 | my %args; | ||
| 82 | if(defined($_[1])){ | ||
| 83 | %args= %{$_[1]}; | ||
| 84 | }; | ||
| 85 | |||
| 86 | my $self={ | ||
| 87 | error=>undef, | ||
| 88 | errorString=>'', | ||
| 89 | perror=>undef, | ||
| 90 | isatd=>Toader::isaToaderDir->new, | ||
| 91 | soc=>Toader::Render::supportedObjects->new, | ||
| 92 | toDir=>'../../', | ||
| 93 | fullURL=>0, | ||
| 94 | locationSub=>'', | ||
| 95 | errorExtra=>{ | ||
| 96 | flags=>{ | ||
| 97 | 1=>'noToaderObj', | ||
| 98 | 2=>'notAtoaderObj', | ||
| 99 | 3=>'toaderPerror', | ||
| 100 | 4=>'noRenderableObj', | ||
| 101 | 5=>'notArenderableObj', | ||
| 102 | 6=>'objPerror', | ||
| 103 | 7=>'noDirSet', | ||
| 104 | 8=>'noLinkDefined', | ||
| 105 | 9=>'templateFetchErrored', | ||
| 106 | 11=>'noToaderdirSpecified', | ||
| 107 | 12=>'notAtoaderDir', | ||
| 108 | 13=>'noEntryIDspecified', | ||
| 109 | 14=>'entryDoesNotExist', | ||
| 110 | 15=>'noPageSpecified', | ||
| 111 | 16=>'pageDoesNotExist', | ||
| 112 | 17=>'noFileSpecified', | ||
| 113 | 18=>'templateInitErrored', | ||
| 114 | 19=>'r2rErrored', | ||
| 115 | 20=>'b2rErrored', | ||
| 116 | 21=>'pathhelperInitErrored', | ||
| 117 | 22=>'subToaderDirListErrored', | ||
| 118 | 23=>'pageManageDirSetErrored', | ||
| 119 | 24=>'listPagesErrored', | ||
| 120 | 25=>'entryManageErrored', | ||
| 121 | 26=>'readEntryErrored', | ||
| 122 | 27=>'renderEntryInitErrored', | ||
| 123 | 28=>'renderEntryErrored', | ||
| 124 | 29=>'noAuthorsLineSpecified', | ||
| 125 | 30=>'authorsLineParseFailed', | ||
| 126 | 31=>'entryManageDirSetErrored', | ||
| 127 | 32=>'pageListErrored', | ||
| 128 | 33=>'pageReadErrored', | ||
| 129 | 34=>'autoDocFileDotDotError', | ||
| 130 | 35=>'noURLinConfig', | ||
| 131 | 36=>'noImageURLspecified', | ||
| 132 | 37=>'noImageFileSpecified', | ||
| 133 | 38=>'imageDoesNotExist', | ||
| 134 | 39=>'pathCleanupErrored', | ||
| 135 | 40=>'galleryInitErrored', | ||
| 136 | 41=>'outputURLnotSpecified', | ||
| 137 | 42=>'noSrcPathSpecified', | ||
| 138 | 43=>'noURLspecified', | ||
| 139 | 44=>'relativeDirContainsAperiod', | ||
| 140 | 45=>'noSrcURLspecified', | ||
| 141 | }, | ||
| 142 | }, | ||
| 143 | }; | ||
| 144 | bless $self; | ||
| 145 | |||
| 146 | if ( defined ( $args{toDir} ) ){ | ||
| 147 | $self->{toDir}=$args{toDir}; | ||
| 148 | } | ||
| 149 | |||
| 150 | |||
| 151 | if ( defined( $args{fullURL} ) ){ | ||
| 152 | $self->{fullURL}=$args{fullURL}; | ||
| 153 | } | ||
| 154 | |||
| 155 | #make sure we have a usable Toader object | ||
| 156 | if ( ! defined( $args{toader} ) ){ | ||
| 157 | $self->{perror}=1; | ||
| 158 | $self->{error}=1; | ||
| 159 | $self->{errorString}='No Toader object defined'; | ||
| 160 | $self->warn; | ||
| 161 | return $self; | ||
| 162 | } | ||
| 163 | if ( ref( $args{toader} ) ne 'Toader' ){ | ||
| 164 | $self->{perror}=1; | ||
| 165 | $self->{error}=2; | ||
| 166 | $self->{errorString}='The specified Toader object is actually a "'.ref( $args{ref} ).'"'; | ||
| 167 | $self->warn; | ||
| 168 | return $self; | ||
| 169 | } | ||
| 170 | if ( ! $args{toader}->errorblank ){ | ||
| 171 | $self->{perror}=1; | ||
| 172 | $self->{error}=3; | ||
| 173 | $self->{errorString}='The Toader object has a permanent error set'; | ||
| 174 | $self->warn; | ||
| 175 | return $self; | ||
| 176 | } | ||
| 177 | $self->{toader}=$args{toader}; | ||
| 178 | $self->{ph}=$self->{toader}->getPathHelper; | ||
| 179 | |||
| 180 | #make sure we have a usable object | ||
| 181 | if ( ! defined( $args{obj} ) ){ | ||
| 182 | $self->{perror}=1; | ||
| 183 | $self->{error}=4; | ||
| 184 | $self->{errorString}='No object specified for the renderable object'; | ||
| 185 | $self->warn; | ||
| 186 | return $self; | ||
| 187 | } | ||
| 188 | if ( ! $self->{soc}->isSupported( $args{obj} ) ){ | ||
| 189 | $self->{perror}=1; | ||
| 190 | $self->{error}=5; | ||
| 191 | $self->{errorString}='"'.ref( $args{obj} ).'" does not appear to be a Toader renderable object'; | ||
| 192 | $self->warn; | ||
| 193 | return $self; | ||
| 194 | } | ||
| 195 | if ( ! $args{obj}->errorblank ){ | ||
| 196 | $self->{perror}=1; | ||
| 197 | $self->{error}=6; | ||
| 198 | $self->{errorString}='The specified renderable object has a permanent error set'; | ||
| 199 | $self->warn; | ||
| 200 | return $self; | ||
| 201 | } | ||
| 202 | $self->{obj}=$args{obj}; | ||
| 203 | |||
| 204 | #make sure the renderable object has a directory set | ||
| 205 | $self->{odir}=$self->{obj}->dirGet; | ||
| 206 | if ( ! defined( $self->{odir} ) ){ | ||
| 207 | $self->{perror}=1; | ||
| 208 | $self->{error}=7; | ||
| 209 | $self->{errorString}='The renderable object does not have a directory specified'; | ||
| 210 | $self->warn; | ||
| 211 | return $self; | ||
| 212 | } | ||
| 213 | |||
| 214 | #initialize the Toader::pathHelper | ||
| 215 | $self->{ph}=Toader::pathHelper->new( $self->{odir} ); | ||
| 216 | if ( $self->{ph}->error ){ | ||
| 217 | $self->{perror}=1; | ||
| 218 | $self->{error}=6; | ||
| 219 | $self->{errorString}='Failed to initiate pathHelper. error="'. | ||
| 220 | $self->{ph}->error.'" errorString="'.$self->{ph}->errorString.'"'; | ||
| 221 | $self->warn; | ||
| 222 | return $self; | ||
| 223 | } | ||
| 224 | |||
| 225 | #cleans up the object directory path | ||
| 226 | $self->{odir}=$self->{ph}->cleanup( $self->{odir} ); | ||
| 227 | if ( $self->{ph}->error ){ | ||
| 228 | $self->{perror}=1; | ||
| 229 | $self->{error}=39; | ||
| 230 | $self->{errorString}='Failed to clean up the path for "'.$self->{odir}.'"'; | ||
| 231 | $self->warn; | ||
| 232 | return undef; | ||
| 233 | } | ||
| 234 | |||
| 235 | #get this once as it does not change and is likely to be used | ||
| 236 | #gets the r2r for the object | ||
| 237 | $self->{or2r}=$self->{ph}->relative2root( $self->{odir} ); | ||
| 238 | if ( $self->{ph}->error ){ | ||
| 239 | $self->{perror}=1; | ||
| 240 | $self->{error}=19; | ||
| 241 | $self->{errorString}='pathHelper failed to find the relative2root path for "'. | ||
| 242 | $self->{odir}.'"'; | ||
| 243 | $self->warn; | ||
| 244 | return $self; | ||
| 245 | } | ||
| 246 | #get the b2r for the object | ||
| 247 | $self->{ob2r}=$self->{toDir}.'/'.$self->{ph}->back2root( $self->{odir} ); | ||
| 248 | if ( $self->{ph}->error ){ | ||
| 249 | $self->{perror}=1; | ||
| 250 | $self->{error}=20; | ||
| 251 | $self->{errorString}='pathHelper failed to find the relative2root path for "'. | ||
| 252 | $self->{odir}.'"'; | ||
| 253 | $self->warn; | ||
| 254 | return $self; | ||
| 255 | } | ||
| 256 | #makes gets the directory to work in | ||
| 257 | if ( defined( $args{dir} ) ){ | ||
| 258 | $self->{dir}=$args{dir}; | ||
| 259 | $self->{r2r}=$self->{ph}->relative2root( $self->{dir} ); | ||
| 260 | if ( $self->{ph}->error ){ | ||
| 261 | $self->{perror}=1; | ||
| 262 | $self->{error}=19; | ||
| 263 | $self->{errorString}='pathHelper failed to find the relative2root path for "'. | ||
| 264 | $self->{dir}.'"'; | ||
| 265 | return $self; | ||
| 266 | } | ||
| 267 | $self->{b2r}=$self->{toDir}.'/'.$self->{toDir}.'/'.$self->{ph}->relative2root( $self->{dir} ); | ||
| 268 | if ( $self->{ph}->error ){ | ||
| 269 | $self->{perror}=1; | ||
| 270 | $self->{error}=20; | ||
| 271 | $self->{errorString}='pathHelper failed to find the relative2root path for "'. | ||
| 272 | $self->{dir}.'"'; | ||
| 273 | return $self; | ||
| 274 | } | ||
| 275 | }else{ | ||
| 276 | $self->{dir}=$self->{odir}; | ||
| 277 | $self->{r2r}=$self->{or2r}; | ||
| 278 | $self->{b2r}=$self->{ob2r}; | ||
| 279 | } | ||
| 280 | |||
| 281 | #clean up the various paths | ||
| 282 | $self->{dir}=File::Spec->canonpath( $self->{dir} ); | ||
| 283 | $self->{r2r}=File::Spec->canonpath( $self->{r2r} ); | ||
| 284 | $self->{b2r}=File::Spec->canonpath( $self->{b2r} ); | ||
| 285 | $self->{or2r}=File::Spec->canonpath( $self->{or2r} ); | ||
| 286 | $self->{ob2r}=File::Spec->canonpath( $self->{ob2r} ); | ||
| 287 | |||
| 288 | #gets the base URL | ||
| 289 | my $c=$self->{toader}->getConfig; | ||
| 290 | if ( defined( $c->{'_'}->{'url'} ) ){ | ||
| 291 | $self->{url}=$c->{'_'}->{'url'}; | ||
| 292 | } | ||
| 293 | if ( $self->{fullURL} ){ | ||
| 294 | if ( ! defined( $c->{'_'}->{url} ) ){ | ||
| 295 | $self->{perror}=1; | ||
| 296 | $self->{error}=35; | ||
| 297 | $self->{errorString}='No URL specified in the Toader config'; | ||
| 298 | $self->warn; | ||
| 299 | return $self; | ||
| 300 | } | ||
| 301 | $self->{toDir}=''; | ||
| 302 | } | ||
| 303 | |||
| 304 | #figures out the file directory | ||
| 305 | $self->{toFiles}=$self->{b2r}.'/'.$self->{or2r}.'/'.$self->{obj}->filesDir; | ||
| 306 | $self->{toFiles}=File::Spec->canonpath( $self->{toFiles} ); | ||
| 307 | |||
| 308 | #initiates the Templates object | ||
| 309 | $self->{t}=Toader::Templates->new({ | ||
| 310 | dir=>$self->{dir}, | ||
| 311 | toader=>$args{toader}, | ||
| 312 | }); | ||
| 313 | if ( $self->{t}->error ){ | ||
| 314 | $self->{perror}=1; | ||
| 315 | $self->{error}=18; | ||
| 316 | $self->{errorString}='Failed to initialize the Toader::Templates module'; | ||
| 317 | $self->warn; | ||
| 318 | return $self; | ||
| 319 | } | ||
| 320 | |||
| 321 | #checks if it is at the root or not | ||
| 322 | $self->{atRoot}=$self->{ph}->atRoot( $self->{odir} ); | ||
| 323 | |||
| 324 | return $self; | ||
| 325 | } | ||
| 326 | |||
| 327 | =head2 adlink | ||
| 328 | |||
| 329 | This generates a link to the the specified documentation file. | ||
| 330 | |||
| 331 | Three arguments are taken. The first is the relative directory to the | ||
| 332 | Toader root in which it resides, which if left undefined is the same | ||
| 333 | as the object used to initiate this object. The second is file found by | ||
| 334 | autodoc. The third is the text for the link, which if left undefined is | ||
| 335 | the same as the file. | ||
| 336 | |||
| 337 | If the text is left undefined and the file ends in ".html", the ".html" | ||
| 338 | part is removed. | ||
| 339 | |||
| 340 | $g->cdlink( $directory, $file, $text ); | ||
| 341 | |||
| 342 | The template used for this is 'linkDirectory', which by default | ||
| 343 | is as below. | ||
| 344 | |||
| 345 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 346 | |||
| 347 | The variables passed to it are as below. | ||
| 348 | |||
| 349 | url - This is the relative URL for this. | ||
| 350 | text - This to use for with the link. | ||
| 351 | toDir - This is the relative back to the directory. | ||
| 352 | toFiles - This is the relative path to the '.files' directory. | ||
| 353 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 354 | self - The L<Toader::Render::General> object. | ||
| 355 | toader - This is a L<Toader> object. | ||
| 356 | g - This is a L<Toader::Render::General> object. | ||
| 357 | obj - This is the object that Toader was initiated with. | ||
| 358 | |||
| 359 | =cut | ||
| 360 | |||
| 361 | sub adlink{ | ||
| 362 | my $self=$_[0]; | ||
| 363 | my $dir=$_[1]; | ||
| 364 | my $file=$_[2]; | ||
| 365 | my $txt=$_[3]; | ||
| 366 | |||
| 367 | #blanks any previous errors | ||
| 368 | if ( ! $self->errorblank ){ | ||
| 369 | return undef; | ||
| 370 | } | ||
| 371 | |||
| 372 | if ( ! defined( $dir ) ){ | ||
| 373 | $dir=$self->{r2r}; | ||
| 374 | } | ||
| 375 | |||
| 376 | # make sure a file is specified | ||
| 377 | if ( ! defined( $file ) ){ | ||
| 378 | $self->{error}=17; | ||
| 379 | $self->{errorString}='No file specified'; | ||
| 380 | $self->warn; | ||
| 381 | return undef; | ||
| 382 | } | ||
| 383 | |||
| 384 | #make sure it does not start with ../ | ||
| 385 | if ( $file =~ /^\.\.\// ){ | ||
| 386 | $self->{error}=34; | ||
| 387 | $self->{errorString}='File matches /^..\//'; | ||
| 388 | $self->warn; | ||
| 389 | return undef; | ||
| 390 | } | ||
| 391 | |||
| 392 | my $checker=Script::isAperlScript->new({ | ||
| 393 | any=>1, | ||
| 394 | env=>1, | ||
| 395 | }); | ||
| 396 | #append .html for POD docs | ||
| 397 | if ( $file =~ /\.[Pp][Oo][Dd]$/ ){ | ||
| 398 | $file=$file.'.html'; | ||
| 399 | } | ||
| 400 | if ( $file =~ /\.[Pp][Mm]$/ ){ | ||
| 401 | $file=$file.'.html'; | ||
| 402 | } | ||
| 403 | if ( $checker->isAperlScript( $self->{dir}.'/'.$file ) ){ | ||
| 404 | $file=$file.'.html'; | ||
| 405 | } | ||
| 406 | |||
| 407 | if ( ! defined( $txt ) ){ | ||
| 408 | $txt=$file; | ||
| 409 | $txt=~s/\.html$//; | ||
| 410 | } | ||
| 411 | |||
| 412 | my $link=''; | ||
| 413 | if ( $self->{fullURL} ){ | ||
| 414 | $link=$dir.'/.autodoc/.files/'.$file; | ||
| 415 | $link=~s/\/\/*/\//g; | ||
| 416 | $link=$self->{url}.$link; | ||
| 417 | }else{ | ||
| 418 | $link=$self->{b2r}.'/'.$dir.'/.autodoc/.files/'.$file; | ||
| 419 | $link=~s/\/\/*/\//g; | ||
| 420 | } | ||
| 421 | |||
| 422 | #renders the AutoDoc link | ||
| 423 | my $adlink=$self->{t}->fill_in( | ||
| 424 | 'autodocLink', | ||
| 425 | { | ||
| 426 | toDir=>$self->{toDir}, | ||
| 427 | toFiles=>$self->{toFiles}, | ||
| 428 | obj=>\$self->{obj}, | ||
| 429 | c=>\$self->{toader}->getConfig, | ||
| 430 | toader=>\$self->{toader}, | ||
| 431 | self=>\$self, | ||
| 432 | g=>\$self, | ||
| 433 | url=>$link, | ||
| 434 | text=>$txt, | ||
| 435 | } | ||
| 436 | ); | ||
| 437 | if ( $self->{t}->error ){ | ||
| 438 | $self->{error}=10; | ||
| 439 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 440 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 441 | $self->warn; | ||
| 442 | return undef; | ||
| 443 | } | ||
| 444 | |||
| 445 | return $adlink; | ||
| 446 | } | ||
| 447 | |||
| 448 | =head2 adListLink | ||
| 449 | |||
| 450 | This returns a link to the documentation list. | ||
| 451 | |||
| 452 | The template used for this is 'linkAutoDocList', which by default | ||
| 453 | is as below. | ||
| 454 | |||
| 455 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 456 | |||
| 457 | The variables passed to it are as below. | ||
| 458 | |||
| 459 | url - This is the relative URL for this. | ||
| 460 | text - This to use for with the link. | ||
| 461 | toDir - This is the relative back to the directory. | ||
| 462 | toFiles - This is the relative path to the '.files' directory. | ||
| 463 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 464 | self - The L<Toader::Render::General> object. | ||
| 465 | toader - This is a L<Toader> object. | ||
| 466 | g - This is a L<Toader::Render::General> object. | ||
| 467 | obj - This is the object that Toader was initiated with. | ||
| 468 | |||
| 469 | =cut | ||
| 470 | |||
| 471 | sub adListLink{ | ||
| 472 | my $self=$_[0]; | ||
| 473 | my $text=$_[1]; | ||
| 474 | |||
| 475 | if ( ! $self->errorblank ){ | ||
| 476 | return undef; | ||
| 477 | } | ||
| 478 | |||
| 479 | if (! defined( $text ) ){ | ||
| 480 | $text='Documentation'; | ||
| 481 | } | ||
| 482 | |||
| 483 | my $link=''; | ||
| 484 | if ( $self->{fullURL} ){ | ||
| 485 | $link=$self->{r2r}; | ||
| 486 | $link=~s/\/\/*/\//g; | ||
| 487 | $link=$self->{url}.$link; | ||
| 488 | }else{ | ||
| 489 | $link=$self->{b2r}.'/'.$self->{r2r}.'/.autodoc/'; | ||
| 490 | $link=~s/\/\/*/\//g; | ||
| 491 | } | ||
| 492 | |||
| 493 | |||
| 494 | #renders the beginning of the authors links | ||
| 495 | my $adllink=$self->{t}->fill_in( | ||
| 496 | 'linkAutoDocList', | ||
| 497 | { | ||
| 498 | toDir=>$self->{toDir}, | ||
| 499 | toFiles=>$self->{toFiles}, | ||
| 500 | obj=>\$self->{obj}, | ||
| 501 | c=>\$self->{toader}->getConfig, | ||
| 502 | toader=>\$self->{toader}, | ||
| 503 | self=>\$self, | ||
| 504 | g=>\$self, | ||
| 505 | url=>$link, | ||
| 506 | text=>$text, | ||
| 507 | } | ||
| 508 | ); | ||
| 509 | if ( $self->{t}->error ){ | ||
| 510 | $self->{error}=10; | ||
| 511 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 512 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 513 | $self->warn; | ||
| 514 | return undef; | ||
| 515 | } | ||
| 516 | |||
| 517 | return $adllink; | ||
| 518 | } | ||
| 519 | |||
| 520 | =head2 atRoot | ||
| 521 | |||
| 522 | This returns a Perl boolean value for if the current directory | ||
| 523 | is the root L<Toader> directory or not. | ||
| 524 | |||
| 525 | my $atRoot=$g->atRoot; | ||
| 526 | if ( $aRoot ){ | ||
| 527 | print "At root.\n"; | ||
| 528 | } | ||
| 529 | |||
| 530 | =cut | ||
| 531 | |||
| 532 | sub atRoot{ | ||
| 533 | my $self=$_[0]; | ||
| 534 | |||
| 535 | if ( ! $self->errorblank ){ | ||
| 536 | return undef; | ||
| 537 | } | ||
| 538 | |||
| 539 | return $self->{atRoot}; | ||
| 540 | } | ||
| 541 | |||
| 542 | =head2 authorsLink | ||
| 543 | |||
| 544 | Used for generating the author line. | ||
| 545 | |||
| 546 | This parses a From header, such as the value returned | ||
| 547 | from Toader::Entry->fromGet. | ||
| 548 | |||
| 549 | One value is requied and that is what is to be parsed and | ||
| 550 | returned as a link. | ||
| 551 | |||
| 552 | $g->authorsLink($entry->fromGet); | ||
| 553 | |||
| 554 | =head3 Templates | ||
| 555 | |||
| 556 | =head4 authorBegin | ||
| 557 | |||
| 558 | This begins the authors link section. | ||
| 559 | |||
| 560 | The default template is blank. | ||
| 561 | |||
| 562 | The variables passed to it are as below. | ||
| 563 | |||
| 564 | toDir - This is the relative back to the directory. | ||
| 565 | toFiles - This is the relative path to the '.files' directory. | ||
| 566 | obj - This is the object that it was invoked for. | ||
| 567 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 568 | toader - This is a L<Toader> object. | ||
| 569 | self - This the L<Toader::Render::General> object. | ||
| 570 | g - This the L<Toader::Render::General> object. | ||
| 571 | |||
| 572 | =head4 authorLink | ||
| 573 | |||
| 574 | This is a link for one of the authors. | ||
| 575 | |||
| 576 | The default template is as below. | ||
| 577 | |||
| 578 | <a href="mailto:[== $address ==]">[== $name ==]</a> | ||
| 579 | |||
| 580 | The variables passed to it are as below. | ||
| 581 | |||
| 582 | toDir - This is the relative back to the directory. | ||
| 583 | toFiles - This is the relative path to the '.files' directory. | ||
| 584 | obj - This is the object that it was invoked for. | ||
| 585 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 586 | toader - This is a L<Toader> object. | ||
| 587 | self - This the L<Toader::Render::General> object. | ||
| 588 | g - This the L<Toader::Render::General> object. | ||
| 589 | address - The email address of the author. | ||
| 590 | comment - The comment portion of it. | ||
| 591 | original - The original form for this chunk. | ||
| 592 | name - The name of the author. | ||
| 593 | |||
| 594 | =head4 authorJoin | ||
| 595 | |||
| 596 | This is used for joining multiple authors. | ||
| 597 | |||
| 598 | The default template is as below. | ||
| 599 | |||
| 600 | , | ||
| 601 | |||
| 602 | |||
| 603 | The variables passed to it are as below. | ||
| 604 | |||
| 605 | The variables passed to it are as below. | ||
| 606 | |||
| 607 | toDir - This is the relative back to the directory. | ||
| 608 | toFiles - This is the relative path to the '.files' directory. | ||
| 609 | obj - This is the object that it was invoked for. | ||
| 610 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 611 | toader - This is a L<Toader> object. | ||
| 612 | self - This the L<Toader::Render::General> object. | ||
| 613 | g - This the L<Toader::Render::General> object. | ||
| 614 | |||
| 615 | =head4 authorEnd | ||
| 616 | |||
| 617 | This ends the authors link section. | ||
| 618 | |||
| 619 | The default template is blank. | ||
| 620 | |||
| 621 | The variables passed to it are as below. | ||
| 622 | |||
| 623 | toDir - This is the relative back to the directory. | ||
| 624 | toFiles - This is the relative path to the '.files' directory. | ||
| 625 | obj - This is the object that it was invoked for. | ||
| 626 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 627 | toader - This is a L<Toader> object. | ||
| 628 | self - This the L<Toader::Render::General> object. | ||
| 629 | g - This the L<Toader::Render::General> object. | ||
| 630 | |||
| 631 | =cut | ||
| 632 | |||
| 633 | sub authorsLink{ | ||
| 634 | my $self=$_[0]; | ||
| 635 | my $aline=$_[1]; | ||
| 636 | |||
| 637 | #blank any previous errors | ||
| 638 | if ( ! $self->errorblank ){ | ||
| 639 | return undef; | ||
| 640 | } | ||
| 641 | |||
| 642 | #make sure we have a authors line | ||
| 643 | if ( ! defined( $aline ) ){ | ||
| 644 | $self->{error}=29; | ||
| 645 | $self->{errorString}='No author line defined'; | ||
| 646 | $self->warn; | ||
| 647 | return undef; | ||
| 648 | } | ||
| 649 | |||
| 650 | #parses the address | ||
| 651 | my @a=Email::Address->parse($aline); | ||
| 652 | if ( ! defined( $a[0] ) ){ | ||
| 653 | $self->{error}=30; | ||
| 654 | $self->{errorString}='The author line "'.$aline.'" could not be parsed'; | ||
| 655 | $self->warn; | ||
| 656 | return undef; | ||
| 657 | } | ||
| 658 | |||
| 659 | #process each | ||
| 660 | my $int=0; | ||
| 661 | my @tojoin; | ||
| 662 | while ( defined( $a[$int] ) ){ | ||
| 663 | my $rendered=$self->{t}->fill_in( | ||
| 664 | 'authorLink', | ||
| 665 | { | ||
| 666 | toDir=>$self->{toDir}, | ||
| 667 | toFiles=>$self->{toFiles}, | ||
| 668 | obj=>\$self->{obj}, | ||
| 669 | c=>\$self->{toader}->getConfig, | ||
| 670 | toader=>\$self->{toader}, | ||
| 671 | self=>\$self, | ||
| 672 | address=>$a[$int]->address, | ||
| 673 | comment=>$a[$int]->comment, | ||
| 674 | original=>$a[$int]->original, | ||
| 675 | name=>$a[$int]->name, | ||
| 676 | g=>\$self, | ||
| 677 | } | ||
| 678 | ); | ||
| 679 | if ( $self->{t}->error ){ | ||
| 680 | $self->{error}=10; | ||
| 681 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 682 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 683 | $self->warn; | ||
| 684 | return undef; | ||
| 685 | } | ||
| 686 | |||
| 687 | push( @tojoin, $rendered ); | ||
| 688 | |||
| 689 | $int++; | ||
| 690 | } | ||
| 691 | |||
| 692 | #renders the joiner | ||
| 693 | my $joiner=$self->{t}->fill_in( | ||
| 694 | 'authorJoin', | ||
| 695 | { | ||
| 696 | toDir=>$self->{toDir}, | ||
| 697 | toFiles=>$self->{toFiles}, | ||
| 698 | obj=>\$self->{obj}, | ||
| 699 | c=>\$self->{toader}->getConfig, | ||
| 700 | toader=>\$self->{toader}, | ||
| 701 | self=>\$self, | ||
| 702 | g=>\$self, | ||
| 703 | } | ||
| 704 | ); | ||
| 705 | if ( $self->{t}->error ){ | ||
| 706 | $self->{error}=10; | ||
| 707 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 708 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 709 | $self->warn; | ||
| 710 | return undef; | ||
| 711 | } | ||
| 712 | |||
| 713 | #renders the beginning of the authors links | ||
| 714 | my $begin=$self->{t}->fill_in( | ||
| 715 | 'authorBegin', | ||
| 716 | { | ||
| 717 | toDir=>$self->{toDir}, | ||
| 718 | toFiles=>$self->{toFiles}, | ||
| 719 | obj=>\$self->{obj}, | ||
| 720 | c=>\$self->{toader}->getConfig, | ||
| 721 | toader=>\$self->{toader}, | ||
| 722 | self=>\$self, | ||
| 723 | g=>\$self, | ||
| 724 | } | ||
| 725 | ); | ||
| 726 | if ( $self->{t}->error ){ | ||
| 727 | $self->{error}=10; | ||
| 728 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 729 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 730 | $self->warn; | ||
| 731 | return undef; | ||
| 732 | } | ||
| 733 | |||
| 734 | |||
| 735 | #renders the end of the authors links | ||
| 736 | my $end=$self->{t}->fill_in( | ||
| 737 | 'authorEnd', | ||
| 738 | { | ||
| 739 | toDir=>$self->{toDir}, | ||
| 740 | toFiles=>$self->{toFiles}, | ||
| 741 | obj=>\$self->{obj}, | ||
| 742 | c=>\$self->{toader}->getConfig, | ||
| 743 | toader=>\$self->{toader}, | ||
| 744 | self=>\$self, | ||
| 745 | g=>\$self, | ||
| 746 | } | ||
| 747 | ); | ||
| 748 | if ( $self->{t}->error ){ | ||
| 749 | $self->{error}=10; | ||
| 750 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 751 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 752 | $self->warn; | ||
| 753 | return undef; | ||
| 754 | } | ||
| 755 | |||
| 756 | return $begin.join( $joiner, @tojoin ).$end; | ||
| 757 | } | ||
| 758 | |||
| 759 | =head2 autodocList | ||
| 760 | |||
| 761 | This a list of generates a table of the various | ||
| 762 | documents. | ||
| 763 | |||
| 764 | One argument is accepted and the directory under the l<Toader> root | ||
| 765 | directory. If not specified, it is the same as object used to initate | ||
| 766 | this object. | ||
| 767 | |||
| 768 | $g->autodocList; | ||
| 769 | |||
| 770 | =head3 Templates | ||
| 771 | |||
| 772 | =head4 autodocListBegin | ||
| 773 | |||
| 774 | This initiates the table for the list. | ||
| 775 | |||
| 776 | The default template is as below. | ||
| 777 | |||
| 778 | <table id="autodocList"> | ||
| 779 | <tr> <td>File</td> </tr> | ||
| 780 | |||
| 781 | |||
| 782 | The variables passed to it are as below. | ||
| 783 | |||
| 784 | toDir - This is the relative back to the directory. | ||
| 785 | toFiles - This is the relative path to the '.files' directory. | ||
| 786 | obj - This is the object that it was invoked for. | ||
| 787 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 788 | toader - This is a L<Toader> object. | ||
| 789 | self - This the L<Toader::Render::General> object. | ||
| 790 | g - This the L<Toader::Render::General> object. | ||
| 791 | dir - This is the directory relative to the root L<Toader> directory. | ||
| 792 | |||
| 793 | =head4 autodocListRow | ||
| 794 | |||
| 795 | This is the represents a row in the document table. | ||
| 796 | |||
| 797 | The default template is as below. | ||
| 798 | |||
| 799 | <tr id="autodocList"> | ||
| 800 | <td id="autodocList">[== $g->adlink( $dir, $file ) ==]</td> | ||
| 801 | </tr> | ||
| 802 | |||
| 803 | The variables passed to it are as below. | ||
| 804 | |||
| 805 | toDir - This is the relative back to the directory. | ||
| 806 | toFiles - This is the relative path to the '.files' directory. | ||
| 807 | obj - This is the object that it was invoked for. | ||
| 808 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 809 | toader - This is a L<Toader> object. | ||
| 810 | self - This the L<Toader::Render::General> object. | ||
| 811 | g - This the L<Toader::Render::General> object. | ||
| 812 | dir - This is the directory relative to the root L<Toader> directory. | ||
| 813 | file - This is the file to show. | ||
| 814 | |||
| 815 | =head4 autodocListJoin | ||
| 816 | |||
| 817 | This is used to join the table rows. | ||
| 818 | |||
| 819 | The default template is blank. | ||
| 820 | |||
| 821 | The variables passed to it are as below. | ||
| 822 | |||
| 823 | toDir - This is the relative back to the directory. | ||
| 824 | toFiles - This is the relative path to the '.files' directory. | ||
| 825 | obj - This is the object that it was invoked for. | ||
| 826 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 827 | toader - This is a L<Toader> object. | ||
| 828 | self - This the L<Toader::Render::General> object. | ||
| 829 | g - This the L<Toader::Render::General> object. | ||
| 830 | dir - This is the directory relative to the root L<Toader> directory. | ||
| 831 | |||
| 832 | =head4 autodocListEnd | ||
| 833 | |||
| 834 | This is ends the documentation list. | ||
| 835 | |||
| 836 | The default template is as below. | ||
| 837 | |||
| 838 | </table> | ||
| 839 | |||
| 840 | The variables passed to it are as below. | ||
| 841 | |||
| 842 | toDir - This is the relative back to the directory. | ||
| 843 | toFiles - This is the relative path to the '.files' directory. | ||
| 844 | obj - This is the object that it was invoked for. | ||
| 845 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 846 | toader - This is a L<Toader> object. | ||
| 847 | self - This the L<Toader::Render::General> object. | ||
| 848 | g - This the L<Toader::Render::General> object. | ||
| 849 | dir - This is the directory relative to the root L<Toader> directory. | ||
| 850 | |||
| 851 | =cut | ||
| 852 | |||
| 853 | sub autodocList{ | ||
| 854 | my $self=$_[0]; | ||
| 855 | my $dir=$_[1]; | ||
| 856 | |||
| 857 | #blank any previous errors | ||
| 858 | if ( ! $self->errorblank ){ | ||
| 859 | return undef; | ||
| 860 | } | ||
| 861 | |||
| 862 | if ( ! defined( $dir ) ){ | ||
| 863 | $dir=$self->{r2r}; | ||
| 864 | } | ||
| 865 | |||
| 866 | my $fullpath=$self->{toader}->getRootDir.'/'.$dir; | ||
| 867 | |||
| 868 | my $ad=Toader::AutoDoc->new( $self->{toader} ); | ||
| 869 | if ( $ad->error ){ | ||
| 870 | $self->{error}=46; | ||
| 871 | $self->{errorString}='Failed to initialize Toader::AutoDoc. error="'. | ||
| 872 | $ad->error.'" errorString="'.$ad->errorString.'"'; | ||
| 873 | $self->warn; | ||
| 874 | return undef; | ||
| 875 | } | ||
| 876 | |||
| 877 | $ad->dirSet( $fullpath ); | ||
| 878 | if ( $ad->error ){ | ||
| 879 | $self->{error}=35; | ||
| 880 | $self->{errorString}='Failed to set the directory for the Toader::AutoDoc object to "'.$fullpath.'"'; | ||
| 881 | $self->warn; | ||
| 882 | return undef; | ||
| 883 | } | ||
| 884 | |||
| 885 | my @files=$ad->findDocs; | ||
| 886 | if ( $ad->error ){ | ||
| 887 | $self->{error}=36; | ||
| 888 | $self->{errorString}=''; | ||
| 889 | $self->warn; | ||
| 890 | return undef; | ||
| 891 | } | ||
| 892 | @files=sort(@files); | ||
| 893 | |||
| 894 | #puts together the list of docs | ||
| 895 | my $int=0; | ||
| 896 | my @links; | ||
| 897 | while ( defined( $files[$int] ) ){ | ||
| 898 | |||
| 899 | my $rendered=$self->{t}->fill_in( | ||
| 900 | 'autodocListRow', | ||
| 901 | { | ||
| 902 | toDir=>$self->{toDir}, | ||
| 903 | toFiles=>$self->{toFiles}, | ||
| 904 | obj=>\$self->{obj}, | ||
| 905 | c=>\$self->{toader}->getConfig, | ||
| 906 | toader=>\$self->{toader}, | ||
| 907 | self=>\$self, | ||
| 908 | g=>\$self, | ||
| 909 | file=>$files[$int], | ||
| 910 | dir=>$dir, | ||
| 911 | } | ||
| 912 | ); | ||
| 913 | if ( $self->{t}->error ){ | ||
| 914 | $self->{error}=10; | ||
| 915 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 916 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 917 | $self->warn; | ||
| 918 | return undef; | ||
| 919 | } | ||
| 920 | |||
| 921 | push( @links, $rendered ); | ||
| 922 | |||
| 923 | $int++; | ||
| 924 | } | ||
| 925 | |||
| 926 | my $begin=$self->{t}->fill_in( | ||
| 927 | 'autodocListBegin', | ||
| 928 | { | ||
| 929 | toDir=>$self->{toDir}, | ||
| 930 | toFiles=>$self->{toFiles}, | ||
| 931 | obj=>\$self->{obj}, | ||
| 932 | c=>\$self->{toader}->getConfig, | ||
| 933 | toader=>\$self->{toader}, | ||
| 934 | self=>\$self, | ||
| 935 | g=>\$self, | ||
| 936 | dir=>$dir, | ||
| 937 | } | ||
| 938 | ); | ||
| 939 | if ( $self->{t}->error ){ | ||
| 940 | $self->{error}=10; | ||
| 941 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 942 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 943 | $self->warn; | ||
| 944 | return undef; | ||
| 945 | } | ||
| 946 | |||
| 947 | my $join=$self->{t}->fill_in( | ||
| 948 | 'autodocListJoin', | ||
| 949 | { | ||
| 950 | toDir=>$self->{toDir}, | ||
| 951 | toFiles=>$self->{toFiles}, | ||
| 952 | obj=>\$self->{obj}, | ||
| 953 | c=>\$self->{toader}->getConfig, | ||
| 954 | toader=>\$self->{toader}, | ||
| 955 | self=>\$self, | ||
| 956 | g=>\$self, | ||
| 957 | dir=>$dir, | ||
| 958 | } | ||
| 959 | ); | ||
| 960 | if ( $self->{t}->error ){ | ||
| 961 | $self->{error}=10; | ||
| 962 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 963 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 964 | $self->warn; | ||
| 965 | return undef; | ||
| 966 | } | ||
| 967 | |||
| 968 | my $end=$self->{t}->fill_in( | ||
| 969 | 'autodocListEnd', | ||
| 970 | { | ||
| 971 | toDir=>$self->{toDir}, | ||
| 972 | toFiles=>$self->{toFiles}, | ||
| 973 | obj=>\$self->{obj}, | ||
| 974 | c=>\$self->{toader}->getConfig, | ||
| 975 | toader=>\$self->{toader}, | ||
| 976 | self=>\$self, | ||
| 977 | g=>\$self, | ||
| 978 | dir=>$dir, | ||
| 979 | } | ||
| 980 | ); | ||
| 981 | if ( $self->{t}->error ){ | ||
| 982 | $self->{error}=10; | ||
| 983 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 984 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 985 | $self->warn; | ||
| 986 | return undef; | ||
| 987 | } | ||
| 988 | |||
| 989 | return $begin.join($join, @links).$end; | ||
| 990 | } | ||
| 991 | |||
| 992 | =head2 b2r | ||
| 993 | |||
| 994 | This returns the current value to get back to the root. | ||
| 995 | |||
| 996 | my $b2r=$g->b2r; | ||
| 997 | |||
| 998 | =cut | ||
| 999 | |||
| 1000 | sub b2r{ | ||
| 1001 | my $self=$_[0]; | ||
| 1002 | |||
| 1003 | #blank any previous errors | ||
| 1004 | if ( ! $self->errorblank ){ | ||
| 1005 | return undef; | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | return $self->{b2r}; | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | =head2 cdlink | ||
| 1012 | |||
| 1013 | This generates a link to the current directory. | ||
| 1014 | |||
| 1015 | There is one option arguement. This is the text for the link. | ||
| 1016 | If not specified, it defaults to ".". | ||
| 1017 | |||
| 1018 | $g->cdlink( "to current directory" ); | ||
| 1019 | |||
| 1020 | The template used for this is 'linkDirectory', which by default | ||
| 1021 | is as below. | ||
| 1022 | |||
| 1023 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 1024 | |||
| 1025 | The variables passed to it are as below. | ||
| 1026 | |||
| 1027 | url - This is the relative URL for this. | ||
| 1028 | text - This to use for with the link. | ||
| 1029 | toDir - This is the relative back to the directory. | ||
| 1030 | toFiles - This is the relative path to the '.files' directory. | ||
| 1031 | obj - The L<Toader::Entry> object. | ||
| 1032 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 1033 | self - The L<Toader::Render::Entry> object. | ||
| 1034 | toader - This is a L<Toader> object. | ||
| 1035 | g - This is a L<Toader::Render::General> object. | ||
| 1036 | |||
| 1037 | =cut | ||
| 1038 | |||
| 1039 | sub cdlink{ | ||
| 1040 | my $self=$_[0]; | ||
| 1041 | my $text=$_[1]; | ||
| 1042 | |||
| 1043 | #blank any previous errors | ||
| 1044 | if ( ! $self->errorblank ){ | ||
| 1045 | return undef; | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | #set the text to the same as the link if no text is defined | ||
| 1049 | if ( ! defined( $text ) ){ | ||
| 1050 | $text='./'; | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | my $url=$self->{toDir}; | ||
| 1054 | $url=~s/\/\/*/\//g; | ||
| 1055 | if ( $self->{fullURL} ){ | ||
| 1056 | $url=$self->{url}.$self->{r2r}; | ||
| 1057 | } | ||
| 1058 | |||
| 1059 | #render it | ||
| 1060 | my $rendered=$self->{t}->fill_in( | ||
| 1061 | 'linkDirectory', | ||
| 1062 | { | ||
| 1063 | url=>$url, | ||
| 1064 | text=>$text, | ||
| 1065 | toDir=>$self->{toDir}, | ||
| 1066 | toFiles=>$self->{toFiles}, | ||
| 1067 | obj=>\$self->{obj}, | ||
| 1068 | c=>\$self->{toader}->getConfig, | ||
| 1069 | self=>\$self, | ||
| 1070 | toader=>\$self->{toader}, | ||
| 1071 | g=>\$self, | ||
| 1072 | } | ||
| 1073 | ); | ||
| 1074 | if ( $self->{t}->error ){ | ||
| 1075 | $self->{error}=10; | ||
| 1076 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1077 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1078 | $self->warn; | ||
| 1079 | return undef; | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | return $rendered; | ||
| 1083 | } | ||
| 1084 | |||
| 1085 | =head2 css | ||
| 1086 | |||
| 1087 | This renders the CSS template and returns it. | ||
| 1088 | |||
| 1089 | $g->css; | ||
| 1090 | |||
| 1091 | For more information on the CSS template and rendering | ||
| 1092 | please see 'Documentation/CSS.pod'. | ||
| 1093 | |||
| 1094 | =cut | ||
| 1095 | |||
| 1096 | sub css{ | ||
| 1097 | my $self=$_[0]; | ||
| 1098 | |||
| 1099 | if ( ! $self->errorblank ){ | ||
| 1100 | return undef; | ||
| 1101 | } | ||
| 1102 | |||
| 1103 | my $renderCSS=Toader::Render::CSS->new( $self->{toader} ); | ||
| 1104 | |||
| 1105 | my $css=$renderCSS->renderCSS; | ||
| 1106 | if ( $renderCSS->error ){ | ||
| 1107 | $self->{error}=18; | ||
| 1108 | $self->{errorString}='Failed to render the CSS. error="'. | ||
| 1109 | $renderCSS->error.'" errorString="'. | ||
| 1110 | $renderCSS->errorString.'"'; | ||
| 1111 | $self->warn; | ||
| 1112 | return undef; | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | return $css; | ||
| 1116 | } | ||
| 1117 | |||
| 1118 | =head2 cssLocation | ||
| 1119 | |||
| 1120 | This returns the relative location to a the CSS file. | ||
| 1121 | |||
| 1122 | $g->cssLocation; | ||
| 1123 | |||
| 1124 | =cut | ||
| 1125 | |||
| 1126 | sub cssLocation{ | ||
| 1127 | my $self=$_[0]; | ||
| 1128 | |||
| 1129 | if ( ! $self->errorblank ){ | ||
| 1130 | return undef; | ||
| 1131 | } | ||
| 1132 | |||
| 1133 | if ( ! $self->{fullURL} ){ | ||
| 1134 | return $self->{b2r}.'/toader.css'; | ||
| 1135 | }else{ | ||
| 1136 | return $self->{url}.'toader.css'; | ||
| 1137 | } | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | =head2 dlink | ||
| 1141 | |||
| 1142 | This generates a link to a different directory object. | ||
| 1143 | |||
| 1144 | Two arguments are taken. | ||
| 1145 | |||
| 1146 | The first and required one is the L<Toader> directory | ||
| 1147 | to link to. This needs to be relative. | ||
| 1148 | |||
| 1149 | The second is the text, which if not specified will will be the | ||
| 1150 | same the link. | ||
| 1151 | |||
| 1152 | $g->link( "./foo/bar", "more info on foo/bar" ); | ||
| 1153 | |||
| 1154 | The template used for this is 'linkDirectory', which by default | ||
| 1155 | is as below. | ||
| 1156 | |||
| 1157 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 1158 | |||
| 1159 | The variables passed to it are as below. | ||
| 1160 | |||
| 1161 | url - This is the relative URL for this. | ||
| 1162 | text - This to use for with the link. | ||
| 1163 | toDir - This is the relative back to the directory. | ||
| 1164 | toFiles - This is the relative path to the '.files' directory. | ||
| 1165 | obj - The L<Toader::Entry> object. | ||
| 1166 | c - The L<Config::Tiny> object containing the L<Toader> config. | ||
| 1167 | self - The L<Toader::Render::Entry> object. | ||
| 1168 | toader - This is a L<Toader> object. | ||
| 1169 | g - This is a L<Toader::Render::General> object. | ||
| 1170 | |||
| 1171 | =cut | ||
| 1172 | |||
| 1173 | sub dlink{ | ||
| 1174 | my $self=$_[0]; | ||
| 1175 | my $dir=$_[1]; | ||
| 1176 | my $text=$_[2]; | ||
| 1177 | |||
| 1178 | #blank any previous errors | ||
| 1179 | if ( ! $self->errorblank ){ | ||
| 1180 | return undef; | ||
| 1181 | } | ||
| 1182 | |||
| 1183 | #make sure we have a link | ||
| 1184 | if ( ! defined( $dir ) ){ | ||
| 1185 | $self->{error}=11; | ||
| 1186 | $self->{errorString}='No Toader directory defined'; | ||
| 1187 | $self->warn; | ||
| 1188 | return undef; | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | #set the text to the same as the link if no text is defined | ||
| 1192 | if ( ! defined( $text ) ){ | ||
| 1193 | $text=$dir; | ||
| 1194 | } | ||
| 1195 | |||
| 1196 | #handles it if it is a full path | ||
| 1197 | my $dirtest; | ||
| 1198 | if ( $dir =~ /^\// ){ | ||
| 1199 | $dir=$self->{toader}->getRootDir.$dir; | ||
| 1200 | $dirtest=$dir; | ||
| 1201 | $dir=$self->{ph}->relative2root( $dir ); | ||
| 1202 | }else{ | ||
| 1203 | $dirtest=$self->{dir}.'/'.$dir; | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | #make sure it is a Toader directory | ||
| 1207 | if ( ! $self->{isatd}->isaToaderDir( $dirtest ) ){ | ||
| 1208 | $self->{error}=12; | ||
| 1209 | $self->{errorString}='"'.$dirtest.'" is not a Toader directory'; | ||
| 1210 | $self->warn; | ||
| 1211 | return undef; | ||
| 1212 | } | ||
| 1213 | |||
| 1214 | if ( $self->{fullURL} ){ | ||
| 1215 | $dir=$dir; | ||
| 1216 | $dir=~s/\/\/*/\//g; | ||
| 1217 | $dir=$self->{url}.$dir; | ||
| 1218 | }else{ | ||
| 1219 | $dir=$self->{toDir}.$dir; | ||
| 1220 | $dir=~s/\/\/*/\//g; | ||
| 1221 | } | ||
| 1222 | |||
| 1223 | #render it | ||
| 1224 | my $rendered=$self->{t}->fill_in( | ||
| 1225 | 'linkDirectory', | ||
| 1226 | { | ||
| 1227 | url=>$dir, | ||
| 1228 | text=>$text, | ||
| 1229 | toDir=>$self->{toDir}, | ||
| 1230 | toFiles=>$self->{toFiles}, | ||
| 1231 | obj=>\$self->{obj}, | ||
| 1232 | c=>\$self->{toader}->getConfig, | ||
| 1233 | self=>\$self, | ||
| 1234 | toader=>\$self->{toader}, | ||
| 1235 | g=>\$self, | ||
| 1236 | } | ||
| 1237 | ); | ||
| 1238 | if ( $self->{t}->error ){ | ||
| 1239 | $self->{error}=10; | ||
| 1240 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1241 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1242 | $self->warn; | ||
| 1243 | return undef; | ||
| 1244 | } | ||
| 1245 | |||
| 1246 | return $rendered; | ||
| 1247 | } | ||
| 1248 | |||
| 1249 | =head2 elink | ||
| 1250 | |||
| 1251 | This generates a link to a different directory object. | ||
| 1252 | |||
| 1253 | Two arguments are taken. | ||
| 1254 | |||
| 1255 | The first and required one is the L<Toader> directory containing | ||
| 1256 | the L<Toader> object. This needs to be relative. | ||
| 1257 | |||
| 1258 | The second is the entry to link to. | ||
| 1259 | |||
| 1260 | The third is the text, which if not specified will will be the | ||
| 1261 | same the link. | ||
| 1262 | |||
| 1263 | $g->link( $dir, $entryID, "whatever at foo.bar" ); | ||
| 1264 | |||
| 1265 | The template used is 'linkEntry' and the default is as below. | ||
| 1266 | |||
| 1267 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 1268 | |||
| 1269 | The variables passed are as below. | ||
| 1270 | |||
| 1271 | url - This is the relative URL for this. | ||
| 1272 | text - This to use for with the link. | ||
| 1273 | toDir - This is the relative back to the directory. | ||
| 1274 | toFiles - This is the relative path to the '.files' directory. | ||
| 1275 | obj - The L<Toader::Entry> object. | ||
| 1276 | c - The L<Config::Tiny> object containing the L<Toader> config. | ||
| 1277 | self - The L<Toader::Render::Entry> object. | ||
| 1278 | toader - This is a L<Toader> object. | ||
| 1279 | g - This is a L<Toader::Render::General> object. | ||
| 1280 | |||
| 1281 | =cut | ||
| 1282 | |||
| 1283 | sub elink{ | ||
| 1284 | my $self=$_[0]; | ||
| 1285 | my $dir=$_[1]; | ||
| 1286 | my $entry=$_[2]; | ||
| 1287 | my $text=$_[3]; | ||
| 1288 | |||
| 1289 | #blank any previous errors | ||
| 1290 | if ( ! $self->errorblank ){ | ||
| 1291 | return undef; | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | #use the object dir if not is specified | ||
| 1295 | if ( ! defined( $dir ) ){ | ||
| 1296 | $self->{error}=11; | ||
| 1297 | $self->{errorString}='No Toader directory defined'; | ||
| 1298 | $self->warn; | ||
| 1299 | return undef; | ||
| 1300 | } | ||
| 1301 | |||
| 1302 | #make sure we have a link | ||
| 1303 | if ( ! defined( $dir ) ){ | ||
| 1304 | $self->{error}=13; | ||
| 1305 | $self->{errorString}='No Toader Entry ID defined'; | ||
| 1306 | $self->warn; | ||
| 1307 | return undef; | ||
| 1308 | } | ||
| 1309 | |||
| 1310 | #set the text to the same as the link if no text is defined | ||
| 1311 | if ( ! defined( $text ) ){ | ||
| 1312 | $text=$entry; | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | #handles it if it is a full path | ||
| 1316 | my $dirtest; | ||
| 1317 | if ( $dir =~ /^\// ){ | ||
| 1318 | $dir=$self->{toader}->getRootDir.$dir; | ||
| 1319 | $dirtest=$dir; | ||
| 1320 | $dir=$self->{ph}->relative2root( $dir ); | ||
| 1321 | }else{ | ||
| 1322 | $dirtest=$self->{dir}.'/'.$dir; | ||
| 1323 | } | ||
| 1324 | |||
| 1325 | #make sure it is a Toader directory | ||
| 1326 | if ( ! $self->{isatd}->isaToaderDir( $dirtest ) ){ | ||
| 1327 | $self->{error}=12; | ||
| 1328 | $self->{errorString}='"'.$dirtest.'" is not a Toader directory'; | ||
| 1329 | $self->warn; | ||
| 1330 | return undef; | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | #make sure entry exists... will also make sure it exists | ||
| 1334 | my $eh=Toader::Entry::Helper->new( $self->{toader} ); | ||
| 1335 | $eh->setDir( $dirtest ); | ||
| 1336 | if ( ! $eh->entryExists( $entry ) ){ | ||
| 1337 | $self->{error}=14; | ||
| 1338 | $self->{errorString}='The entry ID "'.$entry.'" does not exist for the Toader directory "'.$dirtest.'"'; | ||
| 1339 | $self->warn; | ||
| 1340 | return undef; | ||
| 1341 | } | ||
| 1342 | |||
| 1343 | if ( $self->{fullURL} ){ | ||
| 1344 | $dir=$dir.'/.entries/'.$entry.'/'; | ||
| 1345 | $dir=~s/\/\/*/\//g; | ||
| 1346 | $dir=$self->{url}.$dir; | ||
| 1347 | }else{ | ||
| 1348 | $dir=$self->{toDir}.$dir.'/.entries/'.$entry.'/'; | ||
| 1349 | $dir=~s/\/\/*/\//g; | ||
| 1350 | } | ||
| 1351 | |||
| 1352 | #render it | ||
| 1353 | my $rendered=$self->{t}->fill_in( | ||
| 1354 | 'linkEntry', | ||
| 1355 | { | ||
| 1356 | url=>$dir, | ||
| 1357 | text=>$text, | ||
| 1358 | toDir=>$self->{toDir}, | ||
| 1359 | toFiles=>$self->{toFiles}, | ||
| 1360 | obj=>\$self->{obj}, | ||
| 1361 | c=>\$self->{toader}->getConfig, | ||
| 1362 | self=>\$self, | ||
| 1363 | toader=>\$self->{toader}, | ||
| 1364 | g=>\$self, | ||
| 1365 | } | ||
| 1366 | ); | ||
| 1367 | if ( $self->{t}->error ){ | ||
| 1368 | $self->{error}=10; | ||
| 1369 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1370 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1371 | $self->warn; | ||
| 1372 | return undef; | ||
| 1373 | } | ||
| 1374 | |||
| 1375 | return $rendered; | ||
| 1376 | } | ||
| 1377 | |||
| 1378 | =head2 entryArchive | ||
| 1379 | |||
| 1380 | This creates the entry archive for the current directory. | ||
| 1381 | |||
| 1382 | No arguments are taken. | ||
| 1383 | |||
| 1384 | $g->entryArchive; | ||
| 1385 | |||
| 1386 | =head3 Templates | ||
| 1387 | |||
| 1388 | =head4 entryArchiveBegin | ||
| 1389 | |||
| 1390 | This begins the entry archive table. | ||
| 1391 | |||
| 1392 | <table id="entryArchive"> | ||
| 1393 | <tr> <td>Date</td> <td>Title</td> <td>Summary</td> </tr> | ||
| 1394 | |||
| 1395 | The variables passed to it are as below. | ||
| 1396 | |||
| 1397 | toDir - This is the relative back to the directory. | ||
| 1398 | toFiles - This is the relative path to the '.files' directory. | ||
| 1399 | obj - This is the object that it was invoked for. | ||
| 1400 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 1401 | toader - This is a L<Toader> object. | ||
| 1402 | self - This the L<Toader::Render::General> object. | ||
| 1403 | g - This the L<Toader::Render::General> object. | ||
| 1404 | |||
| 1405 | =head4 entryArchiveRow | ||
| 1406 | |||
| 1407 | This generates a row in the entry archive table. | ||
| 1408 | |||
| 1409 | The default template is as below. | ||
| 1410 | |||
| 1411 | <tr id="entryArchive"> | ||
| 1412 | <td id="entryArchive">[== $g->elink( "./", $date, $date ) ==]</td> | ||
| 1413 | <td id="entryArchive">[== $title ==]</td> | ||
| 1414 | <td id="entryArchive">[== $summary ==]</td> | ||
| 1415 | </tr> | ||
| 1416 | |||
| 1417 | The variables passed to it are as below. | ||
| 1418 | |||
| 1419 | toDir - This is the relative back to the directory. | ||
| 1420 | toFiles - This is the relative path to the '.files' directory. | ||
| 1421 | obj - This is the object that it was invoked for. | ||
| 1422 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 1423 | toader - This is a L<Toader> object. | ||
| 1424 | self - This the L<Toader::Render::General> object. | ||
| 1425 | g - This the L<Toader::Render::General> object. | ||
| 1426 | date - This is the entry name/date stamp. | ||
| 1427 | title - This is the title of the entyr. | ||
| 1428 | summary - This is a summary of the entry. | ||
| 1429 | |||
| 1430 | =head4 entryArchiveJoin | ||
| 1431 | |||
| 1432 | This joins the entry rows. | ||
| 1433 | |||
| 1434 | The default template is blank. | ||
| 1435 | |||
| 1436 | The variables passed to it are as below. | ||
| 1437 | |||
| 1438 | toDir - This is the relative back to the directory. | ||
| 1439 | toFiles - This is the relative path to the '.files' directory. | ||
| 1440 | obj - This is the object that it was invoked for. | ||
| 1441 | c - The L<Config::Tiny> object containing the L<Toader> config. | ||
| 1442 | toader - This is a L<Toader> object. | ||
| 1443 | self - This the L<Toader::Render::General> object. | ||
| 1444 | g - This the L<Toader::Render::General> object. | ||
| 1445 | |||
| 1446 | =head4 entryArchiveEnd | ||
| 1447 | |||
| 1448 | This ends the authors link section. | ||
| 1449 | |||
| 1450 | The default template is as below. | ||
| 1451 | |||
| 1452 | </table> | ||
| 1453 | |||
| 1454 | The variables passed to it are as below. | ||
| 1455 | |||
| 1456 | toDir - This is the relative back to the directory. | ||
| 1457 | toFiles - This is the relative path to the '.files' directory. | ||
| 1458 | obj - This is the object that it was invoked for. | ||
| 1459 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 1460 | toader - This is a Toader object. | ||
| 1461 | self - This the L<Toader::Render::General> object. | ||
| 1462 | g - This the L<Toader::Render::General> object. | ||
| 1463 | |||
| 1464 | =cut | ||
| 1465 | |||
| 1466 | sub entryArchive{ | ||
| 1467 | my $self=$_[0]; | ||
| 1468 | |||
| 1469 | #blank any previous errors | ||
| 1470 | if ( ! $self->errorblank ){ | ||
| 1471 | return undef; | ||
| 1472 | } | ||
| 1473 | |||
| 1474 | my $em=Toader::Entry::Manage->new( $self->{toader} ); | ||
| 1475 | $em->setDir( $self->{odir} ); | ||
| 1476 | if ( $em->error ){ | ||
| 1477 | $self->{error}=25; | ||
| 1478 | $self->{errorString}='Failed to set the directory, "'.$self->{odir}. | ||
| 1479 | '", for Toader::Entry::Manage. error="'.$em->error | ||
| 1480 | .'" errorString="'.$em->errorString.'"'; | ||
| 1481 | $self->warn; | ||
| 1482 | return undef; | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | #lists the entries for the directory | ||
| 1486 | my @entries=$em->published; | ||
| 1487 | if ( $em->error ){ | ||
| 1488 | $self->{error}=25; | ||
| 1489 | $self->{errorString}='Failed to read the entries for "'.$self->{odir}. | ||
| 1490 | '". error="'.$em->error.'" errorString="'.$em->errorString.'"'; | ||
| 1491 | $self->warn; | ||
| 1492 | return undef; | ||
| 1493 | } | ||
| 1494 | |||
| 1495 | #return '' if there are none | ||
| 1496 | if ( ! defined( $entries[0] ) ){ | ||
| 1497 | return ''; | ||
| 1498 | } | ||
| 1499 | |||
| 1500 | #sort and order from last to first | ||
| 1501 | @entries=sort(@entries); | ||
| 1502 | @entries=reverse(@entries); | ||
| 1503 | |||
| 1504 | #process each one | ||
| 1505 | my @tojoin; | ||
| 1506 | my $int=0; | ||
| 1507 | while ( defined( $entries[$int] ) ){ | ||
| 1508 | my $entry=$em->read( $entries[$int] ); | ||
| 1509 | if ( $em->error ){ | ||
| 1510 | $self->{error}=26; | ||
| 1511 | $self->{errorString}='Failed to read "'.$entries[$int].'" in "' | ||
| 1512 | .$self->{odir}.'". error="'.$em->error.'" errorstring="' | ||
| 1513 | .$em->errorString.'"'; | ||
| 1514 | $self->warn; | ||
| 1515 | return undef; | ||
| 1516 | } | ||
| 1517 | |||
| 1518 | #renders the row | ||
| 1519 | my $rendered=$self->{t}->fill_in( | ||
| 1520 | 'entryArchiveRow', | ||
| 1521 | { | ||
| 1522 | toDir=>$self->{toDir}, | ||
| 1523 | toFiles=>$self->{toFiles}, | ||
| 1524 | obj=>\$self->{obj}, | ||
| 1525 | c=>\$self->{toader}->getConfig, | ||
| 1526 | toader=>\$self->{toader}, | ||
| 1527 | self=>\$self, | ||
| 1528 | title=>$entry->titleGet, | ||
| 1529 | summary=>$entry->summaryGet, | ||
| 1530 | date=>$entry->entryNameGet, | ||
| 1531 | g=>\$self, | ||
| 1532 | } | ||
| 1533 | ); | ||
| 1534 | if ( $self->{t}->error ){ | ||
| 1535 | $self->{error}=10; | ||
| 1536 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1537 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1538 | $self->warn; | ||
| 1539 | return undef; | ||
| 1540 | } | ||
| 1541 | |||
| 1542 | push( @tojoin, $rendered ); | ||
| 1543 | |||
| 1544 | $int++; | ||
| 1545 | } | ||
| 1546 | |||
| 1547 | #renders the joiner | ||
| 1548 | my $joiner=$self->{t}->fill_in( | ||
| 1549 | 'entryArchiveJoin', | ||
| 1550 | { | ||
| 1551 | toDir=>$self->{toDir}, | ||
| 1552 | toFiles=>$self->{toFiles}, | ||
| 1553 | obj=>\$self->{obj}, | ||
| 1554 | c=>\$self->{toader}->getConfig, | ||
| 1555 | toader=>\$self->{toader}, | ||
| 1556 | self=>\$self, | ||
| 1557 | g=>\$self, | ||
| 1558 | } | ||
| 1559 | ); | ||
| 1560 | if ( $self->{t}->error ){ | ||
| 1561 | $self->{error}=10; | ||
| 1562 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1563 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1564 | $self->warn; | ||
| 1565 | return undef; | ||
| 1566 | } | ||
| 1567 | |||
| 1568 | #renders the end of the dir list | ||
| 1569 | my $end=$self->{t}->fill_in( | ||
| 1570 | 'entryArchiveEnd', | ||
| 1571 | { | ||
| 1572 | toDir=>$self->{toDir}, | ||
| 1573 | toFiles=>$self->{toFiles}, | ||
| 1574 | obj=>\$self->{obj}, | ||
| 1575 | c=>\$self->{toader}->getConfig, | ||
| 1576 | toader=>\$self->{toader}, | ||
| 1577 | self=>\$self, | ||
| 1578 | g=>\$self, | ||
| 1579 | } | ||
| 1580 | ); | ||
| 1581 | if ( $self->{t}->error ){ | ||
| 1582 | $self->{error}=10; | ||
| 1583 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1584 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1585 | $self->warn; | ||
| 1586 | return undef; | ||
| 1587 | } | ||
| 1588 | |||
| 1589 | #renders the end of the dir list | ||
| 1590 | my $begin=$self->{t}->fill_in( | ||
| 1591 | 'entryArchiveBegin', | ||
| 1592 | { | ||
| 1593 | toDir=>$self->{toDir}, | ||
| 1594 | toFiles=>$self->{toFiles}, | ||
| 1595 | obj=>\$self->{obj}, | ||
| 1596 | c=>\$self->{toader}->getConfig, | ||
| 1597 | toader=>\$self->{toader}, | ||
| 1598 | self=>\$self, | ||
| 1599 | g=>\$self, | ||
| 1600 | } | ||
| 1601 | ); | ||
| 1602 | if ( $self->{t}->error ){ | ||
| 1603 | $self->{error}=10; | ||
| 1604 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1605 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1606 | $self->warn; | ||
| 1607 | return undef; | ||
| 1608 | } | ||
| 1609 | |||
| 1610 | return $begin.join( $joiner, @tojoin ).$end; | ||
| 1611 | } | ||
| 1612 | |||
| 1613 | =head2 entriesArchiveLink | ||
| 1614 | |||
| 1615 | Link to the entries directory. | ||
| 1616 | |||
| 1617 | One argument is taken and that is the text to use. | ||
| 1618 | If not specifieid, it defaults to "Index". | ||
| 1619 | |||
| 1620 | $g->entriesIndexLink; | ||
| 1621 | |||
| 1622 | The template is 'entriesArchiveLink' and the default is | ||
| 1623 | as below. | ||
| 1624 | |||
| 1625 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 1626 | |||
| 1627 | The variables used are as below. | ||
| 1628 | |||
| 1629 | url - This is the relative URL for this. | ||
| 1630 | text - This to use for with the link. | ||
| 1631 | toDir - This is the relative back to the directory. | ||
| 1632 | toFiles - This is the relative path to the '.files' directory. | ||
| 1633 | obj - The L<Toader::Entry> object. | ||
| 1634 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 1635 | self - The L<Toader::Render::Entry> object. | ||
| 1636 | toader - This is a L<Toader> object. | ||
| 1637 | g - This is a L<Toader::Render::General> object. | ||
| 1638 | |||
| 1639 | =cut | ||
| 1640 | |||
| 1641 | sub entriesArchiveLink{ | ||
| 1642 | my $self=$_[0]; | ||
| 1643 | my $text=$_[1]; | ||
| 1644 | |||
| 1645 | if ( ! defined( $text ) ){ | ||
| 1646 | $text='Archive'; | ||
| 1647 | } | ||
| 1648 | |||
| 1649 | #blank any previous errors | ||
| 1650 | if ( ! $self->errorblank ){ | ||
| 1651 | return undef; | ||
| 1652 | } | ||
| 1653 | |||
| 1654 | my $url; | ||
| 1655 | if ( $self->{fullURL} ){ | ||
| 1656 | $url=$self->{r2r}.'/.entries/archive.html'; | ||
| 1657 | $url=~s/\/\/*/\//g; | ||
| 1658 | $url=$self->{url}.$url; | ||
| 1659 | }else{ | ||
| 1660 | $url=$self->{toDir}.'/.entries/archive.html'; | ||
| 1661 | $url=~s/\/\/*/\//g; | ||
| 1662 | } | ||
| 1663 | |||
| 1664 | #render it | ||
| 1665 | my $rendered=$self->{t}->fill_in( | ||
| 1666 | 'entriesArchiveLink', | ||
| 1667 | { | ||
| 1668 | url=>$url, | ||
| 1669 | text=>$text, | ||
| 1670 | toDir=>$self->{toDir}, | ||
| 1671 | toFiles=>$self->{toFiles}, | ||
| 1672 | obj=>\$self->{obj}, | ||
| 1673 | c=>\$self->{toader}->getConfig, | ||
| 1674 | self=>\$self, | ||
| 1675 | toader=>\$self->{toader}, | ||
| 1676 | g=>\$self, | ||
| 1677 | } | ||
| 1678 | ); | ||
| 1679 | if ( $self->{t}->error ){ | ||
| 1680 | $self->{error}=10; | ||
| 1681 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1682 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1683 | $self->warn; | ||
| 1684 | return undef; | ||
| 1685 | } | ||
| 1686 | |||
| 1687 | return $rendered; | ||
| 1688 | } | ||
| 1689 | |||
| 1690 | =head2 entriesLink | ||
| 1691 | |||
| 1692 | Link to the entries directory. | ||
| 1693 | |||
| 1694 | One argument is taken and that is the text to use. | ||
| 1695 | If not specifieid, it defaults to "Latest". | ||
| 1696 | |||
| 1697 | $g->entriesLink; | ||
| 1698 | |||
| 1699 | The template 'entriesLink' is used and the default is as below. | ||
| 1700 | |||
| 1701 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 1702 | |||
| 1703 | The variables are as below. | ||
| 1704 | |||
| 1705 | url - This is the relative URL for this. | ||
| 1706 | text - This to use for with the link. | ||
| 1707 | toDir - This is the relative back to the directory. | ||
| 1708 | toFiles - This is the relative path to the '.files' directory. | ||
| 1709 | obj - The L<Toader::Entry> object. | ||
| 1710 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 1711 | self - The L<Toader::Render::Entry> object. | ||
| 1712 | toader - This is a L<Toader> object. | ||
| 1713 | g - This is a L<Toader::Render::General> object. | ||
| 1714 | |||
| 1715 | =cut | ||
| 1716 | |||
| 1717 | sub entriesLink{ | ||
| 1718 | my $self=$_[0]; | ||
| 1719 | my $text=$_[1]; | ||
| 1720 | |||
| 1721 | if ( ! defined( $text ) ){ | ||
| 1722 | $text='Latest'; | ||
| 1723 | } | ||
| 1724 | |||
| 1725 | #blank any previous errors | ||
| 1726 | if ( ! $self->errorblank ){ | ||
| 1727 | return undef; | ||
| 1728 | } | ||
| 1729 | |||
| 1730 | my $url; | ||
| 1731 | if ( $self->{fullURL} ){ | ||
| 1732 | $url=$self->{r2r}.'/.entries/'; | ||
| 1733 | $url=~s/\/\/*/\//g; | ||
| 1734 | $url=$self->{url}.$url; | ||
| 1735 | }else{ | ||
| 1736 | $url=$self->{toDir}.'/.entries/'; | ||
| 1737 | $url=~s/\/\/*/\//g; | ||
| 1738 | } | ||
| 1739 | |||
| 1740 | #render it | ||
| 1741 | my $rendered=$self->{t}->fill_in( | ||
| 1742 | 'entriesLink', | ||
| 1743 | { | ||
| 1744 | url=>$url, | ||
| 1745 | text=>$text, | ||
| 1746 | toDir=>$self->{toDir}, | ||
| 1747 | toFiles=>$self->{toFiles}, | ||
| 1748 | obj=>\$self->{obj}, | ||
| 1749 | c=>\$self->{toader}->getConfig, | ||
| 1750 | self=>\$self, | ||
| 1751 | toader=>\$self->{toader}, | ||
| 1752 | g=>\$self, | ||
| 1753 | } | ||
| 1754 | ); | ||
| 1755 | if ( $self->{t}->error ){ | ||
| 1756 | $self->{error}=10; | ||
| 1757 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1758 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1759 | $self->warn; | ||
| 1760 | return undef; | ||
| 1761 | } | ||
| 1762 | |||
| 1763 | return $rendered; | ||
| 1764 | } | ||
| 1765 | |||
| 1766 | =head2 flink | ||
| 1767 | |||
| 1768 | This generates a link to a included file for the object. | ||
| 1769 | |||
| 1770 | Two arguements are taken. The first and required is the file. | ||
| 1771 | The second and optional is the text to use, which if not specified | ||
| 1772 | is the name of the file. | ||
| 1773 | |||
| 1774 | $g->flink( $file ); | ||
| 1775 | |||
| 1776 | The template 'linkFile' is used and the default is as below. | ||
| 1777 | |||
| 1778 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 1779 | |||
| 1780 | The variables passed are as below. | ||
| 1781 | |||
| 1782 | url - This is the relative URL for this. | ||
| 1783 | text - This to use for with the link. | ||
| 1784 | toDir - This is the relative back to the directory. | ||
| 1785 | toFiles - This is the relative path to the '.files' directory. | ||
| 1786 | obj - The L<Toader::Entry> object. | ||
| 1787 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 1788 | self - The L<Toader::Render::Entry> object. | ||
| 1789 | toader - This is a L<Toader> object. | ||
| 1790 | g - This is a L<Toader::Render::General> object. | ||
| 1791 | |||
| 1792 | =cut | ||
| 1793 | |||
| 1794 | sub flink{ | ||
| 1795 | my $self=$_[0]; | ||
| 1796 | my $file=$_[1]; | ||
| 1797 | my $text=$_[2]; | ||
| 1798 | |||
| 1799 | #blank any previous errors | ||
| 1800 | if ( ! $self->errorblank ){ | ||
| 1801 | return undef; | ||
| 1802 | } | ||
| 1803 | |||
| 1804 | #make sure we have a link | ||
| 1805 | if ( ! defined( $file ) ){ | ||
| 1806 | $self->{error}=17; | ||
| 1807 | $self->{errorString}='No file specified'; | ||
| 1808 | $self->warn; | ||
| 1809 | return undef; | ||
| 1810 | } | ||
| 1811 | |||
| 1812 | if ( ! defined( $text ) ){ | ||
| 1813 | $text=$file; | ||
| 1814 | } | ||
| 1815 | |||
| 1816 | #creates the URL and cleans it up | ||
| 1817 | my $url=$self->{toFiles}.'/'.$file; | ||
| 1818 | $url=~s/\/\/*/\//g; | ||
| 1819 | |||
| 1820 | #render it | ||
| 1821 | my $rendered=$self->{t}->fill_in( | ||
| 1822 | 'linkFile', | ||
| 1823 | { | ||
| 1824 | url=>$self->{toFiles}.'/'.$file, | ||
| 1825 | text=>$text, | ||
| 1826 | toDir=>$self->{toDir}, | ||
| 1827 | toFiles=>$self->{toFiles}, | ||
| 1828 | obj=>\$self->{obj}, | ||
| 1829 | c=>\$self->{toader}->getConfig, | ||
| 1830 | toader=>\$self->{toader}, | ||
| 1831 | self=>\$self, | ||
| 1832 | g=>\$self, | ||
| 1833 | } | ||
| 1834 | ); | ||
| 1835 | if ( $self->{t}->error ){ | ||
| 1836 | $self->{error}=10; | ||
| 1837 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 1838 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 1839 | $self->warn; | ||
| 1840 | return undef; | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | return $rendered; | ||
| 1844 | } | ||
| 1845 | |||
| 1846 | =head2 galleryDirURL | ||
| 1847 | |||
| 1848 | This returns the URL for a gallery directory. | ||
| 1849 | |||
| 1850 | Three arguments are accepted. The first is the Toader | ||
| 1851 | directory to for the gallery, if not specified it uses | ||
| 1852 | the Toader directory for the current object. The | ||
| 1853 | second is the relative gallery directory, which if not | ||
| 1854 | specified defaults to the '', the root gallery directory. | ||
| 1855 | |||
| 1856 | [== $g->galleryDirURL ==] | ||
| 1857 | |||
| 1858 | =cut | ||
| 1859 | |||
| 1860 | sub galleryDirURL{ | ||
| 1861 | my $self=$_[0]; | ||
| 1862 | my $dir=$_[1]; | ||
| 1863 | my $gdir=$_[2]; | ||
| 1864 | |||
| 1865 | #blank any previous errors | ||
| 1866 | if ( ! $self->errorblank ){ | ||
| 1867 | return undef; | ||
| 1868 | } | ||
| 1869 | |||
| 1870 | if ( ! defined( $gdir ) ){ | ||
| 1871 | $gdir=''; | ||
| 1872 | } | ||
| 1873 | |||
| 1874 | #clean it up, removing any possible multi / | ||
| 1875 | $gdir=~s/\/\/*/\//g; | ||
| 1876 | |||
| 1877 | #gets the directory to use if none is specified | ||
| 1878 | if ( ! defined( $dir ) ){ | ||
| 1879 | $dir=$self->{r2r}; | ||
| 1880 | } | ||
| 1881 | |||
| 1882 | #puts together the full path | ||
| 1883 | my $toaderDir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 1884 | |||
| 1885 | #gets a Gallery object | ||
| 1886 | my $tg; | ||
| 1887 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 1888 | $tg=Toader::Gallery->new; | ||
| 1889 | $tg->dirSet( $toaderDir ); | ||
| 1890 | if ( $tg->error ){ | ||
| 1891 | $self->{error}=40; | ||
| 1892 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 1893 | $self->warn; | ||
| 1894 | return undef; | ||
| 1895 | } | ||
| 1896 | }else{ | ||
| 1897 | $tg=$self->{obj}; | ||
| 1898 | } | ||
| 1899 | |||
| 1900 | #gets the output URL | ||
| 1901 | my $outputURL=$tg->outputURLget; | ||
| 1902 | if ( ! defined( $outputURL ) ){ | ||
| 1903 | $self->{error}=41; | ||
| 1904 | $self->{errorString}='Failed to get the output URL for Toader::Gallery for "'.$dir.'"'; | ||
| 1905 | $self->warn; | ||
| 1906 | return undef; | ||
| 1907 | } | ||
| 1908 | |||
| 1909 | my $link='.toader-gallery/html/'.$gdir; | ||
| 1910 | $link=~s/\/\/*/\//g; | ||
| 1911 | return $outputURL.$link; | ||
| 1912 | } | ||
| 1913 | |||
| 1914 | =head2 galleryImageLarge | ||
| 1915 | |||
| 1916 | This generates the HTML for a large gallery image. | ||
| 1917 | |||
| 1918 | Two arguments are taken. The first and optional one is the | ||
| 1919 | directory, which if not specified, it uses the Toader current | ||
| 1920 | directory. The second and required is the gallery directory for | ||
| 1921 | the image, which if not specified it defaults to the root | ||
| 1922 | directory, ''. The third and required is the gallery image. | ||
| 1923 | |||
| 1924 | [== $g->galleryImageLarge( undef, '', $someImage (. | ||
| 1925 | |||
| 1926 | This uses imageDiv with the content provided by imageExifTables. | ||
| 1927 | |||
| 1928 | =cut | ||
| 1929 | |||
| 1930 | sub galleryImageLarge{ | ||
| 1931 | my $self=$_[0]; | ||
| 1932 | my $dir=$_[1]; | ||
| 1933 | my $gdir=$_[2]; | ||
| 1934 | my $image=$_[3]; | ||
| 1935 | |||
| 1936 | #blank any previous errors | ||
| 1937 | if ( ! $self->errorblank ){ | ||
| 1938 | return undef; | ||
| 1939 | } | ||
| 1940 | |||
| 1941 | #gets the directory to use if none is specified | ||
| 1942 | if ( ! defined( $dir ) ){ | ||
| 1943 | $dir=$self->{r2r}; | ||
| 1944 | } | ||
| 1945 | |||
| 1946 | if ( ! defined( $gdir ) ){ | ||
| 1947 | $gdir=''; | ||
| 1948 | } | ||
| 1949 | |||
| 1950 | #puts together the full path | ||
| 1951 | my $toaderDir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 1952 | |||
| 1953 | #gets a Gallery object | ||
| 1954 | my $tg; | ||
| 1955 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 1956 | $tg=Toader::Gallery->new; | ||
| 1957 | $tg->dirSet( $toaderDir ); | ||
| 1958 | if ( $tg->error ){ | ||
| 1959 | $self->{error}=40; | ||
| 1960 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 1961 | $self->warn; | ||
| 1962 | return undef; | ||
| 1963 | } | ||
| 1964 | }else{ | ||
| 1965 | $tg=$self->{obj}; | ||
| 1966 | } | ||
| 1967 | |||
| 1968 | #gets the output URL | ||
| 1969 | my $outputURL=$tg->outputURLget; | ||
| 1970 | if ( ! defined( $outputURL ) ){ | ||
| 1971 | $self->{error}=41; | ||
| 1972 | $self->{errorString}='Failed to get the output URL for Toader::Gallery for "'.$dir.'"'; | ||
| 1973 | $self->warn; | ||
| 1974 | return undef; | ||
| 1975 | } | ||
| 1976 | |||
| 1977 | #gets the source path | ||
| 1978 | my $srcPath=$tg->srcPathGet; | ||
| 1979 | if ( ! defined( $srcPath ) ){ | ||
| 1980 | $self->{error}=42; | ||
| 1981 | $self->{errorString}='No source path specified'; | ||
| 1982 | $self->warn; | ||
| 1983 | return undef; | ||
| 1984 | } | ||
| 1985 | |||
| 1986 | #puts together the image URL | ||
| 1987 | my $imageURL='.toader-gallery/large/'.$gdir.'/'.$image; | ||
| 1988 | $imageURL=~s/\/\/*/\//g; | ||
| 1989 | $imageURL=$outputURL.$imageURL; | ||
| 1990 | |||
| 1991 | #returns the URL for the source gallery image | ||
| 1992 | my $srcURL=$self->gallerySrcURL( $dir, $gdir, $image ); | ||
| 1993 | |||
| 1994 | my $imagePath=$srcPath.'/'.$gdir.'/'.$image; | ||
| 1995 | $imagePath=~s/\/\/*/\//g; | ||
| 1996 | |||
| 1997 | #puts together the EXIF table | ||
| 1998 | my $exifTables=$self->imageExifTables( $imagePath ); | ||
| 1999 | if ( $self->error ){ | ||
| 2000 | $self->warnString('imageExifTables failed'); | ||
| 2001 | return undef; | ||
| 2002 | } | ||
| 2003 | |||
| 2004 | my $rendered=$self->imageDiv( $imageURL, $srcURL, undef, $exifTables ); | ||
| 2005 | if ( $self->error ){ | ||
| 2006 | $self->warnString('imageDiv failed'); | ||
| 2007 | return undef; | ||
| 2008 | } | ||
| 2009 | |||
| 2010 | return $rendered; | ||
| 2011 | } | ||
| 2012 | |||
| 2013 | =head2 galleryImageSmall | ||
| 2014 | |||
| 2015 | This generates the HTML for a small gallery image. | ||
| 2016 | |||
| 2017 | Two arguments are taken. The first and optional one is the | ||
| 2018 | directory, which if not specified, it uses the Toader current | ||
| 2019 | directory. The second and required is the gallery directory for | ||
| 2020 | the image. The third and required is the gallery image. | ||
| 2021 | |||
| 2022 | This invokes imageDiv, using the name of the image as the content. | ||
| 2023 | |||
| 2024 | [== $g->gallerImageSmall( undef, $gdir, $image ); ==] | ||
| 2025 | |||
| 2026 | This uses imageDiv with the link URL being the link to the image details | ||
| 2027 | and the lower text being the image file name. | ||
| 2028 | |||
| 2029 | =cut | ||
| 2030 | |||
| 2031 | sub galleryImageSmall{ | ||
| 2032 | my $self=$_[0]; | ||
| 2033 | my $dir=$_[1]; | ||
| 2034 | my $gdir=$_[2]; | ||
| 2035 | my $image=$_[3]; | ||
| 2036 | |||
| 2037 | #blank any previous errors | ||
| 2038 | if ( ! $self->errorblank ){ | ||
| 2039 | return undef; | ||
| 2040 | } | ||
| 2041 | |||
| 2042 | if ( ! defined( $gdir ) ){ | ||
| 2043 | $gdir=''; | ||
| 2044 | } | ||
| 2045 | |||
| 2046 | #gets the directory to use if none is specified | ||
| 2047 | if ( ! defined( $dir ) ){ | ||
| 2048 | $dir=$self->{r2r}; | ||
| 2049 | } | ||
| 2050 | |||
| 2051 | #puts together the full path | ||
| 2052 | my $toaderDir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 2053 | |||
| 2054 | #gets a Gallery object | ||
| 2055 | my $tg; | ||
| 2056 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 2057 | $tg=Toader::Gallery->new; | ||
| 2058 | $tg->dirSet( $toaderDir ); | ||
| 2059 | if ( $tg->error ){ | ||
| 2060 | $self->{error}=40; | ||
| 2061 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 2062 | $self->warn; | ||
| 2063 | return undef; | ||
| 2064 | } | ||
| 2065 | }else{ | ||
| 2066 | $tg=$self->{obj}; | ||
| 2067 | } | ||
| 2068 | |||
| 2069 | #gets the output URL | ||
| 2070 | my $outputURL=$tg->outputURLget; | ||
| 2071 | if ( ! defined( $outputURL ) ){ | ||
| 2072 | $self->{error}=41; | ||
| 2073 | $self->{errorString}='Failed to get the output URL for Toader::Gallery for "'.$dir.'"'; | ||
| 2074 | $self->warn; | ||
| 2075 | return undef; | ||
| 2076 | } | ||
| 2077 | |||
| 2078 | #puts together the image URL | ||
| 2079 | my $imageURL='.toader-gallery/small/'.$gdir.'/'.$image; | ||
| 2080 | $imageURL=~s/\/\/*/\//g; | ||
| 2081 | $imageURL=$outputURL.$imageURL; | ||
| 2082 | |||
| 2083 | #returns the URL for the large gallery image | ||
| 2084 | my $largeURL=$self->galleryLargeURL( $dir, $gdir, $image ); | ||
| 2085 | |||
| 2086 | my $rendered=$self->imageDiv( $imageURL, $largeURL, undef, $image ); | ||
| 2087 | if ( $self->error ){ | ||
| 2088 | $self->warnString('imageDiv failed'); | ||
| 2089 | return undef; | ||
| 2090 | } | ||
| 2091 | |||
| 2092 | return $rendered; | ||
| 2093 | } | ||
| 2094 | |||
| 2095 | =head2 galleryLargeURL | ||
| 2096 | |||
| 2097 | This returns the large URL for a directory image. | ||
| 2098 | |||
| 2099 | Three arguments are accepted. The first is the Toader | ||
| 2100 | directory to for the gallery, if not specified it uses | ||
| 2101 | the Toader directory for the current object. The | ||
| 2102 | second is the relative gallery directory, which if not | ||
| 2103 | specified defaults to the '', the root gallery directory. | ||
| 2104 | The third is the image in that directory. | ||
| 2105 | |||
| 2106 | [== $g->galleryLargeURL; ==] | ||
| 2107 | |||
| 2108 | =cut | ||
| 2109 | |||
| 2110 | sub galleryLargeURL{ | ||
| 2111 | my $self=$_[0]; | ||
| 2112 | my $dir=$_[1]; | ||
| 2113 | my $gdir=$_[2]; | ||
| 2114 | my $image=$_[3]; | ||
| 2115 | |||
| 2116 | #blank any previous errors | ||
| 2117 | if ( ! $self->errorblank ){ | ||
| 2118 | return undef; | ||
| 2119 | } | ||
| 2120 | |||
| 2121 | #gets the directory to use if none is specified | ||
| 2122 | if ( ! defined( $dir ) ){ | ||
| 2123 | $dir=$self->{r2r}; | ||
| 2124 | } | ||
| 2125 | |||
| 2126 | if ( ! defined( $gdir ) ){ | ||
| 2127 | $gdir=''; | ||
| 2128 | } | ||
| 2129 | |||
| 2130 | #make sure there no multi / | ||
| 2131 | $gdir=~s/\/\/*/\//g; | ||
| 2132 | |||
| 2133 | #puts together the full path | ||
| 2134 | my $toaderDir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 2135 | |||
| 2136 | #gets a Gallery object | ||
| 2137 | my $tg; | ||
| 2138 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 2139 | $tg=Toader::Gallery->new; | ||
| 2140 | $tg->dirSet( $toaderDir ); | ||
| 2141 | if ( $tg->error ){ | ||
| 2142 | $self->{error}=40; | ||
| 2143 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 2144 | $self->warn; | ||
| 2145 | return undef; | ||
| 2146 | } | ||
| 2147 | }else{ | ||
| 2148 | $tg=$self->{obj}; | ||
| 2149 | } | ||
| 2150 | |||
| 2151 | #gets the output URL | ||
| 2152 | my $outputURL=$tg->outputURLget; | ||
| 2153 | if ( ! defined( $outputURL ) ){ | ||
| 2154 | $self->{error}=41; | ||
| 2155 | $self->{errorString}='Failed to get the output URL for Toader::Gallery for "'.$dir.'"'; | ||
| 2156 | $self->warn; | ||
| 2157 | return undef; | ||
| 2158 | } | ||
| 2159 | |||
| 2160 | my $url='.toader-gallery/html/'.$gdir.'/'.$image.'.html'; | ||
| 2161 | $url=~s/\/\/*/\//g; | ||
| 2162 | return $outputURL.$url; | ||
| 2163 | } | ||
| 2164 | |||
| 2165 | =head2 galleryLargeImageURL | ||
| 2166 | |||
| 2167 | This returns the URL for the large gallery image. | ||
| 2168 | |||
| 2169 | Three arguments are accepted. The first is the Toader | ||
| 2170 | directory to for the gallery, if not specified it uses | ||
| 2171 | the Toader directory for the current object. The | ||
| 2172 | second is the relative gallery directory, which if not | ||
| 2173 | specified defaults to the '', the root gallery directory. | ||
| 2174 | The third is the image in that directory. | ||
| 2175 | |||
| 2176 | [== $g->galleryLargeImageURL( undef, $gdir, $image ); ==] | ||
| 2177 | |||
| 2178 | =cut | ||
| 2179 | |||
| 2180 | sub galleryLargeImageURL{ | ||
| 2181 | my $self=$_[0]; | ||
| 2182 | my $dir=$_[1]; | ||
| 2183 | my $gdir=$_[2]; | ||
| 2184 | my $image=$_[3]; | ||
| 2185 | |||
| 2186 | #blank any previous errors | ||
| 2187 | if ( ! $self->errorblank ){ | ||
| 2188 | return undef; | ||
| 2189 | } | ||
| 2190 | |||
| 2191 | #gets the directory to use if none is specified | ||
| 2192 | if ( ! defined( $dir ) ){ | ||
| 2193 | $dir=$self->{r2r}; | ||
| 2194 | } | ||
| 2195 | |||
| 2196 | if ( ! defined( $gdir ) ){ | ||
| 2197 | $gdir=''; | ||
| 2198 | } | ||
| 2199 | |||
| 2200 | #puts together the full path | ||
| 2201 | my $toaderDir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 2202 | |||
| 2203 | #gets a Gallery object | ||
| 2204 | my $tg; | ||
| 2205 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 2206 | $tg=Toader::Gallery->new; | ||
| 2207 | $tg->dirSet( $toaderDir ); | ||
| 2208 | if ( $tg->error ){ | ||
| 2209 | $self->{error}=40; | ||
| 2210 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 2211 | $self->warn; | ||
| 2212 | return undef; | ||
| 2213 | } | ||
| 2214 | }else{ | ||
| 2215 | $tg=$self->{obj}; | ||
| 2216 | } | ||
| 2217 | |||
| 2218 | #gets the output URL | ||
| 2219 | my $outputURL=$tg->outputURLget; | ||
| 2220 | if ( ! defined( $outputURL ) ){ | ||
| 2221 | $self->{error}=41; | ||
| 2222 | $self->{errorString}='Failed to get the output URL for Toader::Gallery for "'.$dir.'"'; | ||
| 2223 | $self->warn; | ||
| 2224 | return undef; | ||
| 2225 | } | ||
| 2226 | |||
| 2227 | my $url='.toader-gallery/large/'.$gdir.'/'.$image; | ||
| 2228 | $url=~s/\/\/*/\//g; | ||
| 2229 | return $outputURL.$url; | ||
| 2230 | } | ||
| 2231 | |||
| 2232 | =head2 galleryLocationbar | ||
| 2233 | |||
| 2234 | Two arguments taken for this. The first argument is required and | ||
| 2235 | it is the relative gallery directory, which if not specified | ||
| 2236 | defaults to the '', the root gallery directory. The second and | ||
| 2237 | optional is a image name, if any. | ||
| 2238 | |||
| 2239 | [== $g->galleryLocationbar; ==] | ||
| 2240 | |||
| 2241 | This is largely useful for setting a locationSub for a gallery | ||
| 2242 | item. See L<Toader::Render::Gallery> for a example of that. | ||
| 2243 | |||
| 2244 | =head3 Templates | ||
| 2245 | |||
| 2246 | =head4 galleryLocationStart | ||
| 2247 | |||
| 2248 | This starts the location bar insert. | ||
| 2249 | |||
| 2250 | The default template is as below. | ||
| 2251 | |||
| 2252 | <h3>Gallery Location: | ||
| 2253 | |||
| 2254 | The variables below are passed to it. | ||
| 2255 | |||
| 2256 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2257 | self - The L<Toader::Render::General> object. | ||
| 2258 | toader - This is a L<Toader> object. | ||
| 2259 | g - This is a L<Toader::Render::General> object. | ||
| 2260 | obj - This is the object that Toader was initiated with. | ||
| 2261 | |||
| 2262 | =head4 galleryLocationPart | ||
| 2263 | |||
| 2264 | This is a one of the gallery directories in the path to the one specified. | ||
| 2265 | |||
| 2266 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 2267 | |||
| 2268 | The variables below are passed to it. | ||
| 2269 | |||
| 2270 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2271 | self - The L<Toader::Render::General> object. | ||
| 2272 | toader - This is a L<Toader> object. | ||
| 2273 | g - This is a L<Toader::Render::General> object. | ||
| 2274 | obj - This is the object that Toader was initiated with. | ||
| 2275 | gdir - The gallery directory this part is for. | ||
| 2276 | url - The URL for that gallery directory. | ||
| 2277 | text - The text(directory name) for that directory. | ||
| 2278 | |||
| 2279 | =head4 galleryLocationJoin | ||
| 2280 | |||
| 2281 | This joins the gallery parts together. | ||
| 2282 | |||
| 2283 | / | ||
| 2284 | |||
| 2285 | The variables below are passed to it. | ||
| 2286 | |||
| 2287 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2288 | self - The L<Toader::Render::General> object. | ||
| 2289 | toader - This is a L<Toader> object. | ||
| 2290 | g - This is a L<Toader::Render::General> object. | ||
| 2291 | obj - This is the object that Toader was initiated with. | ||
| 2292 | |||
| 2293 | =head4 galleryLocationEnd | ||
| 2294 | |||
| 2295 | This ends the gallery location bar. | ||
| 2296 | |||
| 2297 | The default template is as below. | ||
| 2298 | |||
| 2299 | </h3> | ||
| 2300 | |||
| 2301 | |||
| 2302 | The variables below are passed to it. | ||
| 2303 | |||
| 2304 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2305 | self - The L<Toader::Render::General> object. | ||
| 2306 | toader - This is a L<Toader> object. | ||
| 2307 | g - This is a L<Toader::Render::General> object. | ||
| 2308 | obj - This is the object that Toader was initiated with. | ||
| 2309 | |||
| 2310 | =head4 galleryLocationImage | ||
| 2311 | |||
| 2312 | This is appended if something is specified for a image. | ||
| 2313 | |||
| 2314 | The default | ||
| 2315 | |||
| 2316 | <h3>Image: <a href="[== $url ==]">[== $image ==]</a></h3> | ||
| 2317 | |||
| 2318 | The variables below are passed to it. | ||
| 2319 | |||
| 2320 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2321 | self - The L<Toader::Render::General> object. | ||
| 2322 | toader - This is a L<Toader> object. | ||
| 2323 | g - This is a L<Toader::Render::General> object. | ||
| 2324 | obj - This is the object that Toader was initiated with. | ||
| 2325 | gdir - The gallery directory this part is for. | ||
| 2326 | url - The URL for that large(details) image page. | ||
| 2327 | text - The text(directory name) for that directory. | ||
| 2328 | |||
| 2329 | =cut | ||
| 2330 | |||
| 2331 | sub galleryLocationbar{ | ||
| 2332 | my $self=$_[0]; | ||
| 2333 | my $gdir=$_[1]; | ||
| 2334 | my $image=$_[2]; | ||
| 2335 | |||
| 2336 | #blank any previous errors | ||
| 2337 | if ( ! $self->errorblank ){ | ||
| 2338 | return undef; | ||
| 2339 | } | ||
| 2340 | |||
| 2341 | if ( ! defined( $gdir ) ){ | ||
| 2342 | $gdir=''; | ||
| 2343 | } | ||
| 2344 | |||
| 2345 | #save this for later errors, if needed | ||
| 2346 | my $gdirOrig=$gdir; | ||
| 2347 | |||
| 2348 | #makes sure it does not have a ./, which can safely be removed | ||
| 2349 | $gdir=~s/^\.\///; | ||
| 2350 | #make sure it does not start with a /, which can safely be removed | ||
| 2351 | $gdir=~s/^\///; | ||
| 2352 | #make sure it does not have any multie-/, which can safely be made one | ||
| 2353 | $gdir=~s/\/\/*/\//g; | ||
| 2354 | #make sure it does not end in a /, which can safely be removed | ||
| 2355 | $gdir=~s/\/$//; | ||
| 2356 | |||
| 2357 | #if we get here and it still has a period, we have an issue | ||
| 2358 | if ( $gdir=~/^\./ ){ | ||
| 2359 | $self->{error}=44; | ||
| 2360 | $self->{errorString}='"'.$gdirOrig.'" can not be used as a relative gallery directory as it starts with a period'; | ||
| 2361 | $self->warn; | ||
| 2362 | return undef; | ||
| 2363 | } | ||
| 2364 | |||
| 2365 | #splits the gdir apart | ||
| 2366 | my @gdirSplit=split( /\//, $gdir); | ||
| 2367 | |||
| 2368 | #gets a Gallery object | ||
| 2369 | my $tg; | ||
| 2370 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 2371 | $tg=Toader::Gallery->new; | ||
| 2372 | $tg->dirSet( $self->{dir} ); | ||
| 2373 | if ( $tg->error ){ | ||
| 2374 | $self->{error}=40; | ||
| 2375 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 2376 | $self->warn; | ||
| 2377 | return undef; | ||
| 2378 | } | ||
| 2379 | }else{ | ||
| 2380 | $tg=$self->{obj}; | ||
| 2381 | } | ||
| 2382 | |||
| 2383 | #renders the gallery link | ||
| 2384 | my $start=$self->{t}->fill_in( | ||
| 2385 | 'galleryLocationStart', | ||
| 2386 | { | ||
| 2387 | obj=>\$self->{obj}, | ||
| 2388 | c=>\$self->{toader}->getConfig, | ||
| 2389 | toader=>\$self->{toader}, | ||
| 2390 | self=>\$self, | ||
| 2391 | g=>\$self, | ||
| 2392 | gdir=>$gdir, | ||
| 2393 | } | ||
| 2394 | ); | ||
| 2395 | if ( $self->{t}->error ){ | ||
| 2396 | $self->{error}=10; | ||
| 2397 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 2398 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 2399 | $self->warn; | ||
| 2400 | return undef; | ||
| 2401 | } | ||
| 2402 | |||
| 2403 | #renders the gallery link | ||
| 2404 | my $joiner=$self->{t}->fill_in( | ||
| 2405 | 'galleryLocationJoin', | ||
| 2406 | { | ||
| 2407 | obj=>\$self->{obj}, | ||
| 2408 | c=>\$self->{toader}->getConfig, | ||
| 2409 | toader=>\$self->{toader}, | ||
| 2410 | self=>\$self, | ||
| 2411 | g=>\$self, | ||
| 2412 | gdir=>$gdir, | ||
| 2413 | } | ||
| 2414 | ); | ||
| 2415 | if ( $self->{t}->error ){ | ||
| 2416 | $self->{error}=10; | ||
| 2417 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 2418 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 2419 | $self->warn; | ||
| 2420 | return undef; | ||
| 2421 | } | ||
| 2422 | |||
| 2423 | #the parts that will later be joined | ||
| 2424 | my @parts; | ||
| 2425 | |||
| 2426 | #gets the url to use | ||
| 2427 | my $url=$self->galleryDirURL( undef, undef ); | ||
| 2428 | if ( $self->error ){ | ||
| 2429 | $self->warnString('galleryDirURL errored'); | ||
| 2430 | return undef; | ||
| 2431 | } | ||
| 2432 | |||
| 2433 | #renders the gallery link | ||
| 2434 | my $rendered=$self->{t}->fill_in( | ||
| 2435 | 'galleryLocationPart', | ||
| 2436 | { | ||
| 2437 | obj=>\$self->{obj}, | ||
| 2438 | c=>\$self->{toader}->getConfig, | ||
| 2439 | toader=>\$self->{toader}, | ||
| 2440 | self=>\$self, | ||
| 2441 | g=>\$self, | ||
| 2442 | gdir=>$gdir, | ||
| 2443 | url=>$url, | ||
| 2444 | text=>'root', | ||
| 2445 | } | ||
| 2446 | ); | ||
| 2447 | if ( $self->{t}->error ){ | ||
| 2448 | $self->{error}=10; | ||
| 2449 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 2450 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 2451 | $self->warn; | ||
| 2452 | return undef; | ||
| 2453 | } | ||
| 2454 | push( @parts, $rendered ); | ||
| 2455 | |||
| 2456 | #process each part | ||
| 2457 | my $int=0; | ||
| 2458 | my $currentGdir=''; | ||
| 2459 | while( defined( $gdirSplit[$int] ) ){ | ||
| 2460 | #gets the url to use | ||
| 2461 | $currentGdir=$currentGdir.'/'.$gdirSplit[$int]; | ||
| 2462 | $currentGdir=~s/\/\/*/\//g; | ||
| 2463 | $currentGdir=~s/^\///; | ||
| 2464 | |||
| 2465 | my $url=$self->galleryDirURL( undef, $currentGdir ); | ||
| 2466 | if ( $self->error ){ | ||
| 2467 | $self->warnString('galleryDirURL errored'); | ||
| 2468 | return undef; | ||
| 2469 | } | ||
| 2470 | |||
| 2471 | #renders the gallery link | ||
| 2472 | $rendered=$self->{t}->fill_in( | ||
| 2473 | 'galleryLocationPart', | ||
| 2474 | { | ||
| 2475 | obj=>\$self->{obj}, | ||
| 2476 | c=>\$self->{toader}->getConfig, | ||
| 2477 | toader=>\$self->{toader}, | ||
| 2478 | self=>\$self, | ||
| 2479 | g=>\$self, | ||
| 2480 | gdir=>$gdir, | ||
| 2481 | url=>$url, | ||
| 2482 | text=>$gdirSplit[$int], | ||
| 2483 | } | ||
| 2484 | ); | ||
| 2485 | if ( $self->{t}->error ){ | ||
| 2486 | $self->{error}=10; | ||
| 2487 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 2488 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 2489 | $self->warn; | ||
| 2490 | return undef; | ||
| 2491 | } | ||
| 2492 | push( @parts, $rendered ); | ||
| 2493 | |||
| 2494 | $int++; | ||
| 2495 | } | ||
| 2496 | |||
| 2497 | #renders the gallery link | ||
| 2498 | my $end=$self->{t}->fill_in( | ||
| 2499 | 'galleryLocationEnd', | ||
| 2500 | { | ||
| 2501 | obj=>\$self->{obj}, | ||
| 2502 | c=>\$self->{toader}->getConfig, | ||
| 2503 | toader=>\$self->{toader}, | ||
| 2504 | self=>\$self, | ||
| 2505 | g=>\$self, | ||
| 2506 | gdir=>$gdir, | ||
| 2507 | } | ||
| 2508 | ); | ||
| 2509 | if ( $self->{t}->error ){ | ||
| 2510 | $self->{error}=10; | ||
| 2511 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 2512 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 2513 | $self->warn; | ||
| 2514 | return undef; | ||
| 2515 | } | ||
| 2516 | |||
| 2517 | #handles a specified image... | ||
| 2518 | my $imageLine=''; | ||
| 2519 | if ( defined( $image ) ){ | ||
| 2520 | my $url=$self->galleryLargeURL( undef, $gdir, $image ); | ||
| 2521 | if ( $self->error ){ | ||
| 2522 | $self->warnString('galleryDirURL errored'); | ||
| 2523 | return undef; | ||
| 2524 | } | ||
| 2525 | |||
| 2526 | #renders the image link | ||
| 2527 | $imageLine=$self->{t}->fill_in( | ||
| 2528 | 'galleryLocationImage', | ||
| 2529 | { | ||
| 2530 | obj=>\$self->{obj}, | ||
| 2531 | c=>\$self->{toader}->getConfig, | ||
| 2532 | toader=>\$self->{toader}, | ||
| 2533 | self=>\$self, | ||
| 2534 | g=>\$self, | ||
| 2535 | gdir=>$gdir, | ||
| 2536 | image=>$image, | ||
| 2537 | url=>$url, | ||
| 2538 | } | ||
| 2539 | ); | ||
| 2540 | if ( $self->{t}->error ){ | ||
| 2541 | $self->{error}=10; | ||
| 2542 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 2543 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 2544 | $self->warn; | ||
| 2545 | return undef; | ||
| 2546 | } | ||
| 2547 | |||
| 2548 | } | ||
| 2549 | |||
| 2550 | return $start.join( $joiner, @parts ).$end.$imageLine; | ||
| 2551 | } | ||
| 2552 | |||
| 2553 | =head2 gallerySmallImageURL | ||
| 2554 | |||
| 2555 | This returns the URL for the small gallery image. | ||
| 2556 | |||
| 2557 | Three arguments are accepted. The first is the Toader | ||
| 2558 | directory to for the gallery, if not specified it uses | ||
| 2559 | the Toader directory for the current object. The | ||
| 2560 | second is the relative gallery directory, which if not | ||
| 2561 | specified defaults to the '', the root gallery directory. | ||
| 2562 | The third is the image in that directory. | ||
| 2563 | |||
| 2564 | [== $g->gallerySmallImageURL; ==] | ||
| 2565 | |||
| 2566 | =cut | ||
| 2567 | |||
| 2568 | sub gallerySmallImageURL{ | ||
| 2569 | my $self=$_[0]; | ||
| 2570 | my $dir=$_[1]; | ||
| 2571 | my $gdir=$_[2]; | ||
| 2572 | my $image=$_[3]; | ||
| 2573 | |||
| 2574 | #blank any previous errors | ||
| 2575 | if ( ! $self->errorblank ){ | ||
| 2576 | return undef; | ||
| 2577 | } | ||
| 2578 | |||
| 2579 | #gets the directory to use if none is specified | ||
| 2580 | if ( ! defined( $dir ) ){ | ||
| 2581 | $dir=$self->{r2r}; | ||
| 2582 | } | ||
| 2583 | |||
| 2584 | if ( ! defined( $gdir ) ){ | ||
| 2585 | $gdir=''; | ||
| 2586 | } | ||
| 2587 | |||
| 2588 | #puts together the full path | ||
| 2589 | my $toaderDir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 2590 | |||
| 2591 | #gets a Gallery object | ||
| 2592 | my $tg; | ||
| 2593 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 2594 | $tg=Toader::Gallery->new; | ||
| 2595 | $tg->dirSet( $toaderDir ); | ||
| 2596 | if ( $tg->error ){ | ||
| 2597 | $self->{error}=40; | ||
| 2598 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 2599 | $self->warn; | ||
| 2600 | return undef; | ||
| 2601 | } | ||
| 2602 | }else{ | ||
| 2603 | $tg=$self->{obj}; | ||
| 2604 | } | ||
| 2605 | |||
| 2606 | #gets the output URL | ||
| 2607 | my $outputURL=$tg->outputURLget; | ||
| 2608 | if ( ! defined( $outputURL ) ){ | ||
| 2609 | $self->{error}=41; | ||
| 2610 | $self->{errorString}='Failed to get the output URL for Toader::Gallery for "'.$dir.'"'; | ||
| 2611 | $self->warn; | ||
| 2612 | return undef; | ||
| 2613 | } | ||
| 2614 | |||
| 2615 | my $url='.toader-gallery/small/'.$gdir.'/'.$image; | ||
| 2616 | $url=~s/\/\/*/\//g; | ||
| 2617 | return $outputURL.$url; | ||
| 2618 | } | ||
| 2619 | |||
| 2620 | =head2 galleryLink | ||
| 2621 | |||
| 2622 | This links to a Toader::Gallery gallery. | ||
| 2623 | |||
| 2624 | There are three optional arguments taken. The first is Toader | ||
| 2625 | directory this is for, if it is not specified, it assumes | ||
| 2626 | it is the current one. The second is the second one is the directory | ||
| 2627 | under it that it should link to, which defaults to the root of it | ||
| 2628 | if none is specified. The third is text of the link, which defaults | ||
| 2629 | to 'Gallery' if not specified. | ||
| 2630 | |||
| 2631 | [== $g->galleryLink( undef, $gdir, $text ); ==] | ||
| 2632 | |||
| 2633 | The template used is 'linkGallery'. It is as below. | ||
| 2634 | |||
| 2635 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 2636 | |||
| 2637 | The variables passed are as below. | ||
| 2638 | |||
| 2639 | url - This is the relative URL for this. | ||
| 2640 | text - This to use for with the link. | ||
| 2641 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2642 | self - The L<Toader::Render::General> object. | ||
| 2643 | toader - This is a L<Toader> object. | ||
| 2644 | g - This is a L<Toader::Render::General> object. | ||
| 2645 | obj - This is the object that Toader was initiated with. | ||
| 2646 | |||
| 2647 | =cut | ||
| 2648 | |||
| 2649 | sub galleryLink{ | ||
| 2650 | my $self=$_[0]; | ||
| 2651 | my $dir=$_[1]; | ||
| 2652 | my $gdir=$_[2]; | ||
| 2653 | my $text=$_[3]; | ||
| 2654 | |||
| 2655 | |||
| 2656 | #blank any previous errors | ||
| 2657 | if ( ! $self->errorblank ){ | ||
| 2658 | return undef; | ||
| 2659 | } | ||
| 2660 | |||
| 2661 | #default to the root if nothing is defined for the directory under the gallery | ||
| 2662 | if ( ! defined( $gdir ) ){ | ||
| 2663 | $gdir=''; | ||
| 2664 | } | ||
| 2665 | |||
| 2666 | #sets the default text if needed... | ||
| 2667 | if ( ! defined( $text ) ){ | ||
| 2668 | $text='Gallery'; | ||
| 2669 | } | ||
| 2670 | |||
| 2671 | #gets the directory to use if none is specified | ||
| 2672 | if ( ! defined( $dir ) ){ | ||
| 2673 | $dir=$self->{r2r}; | ||
| 2674 | } | ||
| 2675 | |||
| 2676 | #turns the relative directory into a full path and clean it up | ||
| 2677 | $dir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 2678 | $dir=$self->{ph}->cleanup( $dir ); | ||
| 2679 | if ( $self->{ph}->error ){ | ||
| 2680 | $self->{error}=39; | ||
| 2681 | $self->{errorString}='Failed to clean up the path for "'.$dir.'"'; | ||
| 2682 | $self->warn; | ||
| 2683 | return undef; | ||
| 2684 | } | ||
| 2685 | |||
| 2686 | #gets a Gallery object | ||
| 2687 | my $tg; | ||
| 2688 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 2689 | $tg=Toader::Gallery->new; | ||
| 2690 | $tg->dirSet( $dir ); | ||
| 2691 | if ( $tg->error ){ | ||
| 2692 | $self->{error}=40; | ||
| 2693 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 2694 | $self->warn; | ||
| 2695 | return undef; | ||
| 2696 | } | ||
| 2697 | }else{ | ||
| 2698 | $tg=$self->{obj}; | ||
| 2699 | } | ||
| 2700 | |||
| 2701 | #gets the output URL | ||
| 2702 | my $outputURL=$tg->outputURLget; | ||
| 2703 | if ( ! defined( $outputURL ) ){ | ||
| 2704 | $self->{error}=41; | ||
| 2705 | $self->{errorString}='Failed to get the output directory for Toader::Gallery for "'.$dir.'"'; | ||
| 2706 | $self->warn; | ||
| 2707 | return undef; | ||
| 2708 | } | ||
| 2709 | |||
| 2710 | #makes the URL for what is being linked to | ||
| 2711 | my $link='.toader-gallery/html/'.$gdir; | ||
| 2712 | $link=~s/\/\/*/\//g; | ||
| 2713 | $link=$outputURL.$link; | ||
| 2714 | |||
| 2715 | #renders the gallery link | ||
| 2716 | my $galleryLink=$self->{t}->fill_in( | ||
| 2717 | 'linkGallery', | ||
| 2718 | { | ||
| 2719 | obj=>\$self->{obj}, | ||
| 2720 | c=>\$self->{toader}->getConfig, | ||
| 2721 | toader=>\$self->{toader}, | ||
| 2722 | self=>\$self, | ||
| 2723 | g=>\$self, | ||
| 2724 | url=>$link, | ||
| 2725 | text=>$text, | ||
| 2726 | } | ||
| 2727 | ); | ||
| 2728 | if ( $self->{t}->error ){ | ||
| 2729 | $self->{error}=10; | ||
| 2730 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 2731 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 2732 | $self->warn; | ||
| 2733 | return undef; | ||
| 2734 | } | ||
| 2735 | |||
| 2736 | return $galleryLink; | ||
| 2737 | } | ||
| 2738 | |||
| 2739 | =head2 gallerySrcURL | ||
| 2740 | |||
| 2741 | This returns the URL for the source gallery image. | ||
| 2742 | |||
| 2743 | Three arguments are accepted. The first is the Toader | ||
| 2744 | directory to for the gallery, if not specified it uses | ||
| 2745 | the Toader directory for the current object. The | ||
| 2746 | second is the relative gallery directory, which if not | ||
| 2747 | specified defaults to the '', the root gallery directory. | ||
| 2748 | The third is the image in that directory. | ||
| 2749 | |||
| 2750 | [== $g->gallerySrcURL( undef, $gdir, $image ); ==] | ||
| 2751 | |||
| 2752 | =cut | ||
| 2753 | |||
| 2754 | sub gallerySrcURL{ | ||
| 2755 | my $self=$_[0]; | ||
| 2756 | my $dir=$_[1]; | ||
| 2757 | my $gdir=$_[2]; | ||
| 2758 | my $image=$_[3]; | ||
| 2759 | |||
| 2760 | #blank any previous errors | ||
| 2761 | if ( ! $self->errorblank ){ | ||
| 2762 | return undef; | ||
| 2763 | } | ||
| 2764 | |||
| 2765 | #gets the directory to use if none is specified | ||
| 2766 | if ( ! defined( $dir ) ){ | ||
| 2767 | $dir=$self->{r2r}; | ||
| 2768 | } | ||
| 2769 | |||
| 2770 | if ( ! defined( $gdir ) ){ | ||
| 2771 | $gdir=''; | ||
| 2772 | } | ||
| 2773 | |||
| 2774 | #puts together the full path | ||
| 2775 | my $toaderDir=$self->{toader}->getRootDir.'/'.$dir; | ||
| 2776 | |||
| 2777 | #gets a Gallery object | ||
| 2778 | my $tg; | ||
| 2779 | if ( ref( $self->{obj} ) ne 'Toader::Gallery' ){ | ||
| 2780 | $tg=Toader::Gallery->new; | ||
| 2781 | $tg->dirSet( $toaderDir ); | ||
| 2782 | if ( $tg->error ){ | ||
| 2783 | $self->{error}=40; | ||
| 2784 | $self->{errorString}='Failed to initialize Toader::Gallery'; | ||
| 2785 | $self->warn; | ||
| 2786 | return undef; | ||
| 2787 | } | ||
| 2788 | }else{ | ||
| 2789 | $tg=$self->{obj}; | ||
| 2790 | } | ||
| 2791 | |||
| 2792 | #gets the output URL | ||
| 2793 | my $srcURL=$tg->srcURLget; | ||
| 2794 | if ( ! defined( $srcURL ) ){ | ||
| 2795 | $self->{error}=45; | ||
| 2796 | $self->{errorString}='Failed to get the source URL for Toader::Gallery for "'.$dir.'"'; | ||
| 2797 | $self->warn; | ||
| 2798 | return undef; | ||
| 2799 | } | ||
| 2800 | |||
| 2801 | my $url=$gdir.'/'.$image; | ||
| 2802 | $url=~s/\/\/*/\//g; | ||
| 2803 | return $srcURL.$url; | ||
| 2804 | } | ||
| 2805 | |||
| 2806 | =head2 hasDocs | ||
| 2807 | |||
| 2808 | This returns true if the current directory has any | ||
| 2809 | documentation. | ||
| 2810 | |||
| 2811 | if ( $g->hasDocs ){ | ||
| 2812 | print "This directory has documentation..."; | ||
| 2813 | } | ||
| 2814 | |||
| 2815 | =cut | ||
| 2816 | |||
| 2817 | sub hasDocs{ | ||
| 2818 | my $self=$_[0]; | ||
| 2819 | |||
| 2820 | #blank any previous errors | ||
| 2821 | if ( ! $self->errorblank ){ | ||
| 2822 | return undef; | ||
| 2823 | } | ||
| 2824 | |||
| 2825 | #returns true if there is a autodoc directory for the current Toader directory | ||
| 2826 | if ( -d $self->{odir}.'/.toader/autodoc/' ){ | ||
| 2827 | return 1; | ||
| 2828 | } | ||
| 2829 | |||
| 2830 | return 0; | ||
| 2831 | } | ||
| 2832 | |||
| 2833 | =head2 hasEntries | ||
| 2834 | |||
| 2835 | Check if a entries directory exists for the | ||
| 2836 | Toader directory for the current object. | ||
| 2837 | |||
| 2838 | A boolean value is returned. | ||
| 2839 | |||
| 2840 | my $hasEntries=$g->hasEntries; | ||
| 2841 | |||
| 2842 | =cut | ||
| 2843 | |||
| 2844 | sub hasEntries{ | ||
| 2845 | my $self=$_[0]; | ||
| 2846 | |||
| 2847 | #blank any previous errors | ||
| 2848 | if ( ! $self->errorblank ){ | ||
| 2849 | return undef; | ||
| 2850 | } | ||
| 2851 | |||
| 2852 | #returns true if there is a entries directory for the current Toader directory | ||
| 2853 | if ( -d $self->{odir}.'/.toader/entries/' ){ | ||
| 2854 | return 1; | ||
| 2855 | } | ||
| 2856 | |||
| 2857 | return 0; | ||
| 2858 | } | ||
| 2859 | |||
| 2860 | =head2 hasGallery | ||
| 2861 | |||
| 2862 | This returns true if the current Toader directory has a gallery. | ||
| 2863 | |||
| 2864 | This is checked for by seeing if the gallery config exists. | ||
| 2865 | |||
| 2866 | =cut | ||
| 2867 | |||
| 2868 | sub hasGallery{ | ||
| 2869 | my $self=$_[0]; | ||
| 2870 | |||
| 2871 | #blank any previous errors | ||
| 2872 | if ( ! $self->errorblank ){ | ||
| 2873 | return undef; | ||
| 2874 | } | ||
| 2875 | |||
| 2876 | #returns true if there is a autodoc directory for the current Toader directory | ||
| 2877 | if ( -f $self->{odir}.'/.toader/gallery.ini' ){ | ||
| 2878 | return 1; | ||
| 2879 | } | ||
| 2880 | |||
| 2881 | return 0; | ||
| 2882 | } | ||
| 2883 | |||
| 2884 | =head2 hasAnyDirs | ||
| 2885 | |||
| 2886 | This returns true if there are either Toader sub directories or | ||
| 2887 | it is not at root. | ||
| 2888 | |||
| 2889 | if ( $g->hasAnyDirs ){ | ||
| 2890 | print "Either not at root or there are Toader sub directires..."; | ||
| 2891 | } | ||
| 2892 | |||
| 2893 | =cut | ||
| 2894 | |||
| 2895 | sub hasAnyDirs{ | ||
| 2896 | my $self=$_[0]; | ||
| 2897 | |||
| 2898 | #blank any previous errors | ||
| 2899 | if ( ! $self->errorblank ){ | ||
| 2900 | return undef; | ||
| 2901 | } | ||
| 2902 | |||
| 2903 | my $subs=$self->hasSubDirs; | ||
| 2904 | if ( $self->error ){ | ||
| 2905 | $self->warnString('Failed to check if the directory has any Toader sub directories'); | ||
| 2906 | return undef; | ||
| 2907 | } | ||
| 2908 | |||
| 2909 | #return 1 as there are directories | ||
| 2910 | if ( $subs ){ | ||
| 2911 | return 1; | ||
| 2912 | } | ||
| 2913 | |||
| 2914 | #if we are at root and there no Toader sub directories then this is the only Toader directory | ||
| 2915 | if ( $self->atRoot ){ | ||
| 2916 | return 0; | ||
| 2917 | } | ||
| 2918 | |||
| 2919 | #we are not at root then there is a directory that can be go gone to | ||
| 2920 | return 1; | ||
| 2921 | } | ||
| 2922 | |||
| 2923 | =head2 hashToTable | ||
| 2924 | |||
| 2925 | This renders a hash to a table. | ||
| 2926 | |||
| 2927 | Four arguments are taken. The first and required a hash | ||
| 2928 | reference to operate on. The second and optional is the title | ||
| 2929 | to use for the key column. The third and optional is the title | ||
| 2930 | to use for the value column. The fourth and optional is the | ||
| 2931 | CSS ID to use, which defaults to to "hashToTable". | ||
| 2932 | |||
| 2933 | my $table=$foo->hashToTable( \%hash ); | ||
| 2934 | |||
| 2935 | =head3 Templates | ||
| 2936 | |||
| 2937 | =head4 hashToTableBegin | ||
| 2938 | |||
| 2939 | This begins the table. | ||
| 2940 | |||
| 2941 | The default is as below. | ||
| 2942 | |||
| 2943 | <table id="[== $cssID ==]"> | ||
| 2944 | |||
| 2945 | |||
| 2946 | The passed variables are as below. | ||
| 2947 | |||
| 2948 | toDir - This is the relative back to the directory. | ||
| 2949 | toFiles - This is the relative path to the '.files' directory. | ||
| 2950 | obj - This is the object that it was invoked for. | ||
| 2951 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2952 | toader - This is a L<Toader> object. | ||
| 2953 | self - This the L<Toader::Render::General> object. | ||
| 2954 | g - This the L<Toader::Render::General> object. | ||
| 2955 | cssID - The CSS ID to use. | ||
| 2956 | |||
| 2957 | =head4 hashToTableTitle | ||
| 2958 | |||
| 2959 | This is a row that acts as the title row at the top of the table. | ||
| 2960 | |||
| 2961 | It is only rendered if a title is defined for either key or value. | ||
| 2962 | |||
| 2963 | The default is as below. | ||
| 2964 | |||
| 2965 | <tr id="[== $cssID ==]"> | ||
| 2966 | <td id="[== $cssID ==]"><bold>[== $keyTitle ==]</td> | ||
| 2967 | <td id="[== $cssID ==]"><bold>[== $valueTitle ==]</bold></td> | ||
| 2968 | </tr> | ||
| 2969 | |||
| 2970 | |||
| 2971 | The passed variables are as below. | ||
| 2972 | |||
| 2973 | toDir - This is the relative back to the directory. | ||
| 2974 | toFiles - This is the relative path to the '.files' directory. | ||
| 2975 | obj - This is the object that it was invoked for. | ||
| 2976 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 2977 | toader - This is a L<Toader> object. | ||
| 2978 | self - This the L<Toader::Render::General> object. | ||
| 2979 | g - This the L<Toader::Render::General> object. | ||
| 2980 | cssID - The CSS ID to use. | ||
| 2981 | keyTitle - The title to use for the key column. | ||
| 2982 | valueTitle - The title to use for th value column. | ||
| 2983 | |||
| 2984 | =head4 hashToTableRow | ||
| 2985 | |||
| 2986 | This represents a row containing a key/value pair. | ||
| 2987 | |||
| 2988 | The default is as below. | ||
| 2989 | |||
| 2990 | <tr id="[== $cssID ==]"> | ||
| 2991 | <td id="[== $cssID ==]"><bold>[== $key ==]</td> | ||
| 2992 | <td id="[== $cssID ==]"><bold>[== $value ==]</bold></td> | ||
| 2993 | </tr> | ||
| 2994 | |||
| 2995 | |||
| 2996 | The passed variables are as below. | ||
| 2997 | |||
| 2998 | toDir - This is the relative back to the directory. | ||
| 2999 | toFiles - This is the relative path to the '.files' directory. | ||
| 3000 | obj - This is the object that it was invoked for. | ||
| 3001 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3002 | toader - This is a L<Toader> object. | ||
| 3003 | self - This the L<Toader::Render::General> object. | ||
| 3004 | g - This the L<Toader::Render::General> object. | ||
| 3005 | cssID - The CSS ID to use. | ||
| 3006 | key - The key for the row. | ||
| 3007 | value - The value for the row. | ||
| 3008 | |||
| 3009 | =head4 hashToTableJoin | ||
| 3010 | |||
| 3011 | This joins together the rendered rows. | ||
| 3012 | |||
| 3013 | The default is as below. | ||
| 3014 | |||
| 3015 | |||
| 3016 | |||
| 3017 | The passed variables are as below. | ||
| 3018 | |||
| 3019 | toDir - This is the relative back to the directory. | ||
| 3020 | toFiles - This is the relative path to the '.files' directory. | ||
| 3021 | obj - This is the object that it was invoked for. | ||
| 3022 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3023 | toader - This is a L<Toader> object. | ||
| 3024 | self - This the L<Toader::Render::General> object. | ||
| 3025 | g - This the L<Toader::Render::General> object. | ||
| 3026 | cssID - The CSS ID to use. | ||
| 3027 | |||
| 3028 | =head4 hashToTableEnd | ||
| 3029 | |||
| 3030 | This ends the table. | ||
| 3031 | |||
| 3032 | The default is as below. | ||
| 3033 | |||
| 3034 | </table> | ||
| 3035 | |||
| 3036 | The passed variables are as below. | ||
| 3037 | |||
| 3038 | toDir - This is the relative back to the directory. | ||
| 3039 | toFiles - This is the relative path to the '.files' directory. | ||
| 3040 | obj - This is the object that it was invoked for. | ||
| 3041 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3042 | toader - This is a L<Toader> object. | ||
| 3043 | self - This the L<Toader::Render::General> object. | ||
| 3044 | g - This the L<Toader::Render::General> object. | ||
| 3045 | cssID - The CSS ID to use. | ||
| 3046 | |||
| 3047 | =cut | ||
| 3048 | |||
| 3049 | sub hashToTable{ | ||
| 3050 | my $self=$_[0]; | ||
| 3051 | my $hash=$_[1]; | ||
| 3052 | my $keyTitle=$_[2]; | ||
| 3053 | my $valueTitle=$_[3]; | ||
| 3054 | my $cssID=$_[4]; | ||
| 3055 | |||
| 3056 | #blank any previous errors | ||
| 3057 | if ( ! $self->errorblank ){ | ||
| 3058 | return undef; | ||
| 3059 | } | ||
| 3060 | |||
| 3061 | #sets the default CSS ID if none is given | ||
| 3062 | if( !defined( $cssID ) ){ | ||
| 3063 | $cssID='hashToTable'; | ||
| 3064 | } | ||
| 3065 | |||
| 3066 | #checks if it has a column title bar for either | ||
| 3067 | my $titleRow=''; | ||
| 3068 | my $renderTitleRow=0; | ||
| 3069 | if ( | ||
| 3070 | defined( $keyTitle ) || | ||
| 3071 | defined( $valueTitle ) | ||
| 3072 | ){ | ||
| 3073 | if ( ! defined( $keyTitle ) ){ | ||
| 3074 | $keyTitle=''; | ||
| 3075 | } | ||
| 3076 | if ( ! defined( $valueTitle ) ){ | ||
| 3077 | $valueTitle=''; | ||
| 3078 | } | ||
| 3079 | $renderTitleRow=1; | ||
| 3080 | } | ||
| 3081 | |||
| 3082 | #renders the title row if needed... | ||
| 3083 | if ( $renderTitleRow ){ | ||
| 3084 | $titleRow=$self->{t}->fill_in( | ||
| 3085 | 'hashToTableTitle', | ||
| 3086 | { | ||
| 3087 | toDir=>$self->{toDir}, | ||
| 3088 | toFiles=>$self->{toFiles}, | ||
| 3089 | obj=>\$self->{obj}, | ||
| 3090 | c=>\$self->{toader}->getConfig, | ||
| 3091 | toader=>\$self->{toader}, | ||
| 3092 | self=>\$self, | ||
| 3093 | g=>\$self, | ||
| 3094 | cssID=>$cssID, | ||
| 3095 | keyTitle=>$keyTitle, | ||
| 3096 | valueTitle=>$valueTitle, | ||
| 3097 | } | ||
| 3098 | ); | ||
| 3099 | if ( $self->{t}->error ){ | ||
| 3100 | $self->{error}=10; | ||
| 3101 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3102 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3103 | $self->warn; | ||
| 3104 | return undef; | ||
| 3105 | } | ||
| 3106 | } | ||
| 3107 | |||
| 3108 | #renders the top of the table | ||
| 3109 | my $begin=$self->{t}->fill_in( | ||
| 3110 | 'hashToTableBegin', | ||
| 3111 | { | ||
| 3112 | toDir=>$self->{toDir}, | ||
| 3113 | toFiles=>$self->{toFiles}, | ||
| 3114 | obj=>\$self->{obj}, | ||
| 3115 | c=>\$self->{toader}->getConfig, | ||
| 3116 | toader=>\$self->{toader}, | ||
| 3117 | self=>\$self, | ||
| 3118 | g=>\$self, | ||
| 3119 | cssID=>$cssID, | ||
| 3120 | } | ||
| 3121 | ); | ||
| 3122 | if ( $self->{t}->error ){ | ||
| 3123 | $self->{error}=10; | ||
| 3124 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3125 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3126 | $self->warn; | ||
| 3127 | return undef; | ||
| 3128 | } | ||
| 3129 | |||
| 3130 | #renders the bottom of the table | ||
| 3131 | my $end=$self->{t}->fill_in( | ||
| 3132 | 'hashToTableEnd', | ||
| 3133 | { | ||
| 3134 | toDir=>$self->{toDir}, | ||
| 3135 | toFiles=>$self->{toFiles}, | ||
| 3136 | obj=>\$self->{obj}, | ||
| 3137 | c=>\$self->{toader}->getConfig, | ||
| 3138 | toader=>\$self->{toader}, | ||
| 3139 | self=>\$self, | ||
| 3140 | g=>\$self, | ||
| 3141 | cssID=>$cssID, | ||
| 3142 | } | ||
| 3143 | ); | ||
| 3144 | if ( $self->{t}->error ){ | ||
| 3145 | $self->{error}=10; | ||
| 3146 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3147 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3148 | $self->warn; | ||
| 3149 | return undef; | ||
| 3150 | } | ||
| 3151 | |||
| 3152 | #renders the row joiner | ||
| 3153 | my $join=$self->{t}->fill_in( | ||
| 3154 | 'hashToTableJoin', | ||
| 3155 | { | ||
| 3156 | toDir=>$self->{toDir}, | ||
| 3157 | toFiles=>$self->{toFiles}, | ||
| 3158 | obj=>\$self->{obj}, | ||
| 3159 | c=>\$self->{toader}->getConfig, | ||
| 3160 | toader=>\$self->{toader}, | ||
| 3161 | self=>\$self, | ||
| 3162 | g=>\$self, | ||
| 3163 | cssID=>$cssID, | ||
| 3164 | } | ||
| 3165 | ); | ||
| 3166 | if ( $self->{t}->error ){ | ||
| 3167 | $self->{error}=10; | ||
| 3168 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3169 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3170 | $self->warn; | ||
| 3171 | return undef; | ||
| 3172 | } | ||
| 3173 | |||
| 3174 | #renders each row | ||
| 3175 | my @keys=sort {uc($a) cmp uc($b)} keys( %$hash ); | ||
| 3176 | my @rows; | ||
| 3177 | my $int=0; | ||
| 3178 | while( defined( $keys[$int] ) ){ | ||
| 3179 | my $row=$self->{t}->fill_in( | ||
| 3180 | 'hashToTableRow', | ||
| 3181 | { | ||
| 3182 | toDir=>$self->{toDir}, | ||
| 3183 | toFiles=>$self->{toFiles}, | ||
| 3184 | obj=>\$self->{obj}, | ||
| 3185 | c=>\$self->{toader}->getConfig, | ||
| 3186 | toader=>\$self->{toader}, | ||
| 3187 | self=>\$self, | ||
| 3188 | g=>\$self, | ||
| 3189 | cssID=>$cssID, | ||
| 3190 | key=>$keys[$int], | ||
| 3191 | value=>$hash->{$keys[$int]}, | ||
| 3192 | } | ||
| 3193 | ); | ||
| 3194 | if ( $self->{t}->error ){ | ||
| 3195 | $self->{error}=10; | ||
| 3196 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3197 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3198 | $self->warn; | ||
| 3199 | return undef; | ||
| 3200 | } | ||
| 3201 | push( @rows, $row ); | ||
| 3202 | |||
| 3203 | $int++; | ||
| 3204 | } | ||
| 3205 | |||
| 3206 | return $begin.$titleRow.join( $join, @rows ).$end; | ||
| 3207 | } | ||
| 3208 | |||
| 3209 | =head2 hasSubDirs | ||
| 3210 | |||
| 3211 | This returns to true if the current object | ||
| 3212 | directory has any Toader sub directories. | ||
| 3213 | |||
| 3214 | if ( $g->hasSubDirs ){ | ||
| 3215 | print "This directory has sub directories."; | ||
| 3216 | } | ||
| 3217 | |||
| 3218 | =cut | ||
| 3219 | |||
| 3220 | sub hasSubDirs{ | ||
| 3221 | my $self=$_[0]; | ||
| 3222 | |||
| 3223 | #blank any previous errors | ||
| 3224 | if ( ! $self->errorblank ){ | ||
| 3225 | return undef; | ||
| 3226 | } | ||
| 3227 | |||
| 3228 | #gets a list of directories | ||
| 3229 | my @dirs; | ||
| 3230 | if ( ref( $self->{odir} ) eq 'Toader::Directory' ){ | ||
| 3231 | @dirs=$self->{odir}->listSubToaderDirs; | ||
| 3232 | if ( $self->{odir}->error ){ | ||
| 3233 | $self->{error}=22; | ||
| 3234 | $self->{errorString}='Failed to get a list of Toader sub directories. error="' | ||
| 3235 | .$self->{odir}->error.'" errorString="'.$self->{odir}->errorString.'"'; | ||
| 3236 | return undef; | ||
| 3237 | } | ||
| 3238 | }else{ | ||
| 3239 | my $dobj=Toader::Directory->new( $self->{toader} ); | ||
| 3240 | $dobj->dirSet( $self->{odir} ); | ||
| 3241 | @dirs=$dobj->listSubToaderDirs; | ||
| 3242 | if ( $dobj->error ){ | ||
| 3243 | $self->{error}=22; | ||
| 3244 | $self->{errorString}='Failed to get a list of Toader sub directories. error="' | ||
| 3245 | .$dobj->error.'" errorString="'.$dobj->{odir}->errorString.'"'; | ||
| 3246 | return undef; | ||
| 3247 | } | ||
| 3248 | } | ||
| 3249 | |||
| 3250 | if ( defined( $dirs[0] ) ){ | ||
| 3251 | return 1; | ||
| 3252 | } | ||
| 3253 | |||
| 3254 | return 0; | ||
| 3255 | } | ||
| 3256 | |||
| 3257 | =head2 imageDiv | ||
| 3258 | |||
| 3259 | This can be used for creating a captioned image. | ||
| 3260 | |||
| 3261 | The takes five arguments. The first and required is the URL | ||
| 3262 | for the image. Second and optional is link to use for if the image | ||
| 3263 | is clicked on, which if not defined, the image will not be setup | ||
| 3264 | as a link. The third and optional is a caption to show above the | ||
| 3265 | image, which if left undefined defaults to ''. The fourth and | ||
| 3266 | optional is a caption to show below the image, which if left | ||
| 3267 | undefined defaults to ''. The fifth is the CSS ID to use, | ||
| 3268 | which if not defined defaults to 'imageDiv'. The sixth and | ||
| 3269 | optional is the alt test to use, which if not specified defaults | ||
| 3270 | to the provided image URL.. | ||
| 3271 | |||
| 3272 | $g-imageDiv( $imageURL, $imageLink, , 'some caption below it'); | ||
| 3273 | |||
| 3274 | The default template, 'imageDiv' is as below. | ||
| 3275 | |||
| 3276 | <div id='$cssID'> | ||
| 3277 | [== $above ==] | ||
| 3278 | [== if ( defined( $link ) ){ return ' <a href="'.$link.'"'> }else{ return '' } ==] | ||
| 3279 | <img src="[== $image ==]" alt="[== $alt ==]"/> | ||
| 3280 | [== if ( defined( $link ) ){ return ' </a>' }else{ return '' } ==]<br> | ||
| 3281 | [== $below ==] | ||
| 3282 | </div> | ||
| 3283 | |||
| 3284 | The variables passed are as below. | ||
| 3285 | |||
| 3286 | toDir - This is the relative back to the directory. | ||
| 3287 | toFiles - This is the relative path to the '.files' directory. | ||
| 3288 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3289 | self - The L<Toader::Render::General> object. | ||
| 3290 | toader - This is a L<Toader> object. | ||
| 3291 | g - This is a L<Toader::Render::General> object. | ||
| 3292 | obj - This is the object that Toader was initiated with. | ||
| 3293 | image - This is the source URL to usse. | ||
| 3294 | above - This is the caption above the image. | ||
| 3295 | below - This is the caption below the image. | ||
| 3296 | link - This is a optional link to link to if the image is clicked on. | ||
| 3297 | alt - This is the alt text for the image. | ||
| 3298 | |||
| 3299 | =cut | ||
| 3300 | |||
| 3301 | sub imageDiv{ | ||
| 3302 | my $self=$_[0]; | ||
| 3303 | my $imageURL=$_[1]; | ||
| 3304 | my $imageLink=$_[2]; | ||
| 3305 | my $above=$_[3]; | ||
| 3306 | my $below=$_[4]; | ||
| 3307 | my $cssID=$_[5]; | ||
| 3308 | my $alt=$_[6]; | ||
| 3309 | |||
| 3310 | #blank any previous errors | ||
| 3311 | if ( ! $self->errorblank ){ | ||
| 3312 | return undef; | ||
| 3313 | } | ||
| 3314 | |||
| 3315 | #error if we have no URL for the image | ||
| 3316 | if ( ! defined( $imageURL ) ){ | ||
| 3317 | $self->{error}=36; | ||
| 3318 | $self->{errorString}='No URL specified for the image'; | ||
| 3319 | $self->warn; | ||
| 3320 | return undef; | ||
| 3321 | } | ||
| 3322 | |||
| 3323 | #sets the default value for above if none is given | ||
| 3324 | if ( ! defined( $above ) ){ | ||
| 3325 | $above=''; | ||
| 3326 | } | ||
| 3327 | |||
| 3328 | #sets the default value for below if none is given | ||
| 3329 | if ( ! defined( $below ) ){ | ||
| 3330 | $below=''; | ||
| 3331 | } | ||
| 3332 | |||
| 3333 | #sets the default CSS ID if none is specified | ||
| 3334 | if ( ! defined( $cssID ) ){ | ||
| 3335 | $cssID='imageDiv'; | ||
| 3336 | } | ||
| 3337 | |||
| 3338 | #sets alt to the URL if not specified | ||
| 3339 | if ( ! defined( $alt ) ){ | ||
| 3340 | $alt=$imageURL; | ||
| 3341 | } | ||
| 3342 | |||
| 3343 | my $rendered=$self->{t}->fill_in( | ||
| 3344 | 'imageDiv', | ||
| 3345 | { | ||
| 3346 | toDir=>$self->{toDir}, | ||
| 3347 | toFiles=>$self->{toFiles}, | ||
| 3348 | obj=>\$self->{obj}, | ||
| 3349 | c=>\$self->{toader}->getConfig, | ||
| 3350 | toader=>\$self->{toader}, | ||
| 3351 | self=>\$self, | ||
| 3352 | g=>\$self, | ||
| 3353 | cssID=>$cssID, | ||
| 3354 | image=>$imageURL, | ||
| 3355 | above=>$above, | ||
| 3356 | below=>$below, | ||
| 3357 | alt=>$alt, | ||
| 3358 | link=>$imageLink, | ||
| 3359 | } | ||
| 3360 | ); | ||
| 3361 | if ( $self->{t}->error ){ | ||
| 3362 | $self->{error}=10; | ||
| 3363 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3364 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3365 | $self->warn; | ||
| 3366 | return undef; | ||
| 3367 | } | ||
| 3368 | |||
| 3369 | return $rendered; | ||
| 3370 | } | ||
| 3371 | |||
| 3372 | =head2 imageExifTables | ||
| 3373 | |||
| 3374 | This returns the table of the tags for a image. | ||
| 3375 | |||
| 3376 | This puts together a tables of the common EXIF tag groups. | ||
| 3377 | |||
| 3378 | [== $g->imageExifTables( $image ); ==] | ||
| 3379 | |||
| 3380 | this methode ignores the EXIF tables listed below. | ||
| 3381 | |||
| 3382 | ExifTool | ||
| 3383 | System | ||
| 3384 | PrintIM | ||
| 3385 | File | ||
| 3386 | Printing | ||
| 3387 | Copy1 | ||
| 3388 | |||
| 3389 | =head3 Templates | ||
| 3390 | |||
| 3391 | =head4 imageExifTables | ||
| 3392 | |||
| 3393 | This begins it. | ||
| 3394 | |||
| 3395 | The default template is as below. | ||
| 3396 | |||
| 3397 | <b>Image: </b> [== $filename ==] <br/> | ||
| 3398 | [== $tables ==] | ||
| 3399 | |||
| 3400 | |||
| 3401 | The variables passed are as below. | ||
| 3402 | |||
| 3403 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3404 | self - The L<Toader::Render::General> object. | ||
| 3405 | toader - This is a L<Toader> object. | ||
| 3406 | g - This is a L<Toader::Render::General> object. | ||
| 3407 | obj - This is the object that Toader was initiated with. | ||
| 3408 | filename - This is the name of the image file. | ||
| 3409 | tables - This is the rendered tables from generated by the templates below. | ||
| 3410 | |||
| 3411 | =head3 imageExifTablesBegin | ||
| 3412 | |||
| 3413 | This begins the prefixes joining of the tables. | ||
| 3414 | |||
| 3415 | The default template is blank. | ||
| 3416 | |||
| 3417 | The variables passed are as below. | ||
| 3418 | |||
| 3419 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3420 | self - The L<Toader::Render::General> object. | ||
| 3421 | toader - This is a L<Toader> object. | ||
| 3422 | g - This is a L<Toader::Render::General> object. | ||
| 3423 | obj - This is the object that Toader was initiated with. | ||
| 3424 | |||
| 3425 | =head3 imageExifTablesGroup | ||
| 3426 | |||
| 3427 | This is a EXIF tag group. | ||
| 3428 | |||
| 3429 | The default table is as below. | ||
| 3430 | |||
| 3431 | <br /> | ||
| 3432 | <b>EXIF Tag Group: [== $group ==]</b> | ||
| 3433 | [== $table ==] | ||
| 3434 | <br /> | ||
| 3435 | |||
| 3436 | The variables passed are as below. | ||
| 3437 | |||
| 3438 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3439 | self - The L<Toader::Render::General> object. | ||
| 3440 | toader - This is a L<Toader> object. | ||
| 3441 | g - This is a L<Toader::Render::General> object. | ||
| 3442 | obj - This is the object that Toader was initiated with. | ||
| 3443 | group - This is the EXIF tag group. | ||
| 3444 | table - This is the generated by hash2table. | ||
| 3445 | |||
| 3446 | =head3 imageExifTablesJoin | ||
| 3447 | |||
| 3448 | This joins the text rendered for imageExifTablesGroup | ||
| 3449 | |||
| 3450 | The default template is blank. | ||
| 3451 | |||
| 3452 | The variables passed are as below. | ||
| 3453 | |||
| 3454 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3455 | self - The L<Toader::Render::General> object. | ||
| 3456 | toader - This is a L<Toader> object. | ||
| 3457 | g - This is a L<Toader::Render::General> object. | ||
| 3458 | obj - This is the object that Toader was initiated with. | ||
| 3459 | |||
| 3460 | =head3 imageExifTablesEnd | ||
| 3461 | |||
| 3462 | This ends the prefixes joining of the tables. | ||
| 3463 | |||
| 3464 | The default template is blank. | ||
| 3465 | |||
| 3466 | The variables passed are as below. | ||
| 3467 | |||
| 3468 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3469 | self - The L<Toader::Render::General> object. | ||
| 3470 | toader - This is a L<Toader> object. | ||
| 3471 | g - This is a L<Toader::Render::General> object. | ||
| 3472 | obj - This is the object that Toader was initiated with. | ||
| 3473 | |||
| 3474 | =cut | ||
| 3475 | |||
| 3476 | sub imageExifTables{ | ||
| 3477 | my $self=$_[0]; | ||
| 3478 | my $image=$_[1]; | ||
| 3479 | |||
| 3480 | #blank any previous errors | ||
| 3481 | if ( ! $self->errorblank ){ | ||
| 3482 | return undef; | ||
| 3483 | } | ||
| 3484 | |||
| 3485 | if ( ! defined( $image ) ){ | ||
| 3486 | $self->{error}=37; | ||
| 3487 | $self->{errorString}='No image file specified'; | ||
| 3488 | $self->warn; | ||
| 3489 | return undef; | ||
| 3490 | } | ||
| 3491 | |||
| 3492 | if ( ! -f $image ){ | ||
| 3493 | $self->{error}=38; | ||
| 3494 | $self->{errorString}='The specified image, "'.$image.'", does not exist'; | ||
| 3495 | $self->warn; | ||
| 3496 | return undef; | ||
| 3497 | } | ||
| 3498 | |||
| 3499 | my $filename=$image; | ||
| 3500 | $filename=~s/.*\///; | ||
| 3501 | |||
| 3502 | my $et=Image::ExifTool->new; | ||
| 3503 | $et->ExtractInfo( $image ); | ||
| 3504 | |||
| 3505 | my @foundTags=$et->GetFoundTags; | ||
| 3506 | |||
| 3507 | my %tags; | ||
| 3508 | |||
| 3509 | my $int=0; | ||
| 3510 | while( defined( $foundTags[$int] ) ){ | ||
| 3511 | my $value=$et->GetValue( $foundTags[$int] ); | ||
| 3512 | |||
| 3513 | if (ref $value eq 'SCALAR') { | ||
| 3514 | $value='(unprintable value)' | ||
| 3515 | } | ||
| 3516 | |||
| 3517 | my @groups=$et->GetGroup( $foundTags[$int] ); | ||
| 3518 | |||
| 3519 | my $int2=0; | ||
| 3520 | while( defined( $groups[$int2] ) ){ | ||
| 3521 | if ( $groups[$int2] eq "" ){ | ||
| 3522 | $groups[$int2]='""'; | ||
| 3523 | } | ||
| 3524 | |||
| 3525 | if ( ( $groups[$int2] ne 'ExifTool' ) && | ||
| 3526 | ( $groups[$int2] ne 'System' ) && | ||
| 3527 | ( $groups[$int2] ne 'PrintIM' ) && | ||
| 3528 | ( $groups[$int2] ne 'File' ) && | ||
| 3529 | ( $groups[$int2] ne 'Printing' ) && | ||
| 3530 | ( $groups[$int2] ne 'Copy1' ) | ||
| 3531 | ){ | ||
| 3532 | if ( ! defined( $tags{ $groups[$int2] } ) ){ | ||
| 3533 | $tags{ $groups[$int2] }={}; | ||
| 3534 | } | ||
| 3535 | |||
| 3536 | $tags{ $groups[$int2] }{ $foundTags[$int] }=$value; | ||
| 3537 | } | ||
| 3538 | |||
| 3539 | $int2++; | ||
| 3540 | } | ||
| 3541 | |||
| 3542 | $int++; | ||
| 3543 | } | ||
| 3544 | |||
| 3545 | my @groups=sort( keys( %tags ) ); | ||
| 3546 | |||
| 3547 | my @renderedGroups; | ||
| 3548 | |||
| 3549 | #puts together the Composite table if needed | ||
| 3550 | $int=0; | ||
| 3551 | while ( defined( $groups[$int] ) ){ | ||
| 3552 | my $table=$self->hashToTable( $tags{ $groups[$int] } ); | ||
| 3553 | if ( $self->error ){ | ||
| 3554 | $self->warnString('Failed to convert the hash to a table for "'.$groups[$int].'"'); | ||
| 3555 | return undef; | ||
| 3556 | } | ||
| 3557 | #renders the table | ||
| 3558 | my $rendered=$self->{t}->fill_in( | ||
| 3559 | 'imageExifTablesGroup', | ||
| 3560 | { | ||
| 3561 | obj=>\$self->{obj}, | ||
| 3562 | c=>\$self->{toader}->getConfig, | ||
| 3563 | toader=>\$self->{toader}, | ||
| 3564 | self=>\$self, | ||
| 3565 | table=>$table, | ||
| 3566 | group=>$groups[$int], | ||
| 3567 | } | ||
| 3568 | ); | ||
| 3569 | if ( $self->{t}->error ){ | ||
| 3570 | $self->{error}=10; | ||
| 3571 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3572 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3573 | $self->warn; | ||
| 3574 | return undef; | ||
| 3575 | } | ||
| 3576 | push( @renderedGroups, $rendered ); | ||
| 3577 | |||
| 3578 | $int++; | ||
| 3579 | } | ||
| 3580 | |||
| 3581 | #renders the table joiner | ||
| 3582 | my $begin=$self->{t}->fill_in( | ||
| 3583 | 'imageExifTablesBegin', | ||
| 3584 | { | ||
| 3585 | obj=>\$self->{obj}, | ||
| 3586 | c=>\$self->{toader}->getConfig, | ||
| 3587 | toader=>\$self->{toader}, | ||
| 3588 | self=>\$self, | ||
| 3589 | } | ||
| 3590 | ); | ||
| 3591 | if ( $self->{t}->error ){ | ||
| 3592 | $self->{error}=10; | ||
| 3593 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3594 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3595 | $self->warn; | ||
| 3596 | return undef; | ||
| 3597 | } | ||
| 3598 | |||
| 3599 | #renders the table joiner | ||
| 3600 | my $join=$self->{t}->fill_in( | ||
| 3601 | 'imageExifTablesJoin', | ||
| 3602 | { | ||
| 3603 | obj=>\$self->{obj}, | ||
| 3604 | c=>\$self->{toader}->getConfig, | ||
| 3605 | toader=>\$self->{toader}, | ||
| 3606 | self=>\$self, | ||
| 3607 | } | ||
| 3608 | ); | ||
| 3609 | if ( $self->{t}->error ){ | ||
| 3610 | $self->{error}=10; | ||
| 3611 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3612 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3613 | $self->warn; | ||
| 3614 | return undef; | ||
| 3615 | } | ||
| 3616 | |||
| 3617 | #renders the table joiner | ||
| 3618 | my $end=$self->{t}->fill_in( | ||
| 3619 | 'imageExifTablesEnd', | ||
| 3620 | { | ||
| 3621 | obj=>\$self->{obj}, | ||
| 3622 | c=>\$self->{toader}->getConfig, | ||
| 3623 | toader=>\$self->{toader}, | ||
| 3624 | self=>\$self, | ||
| 3625 | } | ||
| 3626 | ); | ||
| 3627 | if ( $self->{t}->error ){ | ||
| 3628 | $self->{error}=10; | ||
| 3629 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3630 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3631 | $self->warn; | ||
| 3632 | return undef; | ||
| 3633 | } | ||
| 3634 | |||
| 3635 | my $joinedtables=$begin.join('', @renderedGroups ).$end; | ||
| 3636 | |||
| 3637 | #renders the tables together | ||
| 3638 | my $rendered=$self->{t}->fill_in( | ||
| 3639 | 'imageExifTables', | ||
| 3640 | { | ||
| 3641 | obj=>\$self->{obj}, | ||
| 3642 | c=>\$self->{toader}->getConfig, | ||
| 3643 | toader=>\$self->{toader}, | ||
| 3644 | self=>\$self, | ||
| 3645 | tables=>$joinedtables, | ||
| 3646 | filename=>$filename, | ||
| 3647 | } | ||
| 3648 | ); | ||
| 3649 | if ( $self->{t}->error ){ | ||
| 3650 | $self->{error}=10; | ||
| 3651 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3652 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3653 | $self->warn; | ||
| 3654 | return undef; | ||
| 3655 | } | ||
| 3656 | |||
| 3657 | return $rendered; | ||
| 3658 | } | ||
| 3659 | |||
| 3660 | =head2 lastEntries | ||
| 3661 | |||
| 3662 | This returns the last entries, post rendering each one and joining them. | ||
| 3663 | |||
| 3664 | There is one optional and that is number of last entries to show. If | ||
| 3665 | not specified, it shows the last 15. | ||
| 3666 | |||
| 3667 | $g->lastEntries; | ||
| 3668 | |||
| 3669 | =head3 Templates | ||
| 3670 | |||
| 3671 | =head4 entryListBegin | ||
| 3672 | |||
| 3673 | This begins the list of the last entries. | ||
| 3674 | |||
| 3675 | The default template is blank. | ||
| 3676 | |||
| 3677 | The passed variables are as below. | ||
| 3678 | |||
| 3679 | toDir - This is the relative back to the directory. | ||
| 3680 | toFiles - This is the relative path to the '.files' directory. | ||
| 3681 | obj - This is the object that it was invoked for. | ||
| 3682 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3683 | toader - This is a L<Toader> object. | ||
| 3684 | self - This the L<Toader::Render::General> object. | ||
| 3685 | g - This the L<Toader::Render::General> object. | ||
| 3686 | |||
| 3687 | =head4 entryListJoin | ||
| 3688 | |||
| 3689 | This joins the rendered entries. | ||
| 3690 | |||
| 3691 | The default template is as below. | ||
| 3692 | |||
| 3693 | <br> | ||
| 3694 | |||
| 3695 | |||
| 3696 | The passed variables are as below. | ||
| 3697 | |||
| 3698 | toDir - This is the relative back to the directory. | ||
| 3699 | toFiles - This is the relative path to the '.files' directory. | ||
| 3700 | obj - This is the object that it was invoked for. | ||
| 3701 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3702 | toader - This is a L<Toader> object. | ||
| 3703 | self - This the L<Toader::Render::General> object. | ||
| 3704 | g - This the L<Toader::Render::General> object. | ||
| 3705 | |||
| 3706 | =head4 entryListEnd | ||
| 3707 | |||
| 3708 | This ends the list of rendered entries. | ||
| 3709 | |||
| 3710 | The default template is as below. | ||
| 3711 | |||
| 3712 | <br> | ||
| 3713 | |||
| 3714 | |||
| 3715 | The passed variables are as below. | ||
| 3716 | |||
| 3717 | toDir - This is the relative back to the directory. | ||
| 3718 | toFiles - This is the relative path to the '.files' directory. | ||
| 3719 | obj - This is the object that it was invoked for. | ||
| 3720 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3721 | toader - This is a L<Toader> object. | ||
| 3722 | self - This the L<Toader::Render::General> object. | ||
| 3723 | g - This the L<Toader::Render::General> object. | ||
| 3724 | |||
| 3725 | =cut | ||
| 3726 | |||
| 3727 | sub lastEntries{ | ||
| 3728 | my $self=$_[0]; | ||
| 3729 | my $show=$_[1]; | ||
| 3730 | |||
| 3731 | #blank any previous errors | ||
| 3732 | if ( ! $self->errorblank ){ | ||
| 3733 | return undef; | ||
| 3734 | } | ||
| 3735 | |||
| 3736 | #default to 15 to show | ||
| 3737 | if ( ! defined( $show ) ){ | ||
| 3738 | $show=15; | ||
| 3739 | } | ||
| 3740 | |||
| 3741 | my $em=Toader::Entry::Manage->new( $self->{toader} ); | ||
| 3742 | $em->setDir( $self->{odir} ); | ||
| 3743 | if ( $em->error ){ | ||
| 3744 | $self->{error}=25; | ||
| 3745 | $self->{errorString}='Failed to set the directory, "'.$self->{odir}. | ||
| 3746 | '", for Toader::Entry::Manage. error="'.$em->error | ||
| 3747 | .'" errorString="'.$em->errorString.'"'; | ||
| 3748 | $self->warn; | ||
| 3749 | return undef; | ||
| 3750 | } | ||
| 3751 | |||
| 3752 | #lists the entries for the directory | ||
| 3753 | my @entries=$em->list; | ||
| 3754 | if ( $em->error ){ | ||
| 3755 | $self->{error}=25; | ||
| 3756 | $self->{errorString}='Failed to read the entries for "'.$self->{odir}. | ||
| 3757 | '". error="'.$em->error.'" errorString="'.$em->errorString.'"'; | ||
| 3758 | $self->warn; | ||
| 3759 | return undef; | ||
| 3760 | } | ||
| 3761 | |||
| 3762 | #return '' if there are none | ||
| 3763 | if ( ! defined( $entries[0] ) ){ | ||
| 3764 | return ''; | ||
| 3765 | } | ||
| 3766 | |||
| 3767 | #sort and order from last to first | ||
| 3768 | @entries=sort(@entries); | ||
| 3769 | @entries=reverse(@entries); | ||
| 3770 | |||
| 3771 | #process each one | ||
| 3772 | my @tojoin; | ||
| 3773 | my $int=0; | ||
| 3774 | while ( defined( $entries[$int] ) ){ | ||
| 3775 | my $entry=$em->read( $entries[$int] ); | ||
| 3776 | if ( $em->error ){ | ||
| 3777 | $self->{error}=26; | ||
| 3778 | $self->{errorString}='Failed to read "'.$entries[$int].'" in "' | ||
| 3779 | .$self->{odir}.'". error="'.$em->error.'" errorstring="' | ||
| 3780 | .$em->errorString.'"'; | ||
| 3781 | $self->warn; | ||
| 3782 | return undef; | ||
| 3783 | } | ||
| 3784 | |||
| 3785 | my $r=Toader::Render::Entry->new({ | ||
| 3786 | obj=>$entry, | ||
| 3787 | toader=>$self->{toader}, | ||
| 3788 | toDir=>$self->{toDir}, | ||
| 3789 | }); | ||
| 3790 | if ( $r->error ){ | ||
| 3791 | $self->{error}=27; | ||
| 3792 | $self->{errorString}='Failed to initialize Toader::Render::Entry for "'. | ||
| 3793 | $entries[$int].'" in "'.$self->{odir}.'". error="'.$r->error. | ||
| 3794 | '" errorString="'.$r->errorString.'"'; | ||
| 3795 | $self->warn; | ||
| 3796 | return undef; | ||
| 3797 | } | ||
| 3798 | |||
| 3799 | my $rendered=$r->content; | ||
| 3800 | if ( $r->error ){ | ||
| 3801 | $self->{error}=28; | ||
| 3802 | $self->{errorString}='Failed to render "'.$entries[$int].'" in "' | ||
| 3803 | .$self->{odir}.'". error="'.$r->error.'" errorString="'.$r->errorString.'"'; | ||
| 3804 | $self->warn; | ||
| 3805 | return undef; | ||
| 3806 | } | ||
| 3807 | |||
| 3808 | push( @tojoin, $rendered ); | ||
| 3809 | |||
| 3810 | $int++; | ||
| 3811 | } | ||
| 3812 | |||
| 3813 | #renders the joiner | ||
| 3814 | my $joiner=$self->{t}->fill_in( | ||
| 3815 | 'entryListJoin', | ||
| 3816 | { | ||
| 3817 | toDir=>$self->{toDir}, | ||
| 3818 | toFiles=>$self->{toFiles}, | ||
| 3819 | obj=>\$self->{obj}, | ||
| 3820 | c=>\$self->{toader}->getConfig, | ||
| 3821 | toader=>\$self->{toader}, | ||
| 3822 | self=>\$self, | ||
| 3823 | g=>\$self, | ||
| 3824 | } | ||
| 3825 | ); | ||
| 3826 | if ( $self->{t}->error ){ | ||
| 3827 | $self->{error}=10; | ||
| 3828 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3829 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3830 | $self->warn; | ||
| 3831 | return undef; | ||
| 3832 | } | ||
| 3833 | |||
| 3834 | #renders the begining of the end of the last entries | ||
| 3835 | my $begin=$self->{t}->fill_in( | ||
| 3836 | 'entryListBegin', | ||
| 3837 | { | ||
| 3838 | toDir=>$self->{toDir}, | ||
| 3839 | toFiles=>$self->{toFiles}, | ||
| 3840 | obj=>\$self->{obj}, | ||
| 3841 | c=>\$self->{toader}->getConfig, | ||
| 3842 | toader=>\$self->{toader}, | ||
| 3843 | self=>\$self, | ||
| 3844 | g=>\$self, | ||
| 3845 | } | ||
| 3846 | ); | ||
| 3847 | if ( $self->{t}->error ){ | ||
| 3848 | $self->{error}=10; | ||
| 3849 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3850 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3851 | $self->warn; | ||
| 3852 | return undef; | ||
| 3853 | } | ||
| 3854 | |||
| 3855 | #renders the end of the end of the last entries | ||
| 3856 | my $end=$self->{t}->fill_in( | ||
| 3857 | 'entryListEnd', | ||
| 3858 | { | ||
| 3859 | toDir=>$self->{toDir}, | ||
| 3860 | toFiles=>$self->{toFiles}, | ||
| 3861 | obj=>\$self->{obj}, | ||
| 3862 | c=>\$self->{toader}->getConfig, | ||
| 3863 | toader=>\$self->{toader}, | ||
| 3864 | self=>\$self, | ||
| 3865 | g=>\$self, | ||
| 3866 | } | ||
| 3867 | ); | ||
| 3868 | if ( $self->{t}->error ){ | ||
| 3869 | $self->{error}=10; | ||
| 3870 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3871 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3872 | $self->warn; | ||
| 3873 | return undef; | ||
| 3874 | } | ||
| 3875 | |||
| 3876 | |||
| 3877 | return $begin.join( $joiner, @tojoin ).$end; | ||
| 3878 | } | ||
| 3879 | |||
| 3880 | =head2 link | ||
| 3881 | |||
| 3882 | This generates a HTML link. | ||
| 3883 | |||
| 3884 | Two arguments are taken. The first and required one is the link. | ||
| 3885 | The second is the text, which if not specified will will be the same | ||
| 3886 | the link. | ||
| 3887 | |||
| 3888 | $g->link( "http://foo.bar/whatever/", "whatever at foo.bar" ); | ||
| 3889 | |||
| 3890 | The template used is 'link' and by default it is as below. | ||
| 3891 | |||
| 3892 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 3893 | |||
| 3894 | The variables passed are as below. | ||
| 3895 | |||
| 3896 | url - This is the relative URL for this. | ||
| 3897 | text - This to use for with the link. | ||
| 3898 | toDir - This is the relative back to the directory. | ||
| 3899 | toFiles - This is the relative path to the '.files' directory. | ||
| 3900 | obj - The L<Toader::Entry> object. | ||
| 3901 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3902 | self - The L<Toader::Render::Entry> object. | ||
| 3903 | toader - This is a L<Toader> object. | ||
| 3904 | g - This is a L<Toader::Render::General> object. | ||
| 3905 | |||
| 3906 | =cut | ||
| 3907 | |||
| 3908 | sub link{ | ||
| 3909 | my $self=$_[0]; | ||
| 3910 | my $link=$_[1]; | ||
| 3911 | my $text=$_[2]; | ||
| 3912 | |||
| 3913 | #blank any previous errors | ||
| 3914 | if ( ! $self->errorblank ){ | ||
| 3915 | return undef; | ||
| 3916 | } | ||
| 3917 | |||
| 3918 | #make sure we have a link | ||
| 3919 | if ( ! defined( $link ) ){ | ||
| 3920 | $self->{error}=8; | ||
| 3921 | $self->{errorString}='No link defined'; | ||
| 3922 | $self->warn; | ||
| 3923 | return undef; | ||
| 3924 | } | ||
| 3925 | |||
| 3926 | #set the text to the same as the link if no text is defined | ||
| 3927 | if ( ! defined( $text ) ){ | ||
| 3928 | $text=$link; | ||
| 3929 | } | ||
| 3930 | |||
| 3931 | #render it | ||
| 3932 | my $rendered=$self->{t}->fill_in( | ||
| 3933 | 'link', | ||
| 3934 | { | ||
| 3935 | url=>$link, | ||
| 3936 | text=>$text, | ||
| 3937 | toDir=>$self->{toDir}, | ||
| 3938 | toFiles=>$self->{toFiles}, | ||
| 3939 | obj=>\$self->{obj}, | ||
| 3940 | self=>\$self, | ||
| 3941 | c=>\$self->{toader}->getConfig, | ||
| 3942 | toader=>\$self->{toader}, | ||
| 3943 | g=>\$self, | ||
| 3944 | } | ||
| 3945 | ); | ||
| 3946 | if ( $self->{t}->error ){ | ||
| 3947 | $self->{error}=10; | ||
| 3948 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 3949 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 3950 | $self->warn; | ||
| 3951 | return undef; | ||
| 3952 | } | ||
| 3953 | |||
| 3954 | return $rendered; | ||
| 3955 | } | ||
| 3956 | |||
| 3957 | =head2 listDirs | ||
| 3958 | |||
| 3959 | This builds the side bar list of directories. | ||
| 3960 | |||
| 3961 | No options are taken. | ||
| 3962 | |||
| 3963 | $g->listDirs; | ||
| 3964 | |||
| 3965 | This does not currently play nicely with any thing that will | ||
| 3966 | set fullURL. | ||
| 3967 | |||
| 3968 | =head3 Templates | ||
| 3969 | |||
| 3970 | =head4 dirListBegin | ||
| 3971 | |||
| 3972 | This begins the dirlist. | ||
| 3973 | |||
| 3974 | The template used is 'dirListBegin' and by default is blank. | ||
| 3975 | |||
| 3976 | The variables passed are as below. | ||
| 3977 | |||
| 3978 | toDir - This is the relative back to the directory. | ||
| 3979 | toFiles - This is the relative path to the '.files' directory. | ||
| 3980 | obj - The L<Toader::Entry> object. | ||
| 3981 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 3982 | self - The L<Toader::Render::Entry> object. | ||
| 3983 | toader - This is a L<Toader> object. | ||
| 3984 | g - This is a L<Toader::Render::General> object. | ||
| 3985 | |||
| 3986 | =head4 dirListJoin | ||
| 3987 | |||
| 3988 | This joins items in the directory list. | ||
| 3989 | |||
| 3990 | The default template is 'dirListJoin' and it is as below. | ||
| 3991 | |||
| 3992 | <br> | ||
| 3993 | |||
| 3994 | |||
| 3995 | The passed variables are as below. | ||
| 3996 | |||
| 3997 | toDir - This is the relative back to the directory. | ||
| 3998 | toFiles - This is the relative path to the '.files' directory. | ||
| 3999 | obj - The L<Toader::Entry> object. | ||
| 4000 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4001 | self - The L<Toader::Render::Entry> object. | ||
| 4002 | toader - This is a L<Toader> object. | ||
| 4003 | g - This is a L<Toader::Render::General> object. | ||
| 4004 | |||
| 4005 | =head4 dirListLink | ||
| 4006 | |||
| 4007 | This is a link for a directory in the directory list. | ||
| 4008 | |||
| 4009 | The template is 'dirListLink' and it is by default as below. | ||
| 4010 | |||
| 4011 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 4012 | |||
| 4013 | The passed variables are as below. | ||
| 4014 | |||
| 4015 | toDir - This is the relative back to the directory. | ||
| 4016 | toFiles - This is the relative path to the '.files' directory. | ||
| 4017 | obj - The L<Toader::Entry>> object. | ||
| 4018 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4019 | self - The L<Toader::Render::Entry> object. | ||
| 4020 | toader - This is a L<Toader> object. | ||
| 4021 | g - This is a L<Toader::Render::General> object. | ||
| 4022 | |||
| 4023 | =head4 dirListEnd | ||
| 4024 | |||
| 4025 | This ends the directory list. | ||
| 4026 | |||
| 4027 | The template used is 'dirListEnd' and the default is as below. | ||
| 4028 | |||
| 4029 | <br> | ||
| 4030 | |||
| 4031 | |||
| 4032 | The passed variables are as below. | ||
| 4033 | |||
| 4034 | toDir - This is the relative back to the directory. | ||
| 4035 | toFiles - This is the relative path to the '.files' directory. | ||
| 4036 | obj - The L<Toader::Entry> object. | ||
| 4037 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4038 | self - The L<Toader::Render::Entry> object. | ||
| 4039 | toader - This is a L<Toader> object. | ||
| 4040 | g - This is a L<Toader::Render::General> object. | ||
| 4041 | |||
| 4042 | =cut | ||
| 4043 | |||
| 4044 | sub listDirs{ | ||
| 4045 | my $self=$_[0]; | ||
| 4046 | |||
| 4047 | #blank any previous errors | ||
| 4048 | if ( ! $self->errorblank ){ | ||
| 4049 | return undef; | ||
| 4050 | } | ||
| 4051 | |||
| 4052 | #renders the joiner | ||
| 4053 | my $joiner=$self->{t}->fill_in( | ||
| 4054 | 'dirListJoin', | ||
| 4055 | { | ||
| 4056 | toDir=>$self->{toDir}, | ||
| 4057 | toFiles=>$self->{toFiles}, | ||
| 4058 | obj=>\$self->{obj}, | ||
| 4059 | c=>\$self->{toader}->getConfig, | ||
| 4060 | toader=>\$self->{toader}, | ||
| 4061 | self=>\$self, | ||
| 4062 | g=>\$self, | ||
| 4063 | } | ||
| 4064 | ); | ||
| 4065 | if ( $self->{t}->error ){ | ||
| 4066 | $self->{error}=10; | ||
| 4067 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4068 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4069 | $self->warn; | ||
| 4070 | return undef; | ||
| 4071 | } | ||
| 4072 | |||
| 4073 | #renders the beginning of the dir list | ||
| 4074 | my $begin=$self->{t}->fill_in( | ||
| 4075 | 'dirListBegin', | ||
| 4076 | { | ||
| 4077 | toDir=>$self->{toDir}, | ||
| 4078 | toFiles=>$self->{toFiles}, | ||
| 4079 | obj=>\$self->{obj}, | ||
| 4080 | c=>\$self->{toader}->getConfig, | ||
| 4081 | toader=>\$self->{toader}, | ||
| 4082 | self=>\$self, | ||
| 4083 | g=>\$self, | ||
| 4084 | } | ||
| 4085 | ); | ||
| 4086 | if ( $self->{t}->error ){ | ||
| 4087 | $self->{error}=10; | ||
| 4088 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4089 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4090 | $self->warn; | ||
| 4091 | return undef; | ||
| 4092 | } | ||
| 4093 | |||
| 4094 | #renders the end of the dir list | ||
| 4095 | my $end=$self->{t}->fill_in( | ||
| 4096 | 'dirListEnd', | ||
| 4097 | { | ||
| 4098 | toDir=>$self->{toDir}, | ||
| 4099 | toFiles=>$self->{toFiles}, | ||
| 4100 | obj=>\$self->{obj}, | ||
| 4101 | c=>\$self->{toader}->getConfig, | ||
| 4102 | toader=>\$self->{toader}, | ||
| 4103 | self=>\$self, | ||
| 4104 | g=>\$self, | ||
| 4105 | } | ||
| 4106 | ); | ||
| 4107 | if ( $self->{t}->error ){ | ||
| 4108 | $self->{error}=10; | ||
| 4109 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4110 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4111 | $self->warn; | ||
| 4112 | return undef; | ||
| 4113 | } | ||
| 4114 | |||
| 4115 | #gets a list of directories | ||
| 4116 | my @dirs; | ||
| 4117 | if ( ref( $self->{odir} ) eq 'Toader::Directory' ){ | ||
| 4118 | @dirs=$self->{odir}->listSubToaderDirs; | ||
| 4119 | if ( $self->{odir}->error ){ | ||
| 4120 | $self->{error}=22; | ||
| 4121 | $self->{errorString}='Failed to get a list of Toader sub directories. error="' | ||
| 4122 | .$self->{odir}->error.'" errorString="'.$self->{odir}->errorString.'"'; | ||
| 4123 | return undef; | ||
| 4124 | } | ||
| 4125 | }else{ | ||
| 4126 | my $dobj=Toader::Directory->new( $self->{toader} ); | ||
| 4127 | $dobj->dirSet( $self->{odir} ); | ||
| 4128 | @dirs=$dobj->listSubToaderDirs; | ||
| 4129 | if ( $dobj->error ){ | ||
| 4130 | $self->{error}=22; | ||
| 4131 | $self->{errorString}='Failed to get a list of Toader sub directories. error="' | ||
| 4132 | .$dobj->error.'" errorString="'.$dobj->{odir}->errorString.'"'; | ||
| 4133 | return undef; | ||
| 4134 | } | ||
| 4135 | } | ||
| 4136 | @dirs=sort(@dirs); | ||
| 4137 | |||
| 4138 | #return black here if there is nothing | ||
| 4139 | if ( ! defined( $dirs[0] ) ){ | ||
| 4140 | return ''; | ||
| 4141 | } | ||
| 4142 | |||
| 4143 | #will hold it all prior to joining | ||
| 4144 | my @tojoin; | ||
| 4145 | |||
| 4146 | #process it all | ||
| 4147 | my $int=0; | ||
| 4148 | while ( defined( $dirs[$int] ) ){ | ||
| 4149 | #add the toDir to it | ||
| 4150 | my $dir=$self->{toDir}.$dirs[$int]; | ||
| 4151 | $dir=~s/\/\/*/\//g; | ||
| 4152 | |||
| 4153 | #render it | ||
| 4154 | my $rendered=$self->{t}->fill_in( | ||
| 4155 | 'dirListLink', | ||
| 4156 | { | ||
| 4157 | url=>$dir, | ||
| 4158 | text=>$dirs[$int], | ||
| 4159 | toDir=>$self->{toDir}, | ||
| 4160 | toFiles=>$self->{toFiles}, | ||
| 4161 | obj=>\$self->{obj}, | ||
| 4162 | c=>\$self->{toader}->getConfig, | ||
| 4163 | self=>\$self, | ||
| 4164 | toader=>\$self->{toader}, | ||
| 4165 | g=>\$self, | ||
| 4166 | } | ||
| 4167 | ); | ||
| 4168 | if ( $self->{t}->error ){ | ||
| 4169 | $self->{error}=10; | ||
| 4170 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4171 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4172 | $self->warn; | ||
| 4173 | return undef; | ||
| 4174 | } | ||
| 4175 | |||
| 4176 | push( @tojoin, $rendered ); | ||
| 4177 | |||
| 4178 | $int++; | ||
| 4179 | } | ||
| 4180 | |||
| 4181 | return $begin.join( $joiner, @tojoin ).$end; | ||
| 4182 | } | ||
| 4183 | |||
| 4184 | =head2 listPages | ||
| 4185 | |||
| 4186 | This returns returns a list of pages. | ||
| 4187 | |||
| 4188 | No options are taken. | ||
| 4189 | |||
| 4190 | $g->listPages; | ||
| 4191 | |||
| 4192 | =head3 Templates | ||
| 4193 | |||
| 4194 | =head4 pageListBegin | ||
| 4195 | |||
| 4196 | This begins the page list. | ||
| 4197 | |||
| 4198 | The template is 'pageListBegin' and is blank. | ||
| 4199 | |||
| 4200 | The variables passed are as below. | ||
| 4201 | |||
| 4202 | toDir - This is the relative back to the directory. | ||
| 4203 | toFiles - This is the relative path to the '.files' directory. | ||
| 4204 | obj - The L<Toader::Entry> object. | ||
| 4205 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4206 | self - The L<Toader::Render::Entry> object. | ||
| 4207 | toader - This is a L<Toader> object. | ||
| 4208 | g - This is a L<Toader::Render::General> object. | ||
| 4209 | |||
| 4210 | =head4 pageListJoin | ||
| 4211 | |||
| 4212 | This joins the items in the page list. | ||
| 4213 | |||
| 4214 | The template is 'pageListJoin' and is blank. | ||
| 4215 | |||
| 4216 | <br> | ||
| 4217 | |||
| 4218 | |||
| 4219 | The variables passed are as below. | ||
| 4220 | |||
| 4221 | toDir - This is the relative back to the directory. | ||
| 4222 | toFiles - This is the relative path to the '.files' directory. | ||
| 4223 | obj - The L<Toader::Entry> object. | ||
| 4224 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4225 | self - The L<Toader::Render::Entry> object. | ||
| 4226 | toader - This is a L<Toader> object. | ||
| 4227 | g - This is a L<Toader::Render::General> object. | ||
| 4228 | |||
| 4229 | =head4 pageListLink | ||
| 4230 | |||
| 4231 | This is a link to a page | ||
| 4232 | |||
| 4233 | The template is 'pageListLink' and is blank. | ||
| 4234 | |||
| 4235 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 4236 | |||
| 4237 | The variables passed are as below. | ||
| 4238 | |||
| 4239 | toDir - This is the relative back to the directory. | ||
| 4240 | toFiles - This is the relative path to the '.files' directory. | ||
| 4241 | obj - The L<Toader::Entry> object. | ||
| 4242 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4243 | self - The L<Toader::Render::Entry> object. | ||
| 4244 | toader - This is a L<Toader> object. | ||
| 4245 | g - This is a L<Toader::Render::General> object. | ||
| 4246 | |||
| 4247 | =head4 pageListEnd | ||
| 4248 | |||
| 4249 | This joins the items in the page list. | ||
| 4250 | |||
| 4251 | The template is 'pageListJoin' and is blank. | ||
| 4252 | |||
| 4253 | <br> | ||
| 4254 | |||
| 4255 | |||
| 4256 | The variables passed are as below. | ||
| 4257 | |||
| 4258 | toDir - This is the relative back to the directory. | ||
| 4259 | toFiles - This is the relative path to the '.files' directory. | ||
| 4260 | obj - The L<Toader::Entry> object. | ||
| 4261 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4262 | self - The L<Toader::Render::Entry> object. | ||
| 4263 | toader - This is a L<Toader> object. | ||
| 4264 | g - This is a L<Toader::Render::General> object. | ||
| 4265 | |||
| 4266 | =cut | ||
| 4267 | |||
| 4268 | sub listPages{ | ||
| 4269 | my $self=$_[0]; | ||
| 4270 | |||
| 4271 | #blank any previous errors | ||
| 4272 | if ( ! $self->errorblank ){ | ||
| 4273 | return undef; | ||
| 4274 | } | ||
| 4275 | |||
| 4276 | #renders the begin | ||
| 4277 | my $begin=$self->{t}->fill_in( | ||
| 4278 | 'pageListBegin', | ||
| 4279 | { | ||
| 4280 | toDir=>$self->{toDir}, | ||
| 4281 | toFiles=>$self->{toFiles}, | ||
| 4282 | obj=>\$self->{obj}, | ||
| 4283 | c=>\$self->{toader}->getConfig, | ||
| 4284 | toader=>\$self->{toader}, | ||
| 4285 | self=>\$self, | ||
| 4286 | g=>\$self, | ||
| 4287 | } | ||
| 4288 | ); | ||
| 4289 | if ( $self->{t}->error ){ | ||
| 4290 | $self->{error}=10; | ||
| 4291 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4292 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4293 | $self->warn; | ||
| 4294 | return undef; | ||
| 4295 | } | ||
| 4296 | |||
| 4297 | #renders the joiner | ||
| 4298 | my $joiner=$self->{t}->fill_in( | ||
| 4299 | 'pageListJoin', | ||
| 4300 | { | ||
| 4301 | toDir=>$self->{toDir}, | ||
| 4302 | toFiles=>$self->{toFiles}, | ||
| 4303 | obj=>\$self->{obj}, | ||
| 4304 | c=>\$self->{toader}->getConfig, | ||
| 4305 | toader=>\$self->{toader}, | ||
| 4306 | self=>\$self, | ||
| 4307 | g=>\$self, | ||
| 4308 | } | ||
| 4309 | ); | ||
| 4310 | if ( $self->{t}->error ){ | ||
| 4311 | $self->{error}=10; | ||
| 4312 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4313 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4314 | $self->warn; | ||
| 4315 | return undef; | ||
| 4316 | } | ||
| 4317 | |||
| 4318 | #renders the end of the dir list | ||
| 4319 | my $end=$self->{t}->fill_in( | ||
| 4320 | 'pageListEnd', | ||
| 4321 | { | ||
| 4322 | toDir=>$self->{toDir}, | ||
| 4323 | toFiles=>$self->{toFiles}, | ||
| 4324 | obj=>\$self->{obj}, | ||
| 4325 | c=>\$self->{toader}->getConfig, | ||
| 4326 | toader=>\$self->{toader}, | ||
| 4327 | self=>\$self, | ||
| 4328 | g=>\$self, | ||
| 4329 | } | ||
| 4330 | ); | ||
| 4331 | if ( $self->{t}->error ){ | ||
| 4332 | $self->{error}=10; | ||
| 4333 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4334 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4335 | $self->warn; | ||
| 4336 | return undef; | ||
| 4337 | } | ||
| 4338 | |||
| 4339 | #gets a list of pages | ||
| 4340 | my $pm=Toader::Page::Manage->new( $self->{toader} ); | ||
| 4341 | $pm->setDir( $self->{odir} ); | ||
| 4342 | if ( $pm->error ){ | ||
| 4343 | $self->{error}=23; | ||
| 4344 | $self->{errorString}='Failed to set the directory for Toader::Page::Manage. '. | ||
| 4345 | 'error="'.$pm->error.'" errorString="'.$pm->errorString.'"'; | ||
| 4346 | $self->warn; | ||
| 4347 | return undef; | ||
| 4348 | } | ||
| 4349 | my @pages=$pm->list; | ||
| 4350 | if ( $pm->error ){ | ||
| 4351 | $self->{error}=24; | ||
| 4352 | $self->{errorString}='Failed to get a list of pages. error="' | ||
| 4353 | .$pm->error.'" errorString="'.$pm->errorString.'"'; | ||
| 4354 | $self->warn; | ||
| 4355 | return undef; | ||
| 4356 | } | ||
| 4357 | |||
| 4358 | #return blank if there pages | ||
| 4359 | if ( ! defined( $pages[0] ) ){ | ||
| 4360 | return ''; | ||
| 4361 | } | ||
| 4362 | |||
| 4363 | #puts it together | ||
| 4364 | my $int=0; | ||
| 4365 | my @tojoin; | ||
| 4366 | while ( $pages[$int] ){ | ||
| 4367 | #add the toDir to it | ||
| 4368 | my $dir=$self->{toDir}.'/.pages/'.$pages[$int].'/'; | ||
| 4369 | $dir=~s/\/\/*/\//g; | ||
| 4370 | |||
| 4371 | #render it | ||
| 4372 | my $rendered=$self->{t}->fill_in( | ||
| 4373 | 'pageListLink', | ||
| 4374 | { | ||
| 4375 | url=>$dir, | ||
| 4376 | text=>$pages[$int], | ||
| 4377 | toDir=>$self->{toDir}, | ||
| 4378 | toFiles=>$self->{toFiles}, | ||
| 4379 | obj=>\$self->{obj}, | ||
| 4380 | c=>\$self->{toader}->getConfig, | ||
| 4381 | self=>\$self, | ||
| 4382 | toader=>\$self->{toader}, | ||
| 4383 | g=>\$self, | ||
| 4384 | } | ||
| 4385 | ); | ||
| 4386 | if ( $self->{t}->error ){ | ||
| 4387 | $self->{error}=10; | ||
| 4388 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4389 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4390 | $self->warn; | ||
| 4391 | return undef; | ||
| 4392 | } | ||
| 4393 | |||
| 4394 | push( @tojoin, $rendered ); | ||
| 4395 | |||
| 4396 | $int++; | ||
| 4397 | } | ||
| 4398 | |||
| 4399 | return $begin.join( $joiner, @tojoin ).$end; | ||
| 4400 | } | ||
| 4401 | |||
| 4402 | =head2 locationbar | ||
| 4403 | |||
| 4404 | This puts together the the location bar. | ||
| 4405 | |||
| 4406 | One argument is taken and that is what to use for the lcation ID. | ||
| 4407 | |||
| 4408 | $g->locationbar( $locationID ); | ||
| 4409 | |||
| 4410 | =head3 Templates | ||
| 4411 | |||
| 4412 | =head4 locationStart | ||
| 4413 | |||
| 4414 | This starts the location bar. | ||
| 4415 | |||
| 4416 | The template used is 'locationStart' and the default is as below. | ||
| 4417 | |||
| 4418 | <h2>Location: | ||
| 4419 | |||
| 4420 | The variabled passed are as below. | ||
| 4421 | |||
| 4422 | toDir - This is the relative back to the directory. | ||
| 4423 | toFiles - This is the relative path to the '.files' directory. | ||
| 4424 | obj - The L<Toader::Entry> object. | ||
| 4425 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4426 | self - The L<Toader::Render::Entry> object. | ||
| 4427 | toader - This is a L<Toader> object. | ||
| 4428 | g - This is a L<Toader::Render::General> object. | ||
| 4429 | |||
| 4430 | =head4 locationPart | ||
| 4431 | |||
| 4432 | This is a part of the path in the location bar. | ||
| 4433 | |||
| 4434 | The template used is 'locationPart' and the default is as below. | ||
| 4435 | |||
| 4436 | <a href="[== $url ==]">[== $text ==]</a> / | ||
| 4437 | |||
| 4438 | The variables passed are as below. | ||
| 4439 | |||
| 4440 | url - This is the relative URL for this. | ||
| 4441 | text - This to use for with the link. | ||
| 4442 | toDir - This is the relative back to the directory. | ||
| 4443 | toFiles - This is the relative path to the '.files' directory. | ||
| 4444 | obj - The L<Toader::Entry> object. | ||
| 4445 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4446 | self - The L<Toader::Render::Entry> object. | ||
| 4447 | toader - This is a L<Toader> object. | ||
| 4448 | g - This is a L<Toader::Render::General> object. | ||
| 4449 | |||
| 4450 | =head4 locationEnd | ||
| 4451 | |||
| 4452 | This is the end of the location bar. | ||
| 4453 | |||
| 4454 | The template used is 'locationEnd' and the default is as below. | ||
| 4455 | |||
| 4456 | [== $locationID ==]</h2> | ||
| 4457 | |||
| 4458 | |||
| 4459 | The variables passed are as below. | ||
| 4460 | |||
| 4461 | url - This is the relative URL for this. | ||
| 4462 | text - This to use for with the link. | ||
| 4463 | toDir - This is the relative back to the directory. | ||
| 4464 | toFiles - This is the relative path to the '.files' directory. | ||
| 4465 | obj - The L<Toader::Entry> object. | ||
| 4466 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4467 | self - The L<Toader::Render::Entry> object. | ||
| 4468 | toader - This is a L<Toader> object. | ||
| 4469 | g - This is a L<Toader::Render::General> object. | ||
| 4470 | locationID - The string to use for the end location bar. | ||
| 4471 | |||
| 4472 | =cut | ||
| 4473 | |||
| 4474 | sub locationbar{ | ||
| 4475 | my $self=$_[0]; | ||
| 4476 | my $locationID=$_[1]; | ||
| 4477 | |||
| 4478 | #blank any previous errors | ||
| 4479 | if ( ! $self->errorblank ){ | ||
| 4480 | return undef; | ||
| 4481 | } | ||
| 4482 | |||
| 4483 | my @parts=split( /\//, $self->{r2r} ); | ||
| 4484 | |||
| 4485 | #render it | ||
| 4486 | my $rendered=$self->{t}->fill_in( | ||
| 4487 | 'locationStart', | ||
| 4488 | { | ||
| 4489 | toDir=>$self->{toDir}, | ||
| 4490 | toFiles=>$self->{toFiles}, | ||
| 4491 | obj=>\$self->{obj}, | ||
| 4492 | self=>\$self, | ||
| 4493 | c=>\$self->{toader}->getConfig, | ||
| 4494 | g=>\$self, | ||
| 4495 | } | ||
| 4496 | ); | ||
| 4497 | if ( $self->{t}->error ){ | ||
| 4498 | $self->{error}=10; | ||
| 4499 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4500 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4501 | $self->warn; | ||
| 4502 | return undef; | ||
| 4503 | } | ||
| 4504 | |||
| 4505 | #creates the url and cleans it up | ||
| 4506 | my $url=$self->{b2r}; | ||
| 4507 | $url=~s/\/\/*/\//g; | ||
| 4508 | |||
| 4509 | if ( $self->{fullURL} ){ | ||
| 4510 | $url=$self->{url}; | ||
| 4511 | } | ||
| 4512 | |||
| 4513 | #does the initial link to the root directory | ||
| 4514 | $rendered=$rendered.$self->{t}->fill_in( | ||
| 4515 | 'locationPart', | ||
| 4516 | { | ||
| 4517 | url=>$url, | ||
| 4518 | text=>'root', | ||
| 4519 | toDir=>$self->{toDir}, | ||
| 4520 | toFiles=>$self->{toFiles}, | ||
| 4521 | obj=>\$self->{obj}, | ||
| 4522 | c=>\$self->{toader}->getConfig, | ||
| 4523 | self=>\$self, | ||
| 4524 | toader=>\$self->{toader}, | ||
| 4525 | g=>\$self, | ||
| 4526 | } | ||
| 4527 | ); | ||
| 4528 | if ( $self->{t}->error ){ | ||
| 4529 | $self->{error}=10; | ||
| 4530 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4531 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4532 | $self->warn; | ||
| 4533 | return undef; | ||
| 4534 | } | ||
| 4535 | |||
| 4536 | #processes each item | ||
| 4537 | my $int=0; | ||
| 4538 | my $dir=$self->{b2r}.'/'; | ||
| 4539 | while ( defined( $parts[$int] ) ){ | ||
| 4540 | |||
| 4541 | if ( $parts[$int] ne '.' ){ | ||
| 4542 | $dir=$dir.$parts[$int].'/'; | ||
| 4543 | $dir=~s/\/\/*/\//g; | ||
| 4544 | $rendered=$rendered.$self->{t}->fill_in( | ||
| 4545 | 'locationPart', | ||
| 4546 | { | ||
| 4547 | url=>$dir, | ||
| 4548 | text=>$parts[$int], | ||
| 4549 | toDir=>$self->{toDir}, | ||
| 4550 | toFiles=>$self->{toFiles}, | ||
| 4551 | obj=>\$self->{obj}, | ||
| 4552 | c=>\$self->{toader}->getConfig, | ||
| 4553 | self=>\$self, | ||
| 4554 | toader=>\$self->{toader}, | ||
| 4555 | g=>\$self, | ||
| 4556 | } | ||
| 4557 | ); | ||
| 4558 | if ( $self->{t}->error ){ | ||
| 4559 | $self->{error}=10; | ||
| 4560 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4561 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4562 | $self->warn; | ||
| 4563 | return undef; | ||
| 4564 | } | ||
| 4565 | } | ||
| 4566 | |||
| 4567 | $int++; | ||
| 4568 | } | ||
| 4569 | |||
| 4570 | #gets the location ID | ||
| 4571 | if( ! defined( $locationID ) ){ | ||
| 4572 | $locationID=$self->{obj}->locationID; | ||
| 4573 | } | ||
| 4574 | |||
| 4575 | |||
| 4576 | $rendered=$rendered.$self->{t}->fill_in( | ||
| 4577 | 'locationEnd', | ||
| 4578 | { | ||
| 4579 | toDir=>$self->{toDir}, | ||
| 4580 | toFiles=>$self->{toFiles}, | ||
| 4581 | obj=>\$self->{obj}, | ||
| 4582 | locationID=>$locationID, | ||
| 4583 | c=>\$self->{toader}->getConfig, | ||
| 4584 | self=>\$self, | ||
| 4585 | toader=>\$self->{toader}, | ||
| 4586 | g=>\$self, | ||
| 4587 | } | ||
| 4588 | ); | ||
| 4589 | if ( $self->{t}->error ){ | ||
| 4590 | $self->{error}=10; | ||
| 4591 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4592 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4593 | $self->warn; | ||
| 4594 | return undef; | ||
| 4595 | } | ||
| 4596 | |||
| 4597 | return $rendered; | ||
| 4598 | } | ||
| 4599 | |||
| 4600 | =head2 locationSubSet | ||
| 4601 | |||
| 4602 | This returns what ever has been set for the location sub via | ||
| 4603 | L<Toader::Render::General>->locationSubSet. | ||
| 4604 | |||
| 4605 | [== $g->locationSub ==] | ||
| 4606 | |||
| 4607 | =cut | ||
| 4608 | |||
| 4609 | sub locationSub{ | ||
| 4610 | my $self=$_[0]; | ||
| 4611 | |||
| 4612 | #blank any previous errors | ||
| 4613 | if ( ! $self->errorblank ){ | ||
| 4614 | return undef; | ||
| 4615 | } | ||
| 4616 | |||
| 4617 | return $self->{locationSub}; | ||
| 4618 | } | ||
| 4619 | |||
| 4620 | =head2 locationSub | ||
| 4621 | |||
| 4622 | This sets the location sub. | ||
| 4623 | |||
| 4624 | One argument is taken and that is what to set it to. | ||
| 4625 | |||
| 4626 | If not defined, '' is used. | ||
| 4627 | |||
| 4628 | [== $g->locationSubSet( $whatever ) ==] | ||
| 4629 | |||
| 4630 | =cut | ||
| 4631 | |||
| 4632 | sub locationSubSet{ | ||
| 4633 | my $self=$_[0]; | ||
| 4634 | my $locationSub=$_[1]; | ||
| 4635 | |||
| 4636 | #blank any previous errors | ||
| 4637 | if ( ! $self->errorblank ){ | ||
| 4638 | return undef; | ||
| 4639 | } | ||
| 4640 | |||
| 4641 | if ( ! defined( $locationSub ) ){ | ||
| 4642 | $locationSub=''; | ||
| 4643 | } | ||
| 4644 | |||
| 4645 | $self->{locationSub}=$locationSub; | ||
| 4646 | |||
| 4647 | return 1; | ||
| 4648 | } | ||
| 4649 | |||
| 4650 | =head2 or2r | ||
| 4651 | |||
| 4652 | This returns the current value to from the root directory | ||
| 4653 | to directory for the object that initialized this instance | ||
| 4654 | of L<Toader::Render::General>. | ||
| 4655 | |||
| 4656 | my $or2r=$g->or2r; | ||
| 4657 | |||
| 4658 | =cut | ||
| 4659 | |||
| 4660 | sub or2r{ | ||
| 4661 | my $self=$_[0]; | ||
| 4662 | |||
| 4663 | #blank any previous errors | ||
| 4664 | if ( ! $self->errorblank ){ | ||
| 4665 | return undef; | ||
| 4666 | } | ||
| 4667 | |||
| 4668 | return $self->{or2r}; | ||
| 4669 | } | ||
| 4670 | |||
| 4671 | =head2 pageSummary | ||
| 4672 | |||
| 4673 | This creates a summary of the pages in the current directory. | ||
| 4674 | |||
| 4675 | No arguments are taken. | ||
| 4676 | |||
| 4677 | $g->pageSummary; | ||
| 4678 | |||
| 4679 | =head3 Templates | ||
| 4680 | |||
| 4681 | =head4 pageSummaryBegin | ||
| 4682 | |||
| 4683 | The begins the summary of the pages. | ||
| 4684 | |||
| 4685 | The template used is 'pageSummaryBegin' and the default is as below. | ||
| 4686 | |||
| 4687 | <table id="pageSummary"> | ||
| 4688 | <tr> <td>Name</td> <td>Summary</td> </tr> | ||
| 4689 | |||
| 4690 | |||
| 4691 | The variabled passed are as below. | ||
| 4692 | |||
| 4693 | toDir - This is the relative back to the directory. | ||
| 4694 | toFiles - This is the relative path to the '.files' directory. | ||
| 4695 | obj - The Toader::Entry object. | ||
| 4696 | c - The Config::Tiny object containing the Toader config. | ||
| 4697 | self - The Toader::Render::Entry object. | ||
| 4698 | toader - This is a Toader object. | ||
| 4699 | g - This is a Toader::Render::General object. | ||
| 4700 | |||
| 4701 | =head4 pageSummaryJoin | ||
| 4702 | |||
| 4703 | This joins the rows. | ||
| 4704 | |||
| 4705 | The template used is 'pageSummaryJoin' and by default is blank. | ||
| 4706 | |||
| 4707 | The variabled passed are as below. | ||
| 4708 | |||
| 4709 | toDir - This is the relative back to the directory. | ||
| 4710 | toFiles - This is the relative path to the '.files' directory. | ||
| 4711 | obj - The L<Toader::Entry> object. | ||
| 4712 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4713 | self - The L<Toader::Render::Entry> object. | ||
| 4714 | toader - This is a L<Toader> object. | ||
| 4715 | g - This is a L<Toader::Render::General> object. | ||
| 4716 | |||
| 4717 | =head4 pageSummarySummary | ||
| 4718 | |||
| 4719 | This is a row in the table of pages. | ||
| 4720 | |||
| 4721 | The template used is 'pageSummarySummary' and by default is as below. | ||
| 4722 | |||
| 4723 | <tr id="pageSummary"> | ||
| 4724 | <td id="pageSummary"><a href="./[== $name ==]/">[== $name ==]</a></td> | ||
| 4725 | <td id="pageSummary">[== $summary ==]</td> | ||
| 4726 | </tr> | ||
| 4727 | |||
| 4728 | The variabled passed are as below. | ||
| 4729 | |||
| 4730 | toDir - This is the relative back to the directory. | ||
| 4731 | toFiles - This is the relative path to the '.files' directory. | ||
| 4732 | obj - The L<Toader::Entry> object. | ||
| 4733 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4734 | self - The L<Toader::Render::Entry> object. | ||
| 4735 | toader - This is a L<Toader> object. | ||
| 4736 | g - This is a L<Toader::Render::General> object. | ||
| 4737 | name - This is the name of the page. | ||
| 4738 | summary - This is a summary of the page. | ||
| 4739 | |||
| 4740 | =cut | ||
| 4741 | |||
| 4742 | sub pageSummary{ | ||
| 4743 | my $self=$_[0]; | ||
| 4744 | |||
| 4745 | #blank any previous errors | ||
| 4746 | if ( ! $self->errorblank ){ | ||
| 4747 | return undef; | ||
| 4748 | } | ||
| 4749 | |||
| 4750 | my $pm=Toader::Page::Manage->new( $self->{toader} ); | ||
| 4751 | $pm->setDir( $self->{odir} ); | ||
| 4752 | if ( $pm->error ){ | ||
| 4753 | $self->{error}=31; | ||
| 4754 | $self->{errorString}='Failed to set the directory, "'.$self->{odir}. | ||
| 4755 | '", for Toader::Page::Manage. error="'.$pm->error | ||
| 4756 | .'" errorString="'.$pm->errorString.'"'; | ||
| 4757 | $self->warn; | ||
| 4758 | return undef; | ||
| 4759 | } | ||
| 4760 | |||
| 4761 | #lists the entries for the directory | ||
| 4762 | my @pages=$pm->published; | ||
| 4763 | if ( $pm->error ){ | ||
| 4764 | $self->{error}=32; | ||
| 4765 | $self->{errorString}='Failed to list the pages for "'.$self->{odir}. | ||
| 4766 | '". error="'.$pm->error.'" errorString="'.$pm->errorString.'"'; | ||
| 4767 | $self->warn; | ||
| 4768 | return undef; | ||
| 4769 | } | ||
| 4770 | |||
| 4771 | #return '' if there are none | ||
| 4772 | if ( ! defined( $pages[0] ) ){ | ||
| 4773 | return ''; | ||
| 4774 | } | ||
| 4775 | |||
| 4776 | #sort and order from last to first | ||
| 4777 | @pages=sort(@pages); | ||
| 4778 | @pages=reverse(@pages); | ||
| 4779 | |||
| 4780 | #process each one | ||
| 4781 | my @tojoin; | ||
| 4782 | my $int=0; | ||
| 4783 | while ( defined( $pages[$int] ) ){ | ||
| 4784 | my $entry=$pm->read( $pages[$int] ); | ||
| 4785 | if ( $pm->error ){ | ||
| 4786 | $self->{error}=33; | ||
| 4787 | $self->{errorString}='Failed to read "'.$pages[$int].'" in "' | ||
| 4788 | .$self->{odir}.'". error="'.$pm->error.'" errorstring="' | ||
| 4789 | .$pm->errorString.'"'; | ||
| 4790 | $self->warn; | ||
| 4791 | return undef; | ||
| 4792 | } | ||
| 4793 | |||
| 4794 | #renders the row | ||
| 4795 | my $rendered=$self->{t}->fill_in( | ||
| 4796 | 'pageSummaryRow', | ||
| 4797 | { | ||
| 4798 | toDir=>$self->{toDir}, | ||
| 4799 | toFiles=>$self->{toFiles}, | ||
| 4800 | obj=>\$self->{obj}, | ||
| 4801 | c=>\$self->{toader}->getConfig, | ||
| 4802 | toader=>\$self->{toader}, | ||
| 4803 | self=>\$self, | ||
| 4804 | name=>$entry->nameGet, | ||
| 4805 | summary=>$entry->summaryGet, | ||
| 4806 | g=>\$self, | ||
| 4807 | } | ||
| 4808 | ); | ||
| 4809 | if ( $self->{t}->error ){ | ||
| 4810 | $self->{error}=10; | ||
| 4811 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4812 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4813 | $self->warn; | ||
| 4814 | return undef; | ||
| 4815 | } | ||
| 4816 | |||
| 4817 | push( @tojoin, $rendered ); | ||
| 4818 | |||
| 4819 | $int++; | ||
| 4820 | } | ||
| 4821 | |||
| 4822 | #renders the joiner | ||
| 4823 | my $joiner=$self->{t}->fill_in( | ||
| 4824 | 'pageSummaryJoin', | ||
| 4825 | { | ||
| 4826 | toDir=>$self->{toDir}, | ||
| 4827 | toFiles=>$self->{toFiles}, | ||
| 4828 | obj=>\$self->{obj}, | ||
| 4829 | c=>\$self->{toader}->getConfig, | ||
| 4830 | toader=>\$self->{toader}, | ||
| 4831 | self=>\$self, | ||
| 4832 | g=>\$self, | ||
| 4833 | } | ||
| 4834 | ); | ||
| 4835 | if ( $self->{t}->error ){ | ||
| 4836 | $self->{error}=10; | ||
| 4837 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4838 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4839 | $self->warn; | ||
| 4840 | return undef; | ||
| 4841 | } | ||
| 4842 | |||
| 4843 | #renders the end of the dir list | ||
| 4844 | my $end=$self->{t}->fill_in( | ||
| 4845 | 'pageSummaryEnd', | ||
| 4846 | { | ||
| 4847 | toDir=>$self->{toDir}, | ||
| 4848 | toFiles=>$self->{toFiles}, | ||
| 4849 | obj=>\$self->{obj}, | ||
| 4850 | c=>\$self->{toader}->getConfig, | ||
| 4851 | toader=>\$self->{toader}, | ||
| 4852 | self=>\$self, | ||
| 4853 | g=>\$self, | ||
| 4854 | } | ||
| 4855 | ); | ||
| 4856 | if ( $self->{t}->error ){ | ||
| 4857 | $self->{error}=10; | ||
| 4858 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4859 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4860 | $self->warn; | ||
| 4861 | return undef; | ||
| 4862 | } | ||
| 4863 | |||
| 4864 | #renders the end of the dir list | ||
| 4865 | my $begin=$self->{t}->fill_in( | ||
| 4866 | 'pageSummaryBegin', | ||
| 4867 | { | ||
| 4868 | toDir=>$self->{toDir}, | ||
| 4869 | toFiles=>$self->{toFiles}, | ||
| 4870 | obj=>\$self->{obj}, | ||
| 4871 | c=>\$self->{toader}->getConfig, | ||
| 4872 | toader=>\$self->{toader}, | ||
| 4873 | self=>\$self, | ||
| 4874 | g=>\$self, | ||
| 4875 | } | ||
| 4876 | ); | ||
| 4877 | if ( $self->{t}->error ){ | ||
| 4878 | $self->{error}=10; | ||
| 4879 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4880 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4881 | $self->warn; | ||
| 4882 | return undef; | ||
| 4883 | } | ||
| 4884 | |||
| 4885 | return $begin.join( $joiner, @tojoin ).$end; | ||
| 4886 | } | ||
| 4887 | |||
| 4888 | =head2 pageSummaryLink | ||
| 4889 | |||
| 4890 | This is a link to summary of the pages for directory of the object. | ||
| 4891 | |||
| 4892 | On argument is accepted and that is the text to use for the link. If | ||
| 4893 | not specified, it defaults to 'Pages'. | ||
| 4894 | |||
| 4895 | $g->pageSummaryLink; | ||
| 4896 | |||
| 4897 | The template used is 'pageSummaryLink' and the default is as below. | ||
| 4898 | |||
| 4899 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 4900 | |||
| 4901 | The variables passed are as below. | ||
| 4902 | |||
| 4903 | url - This is the relative URL for this. | ||
| 4904 | text - This to use for with the link. | ||
| 4905 | toDir - This is the relative back to the directory. | ||
| 4906 | toFiles - This is the relative path to the '.files' directory. | ||
| 4907 | obj - The L<Toader::Entry> object. | ||
| 4908 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4909 | self - The L<Toader::Render::Entry> object. | ||
| 4910 | toader - This is a L<Toader> object. | ||
| 4911 | g - This is a L<Toader::Render::General> object. | ||
| 4912 | |||
| 4913 | =cut | ||
| 4914 | |||
| 4915 | sub pageSummaryLink{ | ||
| 4916 | my $self=$_[0]; | ||
| 4917 | my $text=$_[1]; | ||
| 4918 | |||
| 4919 | if ( ! defined( $text ) ){ | ||
| 4920 | $text='Pages'; | ||
| 4921 | } | ||
| 4922 | |||
| 4923 | #blank any previous errors | ||
| 4924 | if ( ! $self->errorblank ){ | ||
| 4925 | return undef; | ||
| 4926 | } | ||
| 4927 | |||
| 4928 | my $url; | ||
| 4929 | if ( $self->{fullURL} ){ | ||
| 4930 | $url=$self->{r2r}.'/.pages/summary.html'; | ||
| 4931 | $url=~s/\/\/*/\//g; | ||
| 4932 | $url=$self->{url}; | ||
| 4933 | }else{ | ||
| 4934 | $url=$self->{toDir}.'/.pages/summary.html'; | ||
| 4935 | $url=~s/\/\/*/\//g; | ||
| 4936 | } | ||
| 4937 | |||
| 4938 | #render it | ||
| 4939 | my $rendered=$self->{t}->fill_in( | ||
| 4940 | 'pageSummaryLink', | ||
| 4941 | { | ||
| 4942 | url=>$url, | ||
| 4943 | text=>$text, | ||
| 4944 | toDir=>$self->{toDir}, | ||
| 4945 | toFiles=>$self->{toFiles}, | ||
| 4946 | obj=>\$self->{obj}, | ||
| 4947 | c=>\$self->{toader}->getConfig, | ||
| 4948 | self=>\$self, | ||
| 4949 | toader=>\$self->{toader}, | ||
| 4950 | g=>\$self, | ||
| 4951 | } | ||
| 4952 | ); | ||
| 4953 | if ( $self->{t}->error ){ | ||
| 4954 | $self->{error}=10; | ||
| 4955 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 4956 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 4957 | $self->warn; | ||
| 4958 | return undef; | ||
| 4959 | } | ||
| 4960 | |||
| 4961 | return $rendered; | ||
| 4962 | } | ||
| 4963 | |||
| 4964 | =head2 plink | ||
| 4965 | |||
| 4966 | This generates a link to a different page object. | ||
| 4967 | |||
| 4968 | Two arguments are taken. | ||
| 4969 | |||
| 4970 | The first and required one is the Toader directory containing | ||
| 4971 | the Toader object. | ||
| 4972 | |||
| 4973 | The second is the page to link to. | ||
| 4974 | |||
| 4975 | The third is the text, which if not specified will will be the | ||
| 4976 | same the link. | ||
| 4977 | |||
| 4978 | $g->plink( $dir, $page, "whatever at foo.bar" ); | ||
| 4979 | |||
| 4980 | The template used is 'linkPage' and it is by default as below. | ||
| 4981 | |||
| 4982 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 4983 | |||
| 4984 | The variables passed are as below. | ||
| 4985 | |||
| 4986 | url - This is the relative URL for this. | ||
| 4987 | text - This to use for with the link. | ||
| 4988 | toDir - This is the relative back to the directory. | ||
| 4989 | toFiles - This is the relative path to the '.files' directory. | ||
| 4990 | obj - The L<Toader::Entry> object. | ||
| 4991 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 4992 | self - The L<Toader::Render::Entry> object. | ||
| 4993 | toader - This is a L<Toader> object. | ||
| 4994 | g - This is a L<Toader::Render::General> object. | ||
| 4995 | |||
| 4996 | =cut | ||
| 4997 | |||
| 4998 | sub plink{ | ||
| 4999 | my $self=$_[0]; | ||
| 5000 | my $dir=$_[1]; | ||
| 5001 | my $page=$_[2]; | ||
| 5002 | my $text=$_[3]; | ||
| 5003 | |||
| 5004 | #blank any previous errors | ||
| 5005 | if ( ! $self->errorblank ){ | ||
| 5006 | return undef; | ||
| 5007 | } | ||
| 5008 | |||
| 5009 | #make sure we have a link | ||
| 5010 | if ( ! defined( $dir ) ){ | ||
| 5011 | $self->{error}=11; | ||
| 5012 | $self->{errorString}='No Toader directory defined'; | ||
| 5013 | $self->warn; | ||
| 5014 | return undef; | ||
| 5015 | } | ||
| 5016 | |||
| 5017 | #make sure we have a link | ||
| 5018 | if ( ! defined( $page ) ){ | ||
| 5019 | $self->{error}=15; | ||
| 5020 | $self->{errorString}='No Toader page defined'; | ||
| 5021 | $self->warn; | ||
| 5022 | return undef; | ||
| 5023 | } | ||
| 5024 | |||
| 5025 | #set the text to the same as the link if no text is defined | ||
| 5026 | if ( ! defined( $text ) ){ | ||
| 5027 | $text=$page; | ||
| 5028 | } | ||
| 5029 | |||
| 5030 | #handles it if it is a full path | ||
| 5031 | my $dirtest; | ||
| 5032 | if ( $dir =~ /^\// ){ | ||
| 5033 | $dir=$self->{toader}->getRootDir.$dir; | ||
| 5034 | $dirtest=$dir; | ||
| 5035 | $dir=$self->{ph}->relative2root( $dir ); | ||
| 5036 | }else{ | ||
| 5037 | $dirtest=$self->{dir}.'/'.$dir; | ||
| 5038 | } | ||
| 5039 | |||
| 5040 | #make sure it is a Toader directory | ||
| 5041 | if ( ! $self->{isatd}->isaToaderDir( $dirtest ) ){ | ||
| 5042 | $self->{error}=12; | ||
| 5043 | $self->{errorString}='"'.$dirtest.'" is not a Toader directory'; | ||
| 5044 | $self->warn; | ||
| 5045 | return undef; | ||
| 5046 | } | ||
| 5047 | |||
| 5048 | #make sure entry exists... will also make sure it exists | ||
| 5049 | my $ph=Toader::Page::Helper->new( $self->{toader} ); | ||
| 5050 | $ph->setDir( $dirtest ); | ||
| 5051 | if ( ! $ph->pageExists( $page ) ){ | ||
| 5052 | $self->{error}=16; | ||
| 5053 | $self->{errorString}='The Toader page "'.$page.'" does not exist for the Toader directory "'.$dirtest.'"'; | ||
| 5054 | $self->warn; | ||
| 5055 | return undef; | ||
| 5056 | } | ||
| 5057 | |||
| 5058 | if ( $self->{fullURL} ){ | ||
| 5059 | $dir=$dir.'/.pages/'.$page.'/'; | ||
| 5060 | $dir=~s/\/\/*/\//g; | ||
| 5061 | $dir=$self->{url}.$dir; | ||
| 5062 | }else{ | ||
| 5063 | $dir=$self->{toDir}.'/'.$dir.'/.pages/'.$page.'/'; | ||
| 5064 | $dir=~s/\/\/*/\//g; | ||
| 5065 | } | ||
| 5066 | |||
| 5067 | #render it | ||
| 5068 | my $rendered=$self->{t}->fill_in( | ||
| 5069 | 'linkPage', | ||
| 5070 | { | ||
| 5071 | url=>$dir, | ||
| 5072 | text=>$text, | ||
| 5073 | toDir=>$self->{toDir}, | ||
| 5074 | toFiles=>$self->{toFiles}, | ||
| 5075 | obj=>\$self->{obj}, | ||
| 5076 | c=>\$self->{toader}->getConfig, | ||
| 5077 | self=>\$self, | ||
| 5078 | toader=>\$self->{toader}, | ||
| 5079 | g=>\$self, | ||
| 5080 | } | ||
| 5081 | ); | ||
| 5082 | if ( $self->{t}->error ){ | ||
| 5083 | $self->{error}=10; | ||
| 5084 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 5085 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 5086 | $self->warn; | ||
| 5087 | return undef; | ||
| 5088 | } | ||
| 5089 | |||
| 5090 | return $rendered; | ||
| 5091 | } | ||
| 5092 | |||
| 5093 | =head2 r2r | ||
| 5094 | |||
| 5095 | This returns the current value to from the root directory | ||
| 5096 | to current directory. | ||
| 5097 | |||
| 5098 | my $r2r=$g->r2r; | ||
| 5099 | |||
| 5100 | =cut | ||
| 5101 | |||
| 5102 | sub r2r{ | ||
| 5103 | my $self=$_[0]; | ||
| 5104 | |||
| 5105 | #blank any previous errors | ||
| 5106 | if ( ! $self->errorblank ){ | ||
| 5107 | return undef; | ||
| 5108 | } | ||
| 5109 | |||
| 5110 | return $self->{r2r}; | ||
| 5111 | } | ||
| 5112 | |||
| 5113 | =head2 rlink | ||
| 5114 | |||
| 5115 | This generates a link to the root directory. | ||
| 5116 | |||
| 5117 | One option arguement is taken. It is the text part of the link. | ||
| 5118 | If not defined it defaults to the relative path to the root | ||
| 5119 | directory. | ||
| 5120 | |||
| 5121 | $g->rlink("to root"); | ||
| 5122 | |||
| 5123 | The template used is 'toRootLink' and is as below. | ||
| 5124 | |||
| 5125 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 5126 | |||
| 5127 | The variables are as below. | ||
| 5128 | |||
| 5129 | url - This is the relative URL for this. | ||
| 5130 | text - This to use for with the link. | ||
| 5131 | toDir - This is the relative back to the directory. | ||
| 5132 | toFiles - This is the relative path to the '.files' directory. | ||
| 5133 | obj - The L<Toader::Entry> object. | ||
| 5134 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 5135 | self - The L<Toader::Render::Entry> object. | ||
| 5136 | toader - This is a L<Toader> object. | ||
| 5137 | g - This is a L<Toader::Render::General> object. | ||
| 5138 | |||
| 5139 | =cut | ||
| 5140 | |||
| 5141 | sub rlink{ | ||
| 5142 | my $self=$_[0]; | ||
| 5143 | my $text=$_[1]; | ||
| 5144 | |||
| 5145 | #blank any previous errors | ||
| 5146 | if ( ! $self->errorblank ){ | ||
| 5147 | return undef; | ||
| 5148 | } | ||
| 5149 | |||
| 5150 | if ( ! defined( $text ) ){ | ||
| 5151 | $text='/'; | ||
| 5152 | } | ||
| 5153 | |||
| 5154 | #creates the url and cleans it up | ||
| 5155 | my $url=''; | ||
| 5156 | if ( $self->{fullURL} ){ | ||
| 5157 | $url=$self->{url}; | ||
| 5158 | }else{ | ||
| 5159 | $url=$self->{b2r}; | ||
| 5160 | $url=~s/\/\/*/\//g; | ||
| 5161 | } | ||
| 5162 | |||
| 5163 | #render it | ||
| 5164 | my $rendered=$self->{t}->fill_in( | ||
| 5165 | 'toRootLink', | ||
| 5166 | { | ||
| 5167 | url=>$url, | ||
| 5168 | text=>$text, | ||
| 5169 | toDir=>$self->{toDir}, | ||
| 5170 | toFiles=>$self->{toFiles}, | ||
| 5171 | obj=>\$self->{obj}, | ||
| 5172 | c=>\$self->{toader}->getConfig, | ||
| 5173 | self=>\$self, | ||
| 5174 | toader=>\$self->{toader}, | ||
| 5175 | g=>\$self, | ||
| 5176 | } | ||
| 5177 | ); | ||
| 5178 | if ( $self->{t}->error ){ | ||
| 5179 | $self->{error}=10; | ||
| 5180 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 5181 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 5182 | $self->warn; | ||
| 5183 | return undef; | ||
| 5184 | } | ||
| 5185 | |||
| 5186 | return $rendered; | ||
| 5187 | } | ||
| 5188 | |||
| 5189 | =head2 sidebar | ||
| 5190 | |||
| 5191 | This renders the sidebar for a page. | ||
| 5192 | |||
| 5193 | The template is 'sidebar' and the default is as below. | ||
| 5194 | |||
| 5195 | [== | ||
| 5196 | if ( ! $g->hasEntries ){ | ||
| 5197 | return ""; | ||
| 5198 | } | ||
| 5199 | return "<h3>Entries</h3>\n". | ||
| 5200 | " ".$g->entriesLink." <br>\n". | ||
| 5201 | " ".$g->entriesArchiveLink." <br>\n"; | ||
| 5202 | ==] | ||
| 5203 | [== | ||
| 5204 | my $pages=$g->listPages; | ||
| 5205 | if ( ( ! defined( $pages ) ) || ( $pages eq "" ) ){ | ||
| 5206 | return ""; | ||
| 5207 | } | ||
| 5208 | return " <hr><h3>".$g->pageSummaryLink."</h3>\n".$pages."\n <hr>\n"; | ||
| 5209 | ==] | ||
| 5210 | [== | ||
| 5211 | if( $g->hasGallery ){ | ||
| 5212 | return "<hr>\n<h3>".$g->galleryLink."</h3>"; | ||
| 5213 | }else{ | ||
| 5214 | return ""; | ||
| 5215 | } | ||
| 5216 | ==] | ||
| 5217 | [== | ||
| 5218 | if( $g->hasAnyDirs ){ | ||
| 5219 | return "<hr>\n<h3>Directories</h3>"; | ||
| 5220 | }else{ | ||
| 5221 | return ""; | ||
| 5222 | } | ||
| 5223 | ==] | ||
| 5224 | [== | ||
| 5225 | if ( $g->atRoot ){ | ||
| 5226 | return ""; | ||
| 5227 | } | ||
| 5228 | return $g->rlink("Go To The Root")." <br>\n ". | ||
| 5229 | $g->upOneDirLink." <br>\n <br>"; | ||
| 5230 | ==] | ||
| 5231 | |||
| 5232 | [== | ||
| 5233 | if ( $g->hasSubDirs ){ | ||
| 5234 | return $g->listDirs; | ||
| 5235 | } | ||
| 5236 | return ""; | ||
| 5237 | ==] | ||
| 5238 | [== | ||
| 5239 | if ( $g->hasDocs ){ | ||
| 5240 | return "<hr>".$g->adListLink; | ||
| 5241 | } | ||
| 5242 | return ""; | ||
| 5243 | ==] | ||
| 5244 | |||
| 5245 | The variables are as below. | ||
| 5246 | |||
| 5247 | toDir - This is the relative back to the directory. | ||
| 5248 | toFiles - This is the relative path to the '.files' directory. | ||
| 5249 | obj - The L<Toader::Entry> object. | ||
| 5250 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 5251 | self - The L<Toader::Render::Entry> object. | ||
| 5252 | toader - This is a L<Toader> object. | ||
| 5253 | g - This is a L<Toader::Render::General> object. | ||
| 5254 | |||
| 5255 | =cut | ||
| 5256 | |||
| 5257 | sub sidebar{ | ||
| 5258 | my $self=$_[0]; | ||
| 5259 | |||
| 5260 | #blank any previous errors | ||
| 5261 | if ( ! $self->errorblank ){ | ||
| 5262 | return undef; | ||
| 5263 | } | ||
| 5264 | |||
| 5265 | #render it | ||
| 5266 | my $rendered=$self->{t}->fill_in( | ||
| 5267 | 'sidebar', | ||
| 5268 | { | ||
| 5269 | toDir=>$self->{toDir}, | ||
| 5270 | toFiles=>$self->{toFiles}, | ||
| 5271 | obj=>\$self->{obj}, | ||
| 5272 | c=>\$self->{toader}->getConfig, | ||
| 5273 | self=>\$self, | ||
| 5274 | toader=>\$self->{toader}, | ||
| 5275 | g=>\$self, | ||
| 5276 | } | ||
| 5277 | ); | ||
| 5278 | if ( $self->{t}->error ){ | ||
| 5279 | $self->{error}=10; | ||
| 5280 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 5281 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 5282 | $self->warn; | ||
| 5283 | return undef; | ||
| 5284 | } | ||
| 5285 | |||
| 5286 | return $rendered; | ||
| 5287 | } | ||
| 5288 | |||
| 5289 | =head2 toDir | ||
| 5290 | |||
| 5291 | This returns the value that was set for toDir. | ||
| 5292 | |||
| 5293 | my $toDir=>$g->toDir; | ||
| 5294 | |||
| 5295 | =cut | ||
| 5296 | |||
| 5297 | sub toDir{ | ||
| 5298 | my $self=$_[0]; | ||
| 5299 | |||
| 5300 | #blank any previous errors | ||
| 5301 | if ( ! $self->errorblank ){ | ||
| 5302 | return undef; | ||
| 5303 | } | ||
| 5304 | |||
| 5305 | return $self->{toDir}; | ||
| 5306 | } | ||
| 5307 | |||
| 5308 | =head2 top | ||
| 5309 | |||
| 5310 | This renders the top include. | ||
| 5311 | |||
| 5312 | $g->top; | ||
| 5313 | |||
| 5314 | The template is 'top' and the default is as below. | ||
| 5315 | |||
| 5316 | <h1>[== $c->{_}->{site} ==]</h1><br> | ||
| 5317 | |||
| 5318 | The variables are as below. | ||
| 5319 | |||
| 5320 | toDir - This is the relative back to the directory. | ||
| 5321 | toFiles - This is the relative path to the '.files' directory. | ||
| 5322 | obj - The L<Toader::Entry> object. | ||
| 5323 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 5324 | self - The L<Toader::Render::Entry> object. | ||
| 5325 | toader - This is a L<Toader> object. | ||
| 5326 | g - This is a L<Toader::Render::General> object. | ||
| 5327 | |||
| 5328 | =cut | ||
| 5329 | |||
| 5330 | sub top{ | ||
| 5331 | my $self=$_[0]; | ||
| 5332 | |||
| 5333 | #blank any previous errors | ||
| 5334 | if ( ! $self->errorblank ){ | ||
| 5335 | return undef; | ||
| 5336 | } | ||
| 5337 | |||
| 5338 | my $dir=$self->{b2r}; | ||
| 5339 | |||
| 5340 | #add the toDir to it | ||
| 5341 | $dir=$self->{toDir}.$dir; | ||
| 5342 | |||
| 5343 | #render it | ||
| 5344 | my $rendered=$self->{t}->fill_in( | ||
| 5345 | 'top', | ||
| 5346 | { | ||
| 5347 | toDir=>$self->{toDir}, | ||
| 5348 | toFiles=>$self->{toFiles}, | ||
| 5349 | obj=>\$self->{obj}, | ||
| 5350 | c=>\$self->{toader}->getConfig, | ||
| 5351 | toader=>\$self->{toader}, | ||
| 5352 | self=>\$self, | ||
| 5353 | g=>\$self, | ||
| 5354 | } | ||
| 5355 | ); | ||
| 5356 | if ( $self->{t}->error ){ | ||
| 5357 | $self->{error}=10; | ||
| 5358 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 5359 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 5360 | $self->warn; | ||
| 5361 | return undef; | ||
| 5362 | } | ||
| 5363 | |||
| 5364 | return $rendered; | ||
| 5365 | } | ||
| 5366 | |||
| 5367 | =head2 upOneDirLink | ||
| 5368 | |||
| 5369 | This creates a link up to the next directory. | ||
| 5370 | |||
| 5371 | One argument is taken and that is text to show for the link. If | ||
| 5372 | not specified, it defaults to 'Up One Directory'. | ||
| 5373 | |||
| 5374 | $g->upOneDirLink; | ||
| 5375 | |||
| 5376 | The template is 'upOneDirLink' and the default is as below. | ||
| 5377 | |||
| 5378 | <a href="[== $url ==]">[== $text ==]</a> | ||
| 5379 | |||
| 5380 | The passed variables are as below. | ||
| 5381 | |||
| 5382 | url - This is the relative URL for this. | ||
| 5383 | text - This to use for with the link. | ||
| 5384 | toDir - This is the relative back to the directory. | ||
| 5385 | toFiles - This is the relative path to the '.files' directory. | ||
| 5386 | obj - The L<Toader::Entry> object. | ||
| 5387 | c - The L<Config::Tiny> object containing the Toader config. | ||
| 5388 | self - The L<Toader::Render::Entry> object. | ||
| 5389 | toader - This is a L<Toader> object. | ||
| 5390 | g - This is a L<Toader::Render::General> object. | ||
| 5391 | |||
| 5392 | =cut | ||
| 5393 | |||
| 5394 | sub upOneDirLink{ | ||
| 5395 | my $self=$_[0]; | ||
| 5396 | my $text=$_[1]; | ||
| 5397 | |||
| 5398 | #blank any previous errors | ||
| 5399 | if ( ! $self->errorblank ){ | ||
| 5400 | return undef; | ||
| 5401 | } | ||
| 5402 | |||
| 5403 | if ( ! defined( $text ) ){ | ||
| 5404 | $text='Up One Directory'; | ||
| 5405 | } | ||
| 5406 | |||
| 5407 | #creates the url and cleans it up | ||
| 5408 | my $url=$self->{toDir}.'/../'; | ||
| 5409 | $url=~s/\/\/*/\//g; | ||
| 5410 | |||
| 5411 | #render it | ||
| 5412 | my $rendered=$self->{t}->fill_in( | ||
| 5413 | 'upOneDirLink', | ||
| 5414 | { | ||
| 5415 | url=>$url, | ||
| 5416 | text=>$text, | ||
| 5417 | toDir=>$self->{toDir}, | ||
| 5418 | toFiles=>$self->{toFiles}, | ||
| 5419 | obj=>\$self->{obj}, | ||
| 5420 | c=>\$self->{toader}->getConfig, | ||
| 5421 | self=>\$self, | ||
| 5422 | toader=>\$self->{toader}, | ||
| 5423 | g=>\$self, | ||
| 5424 | } | ||
| 5425 | ); | ||
| 5426 | if ( $self->{t}->error ){ | ||
| 5427 | $self->{error}=10; | ||
| 5428 | $self->{errorString}='Failed to fill in the template. error="'. | ||
| 5429 | $self->{t}->error.'" errorString="'.$self->{t}->errorString.'"'; | ||
| 5430 | $self->warn; | ||
| 5431 | return undef; | ||
| 5432 | } | ||
| 5433 | |||
| 5434 | return $rendered; | ||
| 5435 | } | ||
| 5436 | |||
| 5437 | =head1 ERROR CODES | ||
| 5438 | |||
| 5439 | =head2 1, noToaderObj | ||
| 5440 | |||
| 5441 | No L<Toader> object defined. | ||
| 5442 | |||
| 5443 | =head2 2, notAtoaderObj | ||
| 5444 | |||
| 5445 | The object specified for the L<Toader> object is not really a | ||
| 5446 | L<Toader> object. | ||
| 5447 | |||
| 5448 | =head2 3, toaderPerror | ||
| 5449 | |||
| 5450 | The specified L<Toader> object has a permanent error set. | ||
| 5451 | |||
| 5452 | =head2 4, noRenderableObj | ||
| 5453 | |||
| 5454 | No object specified for the renderable object. | ||
| 5455 | |||
| 5456 | =head2 5, notArenderableObj | ||
| 5457 | |||
| 5458 | The object specified for the renderable object was not defined. | ||
| 5459 | |||
| 5460 | =head2 6, objPerror | ||
| 5461 | |||
| 5462 | The specified renderable object has a permanent error set. | ||
| 5463 | |||
| 5464 | =head2 7, noDirSet | ||
| 5465 | |||
| 5466 | The renderable object does not have a directory specified. | ||
| 5467 | |||
| 5468 | =head2 8, noLinkDefined | ||
| 5469 | |||
| 5470 | Nothing defined for the link. | ||
| 5471 | |||
| 5472 | =head2 9, templateFetchErrored | ||
| 5473 | |||
| 5474 | Failed to fetch the template. | ||
| 5475 | |||
| 5476 | =head2 11, noToaderDirSpecified | ||
| 5477 | |||
| 5478 | No Toader directory specified. | ||
| 5479 | |||
| 5480 | =head2 12, notAtoaderDir | ||
| 5481 | |||
| 5482 | The specified directory is not a L<Toader> directory. | ||
| 5483 | |||
| 5484 | =head2 13, noEntryIDspecified | ||
| 5485 | |||
| 5486 | No L<Toader::Entry> ID defined. | ||
| 5487 | |||
| 5488 | =head2 14, entryDoesNotExist | ||
| 5489 | |||
| 5490 | The entry does not exist. | ||
| 5491 | |||
| 5492 | =head2 15, noPageSpecified | ||
| 5493 | |||
| 5494 | No L<Toader> page is defined. | ||
| 5495 | |||
| 5496 | =head2 16, pageDoesNotExist | ||
| 5497 | |||
| 5498 | The page does not exist. | ||
| 5499 | |||
| 5500 | =head2 17, noFileSpecified | ||
| 5501 | |||
| 5502 | No file specified. | ||
| 5503 | |||
| 5504 | =head2 18, templateInitErrored | ||
| 5505 | |||
| 5506 | Failed to initialize the L<Toader::Templates> object. | ||
| 5507 | |||
| 5508 | =head2 19, r2rErrored | ||
| 5509 | |||
| 5510 | Failed to figure out the relative from root path. | ||
| 5511 | |||
| 5512 | =head2 20, b2rErrored | ||
| 5513 | |||
| 5514 | Failed to figure out the relative back to root path. | ||
| 5515 | |||
| 5516 | =head2 21, pathhelperInitErrored | ||
| 5517 | |||
| 5518 | Failed to initialize the L<Toader::pathHelper> object. | ||
| 5519 | |||
| 5520 | =head2 22, subToaderDirListErrored | ||
| 5521 | |||
| 5522 | Failed to get a list of L<Toader> sub directories for the | ||
| 5523 | current directory. | ||
| 5524 | |||
| 5525 | =head2 23, pageManageDirSetErrored | ||
| 5526 | |||
| 5527 | Failed to set the directory for L<Toader::Page::Manage>. | ||
| 5528 | |||
| 5529 | =head2 24, listPagesErrored | ||
| 5530 | |||
| 5531 | Failed to get a list of pages. | ||
| 5532 | |||
| 5533 | =head2 25, entryManageErrored | ||
| 5534 | |||
| 5535 | L<Toader::Entry::Manage> could not have it's directory set. | ||
| 5536 | |||
| 5537 | =head2 26, readEntryErrored | ||
| 5538 | |||
| 5539 | Failed to read a entry. | ||
| 5540 | |||
| 5541 | =head2 27, renderEntryInitErrored | ||
| 5542 | |||
| 5543 | Failed to initialize L<Toader::Render::Entry>. | ||
| 5544 | |||
| 5545 | =head2 28, renderEntryErrored | ||
| 5546 | |||
| 5547 | Failed to render a entry. | ||
| 5548 | |||
| 5549 | =head2 29, noAuthorsLineSpecified | ||
| 5550 | |||
| 5551 | No authors line specified. | ||
| 5552 | |||
| 5553 | =head2 30, authorsLineParseFailed | ||
| 5554 | |||
| 5555 | Failed to parse the authors line. | ||
| 5556 | |||
| 5557 | =head2 31, entryManageDirSetErrored | ||
| 5558 | |||
| 5559 | L<Toader::Entry::Manage> could not have it's directory set. | ||
| 5560 | |||
| 5561 | =head2 32, pageListErrored | ||
| 5562 | |||
| 5563 | Failed to list the pages for the directory. | ||
| 5564 | |||
| 5565 | =head2 33, pageReadErrored | ||
| 5566 | |||
| 5567 | Failed to read the page. | ||
| 5568 | |||
| 5569 | =head2 34, autoDocFileDotDotError | ||
| 5570 | |||
| 5571 | The file specified for the AutoDoc link starts with a "../". | ||
| 5572 | |||
| 5573 | =head2 35, noURLinConfig | ||
| 5574 | |||
| 5575 | No URL specified in in the Toader Config. | ||
| 5576 | |||
| 5577 | =head2 36, noImageURLspecified | ||
| 5578 | |||
| 5579 | No URL specified for the image. | ||
| 5580 | |||
| 5581 | =head2 37, noImageFileSpecified | ||
| 5582 | |||
| 5583 | No image file specified. | ||
| 5584 | |||
| 5585 | =head2 38, imageDoesNotExist | ||
| 5586 | |||
| 5587 | The specified image does not exist. | ||
| 5588 | |||
| 5589 | =head2 39, pathCleanupErrored | ||
| 5590 | |||
| 5591 | Path cleanup failed. | ||
| 5592 | |||
| 5593 | =head2 40, galleryInitErrored | ||
| 5594 | |||
| 5595 | Failed to initialize Toader::Gallery. | ||
| 5596 | |||
| 5597 | =head2 41, outputURLnotSpecified | ||
| 5598 | |||
| 5599 | Undefined outputURL for Toader::Gallery. | ||
| 5600 | |||
| 5601 | =head2 42, noSrcPathSpecified | ||
| 5602 | |||
| 5603 | No source path specified for Toader::Gallery. | ||
| 5604 | |||
| 5605 | =head2 43, noURLspecified | ||
| 5606 | |||
| 5607 | No source URL specified for Toader::Gallery. | ||
| 5608 | |||
| 5609 | =head2 44, relativeDirContainsAperiod | ||
| 5610 | |||
| 5611 | The relative gallery directory contains a period. | ||
| 5612 | |||
| 5613 | =head2 45, noSrcURLspecified | ||
| 5614 | |||
| 5615 | No source URL specified for L<Toader::Gallery>. | ||
| 5616 | |||
| 5617 | =head2 46, toaderAutoDocInitErrored | ||
| 5618 | |||
| 5619 | Failed to initialize Toader::AutoDoc. | ||
| 5620 | |||
| 5621 | =head1 AUTHOR | ||
| 5622 | |||
| 5623 | Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >> | ||
| 5624 | |||
| 5625 | =head1 BUGS | ||
| 5626 | |||
| 5627 | Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through | ||
| 5628 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll | ||
| 5629 | automatically be notified of progress on your bug as I make changes. | ||
| 5630 | |||
| 5631 | =head1 SUPPORT | ||
| 5632 | |||
| 5633 | You can find documentation for this module with the perldoc command. | ||
| 5634 | |||
| 5635 | perldoc Toader::Render::General | ||
| 5636 | |||
| 5637 | You can also look for information at: | ||
| 5638 | |||
| 5639 | =over 4 | ||
| 5640 | |||
| 5641 | =item * RT: CPAN's request tracker | ||
| 5642 | |||
| 5643 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader> | ||
| 5644 | |||
| 5645 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 5646 | |||
| 5647 | L<http://annocpan.org/dist/Toader> | ||
| 5648 | |||
| 5649 | =item * CPAN Ratings | ||
| 5650 | |||
| 5651 | L<http://cpanratings.perl.org/d/Toader> | ||
| 5652 | |||
| 5653 | =item * Search CPAN | ||
| 5654 | |||
| 5655 | L<http://search.cpan.org/dist/Toader/> | ||
| 5656 | |||
| 5657 | =back | ||
| 5658 | |||
| 5659 | =head1 ACKNOWLEDGEMENTS | ||
| 5660 | |||
| 5661 | =head1 LICENSE AND COPYRIGHT | ||
| 5662 | |||
| 5663 | Copyright 2013. Zane C. Bowers-Hadley. | ||
| 5664 | |||
| 5665 | This program is free software; you can redistribute it and/or modify it | ||
| 5666 | under the terms of either: the GNU General Public License as published | ||
| 5667 | by the Free Software Foundation; or the Artistic License. | ||
| 5668 | |||
| 5669 | See http://dev.perl.org/licenses/ for more information. | ||
| 5670 | |||
| 5671 | |||
| 5672 | =cut | ||
| 5673 | |||
| 5674 | 1; # End of Toader::Render::General | ||