#!/usr/bin/perl -w

#    convert.pl convert bitmap images in HTML slides
#    Copyright (C) 2001 Ludovic Rousseau <ludovic.rousseau@free.fr> 
#
#    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;

my ($i, $j, $head, $tail, $file);

$head = "Diapositive";
$tail = ".png";

$i = 1;
$j = sprintf "%02d", $i;

$file = "$head$j.html";
open (FILE, "> $file") or die "Can't open $file: $!";

print FILE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print FILE "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n";
print FILE "\"http://www.w3.org/TR/1998/REC-html40-19980424/strict.dtd\">\n";

print FILE "<html><head><title>Slide $i</title></head><body><p>\n";
print FILE "<a href=\"$head" . (sprintf "%02d", ($i+1)) .  ".html\">next</a></p>\n";
print FILE "<p><img src=\"$head$j$tail\" alt=\"$head$j$tail\"></p>\n";
print FILE "<hr><p>Slides <a href=\"convert.pl\">converted</a> from PPT to HTML/png by <a href=\"mailto:Ludovic.Rousseau\@free.fr\">Ludovic Rousseau</a>, Nov 2001</p>\n";
print FILE "</body></html>\n";

close FILE;

for $i (2..17)
{
	$j = sprintf "%02d", $i;
	print "$i\n";

	$file = "$head$j.html";
	open (FILE, "> $file") or die "Can't open $file: $!";

	print FILE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
	print FILE "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n";
	print FILE "\"http://www.w3.org/TR/1998/REC-html40-19980424/strict.dtd\">\n";

	print FILE "<html><head><title>Slide $i</title></head><body><p>\n";
	print FILE "<a href=\"$head" . (sprintf "%02d", ($i-1)) . ".html\">prev</a>\n";
	print FILE "<a href=\"$head" . (sprintf "%02d", ($i+1)) .  ".html\">next</a></p>\n";
	print FILE "<p><img src=\"$head$j$tail\" alt=\"$head$j$tail\"></p>\n";
	print FILE "<hr><p>Slides <a href=\"convert.pl\">converted</a> from PPT to HTML/png by <a href=\"mailto:Ludovic.Rousseau\@free.fr\">Ludovic Rousseau</a>, Nov 2001</p>\n";
	print FILE "</body></html>\n";

	close FILE;
}

$i = 18;

$file = "$head" . (sprintf "%02d", $i) . ".html";
open (FILE, "> $file") or die "Can't open $file: $!";

print FILE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print FILE "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n";
print FILE "\"http://www.w3.org/TR/1998/REC-html40-19980424/strict.dtd\">\n";

print FILE "<html><head><title>Slide $i</title></head><body><p>\n";
print FILE "<a href=\"$head" . ($i-1) . ".html\">prev</a></p>\n";
print FILE "<p><img src=\"$head$i$tail\" alt=\"$head$i$tail\"></p>\n";
print FILE "<hr><p>Slides <a href=\"convert.pl\">converted</a> from PPT to HTML/png by <a href=\"mailto:Ludovic.Rousseau\@free.fr\">Ludovic Rousseau</a>, Nov 2001</p>\n";
print FILE "</body></html>\n";

close FILE;

