--- okuchuu/piclist.ja.cgi 2005/03/11 11:51:48 1.6 +++ okuchuu/piclist.ja.cgi 2005/03/26 04:51:41 1.7 @@ -54,8 +54,17 @@ } } +my $dirpath = escape $ENV{REQUEST_URI}; +$dirpath =~ s/\#.*$//; +$dirpath =~ s/\?.*$//; +$dirpath =~ s/,[^,]*$//g; unless (-d $dir) { -# $dir =~ s#/+[^/]+$##; + $dir =~ s#/+[^/]+$##; + $dirpath =~ s#/[^/]+$#/#; + $dirpath ||= '/'; +} else { + $dirpath =~ s#/LIST$##; + $dirpath =~ s#/?$#/#; } opendir DIR, $dir or die "$dir: $!"; @@ -76,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#/[^/]+$##; -$dirpath ||= '/'; print STDOUT "Content-Type: text/html; charset=euc-jp\n\n"; @@ -91,6 +114,7 @@ + @{[$Opt{cframe} ? '' : qq<$dirpath の>]}${title} ${linkelement} @@ -126,19 +150,22 @@ for my $file_name (@files) { my $efile = escape $file_name; + my $preview_uri = escape preview_uri $file_name; my $uri = $efile; $uri =~ s/\..+//g; my @cls = split /\./, lc $file_name; shift @cls; print q{
}; print qq{}; - print qq{}; + print qq{}; print qq{
URI
}; print qq{<$uri>
}; print qq{
ファイル名
}; print qq{$efile
}; print qq{
日付
}; print rfc3339date ([stat $dir.'/'.$file_name]->[9]); + print qq{
大きさ
}; + print filesize ([stat $dir.'/'.$file_name]->[7]); print qq{
}; print qq{
}; print q{
}; @@ -212,8 +239,9 @@ for my $file_name (@files) { my $uri = escape $file_name; $uri =~ s/\..+$//g; + my $preview_uri = escape preview_uri $file_name; print ''; - print ''.$uri.''; + print ''.$uri.''; print "\n"; } @@ -302,4 +330,4 @@ =cut -# $Date: 2005/03/11 11:51:48 $ +# $Date: 2005/03/26 04:51:41 $