#!/usr/bin/perl -w # indexgen by CyberPsychotic (fygrave@tigerteam.net) # # details: # usage: indexgen.pl title [heading] # # file description is taken from filename.info files. # file authorship is taken from filename.author files. # files which have brothers file.nolist, are not listened. # # if (! $ARGV[0]) { print "Usage: indexgen.pl startdir [title] [heading] > index.html\n"; exit 1; } my $dir=$ARGV[0]; my $head=$ARGV[1] || $dir; my $title=$ARGV[2] || $head; &generate_index($dir,$head,$title); exit 0; sub generate_index { my $dirname=shift; my $heading=shift || $dirname; my $title=shift || $heading; my $cwd; my $info=''; my $author=''; return if !$dirname; print STDERR "enter $dirname\n"; chop($cwd = `pwd`); my $index_file="$dirname/index.html"; print STDERR "generating $index_file\n"; open(INDEXF,">$index_file") || die "Can not open $index_file"; select INDEXF; &print_head($heading,$title); opendir(LDIR,"$dirname"); my @foo=readdir(LDIR); @foo=sort(@foo); foreach (@foo) { next if (/^\./); next if (/\.info$/i); next if (/\.author$/i); next if (/\.nolist$/i); next if (/index.html/i); my $fullpath=$dirname . '/' . $_; my $infofile=$fullpath . ".info"; my $authfile=$fullpath . ".author"; my $nolist=$fullpath .".nolist"; if ( -r $infofile ) { open(INFO,$infofile); my @info=; close(INFO); $info=join(' ',@info); } if ( -r $authfile ) { open(INFO,$authfile); my @author=; close(INFO); $author=join(' ',@author); } next if (-f $nolist); if ( -f $fullpath) { &generate_entry($fullpath,$_,$info,$author); } if ( -d $fullpath) { &generate_entry($fullpath,$_,$info,$author); #&generate_index($_,$_,$info); system "$0 \'$fullpath\' \'$_\' \'$info\'"; } } &print_foot(); closedir LDIR; chdir $cwd; } sub generate_entry { my $fullname=shift; my $name=shift; my $info=shift; my $author=shift; my $day=''; my $month=''; my $year=''; return if !$name; my $size = (stat($fullname))[7]/1024; my $time = (stat(_))[9]; my $prefix=''; $prefix='/' if -d _; my $postfix=''; $postfix='/index.html' if -d _; $size=~/(\d+\.?\d{0,2})/; $size=$1; $size .="Kb"; print "\n"; print ""; ($day,$month,$year)=(localtime($time))[3,4,5]; print "$prefix $name\n"; print " $day/$month/$year\n"; print " $size \n"; if ($info) { print "\n"; print "\n"; print "$info"; print "\n\n\n"; } if ($author) { print "\n"; print "\n"; print "$author"; print "\n\n\n"; } print "\n"; } sub print_head { my $heading=shift; my $title=shift || $heading; print <<__EOT__; $heading\n

$title


__EOT__ # # } sub print_foot { print <<__EOT__;
Name Date SizeDescriptionAuthor

Page generated by indexgen.pl __EOT__ }