#!/usr/bin/perl -w # #------------------------------------------------------------------------------- # # nav.pl # #------------------------------------------------------------------------------- # # A CGI progam which will generate a navigation bar with links from the # root of a web server to the current page. Each page leading to the # current page is linked, but the current page is not linked. The nav # bar looks like this: # #
# # The sepator (" ⇒ ") , opening (" ") tags and header ("Content-type: text/html; charset=iso-8859-1") are # all configurable. # #------------------------------------------------------------------------------- # # How it works: # # It starts with the current page, reading the title of the page, then if # the current page is not called index.html, it extracts the title of # index.html in the current directory as the next higher link. This is # repeated until the top level index.html is read. # # I've attempted to handle cases where index.html doesn't exist (the # directory name is used instead of the title), but since I have an # index.html in every directory, I've not tested it. # #------------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # #------------------------------------------------------------------------------- # use strict; use File::Basename; use HTML::TreeBuilder; #------------------------------------------------------------------------------- # # Configurable options # my $separator = "\n \» "; my $opening_tag = " "; my $header = "Content-type: text/html; charset=iso-8859-1\n\n"; # #------------------------------------------------------------------------------- my ($uri, $links, $file, $dir, $title); # # GetTitle: opens the file passed as $_[0] and attempts to extract the # title from the