#!/usr/local/bin/perl

# Site Map generator (C) 1997 Sierra Kempster.  All rights reserved.
# For more information or help with the scipt, email darkmoon@lunamorena.net
# This script is emailware.  You're free to use & alter it how you like
# but I'd like to get an email from you letting me know where & how it's
# being used.  Please do not redistribute; you should only get the script
# from me or sites I have approved for distribution.  If you think you
# may have obtained this script from an unapproved source, send me an email
# letting me know where you got it and I'll look into it.

# The above notice must remain intact, regardless of other alterations made.

# Configuration
################

# Full path to the data file, sored in the format:
# filename.html:Title of page
$data_file = "/www/home/users/d/darkmoon/map.data";

# Base URL for file, without trailing slash
$base_url = "http://www.calweb.com/~darkmoon";

# Default HTML file (usually index.html)
$default = "index.html";

# Title of Site Map
$title = "Darkmoon's Site Map";

# BODY tag parameters
$background = "";
$bgcolor = "000000";
$text = "7700ff";
$link = "00bb99";
$vlink = "0099bb";
$alink = "00dddd";

# Other lines in HEAD area.  JavaScript, META tags, whatever.
# Place between: 'print <<EOF' and 'EOF'
sub header {
print <<EOF;
EOF
}

# Other lines after BODY tag but before the map links.
# Place between: 'print <<EOF' and 'EOF'
sub begin {
print <<EOF;
<center><font size=7 face="Arial, Helvetica">Site Index</font><br>
<i>In no particular order</i></center><p>
EOF
}

# Lines after the site map.
# Place between: 'print <<EOF' and 'EOF'
sub end {
print <<EOF;
<hr>
<a href="/~darkmoon/main.html">Darkmoon</a> / Site Map<br>
Copyright &copy; 1997 Sierra Kempster.  All Rights Reserved.
EOF
}

# Format for list:
# center:
#				   Link One
#				   Link Two
#                                 Link Three
#
# unordered:
#     o Link One
#     o Link Two
#     o Link Three
#
# ordered:
#     1. Link One
#     2. Link Two
#     3. Link Three
$format = "center";

# End Configuration
####################

srand($$);
$ver = "0.1";

print"Content-type:text/html\n\n";
print"<HTML>\n";
print"<HEAD>\n";
print"<TITLE>$title</TITLE>\n";
&header;
print"<META http-equiv=\"generator\" content=\"SiteMap v$ver Copyright (C) 1997 Sierra Kempster\">\n";
print"</HEAD>\n";
print"<BODY";
print" background=\"$background\"" if($background);
print" bgcolor=\"$bgcolor\"" if($bgcolor);
print" text=\"$text\"" if($text);
print" link=\"$link\"" if($link);
print" vlink=\"$vlink\"" if($vlink);
print" alink=\"$alink\"" if($alink);
print">\n";
&begin;
if($format eq "center") { print"<center>\n"; }
elsif($format eq "ordered") { print"<ol>\n"; }
elsif($format eq "unordered") { print"<ul>\n"; }
open(DATA, "$data_file");
while(<DATA>)
{
  chomp;
  ($file,$link) = split(/:/,$_,2);
  print"<li>" if (($format eq "ordered") || ($format eq "unordered"));
  $file =~ s/$default//g;
  print"<a href=\"$base_url/$file\">$link</a>";
  if(($format eq "ordered") || ($format eq "unordered")) { print"</li>\n"; }
  else { print"<br>\n"; }
}
close(DATA);
if($format eq "center") { print"</center>\n"; }
elsif($format eq "ordered") { print"</ol>\n"; }
elsif($format eq "unordered") { print"</ul>\n"; }
print"<p>\n";
&end;
print"</BODY>\n";
print"</HTML>\n";
