#!/usr/bin/perl # $Id: pmi2,v 1.1 2000/08/20 08:36:15 jzawodn Exp $ ### Modules use Cwd; use Image::Size 'html_imgsize'; use strict; ### Subs sub print_navbar; sub print_footer; sub gifn($); sub Log($); ### Globals my @filelist; ## Grab file listing... { if (not @ARGV) { opendir D, '.' or die "$!"; @filelist = grep { /\d+\.jpg/i } readdir D; closedir D; } } @filelist = sort @filelist; my $filename; my $basename; my $title; my $newtitle; my $description; my $filecount = scalar @filelist; my $pagesize = 4; my $indexcount = $filecount / $pagesize; my $pagecounter = 1; my $imagecounter= 1; my $timestamp = scalar(localtime(time)); my $indexfilename; my $comments; my %rotate; my $year = (localtime(time))[5] + 1900; my $dir = getcwd; Log("dir: $dir"); $dir =~ /(.*)\/(.+)$/; $dir = $2; Log("dir: $dir"); ### Main (this is one big, ugly script) # Is the "comments" flag on? If so, we'll generate "Comment" links on # all the pictures so that I can flag them and say something witty. if (-e "/tmp/comments") { $comments = 1; } else { $comments = 0; } # Open the log file. It's always log.txt in the current directory. open(LOG, ">log.txt") or die "$!"; # Figure out how many index pages we need. This is just an odd way of # rounding the fractional value up to the next whole number and then # stripping off the decimal stuff. if ($indexcount =~ /\./) { $indexcount++; $indexcount = sprintf("%d", $indexcount); } if ($indexcount > 1) { Log("We're in multi-file mode."); } else { Log("We're in single-file mode. Just like school."); } Log("Will make $indexcount index files for a $filecount images."); # Get Title from the title.txt file in the current directory. Titles # are only one line long. if (-e "title.txt") { open(TITLE, "
" . $description; $description =~ s/\n\n+/\n\n\
\n/; $description .= "
"; Log("Got description."); } else { warn "No description exists.\n"; } # Read in the rotation file if it exists. if (-e "rotate.txt") { Log("Reading rotation file."); open(ROT, "Jeremy's Home Picture Gallery
$newtitle
Each picture is a small JPEG. They are meant to be thumbnail images. Click on any picture below to see a larger JPEG with better color. I have even larger ones available on request (roughly twice the size of the biggest ones I put on-line).
\n";
print<![]() Comment} } # Spit out the catpion if there is one. if ($caption) { print "\n $caption"; } # End the current image. #print "\n"; print "\n | \n";
$imagecount++;
$ipagecount++;
Log("Imagecount: $imagecount. Ipagecount: $ipagecount. Filecount: $filecount");
############################
#
# End of inner image loop.
#
############################
} # end while
print "\n
"; # Previous Link if ($pagecounter > 1) { $num = $pagecounter - 1; $file = gifn($num); print "<< Previous"; } print " [ "; for (1..$indexcount) { $file = gifn($_); if ($pagecounter != $_) { print " $_ "; } else { print " $_ "; } } print " ] "; # Next Link if ($pagecounter < $indexcount) { $num = $pagecounter + 1; $file = gifn($num); print "Next >>"; } print " |