#!/usr/bin/perl

my $THEMES =	"/WWW/web/DavePics.com/Themes";
my $ALBUM =	"/WWW/web/DavePics.com/Examples";
my $TOP =	"http://MarginalHacks.com/Hacks/album/Themes.html";
#$ALBUM =	"/usr/bin/nice -20 $ALBUM";

my $cnt;
foreach my $t ( @ARGV ) {
  $t =~ s|/+$||;
  next unless (-d $t && -f "$t/album.th");
  die("Run this from the theme directory\n") if $t =~ m|/|;

  unless ($cnt++) {
    print "#!/bin/sh\n\n";
    print "album -known_images -top $TOP $ALBUM\n";
  }

  print "album -known_images -theme $t -theme_url /Themes -index ${t}.html -top $TOP $ALBUM\n";

# Just get rid of the old files
unlink "${t}.tar.gz";
unlink "${t}.zip";

  system("tar czf ${t}.tar.gz $t") unless -e "${t}.tar.gz";
  if (!-e "${t}.zip" && open(ZIP,"|zip -z ${t}.zip `find $t` > /dev/null")) {
    print ZIP "---------------------------------------------\n";
    print ZIP "| Zipped Album Theme:                       |\n";
    printf ZIP "|   %-40s|\n",$t;
    print ZIP "|                                           |\n";
    print ZIP "| Album:                                    |\n";
    print ZIP "|   http://MarginalHacks.com/Hacks/Album    |\n";
    print ZIP "|                                           |\n";
    print ZIP "|        http://MarginalHacks.com           |\n";
    print ZIP "---------------------------------------------\n";
    print ZIP ".\n";
    close ZIP;
  }
}
system("go+rx");
print "To update web pages:\n  /WWW/web/MarginalHacks.com/Hacks/album/make_project\n";
print "To update theme album:\n  /WWW/web/MarginalHacks.com/Hacks/album/update_themes\n";
