#!/usr/bin/perl

# mkpixlist: find all non-thumbnail images under the current directory,
# and generate a perl script that sets them up for showpix.cgi;
# or generate one from the argument list.
# Copyright 2001 by Akkana Peck. 
# You may use and distribute this under the GPL.

# Handy ex expression for converting existing files:
# .,$s/href="/href="..\/showpix.cgi?pic=

print "#! /usr/bin/perl\n\n";

# Figure out where we are, and where showpix.pl lives.
#$softwaredir = `pwd`;
#$softwaredir =~ s/\n//;
#$softwaredir =~ s/.*\/web\///;
#$softwaredir =~ s/[^\/]*/\.\./;
#$softwaredir = "$softwaredir/software";
# This never does the right thing!  Just hardwire it and fix it later.
$softwaredir = "../../software";
print "\$softwaredir = \"$softwaredir\";\n";

print "\$title = \"Images\";\n\n";
print "\@pix = (\n";

if ($#ARGV >= 0)
{
    @fils = @ARGV;
}
else
{
    @fils = `find . -name "*.jpg" | grep -v "T.jpg" `;
}

for ($i = 0; $i <= $#fils; ++$i)
{
    $fils[$i] =~ s/\n//;
    $fils[$i] =~ s/.\///;
    print "    [ \"$fils[$i]\", \"\" ],\n";
}

print ");\n\n";

print "do \"\$softwaredir/showpix.pl\";\n";

