Mail Index
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ApacheGallery] more filetype patch
On Thursday 11 December 2003 20:44, Guillaume Rousse wrote:
> Heelo.
>
> Attached is a patch for more configurable filetype selection with A::G.
Here is a better one, with modifications to templates, perl module, README and
INSTALL files.
Note that I didn't included additional mimetype icons, you have to do it
manually.
--
Don't get mad, get even
-- Sad Truths of Life n°14
diff -Naur Apache-Gallery-0.7/INSTALL Apache-Gallery-0.7.new/INSTALL
--- Apache-Gallery-0.7/INSTALL 2003-09-08 22:36:24.000000000 +0200
+++ Apache-Gallery-0.7.new/INSTALL 2003-12-13 16:58:13.000000000 +0100
@@ -88,8 +88,8 @@
by mod_autoindex.
Copy the files from templates/ to where you pointed GalleryTemplateDir to,
-copy htdocs/folder.png and htdocs/video-*.png to your Apache icons
-directory and copy htdocs/gallery.css to the DocumentRoot of your gallery.
+copy htdocs directory as gallery folder in your Apache icons directory and copy
+htdocs/gallery.css to the DocumentRoot of your gallery.
It is possible to include a graphical copyright notice on each picture now.
By setting the GalleryCopyrightImage PerlSetVar you can define the path
diff -Naur Apache-Gallery-0.7/lib/Apache/Gallery.pm Apache-Gallery-0.7.new/lib/Apache/Gallery.pm
--- Apache-Gallery-0.7/lib/Apache/Gallery.pm 2003-09-07 19:28:42.000000000 +0200
+++ Apache-Gallery-0.7.new/lib/Apache/Gallery.pm 2003-12-13 16:45:51.000000000 +0100
@@ -58,6 +58,8 @@
sub handler {
my $r = shift or Apache->request();
+ my $doc_pattern = $r->dir_config('GalleryDocFile');
+ my $img_pattern = $r->dir_config('GalleryImgFile');
if ((not $memoized) and ($r->dir_config('GalleryMemoize'))) {
require Memoize;
@@ -130,7 +132,7 @@
}
# Let Apache serve files we don't know how to handle anyway
- if (-f $filename && $filename !~ m/\.(?:jpe?g|png|tiff?|ppm)$/i) {
+ if (-f $filename && $filename !~ m/$img_pattern/i) {
return MP2 ? Apache::DECLINED : Apache::Constants::DECLINED;
}
@@ -186,11 +188,12 @@
my $file = $topdir."/".$picture;
- if ($file =~ m/\.(mpe?g|mov|avi|asf|wmv|wav|rtf|pdf|ogg|mp3|doc)$/i) {
+ if ($file =~ /$doc_pattern/i) {
push (@downloadable_files, $picture);
+
}
- if ($file =~ m/\.(?:jpe?g|png|tiff?|ppm)$/i) {
+ if ($file =~ /$img_pattern/i) {
push (@new_files, $picture);
}
@@ -279,17 +282,22 @@
$tpl->parse(FILES => '.directory');
}
- elsif (-f $thumbfilename && $thumbfilename =~ m/\.(mpe?g|avi|mov|asf|wmv|doc|mp3|ogg|pdf|rtf|wav)$/i) {
+ elsif (-f $thumbfilename && $thumbfilename =~ /$doc_pattern/i) {
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";
- }
- else {
- $filetype = "application";
+ $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|pdf|rtf|csv|eps)$/i) {
+ $filetype = "application-$type";
+ } else {
+ $filetype = "unknown";
}
$tpl->assign(FILEURL => uri_escape($fileurl, $escape_rule),
@@ -306,7 +314,7 @@
my ($width, $height, $type) = imgsize($thumbfilename);
next if $type eq 'Data stream is not a known image file format';
- my @filetypes = qw(JPG TIF PNG PPM);
+ my @filetypes = qw(JPG TIF PNG PPM GIF);
next unless (grep $type eq $_, @filetypes);
my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $width, $height);
@@ -459,7 +467,7 @@
show_error($r, 500, "Unable to access directory", "Unable to access directory $path");
return MP2 ? Apache::OK : Apache::Constants::OK;
}
- my @pictures = grep { /^[^.].*\.(jpe?g|png|ppm|tiff?)$/i } readdir (DATADIR);
+ my @pictures = grep { /$img_pattern/i } readdir (DATADIR);
closedir(DATADIR);
@pictures = sort @pictures;
@@ -737,7 +745,7 @@
my $scale = 1;
my $newfilename;
- if (grep $type eq $_, qw(PPM TIF)) {
+ if (grep $type eq $_, qw(PPM TIF GIF)) {
$newfilename = $width."x".$height."-".$filename;
# needs to be configurable
$newfilename =~ s/\.(\w+)$/-$1\.jpg/;
@@ -821,7 +829,7 @@
if ($type eq 'Data stream is not a known image file format') {
# should never be reached, this is supposed to be handled outside of here
Apache->request->log_error("Something was fishy with the type of the file $file\n");
- } elsif (grep $type eq $_, qw(PPM TIF PNG)) {
+ } elsif (grep $type eq $_, qw(PPM TIF PNG GIF)) {
# These files do not natively have EXIF info embedded in the file
my $tmpfilename = $file;
# We have a problem with Windows based file extensions here as they are often .THM
diff -Naur Apache-Gallery-0.7/README Apache-Gallery-0.7.new/README
--- Apache-Gallery-0.7/README 2003-09-07 16:40:40.000000000 +0200
+++ Apache-Gallery-0.7.new/README 2003-12-13 16:56:48.000000000 +0100
@@ -135,6 +135,12 @@
Change the name that appears as the root element in the menu. The
default is "root:"
+ GalleryDocFile
+ Pattern matching the files you want Apache::Gallery to serve as normal files.
+
+ GalleryImgFile
+ Pattern matching the files you want Apache::Gallery to serve as images.
+
FEATURES
Rotate images
Some cameras, like the Canon G3, detects the orientation of a
diff -Naur Apache-Gallery-0.7/templates/default/directory.tpl Apache-Gallery-0.7.new/templates/default/directory.tpl
--- Apache-Gallery-0.7/templates/default/directory.tpl 2003-08-09 13:15:32.000000000 +0200
+++ Apache-Gallery-0.7.new/templates/default/directory.tpl 2003-12-13 16:46:49.000000000 +0100
@@ -1 +1 @@
- <div id="folder"><a href="$FILEURL/"><img border="0" src="/icons/folder.png"><br>$FILE</a></div>
+ <div id="folder"><a href="$FILEURL/"><img border="0" src="/icons/gallery/folder.png"><br>$FILE</a></div>
diff -Naur Apache-Gallery-0.7/templates/default/file.tpl Apache-Gallery-0.7.new/templates/default/file.tpl
--- Apache-Gallery-0.7/templates/default/file.tpl 2003-08-09 13:15:32.000000000 +0200
+++ Apache-Gallery-0.7.new/templates/default/file.tpl 2003-12-13 16:46:49.000000000 +0100
@@ -1 +1 @@
- <div id="folder"><a href="$FILEURL"><img border="0" alt="$ALT" src="/icons/$FILETYPE-$TYPE.png"><br>$FILE</a></div>
+ <div id="folder"><a href="$FILEURL"><img border="0" alt="$ALT" src="/icons/gallery/$FILETYPE.png"><br>$FILE</a></div>
diff -Naur Apache-Gallery-0.7/templates/new/directory.tpl Apache-Gallery-0.7.new/templates/new/directory.tpl
--- Apache-Gallery-0.7/templates/new/directory.tpl 2003-09-07 19:32:40.000000000 +0200
+++ Apache-Gallery-0.7.new/templates/new/directory.tpl 2003-12-13 16:46:49.000000000 +0100
@@ -1 +1 @@
- <div class="folder"><a href="$FILEURL/"><img src="/icons/agfolder.png" alt="* $FILE"><br>$FILE</a></div>
+ <div class="folder"><a href="$FILEURL/"><img src="/icons/gallery/folder.png" alt="* $FILE"><br>$FILE</a></div>
diff -Naur Apache-Gallery-0.7/templates/new/file.tpl Apache-Gallery-0.7.new/templates/new/file.tpl
--- Apache-Gallery-0.7/templates/new/file.tpl 2003-08-09 13:14:37.000000000 +0200
+++ Apache-Gallery-0.7.new/templates/new/file.tpl 2003-12-13 16:46:49.000000000 +0100
@@ -1 +1 @@
- <div class="folder"><a href="$FILEURL"><img border="0" alt="$ALT" src="/icons/$FILETYPE-$TYPE.png"><br>$FILE</a></div>
+ <div class="folder"><a href="$FILEURL"><img border="0" alt="$ALT" src="/icons/gallery/$FILETYPE.png"><br>$FILE</a></div>