File Coverage

lib/App/Followme/FolderData.pm
Criterion Covered Total %
statement 282 283 99.6
branch 66 76 86.8
condition 20 28 71.4
subroutine 51 51 100.0
pod 2 43 4.6
total 421 481 87.5


line stmt bran cond sub pod time code
1             package App::Followme::FolderData;
2              
3 18     18   1116 use 5.008005;
  18         71  
4 18     18   112 use strict;
  18         45  
  18         442  
5 18     18   95 use warnings;
  18         39  
  18         572  
6 18     18   125 use integer;
  18         32  
  18         111  
7 18     18   534 use lib '../..';
  18         44  
  18         135  
8              
9 18     18   2453 use File::Spec::Functions qw(abs2rel catfile rel2abs splitdir);
  18         37  
  18         1290  
10              
11 18     18   143 use base qw(App::Followme::BaseData);
  18         73  
  18         8614  
12 18     18   163 use App::Followme::FIO;
  18         57  
  18         70158  
13              
14             our $VERSION = "2.01";
15              
16             #----------------------------------------------------------------------
17             # Read the default parameter values
18              
19             sub parameters {
20 364     364 1 658 my ($self) = @_;
21              
22             return (
23 364         2347 extension => '',
24             site_url => '',
25             remote_url => '',
26             author => '',
27             size_format => 'kb',
28             date_format => 'Mon d, yyyy h:mm',
29             exclude_index => 0,
30             exclude => '',
31             exclude_dirs => '.*,_*',
32             web_extension => 'html',
33             );
34             }
35              
36             #----------------------------------------------------------------------
37             # Return the author's name stored in theconfiguration file
38              
39             sub calculate_author {
40 14     14 0 718 my ($self, $filename) = @_;
41 14         47 return $self->{author};
42             }
43              
44             #----------------------------------------------------------------------
45             # Calculate the creation date from the modification date
46              
47             sub calculate_date {
48 5     5 0 730 my ($self, $filename) = @_;
49 5         30 return $self->get_mdate($filename);
50             }
51              
52             #----------------------------------------------------------------------
53             # Get the list of keywords from the file path
54              
55             sub calculate_keywords {
56 8     8 0 739 my ($self, $filename) = @_;
57 8         28 $filename = $self->dir_to_filename($filename);
58              
59 8         38 $filename = abs2rel($filename);
60 8         699 my @path = splitdir($filename);
61 8         48 pop(@path);
62              
63 8   100     35 my $keywords = pop(@path) || '';
64 8         28 return $keywords;
65             }
66              
67             #----------------------------------------------------------------------
68             # Calculate the title from the filename root
69              
70             sub calculate_title {
71 32     32 0 910 my ($self, $filename) = @_;
72 32         169 $filename = $self->dir_to_filename($filename);
73              
74 32         142 my ($dir, $file) = fio_split_filename($filename);
75 32         125 my ($root, $ext) = split(/\./, $file);
76              
77 32 100       116 if ($root eq 'index') {
78 10         31 my @dirs = splitdir($dir);
79 10   50     73 $root = pop(@dirs) || '';
80             }
81              
82 32 50       185 $root =~ s/^\d+// unless $root =~ /^\d+$/;
83 32         105 my @words = map {ucfirst $_} split(/\-/, $root);
  32         165  
84              
85 32         144 return join(' ', @words);
86             }
87              
88             #----------------------------------------------------------------------
89             # Check that filename is defined, die if not
90              
91             sub check_filename {
92 593     593 0 1179 my ($self, $name, $filename) = @_;
93              
94 593 50       1395 die "Cannot use \$$name outside of loop" unless defined $filename;
95 593         1140 return;
96             }
97              
98             #-----------------------------------------------------------------------
99             # Get the name of the web file a file will be converted to
100              
101             sub convert_filename {
102 12     12 0 33 my ($self, $filename) = @_;
103              
104 12         154 $filename =~ s/\.[^\.]*$/.$self->{web_extension}/;
105 12         47 return $filename;
106             }
107              
108             #-----------------------------------------------------------------------
109             # Get the name of the source directory for ConvertPage
110              
111             sub convert_source_directory {
112 9     9 0 27 my ($self, $directory) = @_;
113              
114             # Defaults to same as output directory
115 9         25 return $directory;
116             }
117              
118             #----------------------------------------------------------------------
119             # Get a filename if the directory happens to be a directory
120              
121             sub dir_to_filename {
122 210     210 0 2919 my ($self, $directory) = @_;
123              
124 210         294 my $filename;
125 210 100       3811 if (-d $directory) {
126 15         83 my $index = 'index.' . $self->{web_extension};
127 15         94 $filename = catfile($directory, $index);
128             } else {
129 195         529 $filename = $directory;
130             }
131              
132 210         627 return $filename;
133             }
134              
135             #----------------------------------------------------------------------
136             # Fetch data from all its possible sources
137              
138             sub fetch_data {
139 39     39 0 90 my ($self, $name, $filename, $loop) = @_;
140              
141             # Look under both sets of functions
142              
143 39         116 $self->check_filename($name, $filename);
144 39         101 my %data = $self->gather_data('get', $name, $filename, $loop);
145              
146             %data = (%data, $self->gather_data('calculate', $name, $filename, $loop))
147 39 100       117 unless exists $data{$name};
148              
149 39         116 return %data;
150             }
151              
152             #----------------------------------------------------------------------
153             # Convert filename to url
154              
155             sub filename_to_url {
156 100     100 0 295 my ($self, $directory, $filename, $ext) = @_;
157              
158 100         221 $filename = $self->dir_to_filename($filename);
159              
160 100         430 $filename = rel2abs($filename);
161 100         1396 $filename = abs2rel($filename, $directory);
162              
163 100 50       6058 my @path = $filename eq '.' ? () : splitdir($filename);
164              
165 100         567 my $url = join('/', @path);
166 100 100       679 $url =~ s/\.[^\.]*$/.$ext/ if defined $ext;
167              
168 100         405 return $url;
169             }
170              
171             #----------------------------------------------------------------------
172             # Find the filename at an offset to the current filename
173              
174             sub find_filename {
175 10     10 0 17 my ($self, $offset, $filename, $loop) = @_;
176 10 50       22 die "Can't use \$url_* outside of for\n" unless $loop;
177              
178 10         16 my $match = -999;
179 10         25 foreach my $i (0 .. @$loop) {
180 30 100       55 if ($loop->[$i] eq $filename) {
181 10         15 $match = $i;
182 10         16 last;
183             }
184             }
185              
186 10         19 my $index = $match + $offset;
187 10 100 100     36 if ($index < 0 || $index > @$loop-1) {
188 2         4 $filename = '';
189             } else {
190 8         14 $filename = $loop->[$index];
191             }
192              
193 10         17 return $filename;
194             }
195              
196             #----------------------------------------------------------------------
197             # Build a recursive list of directories with a breadth first search
198              
199             sub find_matching_directories {
200 41     41 0 100 my ($self, $directory) = @_;
201              
202 41         114 my ($filenames, $subdirectories) = fio_visit($directory);
203              
204 41         816 my @directories;
205 41         116 foreach my $subdirectory (@$subdirectories) {
206 16 50       53 next unless $self->match_directory($subdirectory);
207 16         41 push(@directories, $subdirectory);
208             }
209              
210 41         80 foreach my $subdirectory (@directories) {
211 16         57 push(@directories, $self->find_matching_directories($subdirectory));
212             }
213              
214 41         152 return @directories;
215             }
216              
217             #----------------------------------------------------------------------
218             # Build a list of matching files in a folder
219              
220             sub find_matching_files {
221 86     86 0 186 my ($self, $folder) = @_;
222              
223 86         252 my ($filenames, $folders) = fio_visit($folder);
224              
225 86         1942 my @files;
226 86         224 foreach my $filename (@$filenames) {
227 355 100       921 push(@files, $filename) if $self->match_file($filename);
228             }
229              
230 86         362 return @files;
231             }
232              
233             #----------------------------------------------------------------------
234             # Find the newest file in a set of files
235              
236             sub find_newest_file {
237 20     20 0 54 my ($self, @files) = @_;
238              
239 20         45 my ($newest_file, $newest_date);
240 20   100     107 while (@files && ! defined $newest_file) {
241 16         37 $newest_file = shift(@files);
242 16 100       69 $newest_date =fio_get_date($newest_file) if defined $newest_file;
243             }
244              
245 20         57 foreach my $file (@files) {
246 22 50 33     383 next unless defined $file && -e $file;
247              
248 22         90 my $date = fio_get_date($file);
249 22 100       72 if ($date > $newest_date) {
250 15         19 $newest_date = $date;
251 15         33 $newest_file = $file;
252             }
253             }
254              
255 20         51 return $newest_file;
256             }
257              
258             #----------------------------------------------------------------------
259             # Get the more recently changed files
260              
261             sub find_top_files {
262 19     19 0 50 my ($self, $folder, $augmented_files) = @_;
263              
264 19         55 my @files = $self->find_matching_files($folder);
265 19         99 my @sorted_files = $self->sort_with_field(\@files, 'mdate', 1);
266              
267 19         85 return $self->merge_augmented($augmented_files, \@sorted_files);
268             }
269              
270             #----------------------------------------------------------------------
271             # Format the file creation date
272              
273             sub format_date {
274 44     44 0 782 my ($self, $sorted_order, $date) = @_;
275              
276 44 100       106 if ($sorted_order) {
277 1         4 $date = fio_format_date($date);
278             } else {
279 43         154 $date = fio_format_date($date, $self->{date_format});
280             }
281              
282 44         173 return $date;
283             }
284              
285             #----------------------------------------------------------------------
286             # Format the file modification date
287              
288             sub format_mdate {
289 91     91 0 192 my ($self, $sorted_order, $date) = @_;
290 91         240 return fio_format_date($date);
291             }
292              
293             #----------------------------------------------------------------------
294             # Make filenames sortable in a cross-os manner
295              
296             sub format_name {
297 139     139 0 370 my ($self, $sorted_order, $filename) = @_;
298              
299 139 50       457 $filename = join(' ', fio_split_filename($filename)) if $sorted_order;
300 139         665 return $filename;
301             }
302              
303             #----------------------------------------------------------------------
304             # Format the file size
305              
306             sub format_size {
307 2     2 0 1366 my ($self, $sorted_order, $size) = @_;
308              
309 2 100       59 if ($sorted_order) {
310 1         6 $size = sprintf("%012d", $size);
311              
312             } else {
313 1 50       10 if ($self->{size_format}) {
314 1         4 my $byte_size = $size;
315 1         4 my $fmt = lc($self->{size_format});
316              
317 1         2 foreach my $format (qw(b kb mb gb)) {
318 2 100       7 if ($fmt eq $format) {
319 1         2 undef $fmt;
320 1         3 last;
321             }
322 1         2 $byte_size /= 1024;
323             }
324              
325             $size = join('', int($byte_size), $self->{size_format})
326 1 50       6 unless $fmt;
327             }
328             }
329              
330 2         6 return $size;
331             }
332              
333             #----------------------------------------------------------------------
334             # Get the absolute url from a filename and the site url
335              
336             sub get_absolute_url {
337 1     1 0 675 my ($self, $filename) = @_;
338 1         4 $filename = $self->dir_to_filename($filename);
339              
340 1         4 my $site_url = $self->get_site_url($filename);
341 1         3 my $relative_url = $self->get_url($filename);
342 1         3 my $absolute_url = "$site_url/$relative_url";
343              
344 1         3 return $absolute_url;
345             }
346              
347             #----------------------------------------------------------------------
348             # Get a list of matching files in a folder and its subfolders
349              
350             sub get_all_files {
351 2     2 0 799 my ($self, $filename) = @_;
352              
353 2         9 my ($folder) = fio_split_filename($filename);
354 2         11 my @files = $self->find_matching_files($folder);
355              
356 2         11 my @folders = $self->find_matching_directories($folder);
357 2         8 foreach my $subfolder (@folders) {
358 1         4 push(@files, $self->find_matching_files($subfolder));
359             }
360              
361 2         12 return \@files;
362             }
363              
364             #----------------------------------------------------------------------
365             # Get a list of breadcrumb filenames
366              
367             sub get_breadcrumbs {
368 1     1 0 696 my ($self, $filename) = @_;
369              
370 1         7 my @path = splitdir(abs2rel($filename, $self->{top_directory}));
371 1         83 pop(@path);
372              
373 1         5 my @breadcrumbs;
374 1         2 for (;;) {
375             my $dir = @path ? catfile($self->{top_directory}, @path)
376 2 100       9 : $self->{top_directory};
377              
378 2         11 my $breadcrumb = $self->dir_to_filename($dir);
379 2         5 push (@breadcrumbs, $breadcrumb);
380              
381 2 100       11 last unless @path;
382 1         3 pop(@path);
383             }
384              
385 1         12 @breadcrumbs = reverse(@breadcrumbs);
386 1         3 return \@breadcrumbs;
387             }
388              
389             #----------------------------------------------------------------------
390             # Get the extension from a filename
391              
392             sub get_extension {
393 1     1 0 653 my ($self, $filename) = @_;
394              
395 1         4 my ($folder, $file) = fio_split_filename($filename);
396 1         7 my ($extension) = ($file =~ /\.([^\.]*)$/);
397              
398 1         3 return $extension;
399             }
400              
401              
402             #----------------------------------------------------------------------
403             # Get a list of matching files in a folder
404              
405             sub get_files {
406 45     45 0 477 my ($self, $filename) = @_;
407              
408 45         157 my ($folder) = fio_split_filename($filename);
409 45         246 my @files = $self->find_matching_files($folder);
410 45         165 return \@files;
411             }
412              
413             #-----------------------------------------------------------------------
414             # Get a list of matching directories
415              
416             sub get_folders {
417 52     52 0 739 my ($self, $filename) = @_;
418              
419 52         156 my ($folder) = fio_split_filename($filename);
420 52         165 my ($filenames, $subfolders) = fio_visit($folder);
421              
422 52         1143 my @folders;
423 52         140 foreach my $subfolder (@$subfolders) {
424 28 100       141 next unless $self->match_directory($subfolder);
425 24         76 push(@folders, $subfolder);
426             }
427              
428 52         232 return \@folders;
429             }
430              
431             #-----------------------------------------------------------------------
432             # Get the url of the index page in the same folder as a file
433              
434             sub get_index_url {
435 7     7 0 657 my ($self, $filename) = @_;
436              
437 7         23 my ($dir, $file) = fio_split_filename($filename);
438 7         23 my $index_page = "index.$self->{web_extension}";
439 7         33 $index_page = catfile($dir, $index_page);
440              
441 7         29 return $self->get_url($index_page);
442             }
443              
444             #----------------------------------------------------------------------
445             # Set a flag indicating if the the filename is the index file
446              
447             sub get_is_index {
448 2     2 0 1358 my ($self, $filename) = @_;
449              
450 2         7 my ($folder, $file) = fio_split_filename($filename);
451 2         6 my ($root, $ext) = split(/\./, $file);
452              
453 2   66     11 my $is_index = $root eq 'index' && $ext eq $self->{web_extension};
454 2 100       9 return $is_index ? 1 : 0;
455             }
456              
457             #----------------------------------------------------------------------
458             # Get the modification time in epoch seconds
459              
460             sub get_mdate {
461 96     96 0 196 my ($self, $filename) = @_;
462              
463 96         269 return fio_get_date($filename);
464             }
465              
466             #----------------------------------------------------------------------
467             # Get the most recently modified file in a folder and its subfolders
468              
469             sub get_newest_file {
470 14     14 0 687 my ($self, $filename) = @_;
471              
472 14         55 my ($folder) = fio_split_filename($filename);
473 14         99 my @files = $self->find_matching_files($folder);
474              
475 14         75 my $newest_file = $self->find_newest_file(@files);
476 14         71 my @folders = $self->find_matching_directories($folder);
477              
478 14         34 foreach my $subfolder (@folders) {
479 6         19 @files = $self->find_matching_files($subfolder);
480 6         19 $newest_file = $self->find_newest_file($newest_file, @files);
481             }
482              
483 14 100       94 return defined $newest_file ? [$newest_file] : [];
484             }
485              
486             #----------------------------------------------------------------------
487             # Get a list of files with the same rootname as another filename
488              
489             sub get_related_files {
490 1     1 0 620 my ($self, $filename) = @_;
491 1         5 my ($folder, $file) = fio_split_filename($filename);
492              
493 1         2 my $root;
494 1         14 ($root = $file) =~ s/\.[^\.]*$//;
495              
496 1         5 my @related_files;
497 1         3 my ($filenames, $folders) = fio_visit($folder);
498 1         30 foreach my $filename (@$filenames) {
499 10         22 my ($folder, $file) = fio_split_filename($filename);
500              
501 10         15 my $rootname;
502 10         49 ($rootname = $file) =~ s/\.[^\.]*$//;
503 10 100       32 push(@related_files, $filename) if $root eq $rootname;
504             }
505              
506 1         13 return \@related_files;
507             }
508              
509             #----------------------------------------------------------------------
510             # Get the remote url from a filename and the remote url
511              
512             sub get_remote_url {
513 29     29 0 778 my ($self, $filename) = @_;
514              
515 29         85 my $remote_url;
516 29 50       69 if ($self->{remote_url}) {
517 29         81 my $relative_url = $self->get_url($filename);
518 29         98 $remote_url = "$self->{remote_url}/$relative_url";
519              
520             } else {
521 0         0 $remote_url = $self->get_absolute_url($filename);
522             }
523              
524 29         88 return $remote_url;
525             }
526              
527             #----------------------------------------------------------------------
528             # get the site url
529              
530             sub get_site_url {
531 35     35 0 727 my ($self, $filename) = @_;
532              
533 35         58 my $site_url ;
534 35 100       90 if ($self->{site_url}) {
535 18         29 $site_url = $self->{site_url};
536              
537             } else {
538 17         48 $site_url = 'file://' . $self->{top_directory};
539             }
540              
541 35         73 $site_url =~ s/\/$//;
542 35         90 return $site_url;
543             }
544              
545             #----------------------------------------------------------------------
546             # Get the file size
547              
548             sub get_size {
549 1     1 0 10 my ($self, $filename) = @_;
550              
551 1         4 return fio_get_size($filename);
552             }
553              
554             #----------------------------------------------------------------------
555             # Get a list of matching files in a directory and its subdirectories
556              
557             sub get_top_files {
558 10     10 0 630 my ($self, $filename) = @_;
559              
560 10         22 my $augmented_files = [];
561 10         47 my ($folder) = fio_split_filename($filename);
562 10         78 $augmented_files = $self->find_top_files($folder, $augmented_files);
563              
564 10         37 my @directories = $self->find_matching_directories($folder);
565              
566 10         36 foreach my $subfolder (@directories) {
567 9         24 $augmented_files = $self->find_top_files($subfolder,
568             $augmented_files);
569             }
570              
571 10         49 my @top_files = $self->strip_augmented(@$augmented_files);
572 10         48 return \@top_files;
573             }
574              
575             #----------------------------------------------------------------------
576             # Get a url from a filename
577              
578             sub get_url {
579 64     64 0 2049 my ($self, $filename) = @_;
580 64         176 $filename = $self->dir_to_filename($filename);
581              
582             return $self->filename_to_url($self->{top_directory},
583             $filename,
584 64         263 $self->{web_extension});
585             }
586              
587             #----------------------------------------------------------------------
588             # Get a url with no extension from a filename
589              
590             sub get_url_base {
591 1     1 0 654 my ($self, $filename) = @_;
592 1         3 $filename = $self->dir_to_filename($filename);
593              
594             my $url_base = $self->filename_to_url($self->{top_directory},
595 1         4 $filename, '');
596 1         5 chop($url_base); # remove trailing dot
597 1         3 return $url_base;
598             }
599              
600             #----------------------------------------------------------------------
601             # Get a url from the next filename in the loop
602              
603             sub get_url_next {
604 5     5 0 24 my ($self, $filename, $loop) = @_;
605              
606 5         11 $filename = $self->find_filename(1, $filename, $loop);
607 5 100       13 return $filename ? $self->get_url($filename) : '';
608             }
609              
610             #----------------------------------------------------------------------
611             # Get a url from the previous filename in the loop
612              
613             sub get_url_previous {
614 5     5 0 25 my ($self, $filename, $loop) = @_;
615              
616 5         11 $filename = $self->find_filename(-1, $filename, $loop);
617 5 100       15 return $filename ? $self->get_url($filename) : '';
618             }
619              
620             #----------------------------------------------------------------------
621             # Return true if this is an included directory
622              
623             sub match_directory {
624 44     44 0 99 my ($self, $directory) = @_;
625              
626 44   66     197 $self->{exclude_dir_patterns} ||= fio_glob_patterns($self->{exclude_dirs});
627              
628 44 100       119 return if $self->match_patterns($directory, $self->{exclude_dir_patterns});
629 40         104 return 1;
630             }
631              
632             #----------------------------------------------------------------------
633             # Return true if this is an included file
634              
635             sub match_file {
636 400     400 0 768 my ($self, $filename) = @_;
637              
638 400         882 my ($dir, $file) = fio_split_filename($filename);
639              
640 400 100       1140 if ($self->{exclude_index}) {
641 120         281 my $index_file = join('.', 'index', $self->{web_extension});
642 120 100       392 return if $file eq $index_file;
643             }
644              
645 361         1164 my @patterns = map {"*.$_"} split(/\s*,\s*/, $self->{extension});
  415         1349  
646 361         774 my $patterns = join(',', @patterns);
647              
648 361   66     986 $self->{include_file_patterns} ||= fio_glob_patterns($patterns);
649 361   66     885 $self->{exclude_file_patterns} ||= fio_glob_patterns($self->{exclude});
650              
651 361 100       964 return if $self->match_patterns($file, $self->{exclude_file_patterns});
652 352 100       664 return unless $self->match_patterns($file, $self->{include_file_patterns});
653 213         806 return 1;
654             }
655              
656             #----------------------------------------------------------------------
657             # Return true if filename matches pattern
658              
659             sub match_patterns {
660 766     766 0 1430 my ($self, $file, $patterns) = @_;
661              
662 766         1538 my @path = splitdir($file);
663 766         3284 $file = pop(@path);
664              
665 766         1385 foreach my $pattern (@$patterns) {
666 477 100       4063 return 1 if $file =~ /$pattern/;
667             }
668              
669 540         1512 return;
670             }
671              
672             #----------------------------------------------------------------------
673             # Initialize the configuration parameters
674              
675             sub setup {
676 91     91 1 207 my ($self) = @_;
677              
678             # Set filename extension if unset
679 91   66     639 $self->{extension} ||= $self->{web_extension};
680              
681             # Remove any trailing slash from urls
682 91         234 foreach my $url (qw(remote_url site_url)) {
683 182 100       429 next unless $self->{$url};
684 23         53 $self->{$url} =~ s/\/$//;
685             }
686              
687 91         175 return;
688             }
689              
690             1;
691              
692             =pod
693              
694             =encoding utf-8
695              
696             =head1 NAME
697              
698             App::Followme::FolderData - Build metadata from folder information
699              
700             =head1 SYNOPSIS
701              
702             use Cwd;
703             use App::Followme::FolderData;
704             my $directory = getcwd();
705             my $data = App::Followme::FolderData->new();
706             my $filenames = $data->get_files($directory);
707             foreach my $filename (@$filenames) {
708             print "$filename\n";
709             }
710              
711             =head1 DESCRIPTION
712              
713             This module contains the methods that build metadata values that can be computed
714             from properties of the file system, that is, without opening a file or
715             without regard to the type of file. It serves as the base of all the metadata
716             classes that build metadata for specific file types.
717              
718             =head1 METHODS
719              
720             All data are accessed through the build method.
721              
722             =over 4
723              
724             =item my %data = $obj->build($name, $filename);
725              
726             Build a variable's value. The first argument is the name of the variable. The
727             second argument is the name of the file the metadata is being computed for. If
728             it is undefined, the filename in the object
729             is used.
730              
731             =back
732              
733             =head1 VARIABLES
734              
735             The folder metadata class can evaluate the following variables. When passing
736             a name to the build method, the sigil should not be used.
737              
738             =over 4
739              
740             =item @all_files
741              
742             A list of matching files in a directory and its subdirectories.
743              
744             =item @top_files
745              
746             A list of the most recently created files in a directory and its
747             subdirectory. The length of the list is determined by the
748             configuration parameter list_length.
749              
750             =item @breadcrumbs
751              
752             A list of breadcrumb filenames, which are the names of the index files
753             above the filename passed as the argument.
754              
755             =item @related_files
756              
757             A list of files with the same file root name as a specified file. This
758             list is not filtered by the configuration variables extension and exclude.
759              
760             =item @files
761              
762             A list of matching files in a directory.
763              
764             =item @folders
765              
766             A list of folders under the default folder that contain an index file.
767              
768             =item $author
769              
770             The name of the author of a file
771              
772             =item $absolute_url
773              
774             The absolute url of a web page from a filename.
775              
776             =item $date
777              
778             A date string built from the creation date of the file. The date is
779             built using the template in date_format which contains the fields:
780             C<weekday, month,day, year, hour, minute,> and C<second.>
781              
782             =item $mdate
783              
784             A date string built from the modification date of the file. The date is
785             built using the template in date_format which contains the fields:
786             C<weekday, month,day, year, hour, minute,> and C<second.>
787              
788             =item $is_current
789              
790             One if the filename matches the default filename, zero if it does not.
791              
792             =item $is_index
793              
794             One of the filename is an index file and zero if it is not.
795              
796             =item $keywords
797              
798             A list of keywords describing the file from the filename path.
799              
800             =item $remote_url
801              
802             The remote url of a web page from a filename.
803              
804             =item $site_url
805              
806             The url of the website. Does not have a trailing slash
807              
808             =item $index_url
809              
810             The url of the index page in the same folder as a file.
811              
812             =item $title
813              
814             The title of a file is derived from the file name by removing the filename
815             extension, removing any leading digits,replacing dashes with spaces, and
816             capitalizing the first character of each word.
817              
818             =item $url
819              
820             Build the relative url of a web page from a filename.
821              
822             =item $url_base
823              
824             Build the relative url of a filename minus any extension and trailing dot
825              
826             =item $extension
827              
828             The extension of a filename.
829              
830             =item $url_next
831              
832             Build the relative url of a web page from the next filename in the loop
833             sequence. Empty string if there is no next filename.
834              
835             =item $url_previous
836              
837             Build the relative url of a web page from the previous filename in the loop
838             sequence. Empty string if there is no previous filename.
839              
840             =back
841              
842             =head1 CONFIGURATION
843              
844             The following fields in the configuration file are used in this class and every
845             class based on it:
846              
847             =over 4
848              
849             =item filename
850              
851             The filename used to retrieve metatdata from if no filename is passed to the
852             build method.
853              
854             =item directory
855              
856             The directory used to retrieve metadata. This is used by list valued variables.
857              
858             =item extension
859              
860             A comma separated list of extensions of files to include in a list of files.
861             If it is left empty, it is set to the web extension.
862              
863             =item date_format
864              
865             The format used to produce date strings. The format is described in the
866             POD for Time::Format.
867              
868             =item remote_url
869              
870             The url of the remote website, e.g. http://www.cloudhost.com.
871              
872             =item site_url
873              
874             The url of the local website, e.g. http://www.example.com.
875              
876             =item sort_numeric
877              
878             If one, use numeric comparisons when sorting. If zero, use string comparisons
879             when sorting.
880              
881             =item exclude_index
882              
883             If the value of this variable is true (1) exclude the index page in the list
884             of files. If it is false (0) include the index page. The default value is 0.
885              
886             =item exclude
887              
888             The files to exclude when traversing the list of files. Leave as a zero length
889             string if there are no files to exclude.
890              
891             =item exclude_dirs
892              
893             The directories excluded while traversing the list of directories. The default
894             value of this parameter is '.*,_*',
895              
896             =item web_extension
897              
898             The extension used by web pages. This controls which files are returned. The
899             default value is 'html'.
900              
901             =back
902              
903             =head1 LICENSE
904              
905             Copyright (C) Bernie Simon.
906              
907             This library is free software; you can redistribute it and/or modify
908             it under the same terms as Perl itself.
909              
910             =head1 AUTHOR
911              
912             Bernie Simon E<lt>bernie.simon@gmail.comE<gt>
913              
914             =cut