#!/usr/bin/perl

use strict;
use File::Find;
use lib "/home/tattooman/CPAN/HTML-Parser-2.20/lib";
use HTML::Entities;

## begin config
my (@TOP) =                     # top level directories
  qw(/home/tattooman/public_html);
sub PRUNE {                     # don't search these dirs
  ## $_[0] is basename, $_[1] is full path
  $_[0] =~ /private/|/var/|/analog3.0/|/data/|/wwwboard/|/guestbook/|/poll/|/cgi-shit/|/wb/|/Area51/|/alien-abductions/|/francka/|/hi/|/sekured-area/|/BigBrother/|/webalizer/|/board/;
}
sub IGNORE {                    # don't notice these files
  ## $_[0] is basename, $_[1] is full path
  $_[0] =~ /^\.|~$|\.(html|shtml|mrv|gif|jpe?g)$|whatsnew/;
}
my ($HOWMANY) =                 # keep this many new files
  20;
sub TRANSFORM ($;) {            # turn path into URL
  local($_) = @_;
  s!/home/tattooman/public_html/!/~tattooman/!;
  $_;
}
my ($LIST_PRE) =                # prefix list
  "<UL>\n";
my ($ITEM_PRE) =                # prefix item
  "<LI>";
my ($ITEM_POST) =               # suffix item
  "\n";
my ($LIST_POST) =               # suffix list
  "</UL>\n";
## end config

my (%when);                     # record of stamps

find (sub {
        return $File::Find::prune = 1
          if PRUNE $_, $File::Find::name;
        return unless -f;       # only files
        return if IGNORE $_, $File::Find::name;
        $when{$File::Find::name} = (stat _)[9];
      }, @TOP);

my @names = sort { $when{$b} <=> $when{$a} } keys %when;
splice(@names, $HOWMANY);       # discard older stuff

my $name;                       # shuddup $name
print $LIST_PRE;
for $name (@names) {
  my $url = encode_entities TRANSFORM $name;
  print
    $ITEM_PRE,
    "<A HREF=\"$url\">$url</a> on ",
    scalar localtime $when{$name},
    $ITEM_POST;
}
print $LIST_POST;
