require Apache2::SubRequest;
require Apache2::Const;
- Apache2::Const->import(-compile => 'OK','DECLINED','FORBIDDEN','NOT_FOUND','HTTP_NOT_MODIFIED');
+ Apache2::Const->import(-compile => 'OK','DECLINED','FORBIDDEN',
+ 'NOT_FOUND','HTTP_NOT_MODIFIED', 'REDIRECT');
$::MP2 = 1;
} else {
# Let Apache serve icons without us modifying the request
if ($r->uri =~ m/^\/icons/i) {
if ($r->uri =~ m/^\/icons\/gallery\/([^\/]+$)/i) {
- $filename = "/usr/share/libapache-gallery-perl/icons/$filename";
- $r->filename($filename);
- }
- return $::MP2 ? Apache2::Const::DECLINED() : Apache::Constants::DECLINED();
+ $filename = "/usr/share/libapache-gallery-perl/icons/$1";
+ return send_file($r,$filename);
+ } else {
+ return $::MP2 ? Apache2::Const::DECLINED() : Apache::Constants::DECLINED();
+ }
}
# Lookup the file in the cache and scale the image if the cached
# image does not exist
my $file = cache_dir($r, 0);
$file =~ s/\.cache//;
- my $subr = $r->lookup_file($file);
- $r->content_type($subr->content_type());
+ return send_file($r,$file);
- 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();
- }
-
- $r->headers_out->{"Content-Length"} = $fileinfo->size;
- $r->headers_out->{"Last-Modified-Date"} = time2str($fileinfo->mtime);
- $r->headers_out->{"ETag"} = $nonce;
- $r->sendfile($file);
- return Apache2::Const::OK();
- }
- else {
- $r->path_info('');
- $r->filename($file);
- return Apache::Constants::DECLINED();
- }
}
$filetype = "unknown";
}
- # Debian bug #348724 <http://bugs.debian.org/348724>
+ # Debian bug #337012 <http://bugs.debian.org/337012>
# not images
my $filetitle = $file;
+ if (-e $thumbfilename . ".file") {
+ $filetitle = get_filecontent($thumbfilename . ".file");
+ }
+
+ # Debian bug #348724 <http://bugs.debian.org/348724>
$filetitle =~ s/_/ /g if $r->dir_config('GalleryUnderscoresToSpaces');
$tpl_vars{FILES} .=
my $rotate = readfile_getnum($r, $imageinfo, $thumbfilename.".rotate");
- # Debian bug #348724 <http://bugs.debian.org/348724>
+ # Debian bug #337012 <http://bugs.debian.org/337012>
# HTML <img> tag, alt attribute
my $filetitle = $file;
+ if (-e $thumbfilename . ".file") {
+ $filetitle = get_filecontent($thumbfilename . ".file");
+ }
+
+ # Debian bug #348724 <http://bugs.debian.org/348724>
$filetitle =~ s/_/ /g if $r->dir_config('GalleryUnderscoresToSpaces');
my %file_vars = (FILEURL => uri_escape($fileurl, $escape_rule),
return $::MP2 ? Apache2::Const::FORBIDDEN() : Apache::Constants::FORBIDDEN();
}
}
+ if (defined $ENV{QUERY_STRING} && $ENV{QUERY_STRING} eq 'thumbonly' &&
+ $r->dir_config('GalleryAllowThumbonly') &&
+ -f $filename) {
+
+ my ($width, $height, $type) = imgsize($filename);
+ my @filetypes = qw(JPG TIF PNG PPM GIF);
+ if (grep $type eq $_, @filetypes) {
+ my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $width, $height);
+ my $imageinfo = get_imageinfo($r, $filename, $type, $width, $height);
+ my $cached = get_scaled_picture_name($filename, $thumbnailwidth, $thumbnailheight);
+ $r->headers_out->set(Location => uri_escape(".cache/$cached", $escape_rule));
+ return $::MP2 ? Apache2::Const::REDIRECT() : Apache::Constants::REDIRECT();
+ }
+ }
# Create cache dir if not existing
my @tmp = split (/\//, $filename);
my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $orig_width, $orig_height);
my $imageinfo = get_imageinfo($r, $path.$prevpicture, $type, $orig_width, $orig_height);
my $cached = get_scaled_picture_name($path.$prevpicture, $thumbnailwidth, $thumbnailheight);
+ # Debian bug #337012 <http://bugs.debian.org/337012>
+ my $prevpicture_title = $prevpicture;
+ if (-e $path."/".$prevpicture . ".file") {
+ $prevpicture_title = get_filecontent($path."/".$prevpicture . ".file");
+ }
my %nav_vars;
$nav_vars{URL} = uri_escape($prevpicture, $escape_rule);
- $nav_vars{FILENAME} = $prevpicture;
+ $nav_vars{FILENAME} = $prevpicture_title;
$nav_vars{WIDTH} = $width;
$nav_vars{PICTURE} = uri_escape(".cache/$cached", $escape_rule);
$nav_vars{DIRECTION} = "« <u>p</u>rev";
my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $orig_width, $orig_height);
my $imageinfo = get_imageinfo($r, $path.$nextpicture, $type, $thumbnailwidth, $thumbnailheight);
my $cached = get_scaled_picture_name($path.$nextpicture, $thumbnailwidth, $thumbnailheight);
+ # Debian bug #337012 <http://bugs.debian.org/337012>
+ my $nextpicture_title = $nextpicture;
+ if (-e $path."/".$nextpicture . ".file") {
+ $nextpicture_title = get_filecontent($path."/".$nextpicture . ".file");
+ }
my %nav_vars;
$nav_vars{URL} = uri_escape($nextpicture, $escape_rule);
- $nav_vars{FILENAME} = $nextpicture;
+ $nav_vars{FILENAME} = $nextpicture_title;
$nav_vars{WIDTH} = $width;
$nav_vars{PICTURE} = uri_escape(".cache/$cached", $escape_rule);
$nav_vars{DIRECTION} = "<u>n</u>ext »";
}
+sub send_file {
+ my ($r,$file) = @_;
+ 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();
+ }
+
+ $r->headers_out->{"Content-Length"} = $fileinfo->size;
+ $r->headers_out->{"Last-Modified-Date"} = time2str($fileinfo->mtime);
+ $r->headers_out->{"ETag"} = $nonce;
+ $r->sendfile($file);
+ return Apache2::Const::OK();
+ }
+ else {
+ $r->path_info('');
+ $r->filename($file);
+ return Apache::Constants::DECLINED();
+ }
+}
+
sub cache_dir {
my ($r, $strip_filename) = @_;
my $picturename;
if (-f $filename) {
$picturename = pop(@links);
+ # Debian bug #337012 <http://bugs.debian.org/337012>
+ if (-e $filename . ".file") {
+ $picturename = get_filecontent($filename . ".file");
+ }
}
if ($r->uri eq $root_path) {
Set to 1 or 0, default is 0
+=item B<GalleryAllowThumbOnly>
+
+If true, B<GalleryAllowThumbOnly> allows fooimg.jpg?thumbonly urls
+to output the thumbnail of the image. This is useful when including
+images in a blog (or similar).
+
+Defaults to '0' (false).
+
=item B<GallerySlideshowIntervals>
With this option you can configure which intervals can be selected for
as normal files. All other filetypes will still be served by Apache::Gallery
but are not visible in the index.
-The default is
-
- '\.(mpe?g|avi|mov|asf|wmv|doc|mp3|mp4
- |ogg|pdf|rtf|wav|dlt|txt|html?|csv|eps)$'
+The default is '\.(mpe?g|avi|mov|asf|wmv|doc|mp3|mp4|ogg|pdf|rtf|wav|dlt|txt|html?|csv|eps)$'
=item B<GalleryTTFDir>
the folder, but can be changed by creating a file <directory>.folder
with the visible name of the folder.
+Similarly, the visible name of any file is by default identical to the
+name of the file, but can be changed by creating a file <file>.file
+with the visible name of the file.
+
It is also possible to set GalleryCommentExifKey to the name of an EXIF
field containing the comment, e.g. ImageDescription. The EXIF comment is
overridden by the .comment file if it exists.