head	1.10;
access;
symbols;
locks
	perlman:1.10; strict;
comment	@# @;


1.10
date	2009.08.23.18.14.49;	author perlman;	state Exp;
branches;
next	1.9;

1.9
date	2009.08.23.17.27.35;	author perlman;	state Exp;
branches;
next	1.8;

1.8
date	2007.05.18.16.58.35;	author perlman;	state Exp;
branches;
next	1.7;

1.7
date	2001.10.09.16.27.11;	author perlman;	state Exp;
branches;
next	1.6;

1.6
date	2001.10.09.02.10.45;	author perlman;	state Exp;
branches;
next	1.5;

1.5
date	2001.10.09.02.01.05;	author perlman;	state Exp;
branches;
next	1.4;

1.4
date	2001.10.06.01.50.15;	author perlman;	state Exp;
branches;
next	1.3;

1.3
date	2001.09.10.13.55.39;	author perlman;	state Exp;
branches;
next	1.2;

1.2
date	2001.09.10.09.25.04;	author perlman;	state Exp;
branches;
next	1.1;

1.1
date	2001.08.10.16.02.10;	author perlman;	state Exp;
branches;
next	;


desc
@@


1.10
log
@added doctype
@
text
@#! /usr/bin/perl

($current, $ini) = (@@ARGV);

$ini = "genfile.ini" unless $ini;
$suffix = "html";

require ($ini);

$color = "#DDDDCC" unless $color;
$toctitle = "Table of Contents" unless $toctitle;
$toccols = 1 unless $toccols;
$stoptoc = 0 unless $stoptoc;

if ($current ne $combined) {
	# 1. HTML Header, Menu, Banner
	&genheader($current);
	($index eq $current) && !$stoptoc && &gentoc($current);

	# 2. Include the Body
	print "<a name=\"endnav\"></a>\n";
	open (FILE, "<$current.inc");
	while (<FILE>) {
		print;
	}
	close (FILE);

	# 3. HTML Footer, Menu
	&genfooter($current);
} else { # generate combined file
	&genheader($current);
	&gentoc($current);
	print "<a name=\"endnav\"></a>\n";
	for $item (@@items) {
		($file, $label, $title) = split (/[|]/, $item);
		open (FILE, "<$file.inc");
		print "<a name=\"toc-$file\"></a>\n";
		while (<FILE>) {
			print;
		}
		close (FILE);
	}
	&genfooter();
}

##########################################################################

sub gentoc { # creates a table of contents
	local ($current) = (@@_); # if missing, then make internal TOC
	local ($tocbegin) = "<ul style=\"margin-top: 0; font-size: 80%;\" >";
	local ($toc) = "<p><b>$toctitle</b></p>\n$tocbegin\n";
	local ($item);
	local ($file, $label, $title);
	local ($url); # link from item
	for $item (@@items) {
		($file, $label, $title) = split (/[|]/, $item);
		if ($current ne $combined) { # external toc with links to files
			($file eq $current) && next;
			$url = "$file.$suffix";
		} else { # internal toc with links to names
			$url = "#toc-$file";
		}
		if ($labeltoc) {
			$toc .= "	<li><a href=\"$url\"><b>$label</b>: $title</a></li>\n";
		} else {
			$toc .= "	<li><a href=\"$url\">$title</a></li>\n";
		}
	}
	$toc .= "</ul>\n";
	print $toc;
}

sub genmenu { # sets $menu and $maintitle (called by header and footer)
return unless $current;
($current eq $combined) && return;
local ($current, $top) = @@_; # are we at the top?
local ($options) = $top ? "name='top'" : "";
$menu = "<div align='center'>
<table summary='Navigation Menu' border='0' cellpadding='2' cellspacing='0'><tr valign='top'>
<td>
<a $options accesskey='k' href='#endnav'><img src='2x2.gif' border='0' height='1' width='1' alt='skip navigation' /></a>
</td>\n";
local ($nitems) = 0;
local ($delim) = "<td valign='middle'>|</td>\n";
for $item (@@items) {
	($menu .= $delim) if $nitems++;
	($file, $label, $title) = split (/[|]/, $item);
	if ($current eq $file) {
		$menu .= "<td align='center' bgcolor=\"$color\" style='font-size: 80%'><b title=\"$title\">$label</b></td>\n";
		$maintitle = $title;
		$thisfile = $file;
	} else {
		$menu .= "<td align='center'><a href=\"$file.$suffix\" title=\"$title\"><font size='1'>$label</font></a></td>\n";
	}
}
($menu .= "$delim<td><font size='1'><a href=\"#top\">Top</a></font></td>\n") unless $top;
$menu .= "</tr></table></div>\n";
}

