Apache-AutoIndex
view release on metacpan or search on metacpan
AutoIndex.pm view on Meta::CPAN
$list{$file}{sizenice} =~ s/\s*//;
}
$list{$file}{mod} = (stat _)[9];
$list{$file}{modnice} = ht_time($list{$file}{mod}, "%d-%b-%Y %H:%M", 0);
$list{$file}{modnice} =~ s/\s/ /g;
$list{$file}{mode} = write_mod((stat _)[2]);
$list{$file}{type} = $subr->content_type;
if(($list{$file}{type} =~ m:^image/:) && ($cfg->{options} & THUMBNAILS ) && Apache->module("Image::Magick"))
{
if ($config->{cache_ok}){
($list{$file}{icon},$list{$file}{width},$list{$file}{height}) = get_thumbnail($r, $file, $list{$file}{mod}, $list{$file}{type}, @accept);
}
}
$list{$file}{height} ||= $cfg->{icon_height};
$list{$file}{width} ||= $cfg->{icon_width};
#icons size might be calculated on the fly and cached...
my $icon = Apache::Icon->new($subr);
AutoIndex.pm view on Meta::CPAN
sub get_thumbnail {
my ($r, $filename, $mod, $content, @accept) = @_;
my $accept = join('|', @accept);
my $dir = $r->filename;
#these should sound better.
my $cachedir = $config->{cache_dir};
my $xresize;
my $yresize;
my $img = Image::Magick->new;
my($imgx, $imgy, $img_size, $img_type) = split(',', $img->Ping($dir . $filename));
#Is the image OK?
return "/icons/broken.gif" unless ($imgx && $imgy);
if (($content =~ /$content/) && ($img_type =~ /JPE?G|GIF|PNG/i)){
#We know that what we'll generate will be seen.
if ($dir =~ /$cachedir\/$/){
#Avoiding recursive thumbnails from Hell
return $filename, $imgx, $imgy
}
AutoIndex.pm view on Meta::CPAN
__END__
=head1 NAME
Apache::AutoIndex - Perl replacment for mod_autoindex and mod_dir Apache module
=head1 SYNOPSIS
PerlModule Apache::Icon
PerlModule Apache::AutoIndex
(PerlModule Image::Magick) optionnal
PerlTransHandler Apache::AutoIndex::transhandler
PerlHandler Apache::AutoIndex
=head1 DESCRIPTION
This module can replace completely mod_dir and mod_autoindex
standard directory handling modules shipped with apache.
It can currently live right on top of those modules, but I suggest
simply making a new httpd without these modules compiled-in.
AutoIndex.pm view on Meta::CPAN
For each directory containing pictures, there will be a .thumbnails directory in it that will
hold the thumbnails. Each time the directory is accessed, and if thumbnail generation is
active, small thumbnails will be produced, shown beside each image name, instaed of the normal
, generic, image icon.
That can be done in 2 ways. In the case the image is pretty small, no actual thumbnail will
be created. Instead the image will be resized with the HEIGHT and WIDTH attributes of the IMG
tag.
If the image is big enough, it is resized with Image::Magick and saved in the .thumbnails directory
for the next requests.
Change in the configuration of the indexing options will correctly refresh the thumbnails stored.
Also if an original image is modified, the thumbnail will be modified accordingly. Still, the
browser might screw things up if it preserves the cached images.
The behaviour of the Thumbnail generating code can be customized with these PerlSetVar variables:
=head2 DIRECTIVES
AutoIndex.pm view on Meta::CPAN
Some minor changes to the thumbnails options will still have the thumbnails re-generated. This
should be avoided by checking the attributes of the already existing thumbnail.
Some form of garbage collection should be performed or cache directories will fill up.
Find new things to add...
=head1 SEE ALSO
perl(1), L<Apache>(3), L<Apache::Icon>(3), L<Image::Magick>(3) .
=head1 SUPPORT
Please send any questions or comments to the Apache modperl
mailing list <modperl@apache.org> or to me at <gozer@ectoplasm.dyndns.com>
=head1 NOTES
This code was made possible by :
NAME
Apache::AutoIndex - Perl replacment for mod_autoindex and
mod_dir Apache module
SYNOPSIS
PerlModule Apache::Icon
PerlModule Apache::AutoIndex
(PerlModule Image::Magick) optionnal
PerlTransHandler Apache::AutoIndex::transhandler
PerlHandler Apache::AutoIndex
DESCRIPTION
This module can replace completely mod_dir and mod_autoindex
standard directory handling modules shipped with apache. It can
currently live right on top of those modules, but I suggest
simply making a new httpd without these modules compiled-in.
To start using it on your site right away, simply preload
( run in 0.314 second using v1.01-cache-2.11-cpan-beeb90c9504 )