| 8 |
|
|
| 9 |
=cut |
=cut |
| 10 |
|
|
| 11 |
unless ($main::ENV{PATH_TRANSLATED}) { |
my $dir = $main::ENV{PATH_TRANSLATED} |
| 12 |
die "BAD PATH_TRANSLATED"; |
or die "BAD PATH_TRANSLATED: $ENV{PATH_TRANSLATED}"; |
|
} |
|
| 13 |
|
|
| 14 |
my %Opt; |
my %Opt; |
| 15 |
|
|
| 16 |
my $dir = $main::ENV{PATH_TRANSLATED}; |
if ($dir =~ s#/[^/]+$##) { |
|
if ($dir =~ s#/LIST$##) { |
|
| 17 |
for (split /[&;]/, $ENV{QUERY_STRING}) { |
for (split /[&;]/, $ENV{QUERY_STRING}) { |
| 18 |
my ($name, $val) = split /=/, $_, 2; |
my ($name, $val) = split /=/, $_, 2; |
| 19 |
$Opt{$name} = defined $val ? $val : 1; |
$Opt{$name} = defined $val ? $val : 1; |
| 29 |
$s =~ s/</</g; |
$s =~ s/</</g; |
| 30 |
$s =~ s/>/>/g; |
$s =~ s/>/>/g; |
| 31 |
$s =~ s/"/"/g; |
$s =~ s/"/"/g; |
| 32 |
|
$s =~ s/'/'/g; |
| 33 |
$s; |
$s; |
| 34 |
} |
} |
| 35 |
|
|
| 54 |
} |
} |
| 55 |
} |
} |
| 56 |
|
|
| 57 |
|
my $dirpath = escape $ENV{REQUEST_URI}; |
| 58 |
|
$dirpath =~ s/\#.*$//; |
| 59 |
|
$dirpath =~ s/\?.*$//; |
| 60 |
|
$dirpath =~ s/,[^,]*$//g; |
| 61 |
|
unless (-d $dir) { |
| 62 |
|
$dir =~ s#/+[^/]+$##; |
| 63 |
|
$dirpath =~ s#/[^/]+$#/#; |
| 64 |
|
$dirpath ||= '/'; |
| 65 |
|
} else { |
| 66 |
|
$dirpath =~ s#/LIST$##; |
| 67 |
|
$dirpath =~ s#/?$#/#; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
opendir DIR, $dir or die "$dir: $!"; |
opendir DIR, $dir or die "$dir: $!"; |
| 71 |
my @all_files = sort grep {not /^\./ and /^[A-Za-z0-9._-]+$/} |
my @all_files = sort grep {not /^\./ and /^[A-Za-z0-9._-]+$/} |
| 72 |
(readdir DIR)[0..1000]; |
(readdir DIR)[0..1000]; |
| 85 |
return 0; |
return 0; |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
|
sub preview_uri ($) { |
| 89 |
|
my $original_file_name = shift; |
| 90 |
|
$original_file_name =~ s/\..*$//; |
| 91 |
|
my $file_name = $original_file_name; |
| 92 |
|
if ($file_name =~ /-small$/) { |
| 93 |
|
return $file_name; |
| 94 |
|
} else { |
| 95 |
|
$file_name =~ s/-large$//; |
| 96 |
|
if (has_file $file_name . '-small') { |
| 97 |
|
return $file_name . '-small'; |
| 98 |
|
} elsif (has_file $file_name) { |
| 99 |
|
return $file_name; |
| 100 |
|
} else { |
| 101 |
|
return $original_file_name; |
| 102 |
|
} |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
|
|
| 106 |
my $title = '画像一覧'; |
my $title = '画像一覧'; |
|
my $dirpath = escape $ENV{REQUEST_URI}; |
|
|
$dirpath =~ s/\?.*$//; |
|
|
$dirpath =~ s#/LIST$##; |
|
|
$dirpath ||= '/'; |
|
| 107 |
|
|
| 108 |
print STDOUT "Content-Type: text/html; charset=euc-jp\n\n"; |
print STDOUT "Content-Type: text/html; charset=euc-jp\n\n"; |
| 109 |
|
|
| 114 |
<!DOCTYPE html SYSTEM> |
<!DOCTYPE html SYSTEM> |
| 115 |
<html lang="ja"> |
<html lang="ja"> |
| 116 |
<head> |
<head> |
| 117 |
<title>$dirpath の${title}</title> |
<base href="http://suika.fam.cx$dirpath" /> |
| 118 |
|
<title>@{[$Opt{cframe} ? '' : qq<$dirpath の>]}${title}</title> |
| 119 |
${linkelement} |
${linkelement} |
| 120 |
</head> |
</head> |
|
<body> |
|
|
<h1>${title}</h1> |
|
| 121 |
EOH |
EOH |
| 122 |
|
|
| 123 |
|
my $LISTq = q<>; |
| 124 |
|
$LISTq .= q<;detail> if $Opt{detail}; |
| 125 |
|
$LISTq = substr $LISTq, 1; |
| 126 |
|
$LISTq = 'LIST' . ($LISTq ? '?' . $LISTq : ''); |
| 127 |
|
|
| 128 |
|
if ($Opt{cframe}) { |
| 129 |
|
my $LISTqt = ($LISTq eq 'LIST' ? $LISTq . '?' : $LISTq . ';') . 'target=view'; |
| 130 |
|
print qq{<frameset cols="25%,*"> |
| 131 |
|
<frame src="$LISTqt" name="list" /> |
| 132 |
|
<frame src="./" name="view" /> |
| 133 |
|
<noframes>}; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
my $viewtarget = ''; |
| 137 |
|
my $listtarget = ''; |
| 138 |
|
my $parenttarget = ''; |
| 139 |
|
if ($Opt{target} =~ /^([a-z]+)$/) { |
| 140 |
|
$viewtarget = qq{ target="$1"}; |
| 141 |
|
$listtarget = q{ target="_self"}; |
| 142 |
|
$LISTq .= $LISTq eq 'LIST' ? qq{?target=$1} : qq{;target=$1}; |
| 143 |
|
$parenttarget = q{ target="_parent"}; |
| 144 |
|
} |
| 145 |
|
|
| 146 |
if ($Opt{detail}) { |
if ($Opt{detail}) { |
| 147 |
print q{<div class="pictures detail">}; |
print qq{<body@{[$Opt{target}?' class="has-target"':'']}> |
| 148 |
|
<h1>${title}</h1> |
| 149 |
|
<div class="pictures detail">}; |
| 150 |
|
|
| 151 |
for my $file_name (@files) { |
for my $file_name (@files) { |
| 152 |
my $efile = escape $file_name; |
my $efile = escape $file_name; |
| 153 |
|
my $preview_uri = escape preview_uri $file_name; |
| 154 |
my $uri = $efile; |
my $uri = $efile; |
| 155 |
$uri =~ s/\..+//g; |
$uri =~ s/\..+//g; |
| 156 |
|
my $id = uc $uri; |
| 157 |
my @cls = split /\./, lc $file_name; |
my @cls = split /\./, lc $file_name; |
| 158 |
shift @cls; |
shift @cls; |
| 159 |
print q{<div class="image-with-desc">}; |
print qq{<div class="image-with-desc" id="FILE--$id">}; |
| 160 |
print qq{<a href="$uri">}; |
print qq{<a href="$uri"$viewtarget>}; |
| 161 |
print qq{<img src="$uri" alt="" class="@{[join ' ', @cls, 's']}"></a>}; |
print qq{<img src="$preview_uri" alt="" class="@{[join ' ', @cls, 's']}" /></a>}; |
| 162 |
print qq{<dl><dt>URI</dt><dd>}; |
print qq{<dl><dt>URI</dt><dd>}; |
| 163 |
print qq{<code class="uri"><<a href="$uri">$uri</a>></code></dd>}; |
print qq{<code class="uri"><<a href="$uri"$viewtarget>$uri</a>></code></dd>}; |
| 164 |
print qq{<dt>ファイル名</dt><dd>}; |
print qq{<dt>ファイル名</dt><dd>}; |
| 165 |
print qq{<code class="file"><a href="$efile">$efile</a></code></dd>}; |
print qq{<code class="file"><a href="$efile"$viewtarget>$efile</a></code></dd>}; |
| 166 |
print qq{<dt>日付</dt><dd>}; |
print qq{<dt>日付</dt><dd>}; |
| 167 |
print rfc3339date ([stat $dir.'/'.$file_name]->[9]); |
print rfc3339date ([stat $dir.'/'.$file_name]->[9]); |
| 168 |
|
print qq{<dt>大きさ</dt><dd>}; |
| 169 |
|
print filesize ([stat $dir.'/'.$file_name]->[7]); |
| 170 |
print qq{</dd>}; |
print qq{</dd>}; |
| 171 |
print qq{</dl>}; |
print qq{</dl>}; |
| 172 |
print q{</div>}; |
print q{</div>}; |
| 178 |
my $uri = $efile; |
my $uri = $efile; |
| 179 |
$uri =~ s/\..+//g; |
$uri =~ s/\..+//g; |
| 180 |
print q{<div class="image-with-desc">}; |
print q{<div class="image-with-desc">}; |
| 181 |
print qq{<a href="$uri"><img src="/~wakaba/archive/2005/movie-1" alt=""></a>}; |
print qq{<a href="$uri"$viewtarget><img src="/~wakaba/archive/2005/movie-1" alt="" /></a>}; |
| 182 |
print qq{<dl><dt>URI</dt><dd>}; |
print qq{<dl><dt>URI</dt><dd>}; |
| 183 |
print qq{<code class="uri"><<a href="$uri">$uri</a>></code></dd>}; |
print qq{<code class="uri"><<a href="$uri"$viewtarget>$uri</a>></code></dd>}; |
| 184 |
print qq{<dt>ファイル名</dt><dd>}; |
print qq{<dt>ファイル名</dt><dd>}; |
| 185 |
print qq{<code class="file"><a href="$efile">$efile</a></code></dd>}; |
print qq{<code class="file"><a href="$efile"$viewtarget>$efile</a></code></dd>}; |
| 186 |
print qq{<dt>日付</dt><dd>}; |
print qq{<dt>日付</dt><dd>}; |
| 187 |
print rfc3339date ([stat $dir.'/'.$file_name]->[9]); |
print rfc3339date ([stat $dir.'/'.$file_name]->[9]); |
| 188 |
print qq{</dd>}; |
print qq{</dd>}; |
| 198 |
print q{<div class="dir dir-with-desc">}; |
print q{<div class="dir dir-with-desc">}; |
| 199 |
if (-f $dir . '/' . $dir_name . '/favicon.png' or |
if (-f $dir . '/' . $dir_name . '/favicon.png' or |
| 200 |
-f $dir . '/' . $dir_name . '/favicon.ico') { |
-f $dir . '/' . $dir_name . '/favicon.ico') { |
| 201 |
print qq{<img src="$edir/favicon" alt="" class="mini-icon">}; |
print qq{<img src="$edir/favicon" alt="" class="mini-icon" />}; |
| 202 |
} else { |
} else { |
| 203 |
print qq{<img src="/icons/folder" alt="" class="mini-icon">}; |
print qq{<img src="/icons/folder" alt="" class="mini-icon" />}; |
| 204 |
} |
} |
| 205 |
print qq{<code class="file"><a href="$edir/LIST?detail">$edir/</a></code>}; |
print qq{<code class="file"><a href="$edir/$LISTq"$listtarget>$edir/</a></code>}; |
| 206 |
print q{</div>}; |
print q{</div>}; |
| 207 |
} |
} |
| 208 |
|
|
| 218 |
['current', '現行版']) { |
['current', '現行版']) { |
| 219 |
if (has_file $_->[0]) { |
if (has_file $_->[0]) { |
| 220 |
print q{<div class="file file-with-desc">}; |
print q{<div class="file file-with-desc">}; |
| 221 |
print q{<img src="/icons/layout" alt="" class="mini-icon">}; |
print q{<img src="/icons/layout" alt="" class="mini-icon" />}; |
| 222 |
print qq{<a href="$_->[0]" rel="$_->[2]">$_->[1]</a>}; |
print qq{<a href="$_->[0]" rel="$_->[2]"$viewtarget>$_->[1]</a>}; |
| 223 |
print q{</div>}; |
print q{</div>}; |
| 224 |
} |
} |
| 225 |
} |
} |
| 226 |
|
|
| 227 |
print q{<div class="dir-up dir-with-desc">}; |
print q{<div class="dir-up dir-with-desc">}; |
| 228 |
print q{<img src="/icons/forward" alt="" class="mini-icon">}; |
print q{<img src="/icons/forward" alt="" class="mini-icon" />}; |
| 229 |
print q{<a href="../LIST?detail" rel="up">上の階層</a>}; |
print qq{<a href="../$LISTq" rel="up"$listtarget>上の階層</a>}; |
| 230 |
print q{</div>}; |
print q{</div>}; |
| 231 |
|
|
| 232 |
print q{</div>}; |
print q{</div>}; |
|
} else { |
|
| 233 |
|
|
| 234 |
print q{<div class="pictures">}; |
} else { ## Normal Listing Mode |
| 235 |
|
print qq{<body@{[$Opt{target}?' class="has-target"':'']}> |
| 236 |
|
<h1>${title}</h1> |
| 237 |
|
<div class="pictures">}; |
| 238 |
my $imgsattr = ' class="s"'; |
my $imgsattr = ' class="s"'; |
| 239 |
|
|
| 240 |
for my $file_name (@files) { |
for my $file_name (@files) { |
| 241 |
my $uri = escape $file_name; |
my $uri = escape $file_name; |
| 242 |
$uri =~ s/\..+$//g; |
$uri =~ s/\..+$//g; |
| 243 |
print '<a href="'.$uri.'">'; |
my $preview_uri = escape preview_uri $file_name; |
| 244 |
print '<img src="'.$uri.'" alt="'.$uri.'"'.$imgsattr.' />'; |
print '<a href="'.$uri.'"'.$viewtarget.'>'; |
| 245 |
|
print '<img src="'.$preview_uri.'" alt="'.$uri.'"'.$imgsattr.' />'; |
| 246 |
print "</a>\n"; |
print "</a>\n"; |
| 247 |
} |
} |
| 248 |
|
|
| 252 |
for my $dir_name (@dirs) { |
for my $dir_name (@dirs) { |
| 253 |
my $edir = escape $dir_name; |
my $edir = escape $dir_name; |
| 254 |
print q{<li class="dir">}; |
print q{<li class="dir">}; |
| 255 |
print qq{<code class="file"><a href="$edir/LIST">$edir/</a></code>}; |
print qq{<code class="file"><a href="$edir/$LISTq"$listtarget>$edir/</a></code>}; |
| 256 |
print q{</li>}; |
print q{</li>}; |
| 257 |
} |
} |
| 258 |
print q{<li class="dir-up"><a href="../LIST" rel="up">上の階層</a></li></ul>}; |
print qq{<li class="dir-up"><a href="../$LISTq" rel="up"$listtarget>上の階層</a></li></ul>}; |
| 259 |
} |
} |
| 260 |
|
|
| 261 |
my $cvslink = ''; |
my $cvslink = ''; |
| 262 |
if (-d $dir . '/CVS') { |
if (-d $dir . '/CVS') { |
| 263 |
if (-f $dir . '/CVS/Root') { |
if (-f $dir . '/CVS/Root') { |
| 264 |
open my $root, '<', $dir . '/CVS/Root'; |
open my $root, '<', $dir . '/CVS/Root'; |
| 265 |
if (<$root> =~ m#^(/home/cvs|/home/wakaba/pub/cvs)$#) { |
if (<$root> =~ m#^(/home/cvs|/home/wakaba/pub/cvs)/?$#) { |
| 266 |
my $rpath = $1; |
my $rpath = $1; |
| 267 |
if (-f $dir . '/CVS/Repository') { |
if (-f $dir . '/CVS/Repository') { |
| 268 |
open my $repo, '<', $dir . '/CVS/Repository'; |
open my $repo, '<', $dir . '/CVS/Repository'; |
| 272 |
$cvslink = qq{ <a href="/gate/cvs/$reppath/@{[ |
$cvslink = qq{ <a href="/gate/cvs/$reppath/@{[ |
| 273 |
{q[/home/cvs] => '', |
{q[/home/cvs] => '', |
| 274 |
q[/home/wakaba/pub/cvs] => '?cvsroot=Wakaba'}->{$rpath} |
q[/home/wakaba/pub/cvs] => '?cvsroot=Wakaba'}->{$rpath} |
| 275 |
]}" rel="history">この階層の履歴</a>}; |
]}" rel="history"$parenttarget>この階層の履歴</a>}; |
| 276 |
} |
} |
| 277 |
} |
} |
| 278 |
} |
} |
| 283 |
|
|
| 284 |
<div class="footer"> |
<div class="footer"> |
| 285 |
<div class="navigation"> |
<div class="navigation"> |
| 286 |
[<a href="/" rel="home">/</a>] |
[<a href="/" rel="home"$parenttarget>/</a>] |
| 287 |
[<a href="." rel="contents">この階層</a>$cvslink] |
[<a href="." rel="contents"$parenttarget>この階層</a>$cvslink] |
| 288 |
[<a href="LIST" rel="alternate">画像一覧</a> |
[画像一覧 (<a href="LIST" rel="alternate"$parenttarget>簡易</a>, |
| 289 |
<a href="LIST?detail" rel="alternate">画像一覧 (詳細)</a>] |
<a href="LIST?cframe" rel="alternate"$parenttarget>簡易・横分割</a>, |
| 290 |
|
<a href="LIST?detail" rel="alternate"$parenttarget>詳細</a>, |
| 291 |
|
<a href="LIST?detail;cframe" rel="alternate"$parenttarget>詳細・横分割</a>)] |
| 292 |
</div> |
</div> |
| 293 |
</div> |
</div> |
| 294 |
</body> |
</body> |
|
</html> |
|
| 295 |
EOH |
EOH |
| 296 |
|
|
| 297 |
|
print q{</noframes></frameset>} if $Opt{cframe}; |
| 298 |
|
|
| 299 |
|
print q{</html>}; |
| 300 |
|
|
| 301 |
1; |
1; |
| 302 |
|
|
| 303 |
__END__ |
__END__ |
| 306 |
|
|
| 307 |
=head1 CHANGES |
=head1 CHANGES |
| 308 |
|
|
| 309 |
|
2005-02-26 Wakaba <w@suika.fam.cx> |
| 310 |
|
|
| 311 |
|
- Frame mode implemented. |
| 312 |
|
|
| 313 |
2005-02-25 Wakaba <w@suika.fam.cx> |
2005-02-25 Wakaba <w@suika.fam.cx> |
| 314 |
|
|
| 315 |
- Use external style sheet. |
- Use external style sheet. |
| 316 |
|
- Detail mode implemented. |
| 317 |
|
|
| 318 |
2001-06-25 Wakaba <wakaba@61.201.226.127> |
2001-06-25 Wakaba <wakaba@61.201.226.127> |
| 319 |
|
|