sub genheader
{
local ($current) = @@_;
local ($logfile) = $current ? ".$current.$suffix" : ".$index.$suffix";
local ($htmlfile) = $current ? "$current.$suffix" : "$index.$suffix";
local ($mystartdate) = &getstartdate($current);
local ($leftlogocell, $rightlogocell);
if ($leftlogo) {
	$leftlogocell = "<td align='left' rowspan='2'>$leftlogo</td>";
}
if ($rightlogo) {
	$rightlogocell = "<td align='right' rowspan='2'>$rightlogo</td>";
}
&genmenu($current, 1);

print '<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';

print "<head>
<meta name=\"generator\" content=\"genfile $current $ini\" />
<meta name=\"start-date\" content=\"$mystartdate\" />\n";
if ($hitcounter) {
	print "<meta name=\"accesses\" content=\"<!--#exec cmd=\"$hitcounter $logfile\" -->\" />\n";
}
local ($BOOKTITLE) = "$booktitle : " if $booktitle;

$filekeywords = $keywords{$current};
$filekeywords = $keywords unless $filekeywords;
$filekeywords =~ s/^\s*//;
$filekeywords =~ s/\s*$//;

$filedescription = $description{$current};
$filedescription = $description unless $filedescription;

print "<meta name=\"description\" content=\"$filedescription\" />
<meta name=\"keywords\" content=\"$filekeywords\" />
<!--#config timefmt=\"%Y-%m-%d\"-->
<!--#config sizefmt=\"bytes\"-->
$robot
	<title>
		$BOOKTITLE$maintitle
	</title>
	$style

</head>
<body bgcolor=\"#FFFFFF\">
";
if ($booktitle) {
	print "<table summary='Title' bgcolor='$color' width='100%' border='0' cellpadding='5' cellspacing='0'>
	<tr>
		$leftlogocell
		<td align='center'>
			<div style='font-size: 125%'><b>$booktitle</b></div>
			<div style='font-size: 90%'>$booksubtitle</div>
		</td>
		$rightlogocell
	</tr>
	<tr>
	<td align='center' style='font-size: 80%'>\n";
	&genauthors();
	print "<br/>\n$authornote\n" if $authornote;
	print "	</td>
	</tr>
</table>\n";
}
print "$menu\n";
if ($showtitle) {
	print "<h1>$maintitle</h1>\n";
	print "<p>$filedescription</p>" if ($filedescription && $current eq "index");
}
if ($showstats) {
	print "<p style='font-size: 80%'>\n";
	print "Last updated:\n";
	print "<b><!--#flastmod file=\"$htmlfile\"--></b>\n";
	# print "<br>\n";
	print "&nbsp;\n";
	print "Accesses since $mystartdate: \n";
	print "<b><!--#fsize file=\"$logfile\" --></b>\n";
	print "</p>\n";
}
if ($content{$thisfile}) {
	print "<p>$content{$thisfile}\n";
}
}

sub genauthors
{
	local ($authno) = 0;
	local ($author);
	return unless @@authors;
	if ($attribution) {
		print "$attribution\n";
	} else {
		print "by\n";
	}
	for $author (@@authors) {
		local ($authorname, $authorurl, $authoremail) = split(/[|]/, $author);
		print " and \n" if $authno;
		print "<font size='3'>\n";
		$authorurl && print "<a href=\"$authorurl\">";
		print "<b>$authorname</b>";
		$authorurl && print "</a>";
		print "\n";
		print "</font>\n";
		$authno++;
	}
}

