The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

EOA

my $arrows_html = <<EOA ;

$title [@{[$slide_index+1]}/$number_of_slides] <<  ^  >> Copyright © $copyright

EOA

my $pod = read_file("$out_dir$slide_file.pod") ;
write_file("$out_dir$slide_file.pod", $pod, $arrows_html) ;

my $md5 = 'error' ;
if(open(FILE, "$out_dir$slide_file.pod"))
	{
	binmode(FILE);
	
	$md5 = Digest::MD5->new->addfile(*FILE)->hexdigest ;
	close(FILE) ;
	}
	
my $previous_md5 = "doesn't exist" ;

if(open(FILE, "$out_dir$slide_file.md5"))
	{
	$previous_md5 = <FILE> ;
	}
	
if($md5 ne $previous_md5)
	{
	$regenerated_slides++ ;
	
	print "Generating slide @{[$slide_index + 1]}: '$unmodified_slide_name' $undone_flag.\n" ;
	
	pod2html
		(
		  "--infile=$out_dir$slide_file.pod"
		, "--outfile=$out_dir$slide_file.html"
		, "--css"
		, "perl_style.css"
		, "--noindex"
		) ;
		
	open(FILE, ">", "$out_dir$slide_file.md5") or die "can't open '$out_dir$slide_file.md5': $!" ;
	print FILE $md5 ;
	close FILE ;
	}
else
	{
	print "Undone flag set for: '$unmodified_slide_name'.\n" if $undone_flag eq '*' ;
	}
	
#~ unlink("$out_dir$slide_file.pod") ;

# Arfff!
{
open(FILE, "+<", "$out_dir$slide_file.html") or die "can't open '$out_dir$slide_file.html: $!" ;
local $/ = undef ;
my $text = <FILE> ;
$text =~ s~<p><a name="__index__"></a></p>~~ ;
$text =~ s~<hr />\n<h1>~<h1>~g ;
$text =~ s~<div class=pod><p>\n</p>~<div class=pod>~ ;

seek(FILE, 0, 0) ;
print FILE $text ;
truncate(FILE, tell(FILE)) ;
close(FILE) ;
}

$slide_file =~ s/^$out_dir// ;

$index_text .= sprintf("%03d ", $slide_index + 1) ;
$index_text .= "<a href='$slide_file.html'>$unmodified_slide_name$undone_flag</a><br>\n\n" ;
}

# generate index print "Generating index => $number_of_slides/$regenerated_slides/$number_of_undone_slides\n" ;

open INDEX, ">", "${out_dir}index_slide.html" or die "can't open '${out_dir}index_slide.html': $!" ;

print INDEX <<EOHTML ; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="perl_style.css" type="text/css" /> </head>

<div class="pod"> <body> <H1>$title</H1> $index_text <br> <div class="path"> <table width=100%> <tr> <td width=50%>$title</a></td> <td align="right" width=50%>Copyright &copy; $copyright</td> </tr> </table> </body> </html> EOHTML

close INDEX ;