p3220001.jpg last modified: Tue Jul 1 09:27:30 2008
p3220002.jpg last modified: Tue Jul 1 09:27:30 2008
p3220003.jpg last modified: Tue Jul 1 09:27:30 2008
p3220004.jpg last modified: Tue Jul 1 09:27:30 2008
p3220005.jpg last modified: Tue Jul 1 09:27:30 2008
p3220006.jpg last modified: Tue Jul 1 09:27:30 2008
p3220007.jpg last modified: Tue Jul 1 09:27:30 2008
p3220008.jpg last modified: Tue Jul 1 09:27:30 2008
p3220009.jpg last modified: Tue Jul 1 09:27:30 2008
#! /usr/bin/perl
# make-image-page
# makes an HTML index file for a web image directory so you can see
# your images all at once instead of having to grovel through them.
# Copyright 1998 Electric Lichen L.L.C.
# Don Marti <dmarti@electriclichen.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# height attribute for image tags
my $HEIGHT = 60;
# what to call the index -- don't use this file name for other things
# and this script will never blow away one of your html files.
my $INDEX_NAME = "image_index.html";
# to make image_index.html act like a real index.html either add it to
# the DirectoryIndex directive, or make the appropriate symlink.
# body tag -- change background, text, and link colors here.
my $BODYTAG =
qq{<body bgcolor="#000000" text="#ffffff" link="#ffffff" vlink="#ffffff">
};
######################################################################
### no user-servicable parts below ###
######################################################################
my $directory = $ARGV[0];
# chop off extra / at end of directory name
$directory = $1 if $directory =~ /(.+)\/+/;
if (!$directory) {
print STDERR "Usage: $0 [directory]\n";
exit 1;
}
if (!-d $directory) {
print STDERR "$directory is not a directory.\n";
exit 1;
}
if (!-w $directory) {
print STDERR "Image directory $directory is not writable.\n";
exit 1;
}
index_directory($directory);
exit 0;
sub index_directory {
my $directory = shift;
opendir (IMAGEDIR, $directory) or die $!;
my @images = sort { lc($a) cmp lc($b) } readdir(IMAGEDIR);
closedir IMAGEDIR or die $!;
# always descend recursively...
foreach my $file (@images) {
next if $file =~ /^\.+/;
index_directory("$directory/$file") if -d "$directory/$file" and
((-w "$directory/$file/$INDEX_NAME") or
(!-e "$directory/$file/$INDEX_NAME" and -w "$directory/$file")
);
}
open (INDEX, "> $directory/$INDEX_NAME") or die
"Can't open $directory/$INDEX_Name for writing: $!";
print INDEX head($directory);
foreach my $image (@images) {
next if $image =~ /^\.+$/ or $image =~ /\.html$/;
$mod_time = localtime(time() - -M $image);
if (-d "$directory/$image") {
print INDEX qq{ <p><a href="$image/$INDEX_NAME">
$image (directory)
</a>
}
}
else {
print INDEX qq{
<p><a href="$image">
<img src="$image" height="$HEIGHT" border="0">
<br>$image last modified: $mod_time</a>
}
}
}
print INDEX foot();
close INDEX or die $!;
}
sub foot {
join ('',
'<hr><pre>',
script(),
'</pre>',
qq{ </body></html>
}
)
}
sub head {
my $directory = $_[0];
qq{
<html><head><title>Images in $directory
</title></head>
$BODYTAG
}
}
sub script {
open (SCRIPT, $0) or die $!;
my $content = join ('', <SCRIPT>);
close SCRIPT;
$content =~ s/&/&/g;
$content =~ s/</</g;
$content =~ s/>/>/g;
return $content
}