4cccf49fd3
Remove some HTML output from the code that should be controlled only by the templates (' ' when no navigation, extra '<br>' elements). Add controls for directory separator in menus and the text labels for the navigation elements.
362 lines
11 KiB
Text
362 lines
11 KiB
Text
$NetBSD: patch-aa,v 1.7 2006/04/16 14:19:25 kim Exp $
|
|
|
|
--- lib/Apache/Gallery.pm.orig 2004-09-12 00:53:05.000000000 +0300
|
|
+++ lib/Apache/Gallery.pm 2006-04-16 16:43:43.000000000 +0300
|
|
@@ -13,22 +13,22 @@
|
|
|
|
eval('require mod_perl;');
|
|
if ( $@ ) {
|
|
- require Apache2::mod_perl;
|
|
+ require mod_perl2;
|
|
}
|
|
|
|
$::MP2 = ($mod_perl::VERSION >= 1.99);
|
|
|
|
if ($::MP2) {
|
|
- require Apache2;
|
|
- require Apache::Server;
|
|
- require Apache::RequestRec;
|
|
- require Apache::Log;
|
|
+ #require Apache2;
|
|
+ #require Apache2::Server;
|
|
+ require Apache2::RequestRec;
|
|
+ require Apache2::Log;
|
|
require APR::Table;
|
|
- require Apache::RequestIO;
|
|
- require Apache::SubRequest;
|
|
- require Apache::Const;
|
|
+ require Apache2::RequestIO;
|
|
+ require Apache2::SubRequest;
|
|
+ require Apache2::Const;
|
|
|
|
- Apache::Const->import(-compile => 'OK','DECLINED','FORBIDDEN','NOT_FOUND');
|
|
+ Apache2::Const->import(-compile => 'OK','DECLINED','FORBIDDEN','NOT_FOUND');
|
|
|
|
}
|
|
else {
|
|
@@ -84,10 +84,10 @@
|
|
}
|
|
|
|
if (-f $filename or -d $filename) {
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
else {
|
|
- return $::MP2 ? Apache::NOT_FOUND() : Apache::Constants::NOT_FOUND();
|
|
+ return $::MP2 ? Apache2::Const::NOT_FOUND() : Apache::Constants::NOT_FOUND();
|
|
}
|
|
}
|
|
|
|
@@ -105,7 +105,7 @@
|
|
}
|
|
|
|
$r->print($content);
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
|
|
# Selectmode providing checkboxes beside all thumbnails
|
|
@@ -113,7 +113,7 @@
|
|
|
|
# Let Apache serve icons without us modifying the request
|
|
if ($r->uri =~ m/^\/icons/i) {
|
|
- return $::MP2 ? Apache::DECLINED() : Apache::Constants::DECLINED();
|
|
+ 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
|
|
@@ -142,7 +142,7 @@
|
|
|
|
if ($::MP2) {
|
|
$r->sendfile($file);
|
|
- return Apache::OK();
|
|
+ return Apache2::Const::OK();
|
|
}
|
|
else {
|
|
$r->path_info('');
|
|
@@ -157,7 +157,7 @@
|
|
|
|
unless (-f $filename or -d $filename) {
|
|
show_error($r, 404, "404!", "No such file or directory: ".uri_escape($r->uri, $escape_rule));
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
|
|
my $doc_pattern = $r->dir_config('GalleryDocFile');
|
|
@@ -171,14 +171,14 @@
|
|
|
|
# Let Apache serve files we don't know how to handle anyway
|
|
if (-f $filename && $filename !~ m/$img_pattern/i) {
|
|
- return $::MP2 ? Apache::DECLINED() : Apache::Constants::DECLINED();
|
|
+ return $::MP2 ? Apache2::Const::DECLINED() : Apache::Constants::DECLINED();
|
|
}
|
|
|
|
if (-d $filename) {
|
|
|
|
unless (-d cache_dir($r, 0)) {
|
|
unless (create_cache($r, cache_dir($r, 0))) {
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
}
|
|
|
|
@@ -198,7 +198,7 @@
|
|
|
|
unless (opendir (DIR, $filename)) {
|
|
show_error ($r, 500, $!, "Unable to access directory $filename: $!");
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
|
|
$tpl_vars{MENU} = generate_menu($r);
|
|
@@ -253,9 +253,28 @@
|
|
|
|
# Combine directories and files to one listing
|
|
my @listing;
|
|
- push (@listing, @directories);
|
|
- push (@listing, @files);
|
|
- push (@listing, @downloadable_files);
|
|
+ if (!defined($r->dir_config('GallerySortReverse'))
|
|
+ || $r->dir_config('GallerySortReverse') eq '0') {
|
|
+ push (@listing, @directories);
|
|
+ push (@listing, @files);
|
|
+ push (@listing, @downloadable_files);
|
|
+ } else {
|
|
+ if ($r->dir_config('GallerySortReverse') & 1) {
|
|
+ push (@listing, reverse @directories);
|
|
+ } else {
|
|
+ push (@listing, @directories);
|
|
+ }
|
|
+ if ($r->dir_config('GallerySortReverse') & 2) {
|
|
+ push (@listing, reverse @files);
|
|
+ } else {
|
|
+ push (@listing, @files);
|
|
+ }
|
|
+ if ($r->dir_config('GallerySortReverse') & 4) {
|
|
+ push (@listing, reverse @downloadable_files);
|
|
+ } else {
|
|
+ push (@listing, @downloadable_files);
|
|
+ }
|
|
+ }
|
|
|
|
if (@listing) {
|
|
|
|
@@ -319,7 +338,7 @@
|
|
if (-d $thumbfilename) {
|
|
my $dirtitle = '';
|
|
if (-e $thumbfilename . ".folder") {
|
|
- $dirtitle = get_filecontent($thumbfilename . ".folder");
|
|
+ $dirtitle = get_filecontent($thumbfilename . ".folder", 1);
|
|
}
|
|
|
|
$dirtitle = $dirtitle ? $dirtitle : $file;
|
|
@@ -393,7 +412,7 @@
|
|
if (-f $topdir . '.comment') {
|
|
my $comment_ref = get_comment($topdir . '.comment');
|
|
my %comment_vars;
|
|
- $comment_vars{COMMENT} = $comment_ref->{COMMENT} . '<br>' if $comment_ref->{COMMENT};
|
|
+ $comment_vars{COMMENT} = $comment_ref->{COMMENT} if $comment_ref->{COMMENT};
|
|
$comment_vars{TITLE} = $comment_ref->{TITLE} if $comment_ref->{TITLE};
|
|
$tpl_vars{DIRCOMMENT} = fill_in_file($tpl_vars{comment},
|
|
HASH => \%comment_vars,
|
|
@@ -420,7 +439,7 @@
|
|
}
|
|
|
|
$r->print($tpl_vars{MAIN});
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
|
|
}
|
|
else {
|
|
@@ -429,9 +448,9 @@
|
|
if (defined($ENV{QUERY_STRING}) && $ENV{QUERY_STRING} eq 'orig') {
|
|
if ($r->dir_config('GalleryAllowOriginal') ? 1 : 0) {
|
|
$r->filename($filename);
|
|
- return $::MP2 ? Apache::DECLINED() : Apache::Constants::DECLINED();
|
|
+ return $::MP2 ? Apache2::Const::DECLINED() : Apache::Constants::DECLINED();
|
|
} else {
|
|
- return $::MP2 ? Apache::FORBIDDEN() : Apache::Constants::FORBIDDEN();
|
|
+ return $::MP2 ? Apache2::Const::FORBIDDEN() : Apache::Constants::FORBIDDEN();
|
|
}
|
|
}
|
|
|
|
@@ -443,7 +462,7 @@
|
|
|
|
unless (-d $cache_path) {
|
|
unless (create_cache($r, $cache_path)) {
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
}
|
|
|
|
@@ -465,7 +484,7 @@
|
|
if ($cgi->param('width')) {
|
|
unless ((grep $cgi->param('width') == $_, @sizes) or ($cgi->param('width') == $original_size)) {
|
|
show_error($r, 200, "Invalid width", "The specified width is invalid");
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
|
|
$width = $cgi->param('width');
|
|
@@ -534,7 +553,7 @@
|
|
|
|
unless (opendir(DATADIR, $path)) {
|
|
show_error($r, 500, "Unable to access directory", "Unable to access directory $path");
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
my @pictures = grep { /$img_pattern/i } readdir (DATADIR);
|
|
closedir(DATADIR);
|
|
@@ -542,6 +561,9 @@
|
|
|
|
$tpl_vars{TOTAL} = scalar @pictures;
|
|
|
|
+ my $prevtext = (defined($r->dir_config('GalleryPreviousText')) ? $r->dir_config('GalleryPreviousText') : '« prev' );
|
|
+ my $nexttext = (defined($r->dir_config('GalleryNextText')) ? $r->dir_config('GalleryNextText') : 'next »' );
|
|
+
|
|
my $prevpicture;
|
|
my $nextpicture;
|
|
|
|
@@ -567,13 +589,13 @@
|
|
$nav_vars{FILENAME} = $prevpicture;
|
|
$nav_vars{WIDTH} = $width;
|
|
$nav_vars{PICTURE} = uri_escape(".cache/$cached", $escape_rule);
|
|
- $nav_vars{DIRECTION} = "« prev";
|
|
+ $nav_vars{DIRECTION} = $prevtext;
|
|
$tpl_vars{BACK} = fill_in_file($tpl_vars{navpicture},
|
|
HASH => \%nav_vars,
|
|
);
|
|
}
|
|
else {
|
|
- $tpl_vars{BACK} = " ";
|
|
+ $tpl_vars{BACK} = '';
|
|
}
|
|
|
|
$nextpicture = $pictures[$i+1];
|
|
@@ -591,14 +613,14 @@
|
|
$nav_vars{FILENAME} = $nextpicture;
|
|
$nav_vars{WIDTH} = $width;
|
|
$nav_vars{PICTURE} = uri_escape(".cache/$cached", $escape_rule);
|
|
- $nav_vars{DIRECTION} = "next »";
|
|
+ $nav_vars{DIRECTION} = $nexttext;
|
|
|
|
$tpl_vars{NEXT} = fill_in_file($tpl_vars{navpicture},
|
|
HASH => \%nav_vars
|
|
);
|
|
}
|
|
else {
|
|
- $tpl_vars{NEXT} = " ";
|
|
+ $tpl_vars{NEXT} = '';
|
|
}
|
|
}
|
|
}
|
|
@@ -607,7 +629,7 @@
|
|
if (-f $path . '/' . $picfilename . '.comment') {
|
|
my $comment_ref = get_comment($path . '/' . $picfilename . '.comment');
|
|
$foundcomment = 1;
|
|
- $tpl_vars{COMMENT} = $comment_ref->{COMMENT} . '<br>' if $comment_ref->{COMMENT};
|
|
+ $tpl_vars{COMMENT} = $comment_ref->{COMMENT} if $comment_ref->{COMMENT};
|
|
$tpl_vars{TITLE} = $comment_ref->{TITLE} if $comment_ref->{TITLE};
|
|
} else {
|
|
$tpl_vars{COMMENT} = '';
|
|
@@ -749,7 +771,7 @@
|
|
|
|
unless ((grep $cgi->param('slideshow') == $_, @slideshow_intervals)) {
|
|
show_error($r, 200, "Invalid interval", "Invalid slideshow interval choosen");
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
}
|
|
|
|
$tpl_vars{URL} = uri_escape($nextpicture, $escape_rule);
|
|
@@ -781,7 +803,7 @@
|
|
}
|
|
|
|
$r->print($tpl_vars{MAIN});
|
|
- return $::MP2 ? Apache::OK() : Apache::Constants::OK();
|
|
+ return $::MP2 ? Apache2::Const::OK() : Apache::Constants::OK();
|
|
|
|
}
|
|
|
|
@@ -1040,7 +1062,7 @@
|
|
}
|
|
}
|
|
elsif (ref($element) eq 'HASH') {
|
|
- $value .= "<br>{ ";
|
|
+ $value .= " { ";
|
|
foreach (sort keys %{$element}) {
|
|
$value .= "$_ = " . $element->{$_} . ' ';
|
|
}
|
|
@@ -1226,6 +1248,7 @@
|
|
|
|
sub get_filecontent {
|
|
my $file = shift;
|
|
+ my $fold = shift;
|
|
open(FH, $file) or return undef;
|
|
my $content = '';
|
|
{
|
|
@@ -1233,6 +1256,8 @@
|
|
$content = <FH>;
|
|
}
|
|
close(FH);
|
|
+ chomp($content);
|
|
+ $content =~ s/\n/<br \/>\n/g if $fold;
|
|
return $content;
|
|
}
|
|
|
|
@@ -1252,7 +1277,6 @@
|
|
}
|
|
|
|
while (<FH>) {
|
|
- chomp;
|
|
$comment_ref->{COMMENT} .= $_;
|
|
}
|
|
close(FH);
|
|
@@ -1319,6 +1343,8 @@
|
|
return qq{ <a href="/">$root_text</a> };
|
|
}
|
|
|
|
+ my $delim = (defined($r->dir_config('GalleryMenuSeparator')) ? $r->dir_config('GalleryMenuSeparator') : ' / ' );
|
|
+
|
|
my $menu;
|
|
my $menuurl;
|
|
foreach my $link (@links) {
|
|
@@ -1326,23 +1352,26 @@
|
|
$menuurl .= $link."/";
|
|
my $linktext = $link;
|
|
unless (length($link)) {
|
|
- $linktext = "$root_text ";
|
|
+ $linktext = $root_text;
|
|
}
|
|
else {
|
|
|
|
$dirname = File::Spec->catdir($dirname, $link);
|
|
|
|
if (-e $dirname . ".folder") {
|
|
- $linktext = get_filecontent($dirname . ".folder");
|
|
+ $linktext = get_filecontent($dirname . ".folder", 0);
|
|
}
|
|
}
|
|
|
|
- $menu .= "<a href=\"".uri_escape($menuurl, $escape_rule)."\">$linktext</a> / ";
|
|
+ if (length($menu)) {
|
|
+ $menu .= $delim;
|
|
+ }
|
|
+ $menu .= '<a href="' . uri_escape($menuurl, $escape_rule) . '">' . $linktext . '</a>';
|
|
|
|
}
|
|
|
|
if (-f $filename) {
|
|
- $menu .= $picturename;
|
|
+ $menu .= $delim . $picturename;
|
|
}
|
|
else {
|
|
|
|
@@ -1752,7 +1781,7 @@
|
|
Example:
|
|
|
|
TITLE: This is the new title of the page
|
|
- And this is the comment.<br>
|
|
+ And this is the comment.<br />
|
|
And this is line two of the comment.
|
|
|
|
The visible name of the folder is by default identical to the name of
|