sub genfooter
{
local ($current) = @@_;
&genmenu($current, 0);
print "<br/>
<table summary='Page Footer' bgcolor='$color' width='100%' border='0' cellpadding='5' cellspacing='0'>
	<tr><td align='center' style='font-size: 80%'>
		$footer
	</td></tr>
</table>
$menu
</body>
</html>
";
}

sub getstartdate # file
{
	local ($target) = (@@_);
	$target = "index" unless $target;
	local ($item);
	local ($file, $label, $title, $date);
	for $item (@@items) {
		($file, $label, $title, $date) = split (/[|]/, $item);
		if ($file eq $target) {
			if ($date) {
				return ($date);
			} else {
				return ($startdate);
			}
		}
	}
	return ($startdate);
}
@


1.9
log
@*** empty log message ***
@
text
@d51 1
a51 1
	local ($toc) = "<p><b>$toctitle</b>\n$tocbegin\n";
d64 1
a64 1
			$toc .= "	<li><a href=\"$url\"><b>$label</b>: $title</a>\n";
d66 1
a66 1
			$toc .= "	<li><a href=\"$url\">$title</a>\n";
d81 1
a81 1
<a $options accesskey='k' href='#endnav'><img src='2x2.gif' border='0' height='1' width='1' alt='skip navigation'></a>
d115 7
a121 4
print "<html lang=\"en\">
<head>
<meta name=\"generator\" content=\"genfile $current $ini\">
<meta name=\"start-date\" content=\"$mystartdate\">\n";
d123 1
a123 1
	print "<meta name=\"accesses\" content=\"<!--#exec cmd=\"$hitcounter $logfile\" -->\">\n";
d135 2
a136 2
print "<meta name=\"description\" content=\"$filedescription\">
<meta name=\"keywords\" content=\"$filekeywords\">
@


1.8
log
@*** empty log message ***
@
text
@d50 2
a51 2
	local ($tocbegin) = "<ul style=\"margin-top: 0\" >";
	local ($toc) = "<p><b>$toctitle</b>\n$tocbegin\n<font size=2>";
d69 1
a69 1
	$toc .= "</font></ul>\n";
d76 4
a79 3
local ($current, $top) = @@_; # should we show the top link/
$menu = "<div align=center>
<table border=0 cellpadding=2 cellspacing=0><tr valign=top>
d81 1
a81 1
<a name=top accesskey=k href=\"#endnav\"><img src=2x2.gif border=0 height=1 width=1 alt=\"skip navigation\"></a>
d84 1
a84 1
local ($delim) = "<td valign=center>|</td>\n";
d89 1
a89 1
		$menu .= "<td align=center bgcolor=\"$color\"><font size=2><b title=\"$title\">$label</b></font></td>\n";
d93 1
a93 1
		$menu .= "<td align=center><a href=\"$file.$suffix\" title=\"$title\"><font size=1>$label</font></a></td>\n";
d96 1
a96 1
($menu .= "$delim<td><font size=1><a href=\"#top\">Top</a></font></td>\n") if $top;
d108 1
a108 1
	$leftlogocell = "<td align=left rowspan=2>$leftlogo</td>";
d111 1
a111 1
	$rightlogocell = "<td align=right rowspan=2>$rightlogo</td>";
d113 2
a114 1
&genmenu($current, 0);
d118 1
a118 1
<meta name = \"start-date\" content=\"$mystartdate\">\n";
d123 11
a133 2
print "<meta name=\"description\" content=\"$description\">
<meta name=\"keywords\" content=\"$keywords\">
d136 1
a143 18
<table bgcolor=\"$color\" width=\"100%\" border=0 cellpadding=5 cellspacing=0>
<tr>
	$leftlogocell
	<td align=center>
		<div style=\"font-size: 125%\"><b>$booktitle</b></div>
		<div style=\"font-size: 90%\">$booksubtitle</div>
	</td>
	$rightlogocell
</tr>
";
print "<tr>
	<td align=center><font size=2>\n";
&genauthors();
print "<br>\n$authornote\n" if $authornote;
print "	</font></td>
</tr>
</table>
$menu
d145 19
d166 1
a166 1
	print "<p>$description</p>" if ($current eq "index");
d169 1
a169 1
	print "<p><font size=2>\n";
