1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
Origin: 7debf8b5eda2ad917af8ccb06f987a1ce8cb14cd Mon Sep 17 00:00:00 2001
From: Don Armstrong <don@donarmstrong.com>
Last-Update: 2017-11-02
Bug-Debian: https://bugs.debian.org/770687
Subject: add updates for -4
git-svn-id: file:///srv/don_svn/deb_pkgs/libapache-gallery-perl/trunk@727 8f7917da-ec0b-0410-a553-b9b0e350d17e
---
debian/changelog | 7 +++++
lib/Apache/Gallery.pm | 72 ++++++++++++++++++++++---------------------
t/004_cache_dir.t | 8 ++---
3 files changed, 48 insertions(+), 39 deletions(-)
diff --git a/lib/Apache/Gallery.pm b/lib/Apache/Gallery.pm
index 10b4381..b4575be 100644
--- a/lib/Apache/Gallery.pm
+++ b/lib/Apache/Gallery.pm
@@ -121,10 +121,11 @@ sub handler {
# 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
@@ -148,32 +149,8 @@ sub handler {
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();
- }
}
@@ -189,8 +166,7 @@ sub handler {
unless ($doc_pattern) {
$doc_pattern = '\.(mpe?g|avi|mov|asf|wmv|doc|mp3|mp4|ogg|pdf|rtf|wav|dlt|txt|html?|csv|eps)$'
}
- my $img_pattern = $r->dir_config('GalleryImgFile');
- unless ($img_pattern) {
+ my $img_pattern = $r->dir_config('GalleryImgFile') unless ($img_pattern) {
$img_pattern = '\.(jpe?g|png|tiff?|ppm)$'
}
@@ -852,6 +828,35 @@ sub handler {
}
+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) = @_;
@@ -1833,10 +1838,7 @@ Pattern matching the files you want Apache::Gallery to view in the index
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>
diff --git a/t/004_cache_dir.t b/t/004_cache_dir.t
index 4998b3c..d3dfa3b 100644
--- a/t/004_cache_dir.t
+++ b/t/004_cache_dir.t
@@ -42,12 +42,12 @@ sub request {
}
my $r=request(undef, 1);
-is(Apache::Gallery::cache_dir($r, 1), '/var/tmp/Apache-Gallery/hostname/uripath1/uripath2');
-is(Apache::Gallery::cache_dir($r, 0), '/var/tmp/Apache-Gallery/hostname/uripath1/uripath2/urifile');
+is(Apache::Gallery::cache_dir($r, 1), '/var/cache/www/hostname/uripath1/uripath2');
+is(Apache::Gallery::cache_dir($r, 0), '/var/cache/www/hostname/uripath1/uripath2/urifile');
$r=request(undef, 0);
-is(Apache::Gallery::cache_dir($r, 1), '/var/tmp/Apache-Gallery/location/uripath1/uripath2');
-is(Apache::Gallery::cache_dir($r, 0), '/var/tmp/Apache-Gallery/location/uripath1/uripath2/urifile');
+is(Apache::Gallery::cache_dir($r, 1), '/var/cache/www/location/uripath1/uripath2');
+is(Apache::Gallery::cache_dir($r, 0), '/var/cache/www/location/uripath1/uripath2/urifile');
$r=request('t/cachetest', 1);
is(Apache::Gallery::cache_dir($r, 1), 't/cachetest/uripath1/uripath2');
|