53 |
## |
## |
54 |
|
|
55 |
## show debug output |
## show debug output |
56 |
my $debug=1; |
my $debug=0; |
57 |
|
|
58 |
## default DOCTYPE added on the slides |
## default DOCTYPE added on the slides |
59 |
$doctype = '<html xmlns="http://www.w3.org/TR/REC-html40">'; |
$doctype = '<html xmlns="http://www.w3.org/TR/REC-html40">'; |
133 |
my %page_data; |
my %page_data; |
134 |
my %overview_data; |
my %overview_data; |
135 |
|
|
136 |
|
my $pack = 0; |
137 |
|
my @pack_additional; # additional files to pack (pictures, logos...) |
138 |
|
|
139 |
############################################################################## |
############################################################################## |
140 |
## reading user input from $infos |
## reading user input from $infos |
141 |
## |
## |
142 |
@PARAM = @ARGV; # we keep this for backward compatibility with an old version |
my @file; |
|
# of the slidemaker tool |
|
|
#when the parameters were in Makefile or make.bat |
|
143 |
|
|
144 |
# read parameters from infos.txt and put them in @PARAM |
############################################################################## |
145 |
if (open(INFOS, $infos)) { |
sub parse_infos { |
146 |
print STDOUT "--- Reading parameters file $infos ---\n"; |
my @file=@_; |
|
local(@file,$counter); |
|
|
$counter = 0; |
|
|
@file = <INFOS>; |
|
|
@PARAM = (); |
|
147 |
do { |
do { |
148 |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
149 |
$file[0] =~ s/\n//; # remove UNIX \n |
$file[0] =~ s/\n//; # remove UNIX \n |
150 |
$file[0] =~ s/\r//; # remove WINDOWS \r |
$file[0] =~ s/\r//; # remove WINDOWS \r |
151 |
$file[0] =~ s/ *= */=/; |
my ($var,$value) = split(/ *= */,$file[0],2); |
152 |
$PARAM[$counter++] = $file[0]; |
$value=~s/'/\\'/g; |
153 |
print "$file[0]\n"; |
$cmd="\$$var = \'$value\';"; |
154 |
|
if (defined($value)) { |
155 |
|
eval($cmd) || warn "problem with eval of: $cmd"; |
156 |
|
} else { |
157 |
|
die "no value defined for $var"; |
158 |
|
} |
159 |
|
print STDERR "$file[0]\n"; |
160 |
} |
} |
161 |
} while (shift(@file)); |
} while (shift(@file)); |
162 |
} |
} |
163 |
## @PARAM is now a table with the user preferences for his presentation |
############################################################################## |
164 |
|
|
165 |
## process arguments |
parse_infos(@ARGV); # backward compatibility and for pack |
166 |
## each preset variable is now re-attributed using the user preferences |
|
167 |
foreach (@PARAM) { |
# read parameters from infos.txt and put them in @PARAM |
168 |
my ($var,$value) = split(/ *= */,$_,2); |
if (open(INFOS, $infos)) { |
169 |
$value=~s/'/\\'/g; |
print STDERR "--- Reading parameters file $infos ---\n"; |
170 |
$cmd="\$$var = \'$value\';"; |
@file = <INFOS>; |
171 |
if ($value) { |
parse_infos(@file); |
|
eval($cmd) || die "problem with eval of: $cmd"; |
|
|
} else { |
|
|
die "no value defined for $var"; |
|
|
} |
|
172 |
} |
} |
173 |
|
|
174 |
|
# try to read local infos.txt for template |
175 |
|
if (-f "$template/$infos" && open(INFOS,"$template/$infos")) { |
176 |
|
print STDERR "--- Reading template parameters file $template/$infos ---\n"; |
177 |
|
@file = <INFOS>; |
178 |
|
parse_infos(@file); |
179 |
|
close(INFOS); |
180 |
|
} |
181 |
|
|
182 |
|
## @PARAM is now a table with the user preferences for his presentation |
183 |
|
|
184 |
## use charset |
## use charset |
185 |
|
|
186 |
if ($charset) { |
if ($charset) { |
189 |
$http_equiv=''; |
$http_equiv=''; |
190 |
} |
} |
191 |
|
|
192 |
|
|
193 |
############################################################################## |
############################################################################## |
194 |
## read the raw html presentation |
## read the raw html presentation |
195 |
## |
## |
199 |
$/ = undef; |
$/ = undef; |
200 |
open(ALL, $all) || die "Error: Cannot open file: $all"; |
open(ALL, $all) || die "Error: Cannot open file: $all"; |
201 |
my $buf = <ALL>; |
my $buf = <ALL>; |
202 |
|
$buf =~ s/\r//g; # remove WINDOWS \r |
203 |
close(ALL); |
close(ALL); |
204 |
$/ = $sep; |
$/ = $sep; |
205 |
|
|
207 |
## they do not need to show up on the slides |
## they do not need to show up on the slides |
208 |
$buf =~ s/<!--.*?-->//sgo; |
$buf =~ s/<!--.*?-->//sgo; |
209 |
|
|
210 |
|
## if $pack is set, output name of css (for inclusion in archive), but |
211 |
|
## reset $cssStandard only to filename (without path) |
212 |
|
|
213 |
|
if ($pack) { |
214 |
|
push @pack_additional,$cssStandard; |
215 |
|
$cssStandard =~ s/^.*\/([^\/]+)$/$1/g; |
216 |
|
} |
217 |
|
|
218 |
## the slidemaker tool assumes that each slide is self contained between 2 sets of h1 tags |
## the slidemaker tool assumes that each slide is self contained between 2 sets of h1 tags |
219 |
## if not it will generate a rather weird output |
## if not it will generate a rather weird output |
220 |
## split using <h1...> and </h1...> as separator (ignores attributes!) |
## split using <h1...> and </h1...> as separator (ignores attributes!) |
234 |
############################################################################## |
############################################################################## |
235 |
## processing the slides |
## processing the slides |
236 |
|
|
237 |
print STDOUT "\n--- Processing $total slides ---\n"; |
print STDERR "\n--- Processing $total slides ---\n"; |
238 |
|
|
239 |
## generate the header table of content of the presentation |
## generate the header table of content of the presentation |
240 |
## which is also the first page of the talk |
## which is also the first page of the talk |
251 |
Text::FastTemplate->preload( [ |
Text::FastTemplate->preload( [ |
252 |
{ file => 'slide.html', key => 'slide' }, |
{ file => 'slide.html', key => 'slide' }, |
253 |
{ file => 'overview.html', key => 'overview' }, |
{ file => 'overview.html', key => 'overview' }, |
254 |
|
{ file => 'title.html', key => 'title' }, |
255 |
]); |
]); |
256 |
|
|
257 |
## unroll relative anchors (#something) into links with slides |
## unroll relative anchors (#something) into links with slides |
263 |
my $tmp = $table[($i*2)].$table[($i*2)+1]; |
my $tmp = $table[($i*2)].$table[($i*2)+1]; |
264 |
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
265 |
$anchor_on_slide{$1}=($i+1); |
$anchor_on_slide{$1}=($i+1); |
266 |
print "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
print STDERR "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
267 |
} |
} |
268 |
} |
} |
269 |
|
|
342 |
## and would not work on all platforms (ie would fail on Joe's laptop) |
## and would not work on all platforms (ie would fail on Joe's laptop) |
343 |
&generateTOC; |
&generateTOC; |
344 |
|
|
345 |
|
## print additional files to pack |
346 |
|
print STDOUT join("\n",@pack_additional) if ($pack); |
347 |
|
|
348 |
print STDOUT "--- Finished ---\n"; |
print STDERR "--- Finished ---\n"; |
349 |
exit 0; |
exit 0; |
350 |
## |
## |
351 |
## end of the slidemaker main program |
## end of the slidemaker main program |
359 |
{ |
{ |
360 |
## open the file to write to |
## open the file to write to |
361 |
open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!"; |
open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!"; |
362 |
|
push @pack_additional,"$_[0].html" if ($pack); |
363 |
|
|
364 |
## the style sheet used in the table of content is |
## the style sheet used in the table of content is |
365 |
$stylelink = ""; |
$stylelink = ""; |
388 |
author => $author, |
author => $author, |
389 |
authorUrl => $authorUrl, |
authorUrl => $authorUrl, |
390 |
author2 => $author2, |
author2 => $author2, |
391 |
authorUrl2 => $authorUrl2, |
author2Url => $author2Url, |
392 |
|
|
393 |
date => $date, |
date => $date, |
394 |
|
|
395 |
toc => $loc_toc, |
toc_title => $loc_toc, |
396 |
|
template_dir => "$template/", |
397 |
); |
); |
398 |
|
|
399 |
} |
} |
410 |
$overview_data{toc_entries} = [ @toc_entries ]; |
$overview_data{toc_entries} = [ @toc_entries ]; |
411 |
|
|
412 |
my $page= new Text::FastTemplate key => 'overview'; |
my $page= new Text::FastTemplate key => 'overview'; |
413 |
|
$page_data{template_dir}='' if ($pack); |
414 |
print FOO $page->output( \%overview_data ); |
print FOO $page->output( \%overview_data ); |
415 |
|
|
416 |
close(FOO); |
close(FOO); |
454 |
} |
} |
455 |
|
|
456 |
$pre_ul=$post_ul=''; |
$pre_ul=$post_ul=''; |
457 |
if ($last_toc_title eq $title) { |
if ($last_toc_title eq $title && $subtitle) { |
458 |
$title = $subtitle; |
$title = $subtitle; |
459 |
$pre_ul='<ul>'; |
$pre_ul='<ul>'; |
460 |
$post_ul='</ul>'; |
$post_ul='</ul>'; |
526 |
|
|
527 |
$status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle; |
$status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle; |
528 |
$status =~ s/<[^>]+>//g; |
$status =~ s/<[^>]+>//g; |
529 |
print STDOUT $status; |
print STDERR $status; |
530 |
|
|
531 |
&verify_html($content); # check the html |
&verify_html($content); # check the html |
532 |
|
|
533 |
## write to the slide |
## write to the slide |
534 |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
535 |
|
push @pack_additional,"slide$nr.html" if ($pack); |
536 |
|
|
537 |
my $toc_link = "$overview\.html"; |
my $toc_link = "$overview\.html"; |
538 |
|
|
557 |
|
|
558 |
my $slide_html=make_progress_bar($nr,$total); |
my $slide_html=make_progress_bar($nr,$total); |
559 |
|
|
560 |
|
# undefine body if no content is found (so that template can show |
561 |
|
# only title and sub-title |
562 |
|
if ($content !~ m/\S/g) { |
563 |
|
undef $content; |
564 |
|
} |
565 |
|
|
566 |
%page_data = ( |
%page_data = ( |
567 |
doctype => $doctype, |
doctype => $doctype, |
568 |
talkTitle => $talkTitle, |
talkTitle => $talkTitle, |
587 |
toc_link => $toc_link, |
toc_link => $toc_link, |
588 |
next_link => $next_link, |
next_link => $next_link, |
589 |
prev_title => $prev_title, |
prev_title => $prev_title, |
590 |
|
toc_title => $loc_toc, |
591 |
next_title => $next_title, |
next_title => $next_title, |
592 |
|
|
593 |
author => $author, |
author => $author, |
594 |
authorUrl => $authorUrl, |
authorUrl => $authorUrl, |
595 |
author2 => $author2, |
author2 => $author2, |
596 |
authorUrl2 => $authorUrl2, |
author2Url => $author2Url, |
597 |
|
|
598 |
date => $date, |
date => $date, |
599 |
|
|
600 |
slide_html => $slide_html, |
slide_html => $slide_html, |
601 |
|
|
602 |
|
template_dir => "$template/", |
603 |
); |
); |
604 |
|
|
605 |
my $page= new Text::FastTemplate key => 'slide'; |
my $page; |
606 |
|
if ($content) { |
607 |
|
$page= new Text::FastTemplate key => 'slide'; |
608 |
|
} else { |
609 |
|
$page= new Text::FastTemplate key => 'title'; |
610 |
|
} |
611 |
|
$page_data{template_dir}='' if ($pack); |
612 |
print SLIDE $page->output( \%page_data ); |
print SLIDE $page->output( \%page_data ); |
613 |
|
extract_files($page->output( \%page_data )) if ($pack); |
614 |
close(SLIDE); |
close(SLIDE); |
615 |
return 0; |
return 0; |
616 |
} |
} |
658 |
|
|
659 |
if ($_[0] =~ /<img([^>]*)>/im) { |
if ($_[0] =~ /<img([^>]*)>/im) { |
660 |
if (!($1 =~ /ALT=/im)) { |
if (!($1 =~ /ALT=/im)) { |
661 |
print STDOUT "WARNING: <IMG> without ALT\n"; |
print STDERR "WARNING: <IMG> without ALT\n"; |
662 |
print STDOUT " <IMG$1>\n" ; |
print STDERR " <IMG$1>\n" ; |
663 |
} |
} |
664 |
} |
} |
665 |
} |
} |
696 |
my $pcnt_done=int($nr*100/$total); |
my $pcnt_done=int($nr*100/$total); |
697 |
my $pcnt_left=100-$pcnt_done; |
my $pcnt_left=100-$pcnt_done; |
698 |
|
|
699 |
if ($progress_bar) { |
if ($progress_bar && uc($progress_bar) ne "NO") { |
700 |
my $l=$r=" "; |
my $l=$r=" "; |
701 |
my $t="$nr of $total"; |
my $t="$nr of $total"; |
702 |
if ($pcnt_done > 50) { |
if ($pcnt_done > 50) { |
704 |
} else { |
} else { |
705 |
$r=$t; |
$r=$t; |
706 |
} |
} |
707 |
$html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr><td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td><td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td></tr></table>'; |
$html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr>'; |
708 |
|
if ($pcnt_done != 0) { |
709 |
|
$html.='<td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td>'; |
710 |
|
} |
711 |
|
if ($pcnt_left != 0) { |
712 |
|
$html.='<td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td>'; |
713 |
|
} |
714 |
|
$html.='</tr></table>'; |
715 |
} else { |
} else { |
716 |
$html="$loc_slide $nr $loc_of $total"; |
$html="$loc_slide $nr $loc_of $total"; |
717 |
} |
} |
720 |
} |
} |
721 |
|
|
722 |
############################################################################## |
############################################################################## |
723 |
# make slide progress bar |
# remove anchors <a href...> from html (for titles) |
724 |
sub remove_anchor { |
sub remove_anchor { |
725 |
my $tmp = $_[0]; |
my $tmp = $_[0]; |
726 |
$tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig; |
$tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig; |
727 |
return $tmp; |
return $tmp; |
728 |
} |
} |
729 |
|
|
730 |
|
############################################################################## |
731 |
|
# extract files referenced in presentation |
732 |
|
|
733 |
|
sub extract_files { |
734 |
|
my $tmp = $_[0]; |
735 |
|
while ($tmp =~ s/href="*([^"\s]+)"*//ism || |
736 |
|
$tmp =~ s/src="*([^"\s]+)"*//ism) { |
737 |
|
if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) { |
738 |
|
push @pack_additional,$1; |
739 |
|
} |
740 |
|
} |
741 |
|
} |