tofc.prl
takes a table of contents specification and writes the
files in a table of contents, such as the one in the frame to the
left. Here's a specification:
@ frconten.html Title Page : default.html New and unfiled : random.html Oregon : oregon.html North Carolina : nc.html Orem : orem.html Yosemite : yosemite.html + Southern Utah : so_utah.html - Green River : green_river.html - Zion NP : zion.html - Eagle Canyon : http://lal.cs.byu.edu/people/jones/swell.html - Moab : moab.html - Little Holes Canyon : san_raphael.html Washington DC : dc.html + Laura : laura_frconten.html - The archive : laura/ - Sledding : sledding.html Geodes : geode.html Summer skiing: skiing.html Donut falls ski trip: donut_falls.html Perl : perl.htmland here's the script:
#! /usr/local/bin/perl open (spec, $ARGV[0]); $frmain = "main"; $frconten = "contents"; $target = $frmain; $space = " "; while ($line =The other script changes all references to images to point to a smaller version of the same image and adds a link to the larger version.) { chop ($line); if ($line =~ /\+.*/) { # print "a new sub-directory\n"; $target = $frconten; ($_, $parent) = split(/\s*:\s*/,$line); push (@subdir_list, $parent); } elsif ($line =~ /\@.*/) { ($_,$frname) = split(/\s/,$line); # print "the tofc frame name = $frname \n"; push (@subdir_list, $frname); } elsif ($line =~ /\-.*/) {# print "an entry in a sub-directory\n"; $home = $parent;} else { # print "a heading\n"; }; ($name, $ref) = split(/\s*:\s*/,$line); $name =~ s/(-|\+)\s//; # print "name = $name, ref = $ref, target = $target, home = $home\n"; push (@entry_list, "$name~~$ref~~$target~~$home"); $target = $frmain; $home = $frname; } foreach $parent (@subdir_list) { print "\n$parent:\n"; unless (open (CONTEN, ">$parent")) { die "couldn't open $parent for writing."}; print CONTEN " Contents
\n"; foreach $entry (@entry_list) { $plus_minus = ""; ($name,$ref,$target,$home) = split(/~~/,$entry); if ($target eq $frconten) { $plus_minus = "+"; }; if ($ref eq $parent) { print "$name\n"; print CONTEN "
"; print CONTEN "- $name\n"; } elsif ($home eq $frname) { print "$name\n"; print CONTEN "
"; print CONTEN "$plus_minus $name\n"; } elsif ($home eq $parent) { print " $name\n"; print CONTEN "
$space$space$name\n"; } }; print "Generated: $DATE\n"; close (CONTEN) || die "couldn't close $parent."; }; print "done.\n"; sub line_to_html { local ($line); $line = $_[0]; ($name, $ref) = split(/\s*:\s*/,$line); $name =~ s/(-|\+)\s//; print "name = $name, ref = $ref, target = $_[1], home = $_[2]\n"; };
#! /usr/local/bin/perl
$link =")
{
chop ($file);
printf "$file\n";
open (file, "$file");
while ($line = )
{
$line =~ s/<(img\s*src\s*=)\"([a-zA-Z0-9_\-.]*)\"\s*>/<$1\"small\/$2\"><\/a>/gi ;
push (@lines, $line);
}
close (file);
open (file, ">$file");
foreach $new_line (@lines)
{
print file $new_line;
};
close (file);
@lines = ();
};