#!/usr/bin/perl

# A perl filter to update the index.html page for HOWTO's
# Ralph Siemsen Oct 1999

my %description = (

'Firmware-HOWTO' => "explains how to use and update the NetWinder flash
memory.  This is the equivalent to a normal PC's BIOS, though it has a few
more options.",

'Kernel-HOWTO' => "describes howto compile and install kernels on a
NetWinder.  It needs to be updated for the 2.2.x and beyond kernel series
(soon, I promise!).",

'Disk-Update-HOWTO' => "explains how to install new disk images on a
NetWinder.  Particularly usefulfor doing upgrades or for rescuing a system
that no longer boots.",

'Rescue-HOWTO' => "explains how to use the rescue partition used on the
OfficeServer (and dm-3.1-15), and how it can be used to easily recover your
system.",

);

foreach $file (sort keys %description) {
  $description .= qq(<li>The <a href="$file.html">$file</a> $description{$file}</li>);
  $tableline = "<th>$file</th>\n";
  foreach $type (qw/.html -all.html .ps .ps.gz .dvi .sgml/) {
    $size = getsize("$file$type");
    $tableline .= qq(<td align=center><a href="$file$type">$size</a></td>);
  }
  $table .= "<tr>$tableline</tr>";
}

$date = `date "+%A, %B %d @ %I:%M %p"`;

print <<EOF;
<!doctype html public "-//w3c//dtd html 3.2 final//en">
<html>
<head>
 <title>Netwinder HOWTO's</title>
</head>
<body bgcolor="white">

<hr size=1 width="100%" shade>

<h3>NetWinder howto's<br>
<span class=small>Last updated by <a href="mailto:ralphs\@netwinder.org">Ralph</a> on
$date</span></h3>

<p>A number of HOWTO's now exist to help with common tasks such as kernel,
firmware and disk upgrades.  Feedback on these documents is appreciated,
please direct your comments to the author of the HOWTO.  The following
documents are currently available:</p>

<ul>$description</ul>

<p>For your convenience, the HOWTO's are available in a number of different
formats.  They are generated from a common source document so they should
all be identical in content.</p>

<center><table>
<tr>
  <th></th>
  <th>HTML (individual pages)</th>
  <th>HTML (one big page)</th>
  <th>PostScript</th>
  <th>Compressed PostScript</th>
  <th>DVI</th>
  <th>SGML Source</th>
</tr>
$table
</table></center>

<p>If in doubt, use the first column :)</p>

<hr size="1" width="100%" shade>

<h5>Copyright &copy;1998, 1999 NetWinder.Org.&nbsp; All Rights Reserved.
<br>For questions, comments, or suggestions contact
<a href="mailto:webmaster\@netwinder.org">webmaster\@netwinder.org</h5>

</body>
</html>
EOF

sub getsize {
  $size = `ls -l $_[0] | awk '{print \$5}'`;
  ($num, $let) = $size =~ /([\d.]+)(.*)/;
  if ($num > 1024 * 1024) {
    $num = sprintf ("%.1f M", $num / 1024 / 1024);
  } elsif ($num > 1024) {
    $num = sprintf ("%.1f k", $num / 1024);
  }
  return $num . 'bytes';
}
