#!/opt/bin/perl # ________________________________________________________________ # /\ /\ CyberWeb SoftWare: Internet Information Systems # -{-<*>-}- World-Wide Web # __\/_\/_________________________________________________________ # Author : Alan Richmond, $File = 'cmap.pl'; $Version = '1.0'; # Purpose : Generate Contents Map for site. # Usage : cmap.pl # Comment : Create a dir_file with 'find', e.g. # find -name "index.html" -print>dir # where is, for example, ../.. if the # current dir is two levels below the web doc root. # Output goes to test.ht # This file lists all your directory index files. # Every directory is assumed to have an 'index.html'. # If the map has wrong indentation you may be missing # an 'index.html'.. # Disclaimer: This software is provided freely on the understanding # that the Author will not be held responsible for any # problems arising from it's use, and that there is no # support except by agreement on a fee for services. # ________________________________________________________________ # Configuration: edit this.. $debug = 1; # Location of the required subroutines file. $subs = '/www/wdvl/wdvl/Software/Perl'; require "$subs/ht_subs.pl"; # @colors = ( '0000ff', '0033ff', '3366ff', '6699ff'); $thbgc = "#336699"; # Open the input and output files. # The input file is a list of paths to index.html files. open (IN, "ToC.ht")||die$!; # Output an ht header and start the table. print HT < EOT # Read in the directory of index.html files, line by line. while () { s/^\.\.\/\.\.//; s/index\.html$//; # Skip over directories we don't want on the map. next if /\/x\//; next if /^\/Astro/; next if /^\/Development/; next if /^\/Richmond/; next if /^\/Spectrum/; next if /^\/Multimedia\/Gallery\/RHarris\/DS9\/Walkthrough/; chop ; # Add the path to a list array. push (@dir, $_); } # For each item in the list (after sorting): foreach (sort @dir) { # $name = "x"; $file[$k] = $x; $x = $_; # Split the pathname into components. @dirs = split(/\//); # get each directory level $n = $#dirs; # If there are not more parts than in the previous entry, # then the previous row is finished. $rowend = $n <= $nx; # For each component in the previous entry: foreach (@dirsx) { # previous line # Append to the name and add to its count. $name .= $_; # build up a name $rows{$name}++ if $rowend; } print "$name: $rows{$name}\n" if $debug; # Save some data for each item: # depth in hierarchy; # whether at end of row; # item name; etc. $lev = 4 - $nx; if ($lev >= 0) { $s = '+'; } else { $s = ''; } $lev[$k] = $s . $lev; $roe[$k] = $rowend; $cell[$k++] = $name; undef $name; @dirsx = @dirs; $nx = $n; } # For each item except first two: # why 2? first is that previous loop added spurious 'previous' entry, # second is that the home page top level isn't really needed. for ($i=2; $i<$k; $i++) { # for each dir level $_ = $cell[$i]; print "$i $_\n" if $debug; $rows = $rows{$_}; print "Rows: $rows\n" if $debug; $url = $file[$i]; $file = "../.." . $file[$i] . "index.html"; # Open the corresponding index.html file open (IN,"<$file")||die $file; # Get the Title from the file. &GetTitle(1); close (IN); # Print the table cell. print HT < $title EOT # Print the row separator if it's the last row item. print HT "\n" if $roe[$i]; } # Print end of table; empty cell allows to complete last row validly. print HT "\n";