d176 1
a176 1
	print "</font>\n";
d196 1
a196 1
		print "<font size=3>\n";
d209 6
a214 8
&genmenu($current, 1);
print "<p>
<table bgcolor=\"$color\" width=\"100%\" border=0 cellpadding=5 cellspacing=0>
<tr><td align=center>
<font size=2>
$footer
</font>
</td></tr>
@


1.7
log
@*** empty log message ***
@
text
@d1 1
a1 1
#! /usr/local/bin/perl
d6 1
d13 1
d18 1
a18 1
	($index eq $current) && &gentoc($current);
d59 1
a59 1
			$url = "$file.html";
d63 5
a67 1
		$toc .= "	<li><a href=\"$url\">$title</a>\n";
d77 5
a81 1
$menu = "<div align=center><table border=0 cellpadding=2 cellspacing=0><tr>\n";
d83 1
a83 1
local ($delim) = "<td>|</td>\n";
d88 1
a88 1
		$menu .= "<td bgcolor=\"$color\"><font size=2><b title=\"$title\">$label</b></font></td>\n";
d90 1
d92 1
a92 1
		$menu .= "<td><a href=\"$file.html\" title=\"$title\"><font size=1>$label</font></a></td>\n";
d102 2
a103 1
local ($logfile) = $current ? ".$current.html" : ".$index.html";
d105 7
d116 6
a121 3
<meta name = \"start-date\" content=\"$mystartdate\">
<meta name=\"accesses\" content=\"<!--#exec cmd=\"$hitcounter $logfile\" -->\">
<meta name=\"description\" content=\"$description\">
d126 1
a126 1
		$booktitle : $maintitle
d134 1
d136 2
a137 7
<a name=top accesskey=k href=\"#endnav\"><img src=2x2.gif border=0 alt=\"skip navigation\"></a>
		<font size=4>
		<b>$booktitle</b>
		</font>
		<font size=2>
		<br>$booksubtitle
		</font>
d139 1
d151 4
d158 3
a160 2
	print "<b><!--#flastmod file=\"$logfile\"--></b>\n";
	print "<br>\n";
d165 3
d175 5
a179 1
	print "by\n";
@


1.6
log
@added startdate override
@
text
@d11 1
d48 2
a49 1
	local ($toc) = "<p><b>$toctitle</b>\n<ul style=\"margin-top: 0\" >\n<font size=2>";
@


1.5
log
@*** empty log message ***
@
text
@d90 1
a90 1
local ($thisstartdate) = $startdate;
d95 1
a95 1
<meta name=\"start-date\" content=\"$startdate\">
d135 1
a135 1
	print "Accesses since $startdate: \n";
d176 19
@


1.4
log
@*** empty log message ***
@
text
@d10 1
d47 1
a47 1
	local ($toc) = "<p><b>Table of Contents</b>\n<ul>\n<font size=2>";
d90 1
d111 1
a111 1
<a name=top href=\"#endnav\"><img src=2x2.gif border=0 alt=\"skip navigation\"></a>
@


1.3
log
@working version while adding multifile capability
@
text
@d11 1
a11 1
if ($current) {
d14 1
d17 1
d27 3
a29 1
	&genheader();
d33 1
d44 20
d66 1
d88 1
d90 1
a90 2
print "
<html>
d94 1
a94 1
<meta name=\"accesses\" content=\"<!--#exec cmd=\"$hitcounter .$current.html\" -->\">
d96 3
a98 1
<meta <META NAME=\"keywords\" CONTENT=\"$keywords\">
d105 1
a105 1
<body bgcolor=\"#FFFFFF\"><a name=top></a>
d109 1
d128 9
@


1.2
log
@*** empty log message ***
@
text
@d24 1
a24 1
} else { # generate comined file
@


1.1
log
@Initial revision
@
text
@d11 3
a13 2
# 1. HTML Header, Menu, Banner
&genheader($current);
d15 20
a34 4
# 2. Include the Body
open (FILE, "<$current.inc");
while (<FILE>) {
	print;
a36 3
# 3. HTML Footer, Menu
&genfooter($current);

d40 1
d66 1
@
