Apache-Gallery

 view release on metacpan or  search on metacpan

lib/Apache/Gallery.pm  view on Meta::CPAN

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
my $cached = scale_picture($r, $filename, $image_width, $image_height, $imageinfo);
 
my $file = cache_dir($r, 0);
$file =~ s/\.cache//;
 
my $subr = $r->lookup_file($file);
$r->content_type($subr->content_type());
 
if ($::MP2) {
        my $fileinfo = stat($file);
 
        my $nonce = md5_base64($fileinfo->ino.$fileinfo->mtime);
        if ($r->headers_in->{"If-None-Match"} eq $nonce) {
                return Apache2::Const::HTTP_NOT_MODIFIED();
        }
 
        if ($r->headers_in->{"If-Modified-Since"} && str2time($r->headers_in->{"If-Modified-Since"}) < $fileinfo->mtime) {
                return Apache2::Const::HTTP_NOT_MODIFIED();
        }

lib/Apache/Gallery.pm  view on Meta::CPAN

271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# Read and sort directories
rewinddir (DIR);
my @directories = grep { !/^\./ && -d "$filename/$_" } readdir (DIR);
my $dirsortby;
if (defined($r->dir_config('GalleryDirSortBy'))) {
        $dirsortby=$r->dir_config('GalleryDirSortBy');
} else {
        $dirsortby=$r->dir_config('GallerySortBy');
}
if ($dirsortby && $dirsortby =~ m/^(size|atime|mtime|ctime)$/) {
        @directories = map(/^\d+ (.*)/, sort map(stat("$filename/$_")->$dirsortby()." $_", @directories));
} else {
        @directories = sort @directories;
}
 
closedir(DIR);
 
 
# Combine directories and files to one listing
my @listing;
push (@listing, @directories);

lib/Apache/Gallery.pm  view on Meta::CPAN

364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
        $tpl_vars{FILES} .=
             $templates{directory}->fill_in(HASH=> {FILEURL => uri_escape($fileurl, $escape_rule),
                                                    FILE    => $dirtitle,
                                                   }
                                           );
 
}
# Debian bug #619625 <http://bugs.debian.org/619625>
elsif (-f $thumbfilename && $thumbfilename =~ /$doc_pattern/i && $thumbfilename !~ /$img_pattern/i && ! -e $thumbfilename . ".ignore") {
        my $type = lc($1);
        my $stat = stat($thumbfilename);
        my $size = $stat->size;
        my $filetype;
 
        if ($thumbfilename =~ m/\.(mpe?g|avi|mov|asf|wmv)$/i) {
                $filetype = "video-$type";
        } elsif ($thumbfilename =~ m/\.(txt|html?)$/i) {
                $filetype = "text-$type";
        } elsif ($thumbfilename =~ m/\.(mp3|ogg|wav)$/i) {
                $filetype = "sound-$type";
        } elsif ($thumbfilename =~ m/$doc_pattern/i) {

lib/Apache/Gallery.pm  view on Meta::CPAN

469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# Debian bug #619625 <http://bugs.debian.org/619625>
my @neighbour_directories = grep { !/^\./ && -d "$parent_filename/$_" && ! -e "$parent_filename/$_" . ".ignore" } readdir (PARENT_DIR);
my $dirsortby;
if (defined($r->dir_config('GalleryDirSortBy'))) {
        $dirsortby=$r->dir_config('GalleryDirSortBy');
} else {
        $dirsortby=$r->dir_config('GallerySortBy');
}
if ($dirsortby && $dirsortby =~ m/^(size|atime|mtime|ctime)$/) {
        @neighbour_directories = map(/^\d+ (.*)/, sort map(stat("$parent_filename/$_")->$dirsortby()." $_", @neighbour_directories));
} else {
        @neighbour_directories = sort @neighbour_directories;
}
 
closedir(PARENT_DIR);
 
my $neightbour_counter = 0;
foreach my $neighbour_directory (@neighbour_directories) {
        if ($parent_filename.'/'.$neighbour_directory eq $filename) {
                if ($neightbour_counter > 0) {

lib/Apache/Gallery.pm  view on Meta::CPAN

955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $orig_width, $orig_height);
 
# Do we want to generate a new file in the cache?
my $scale = 1;
 
if (-f $cache."/".$newfilename) {      
        $scale = 0;
 
        # Check to see if the image has changed
        my $filestat = stat($fullpath);
        my $cachestat = stat($cache."/".$newfilename);
        if ($filestat->mtime >= $cachestat->mtime) {
                $scale = 1;
        }      
 
        # Check to see if the .rotate file has been added or changed
        if (-f $fullpath . ".rotate") {
                my $rotatestat = stat($fullpath . ".rotate");
                if ($rotatestat->mtime > $cachestat->mtime) {
                        $scale = 1;
                }      
        }              
        # Check to see if the copyrightimage has been added or changed
        if ($r->dir_config('GalleryCopyrightImage') && -f $r->dir_config('GalleryCopyrightImage')) {
                unless ($width == $thumbnailwidth or $width == $thumbnailheight) {
                        my $copyrightstat = stat($r->dir_config('GalleryCopyrightImage'));
                        if ($copyrightstat->mtime > $cachestat->mtime) {
                                $scale = 1;
                        }      
                }
        }      
 
}      
 
if ($scale) {

lib/Apache/Gallery.pm  view on Meta::CPAN

1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
                                }
                        }
                        $imageinfo->{$human_key} = $value;
                }
        }
 
        if ($r->dir_config('GalleryUseFileDate') &&
                ($r->dir_config('GalleryUseFileDate') eq '1'
                || !$imageinfo->{"Picture Taken"} )) {
 
                my $st = stat($file);
                $imageinfo->{"DateTimeOriginal"} = $imageinfo->{"Picture Taken"} = scalar localtime($st->mtime) if $st;
        }
 
        return $imageinfo;
}
 
sub get_imageinfo_from_thm_file {
 
        my ($file, $width, $height) = @_;

lib/Apache/Gallery.pm  view on Meta::CPAN

1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
}
 
sub gallerysort {
        my $r=shift;
        my @files=@_;
        my $sortby = $r->dir_config('GallerySortBy');
        my $filename=$r->lookup_uri($r->uri)->filename;
        $filename=(File::Spec->splitpath($filename))[1] if (-f $filename);
        if ($sortby && $sortby =~ m/^(size|atime|mtime|ctime)$/) {
                @files = map(/^\d+ (.*)/, sort map(stat("$filename/$_")->$sortby()." $_", @files));
        } else {
                @files = sort @files;
        }
        return @files;
}
 
# Create Text::Template objects used by Apache::Gallery. Takes a
# hashref of template_name, template_filename pairs, and returns a
# list of template_name, texttemplate_object pairs.
sub create_templates {



( run in 1.005 second using v1.01-cache-2.11-cpan-49f99fa48dc )