--- okuchuu/piclist.ja.cgi 2005/02/26 04:15:33 1.5
+++ okuchuu/piclist.ja.cgi 2007/11/22 12:50:09 1.8
@@ -8,14 +8,12 @@
=cut
-unless ($main::ENV{PATH_TRANSLATED}) {
- die "BAD PATH_TRANSLATED";
-}
+my $dir = $main::ENV{PATH_TRANSLATED}
+ or die "BAD PATH_TRANSLATED: $ENV{PATH_TRANSLATED}";
my %Opt;
-my $dir = $main::ENV{PATH_TRANSLATED};
-if ($dir =~ s#/LIST$##) {
+if ($dir =~ s#/[^/]+$##) {
for (split /[&;]/, $ENV{QUERY_STRING}) {
my ($name, $val) = split /=/, $_, 2;
$Opt{$name} = defined $val ? $val : 1;
@@ -56,6 +54,19 @@
}
}
+my $dirpath = escape $ENV{REQUEST_URI};
+$dirpath =~ s/\#.*$//;
+$dirpath =~ s/\?.*$//;
+$dirpath =~ s/,[^,]*$//g;
+unless (-d $dir) {
+ $dir =~ s#/+[^/]+$##;
+ $dirpath =~ s#/[^/]+$#/#;
+ $dirpath ||= '/';
+} else {
+ $dirpath =~ s#/LIST$##;
+ $dirpath =~ s#/?$#/#;
+}
+
opendir DIR, $dir or die "$dir: $!";
my @all_files = sort grep {not /^\./ and /^[A-Za-z0-9._-]+$/}
(readdir DIR)[0..1000];
@@ -74,11 +85,25 @@
return 0;
}
+sub preview_uri ($) {
+ my $original_file_name = shift;
+ $original_file_name =~ s/\..*$//;
+ my $file_name = $original_file_name;
+ if ($file_name =~ /-small$/) {
+ return $file_name;
+ } else {
+ $file_name =~ s/-large$//;
+ if (has_file $file_name . '-small') {
+ return $file_name . '-small';
+ } elsif (has_file $file_name) {
+ return $file_name;
+ } else {
+ return $original_file_name;
+ }
+ }
+}
+
my $title = '画像一覧';
-my $dirpath = escape $ENV{REQUEST_URI};
-$dirpath =~ s/\?.*$//;
-$dirpath =~ s#/LIST$##;
-$dirpath ||= '/';
print STDOUT "Content-Type: text/html; charset=euc-jp\n\n";
@@ -89,6 +114,7 @@
+
@{[$Opt{cframe} ? '' : qq<$dirpath の>]}${title}
${linkelement}
@@ -102,8 +128,8 @@
if ($Opt{cframe}) {
my $LISTqt = ($LISTq eq 'LIST' ? $LISTq . '?' : $LISTq . ';') . 'target=view';
print qq{