1 |
#!/usr/local/bin/perl |
#!/usr/bin/perl |
2 |
# |
# |
3 |
# SLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org> |
# PLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org> |
4 |
# |
# |
5 |
# this tool is based on SlideMaker and XLSies tool |
# this tool is based on SlideMaker and XLSies tool |
6 |
# split a all.htm into slide*.htm |
# split a all.htm into slide*.htm |
42 |
# |
# |
43 |
# Sami Lempinen - lempinen@iki.fi |
# Sami Lempinen - lempinen@iki.fi |
44 |
# http://www.snowman.sgic.fi/ssl/xslies/ |
# http://www.snowman.sgic.fi/ssl/xslies/ |
45 |
|
# |
46 |
|
# Text::FastTemplate: |
47 |
|
# Robert Lehr - bozzio@the-lehrs.com |
48 |
|
|
49 |
|
use Text::FastTemplate; |
50 |
|
|
51 |
############################################################################## |
############################################################################## |
52 |
## default values of variables |
## default values of variables |
53 |
## |
## |
54 |
|
|
55 |
|
## show debug output |
56 |
|
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">'; |
60 |
|
|
107 |
## standard style sheets |
## standard style sheets |
108 |
$cssStandard = '../PLies/css/default.css'; |
$cssStandard = '../PLies/css/default.css'; |
109 |
|
|
110 |
|
## template name |
111 |
|
$template = '../PLies/default'; |
112 |
|
|
113 |
## default charset use in meta tag http-equiv (undef to skip) |
## default charset use in meta tag http-equiv (undef to skip) |
114 |
#$charset = 'ISO-8859-1'; |
#$charset = 'ISO-8859-1'; |
115 |
|
|
129 |
############################################################################## |
############################################################################## |
130 |
|
|
131 |
## globals |
## globals |
|
my $logo_html; |
|
|
my $date_html; |
|
132 |
my $last_toc_title; |
my $last_toc_title; |
133 |
|
my %page_data; |
134 |
|
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 |
143 |
# of the slidemaker tool |
# of the slidemaker tool |
144 |
#when the parameters were in Makefile or make.bat |
#when the parameters were in Makefile or make.bat |
145 |
|
|
146 |
|
my @file; |
147 |
|
|
148 |
|
############################################################################## |
149 |
|
sub parse_infos { |
150 |
|
my @file=@_; |
151 |
|
do { |
152 |
|
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
153 |
|
$file[0] =~ s/\n//; # remove UNIX \n |
154 |
|
$file[0] =~ s/\r//; # remove WINDOWS \r |
155 |
|
my ($var,$value) = split(/ *= */,$file[0],2); |
156 |
|
$value=~s/'/\\'/g; |
157 |
|
$cmd="\$$var = \'$value\';"; |
158 |
|
if (defined($value)) { |
159 |
|
eval($cmd) || warn "problem with eval of: $cmd"; |
160 |
|
} else { |
161 |
|
die "no value defined for $var"; |
162 |
|
} |
163 |
|
print STDERR "$file[0]\n"; |
164 |
|
} |
165 |
|
} while (shift(@file)); |
166 |
|
} |
167 |
|
############################################################################## |
168 |
|
|
169 |
# read parameters from infos.txt and put them in @PARAM |
# read parameters from infos.txt and put them in @PARAM |
170 |
if (open(INFOS, $infos)) { |
if (open(INFOS, $infos)) { |
171 |
print STDOUT "--- Reading parameters file $infos ---\n"; |
print STDERR "--- Reading parameters file $infos ---\n"; |
172 |
local(@file,$counter); |
@file = <INFOS>; |
173 |
$counter = 0; |
parse_infos(@file); |
|
@file = <INFOS>; |
|
|
@PARAM = (); |
|
|
do { |
|
|
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
|
|
$file[0] =~ s/\n//; # remove UNIX \n |
|
|
$file[0] =~ s/\r//; # remove WINDOWS \r |
|
|
$file[0] =~ s/ *= */=/; |
|
|
$PARAM[$counter++] = $file[0]; |
|
|
print "$file[0]\n"; |
|
|
} |
|
|
} while (shift(@file)); |
|
174 |
} |
} |
|
## @PARAM is now a table with the user preferences for his presentation |
|
175 |
|
|
176 |
## process arguments |
# try to read local infos.txt for template |
177 |
## each preset variable is now re-attributed using the user preferences |
if (-f "$template/$infos" && open(INFOS,"$template/$infos")) { |
178 |
foreach (@PARAM) { |
print STDERR "--- Reading template parameters file $template/$infos ---\n"; |
179 |
@_ = split(/ *= */,$_,2); |
@file = <INFOS>; |
180 |
$cmd="\$$_[0] = \'$_[1]\';"; |
parse_infos(@file); |
181 |
if (length $_[1] != 0) { |
close(INFOS); |
|
eval($cmd); |
|
|
} |
|
182 |
} |
} |
183 |
|
|
184 |
|
## @PARAM is now a table with the user preferences for his presentation |
185 |
|
|
186 |
## use charset |
## use charset |
187 |
|
|
188 |
if ($charset) { |
if ($charset) { |
192 |
} |
} |
193 |
|
|
194 |
|
|
|
## build an html string for the author variable |
|
|
## containing the presentation author name linked to |
|
|
## a location of his choice |
|
|
if ($authorUrl) { |
|
|
$author = "<a href=\"$authorUrl\">$author</a>"; |
|
|
} |
|
|
|
|
|
## same string is built if there is a second author for the presentation |
|
|
if ($author2Url) { |
|
|
$author2 = "<a href=\"$author2Url\">$author2</a>"; |
|
|
} |
|
|
if ($author2) { |
|
|
$author2 = "<br>$author2"; |
|
|
} |
|
|
|
|
195 |
############################################################################## |
############################################################################## |
196 |
## read the raw html presentation |
## read the raw html presentation |
197 |
## |
## |
199 |
## copy file in memory |
## copy file in memory |
200 |
my $sep = $/; |
my $sep = $/; |
201 |
$/ = undef; |
$/ = undef; |
202 |
if (!open(ALL, $all)) { |
open(ALL, $all) || die "Error: Cannot open file: $all"; |
|
print "Error: Cannot open file: $all\n"; |
|
|
exit 0; |
|
|
} |
|
203 |
my $buf = <ALL>; |
my $buf = <ALL>; |
204 |
|
$buf =~ s/\r//g; # remove WINDOWS \r |
205 |
close(ALL); |
close(ALL); |
206 |
$/ = $sep; |
$/ = $sep; |
207 |
|
|
209 |
## they do not need to show up on the slides |
## they do not need to show up on the slides |
210 |
$buf =~ s/<!--.*?-->//sgo; |
$buf =~ s/<!--.*?-->//sgo; |
211 |
|
|
212 |
|
## if $pack is set, output name of css (for inclusion in archive), but |
213 |
|
## reset $cssStandard only to filename (without path) |
214 |
|
|
215 |
|
if ($pack) { |
216 |
|
push @pack_additional,$cssStandard; |
217 |
|
$cssStandard =~ s/^.*\/([^\/]+)$/$1/g; |
218 |
|
} |
219 |
|
|
220 |
## 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 |
221 |
## if not it will generate a rather weird output |
## if not it will generate a rather weird output |
222 |
## split using <h1...> and </h1...> as separator (ignores attributes!) |
## split using <h1...> and </h1...> as separator (ignores attributes!) |
236 |
############################################################################## |
############################################################################## |
237 |
## processing the slides |
## processing the slides |
238 |
|
|
239 |
print STDOUT "\n--- Processing $total slides ---\n"; |
print STDERR "\n--- Processing $total slides ---\n"; |
240 |
|
|
241 |
## generate the header table of content of the presentation |
## generate the header table of content of the presentation |
242 |
## which is also the first page of the talk |
## which is also the first page of the talk |
245 |
## start the slide count so we can number them |
## start the slide count so we can number them |
246 |
$slideCount = 1; |
$slideCount = 1; |
247 |
|
|
248 |
|
## pre-load template slides using $template dir |
249 |
|
Text::FastTemplate->defaults( |
250 |
|
path => [ $template ] |
251 |
|
); |
252 |
|
|
253 |
|
Text::FastTemplate->preload( [ |
254 |
|
{ file => 'slide.html', key => 'slide' }, |
255 |
|
{ file => 'overview.html', key => 'overview' }, |
256 |
|
{ file => 'title.html', key => 'title' }, |
257 |
|
]); |
258 |
|
|
259 |
|
## unroll relative anchors (#something) into links with slides |
260 |
|
|
261 |
|
my %anchor_on_slide; |
262 |
|
|
263 |
|
## step 1: record anchors |
264 |
|
for($i=0; $i<$total; $i++) { |
265 |
|
my $tmp = $table[($i*2)].$table[($i*2)+1]; |
266 |
|
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
267 |
|
$anchor_on_slide{$1}=($i+1); |
268 |
|
print STDERR "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
269 |
|
} |
270 |
|
} |
271 |
|
|
272 |
|
## step 2: fix links |
273 |
|
for($i=0; $i<$total; $i++) { |
274 |
|
foreach (keys %anchor_on_slide) { |
275 |
|
$table[($i*2)] =~ s,href="*#$_"*>,href="slide$anchor_on_slide{$_}\.html#$_">,gi; |
276 |
|
} |
277 |
|
} |
278 |
|
|
279 |
## @table is the array containing each slide with its title |
## @table is the array containing each slide with its title |
280 |
## for each slide to be generated |
## for each slide to be generated |
281 |
## we delete each slide and its title when generated |
## we delete each slide and its title when generated |
282 |
## so that the current slide and its title are always at $table[0] (for the title) |
## so that the current slide and its title are always at $table[0] (for the title) |
283 |
## and $table[1] (for the slide content) |
## and $table[1] (for the slide content) |
284 |
|
|
285 |
|
undef $prev_title; |
286 |
|
undef $next_title; |
287 |
|
|
288 |
do { |
do { |
289 |
|
|
290 |
## get rid of the first element contained by the raw presentation array |
## get rid of the first element contained by the raw presentation array |
300 |
## need to check if the title contains any anchor |
## need to check if the title contains any anchor |
301 |
## if so it needs to be removed |
## if so it needs to be removed |
302 |
## because the title is being used in the table of content to link to the corresponding slide |
## because the title is being used in the table of content to link to the corresponding slide |
303 |
$table[0] =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i; |
$table[0] = remove_anchor($table[0]); |
304 |
|
|
305 |
## grab next slide title $table[2] (if there's a next slide) |
## grab next slide title $table[2] (if there's a next slide) |
306 |
## to be able to use in the 'next' navigation button |
## to be able to use in the 'next' navigation button |
307 |
## keep in mind that $table[1] contains the slide corresponding to the title $table[0] |
## keep in mind that $table[1] contains the slide corresponding to the title $table[0] |
308 |
$next_slide_title = $table[2] if $table[2]; |
if ($table[2]) { |
309 |
## remove any anchor from the next slide title |
$next_title= remove_anchor($table[2]); |
310 |
$next_slide_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i; |
} |
311 |
|
|
312 |
## the current slide content is stored $table[1] |
## the current slide content is stored $table[1] |
313 |
## there is an attempt to make sure it's clean HTML |
## there is an attempt to make sure it's clean HTML |
317 |
|
|
318 |
## extract slide Sub Title <h2> |
## extract slide Sub Title <h2> |
319 |
undef $slideSubTitle; |
undef $slideSubTitle; |
320 |
if ($slideContent =~ s/<[hH]2[^>]*>([^<]+)<\/[hH]2[^>]*>//) { |
if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) { |
321 |
$slideSubTitle=$1; |
$slideSubTitle=remove_anchor($1); |
322 |
} |
} |
323 |
|
|
324 |
## add the title of the current slide to the table of content |
## add the title of the current slide to the table of content |
327 |
## generate the current slide |
## generate the current slide |
328 |
## parameters are: |
## parameters are: |
329 |
## title of the slide, its content, the slide number, the title of the previous slide and the title of the next slide |
## title of the slide, its content, the slide number, the title of the previous slide and the title of the next slide |
330 |
&createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$previous_slide_title,$next_slide_title); |
&createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title); |
331 |
|
|
332 |
## save the title of the previous slide to be displayed in the 'previous' navigation button |
## save the title of the previous slide to be displayed in the 'previous' navigation button |
333 |
$previous_slide_title="$table[0]"; |
$prev_title=remove_anchor($table[0]); |
334 |
} |
} |
335 |
## process the next slide |
## process the next slide |
336 |
while (shift(@table)); |
while (shift(@table)); |
344 |
## 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) |
345 |
&generateTOC; |
&generateTOC; |
346 |
|
|
347 |
|
## print additional files to pack |
348 |
|
print STDOUT join("\n",@pack_additional) if ($pack); |
349 |
|
|
350 |
print STDOUT "--- Finished ---\n"; |
print STDERR "--- Finished ---\n"; |
351 |
exit 0; |
exit 0; |
352 |
## |
## |
353 |
## end of the slidemaker main program |
## end of the slidemaker main program |
361 |
{ |
{ |
362 |
## open the file to write to |
## open the file to write to |
363 |
open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!"; |
open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!"; |
364 |
|
push @pack_additional,"$_[0].html" if ($pack); |
365 |
|
|
366 |
## the style sheet used in the table of content is |
## the style sheet used in the table of content is |
367 |
$stylelink = ""; |
$stylelink = ""; |
368 |
## here is the standard style sheet |
## here is the standard style sheet |
369 |
$stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\" media=\"screen\">"; |
$stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\" media=\"screen\">"; |
370 |
|
|
371 |
if ($logoFile) { |
%overview_data = ( |
372 |
$logo_html="<a href=\"$logoLink\"><img src=\"$logoFile\" alt=\"$logoAlt\" border=\"0\"></a>"; |
doctype => $doctype, |
373 |
} |
title => $title, |
374 |
|
http_equiv => $http_equiv, |
375 |
if ($logoFile2) { |
stylelink => $stylelink, |
376 |
$logo_html.="<a href=\"$logoLink2\"><img src=\"$logoFile2\" alt=\"$logoAlt2\" border=\"0\"></a>"; |
body => $body, |
377 |
} |
|
378 |
|
logoLink => $logoLink, |
379 |
$title_html="<h1>$talkTitle</h1>"; |
logoFile => $logoFile, |
380 |
if (length $talkSubTitle != 0) { |
logoAlt => $logoAlt, |
381 |
$title_html.="<h2>$talkSubTitle</h2>"; |
logoLink2 => $logoLink2, |
382 |
} |
logoFile2 => $logoFile2, |
383 |
|
logoAlt2 => $logoAlt2, |
384 |
if (length $date != 0) { |
|
385 |
$date_html="($date)"; |
talkTitle => $talkTitle, |
386 |
} |
talkSubTitle => $talkSubTitle, |
387 |
|
|
388 |
print FOO <<END; |
content_hight => $content_hight, |
389 |
$doctype |
|
390 |
<head> |
author => $author, |
391 |
<title>$talkTitle - $loc_toc</title> |
authorUrl => $authorUrl, |
392 |
$http_equiv |
author2 => $author2, |
393 |
$stylelink |
authorUrl2 => $authorUrl2, |
394 |
</head> |
|
395 |
$body |
date => $date, |
396 |
<table height="100%" width="100%"> |
|
397 |
<tr> |
toc_title => $loc_toc, |
398 |
<td class="header-first" valign="top"> |
template => $template, |
399 |
<table width="100%" border="0"> |
); |
|
<tr> |
|
|
<td class="cell-logo">$logo_html</td> |
|
|
<td class="cell-heading">$title_html</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td height="$content_hight" class="body" valign="top"> |
|
|
<div class="body"> |
|
|
<h3>$loc_toc</h3> |
|
|
<ul> |
|
|
END |
|
400 |
|
|
401 |
} |
} |
402 |
## |
## |
408 |
|
|
409 |
sub closeOverview |
sub closeOverview |
410 |
{ |
{ |
411 |
my $slide_html=make_progress_bar(0,$total); |
$overview_data{slide_html} = make_progress_bar(0,$total); |
412 |
print FOO <<END; |
$overview_data{toc_entries} = [ @toc_entries ]; |
413 |
</ul> |
|
414 |
</div> |
my $page= new Text::FastTemplate key => 'overview'; |
415 |
</td> |
print FOO $page->output( \%overview_data ); |
|
</tr> |
|
|
<tr> |
|
|
<td class="footer"> |
|
|
<table border="0" width="100%"> |
|
|
<tr> |
|
|
<td width="33%" class="footer-info"> |
|
|
<p> |
|
|
<i>$talkTitle</i> |
|
|
<br>$author $date_html |
|
|
</p> |
|
|
</td><td width="33%" class="footer-nav"> |
|
|
<table border="0"> |
|
|
<tr> |
|
|
<td> |
|
|
[ <a href="slide1.html">On with the show</a> ] |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td><td width="33%" class="footer-count"> |
|
|
$slide_html |
|
|
$author2</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</body> |
|
|
</html> |
|
|
END |
|
416 |
|
|
417 |
close(FOO); |
close(FOO); |
418 |
} |
} |
438 |
if ($nr % $toc_on_page == 0) { |
if ($nr % $toc_on_page == 0) { |
439 |
my $toc_nr=int($nr/$toc_on_page); |
my $toc_nr=int($nr/$toc_on_page); |
440 |
|
|
441 |
print FOO <<END; |
$item = { |
442 |
<br><small><a accesskey=" " tabindex=" " href="index-toc$toc_nr.html">...</a></small></br> |
pre_html => $pre_ul, |
443 |
END |
accesskey => " ", # space |
444 |
|
href => "index-toc$toc_nr.html", |
445 |
|
title => "...", |
446 |
|
post_html => $post_ul, |
447 |
|
more => 1, # use style for more pages link (...) |
448 |
|
}; |
449 |
|
push @toc_entries, $item; |
450 |
|
|
451 |
&closeOverview; |
&closeOverview; |
452 |
|
undef @toc_entries; |
453 |
&openOverview("$overview-toc$toc_nr"); |
&openOverview("$overview-toc$toc_nr"); |
454 |
$last_toc_title=''; |
$last_toc_title=''; |
455 |
} |
} |
456 |
|
|
457 |
$ul1=$ul2=''; |
$pre_ul=$post_ul=''; |
458 |
if ($last_toc_title eq $title) { |
if ($last_toc_title eq $title && $subtitle) { |
459 |
$title = $subtitle; |
$title = $subtitle; |
460 |
$ul1='<ul>'; |
$pre_ul='<ul>'; |
461 |
$ul2='</ul>'; |
$post_ul='</ul>'; |
462 |
} else { |
} else { |
463 |
$last_toc_title=$title; |
$last_toc_title=$title; |
464 |
} |
} |
466 |
# add accesskey for first 9 slides (`1' - `9') or just for first |
# add accesskey for first 9 slides (`1' - `9') or just for first |
467 |
# TOC page, and tabindex for all slides |
# TOC page, and tabindex for all slides |
468 |
if ($nr < 10 && $nr < $toc_on_page) { |
if ($nr < 10 && $nr < $toc_on_page) { |
469 |
print FOO <<END; |
$item = { |
470 |
$ul1<li><a accesskey="$nr" tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2 |
pre_html => $pre_ul, |
471 |
END |
accesskey => "$nr", |
472 |
|
tabindex => "$nr", |
473 |
|
href => "slide$nr.html", |
474 |
|
title => $title, |
475 |
|
post_html => $post_ul, |
476 |
|
more => 0, |
477 |
|
}; |
478 |
|
push @toc_entries,$item; |
479 |
} else { |
} else { |
480 |
print FOO <<END; |
$item = { |
481 |
$ul1<li><a tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2 |
pre_html => $pre_ul, |
482 |
END |
tabindex => "$nr", |
483 |
|
href => "slide$nr.html", |
484 |
|
title => $title, |
485 |
|
post_html => $post_ul, |
486 |
|
}; |
487 |
|
push @toc_entries,$item; |
488 |
} |
} |
489 |
} |
} |
490 |
## |
## |
499 |
# parameters are respectively the slide title, its content, |
# parameters are respectively the slide title, its content, |
500 |
# its number, the next slide title and the previous slide title |
# its number, the next slide title and the previous slide title |
501 |
|
|
502 |
my ($title,$subtitle,$content,$nr,$next_title,$prev_title) = @_; |
my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_; |
503 |
|
|
504 |
if (! $title) { |
if (! $title) { |
505 |
return 1; |
return 1; |
527 |
|
|
528 |
$status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle; |
$status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle; |
529 |
$status =~ s/<[^>]+>//g; |
$status =~ s/<[^>]+>//g; |
530 |
print STDOUT $status; |
print STDERR $status; |
531 |
|
|
532 |
&verify_html($content); # check the html |
&verify_html($content); # check the html |
533 |
|
|
534 |
## write to the slide |
## write to the slide |
535 |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
536 |
|
push @pack_additional,"slide$nr.html" if ($pack); |
537 |
|
|
538 |
my $toclink = "[ <a href=\"$overview\.html\" title=\"Contents\">Contents</a> ]"; |
my $toc_link = "$overview\.html"; |
539 |
|
|
540 |
## initialization of the navigation links |
## initialization of the navigation links |
541 |
my $nextlink = ""; |
my $next_link = ""; |
542 |
my $prevlink = ""; |
my $prev_link = ""; |
543 |
|
|
544 |
if ($nr>1) { |
if ($nr>1) { |
545 |
$prevlink = "<a href=\"slide".($nr-1).".html\" title=\"Previous\"><<</a>"; |
$prev_link = "slide".($nr-1).".html"; |
546 |
# } else { |
# } else { |
547 |
# ## add a link back to the toc for the first slide --CMN 19991102 |
# ## add a link back to the toc for the first slide --CMN 19991102 |
548 |
# $prevlink = "<a href=\"$overview\.html\" title=\"Previous\"><<</a>"; |
# $prev_link = "$overview\.html"; |
549 |
} |
} |
550 |
|
|
551 |
if ($nr != $total) { |
if ($nr != $total) { |
552 |
$nextlink = "<a href=\"slide".($nr+1).".html\" title=\"Next\">>></a>"; |
$next_link = "slide".($nr+1).".html"; |
553 |
} |
} |
554 |
|
|
555 |
$stylelink = ""; |
$stylelink = ""; |
556 |
# here is the standard style sheet |
# here is the standard style sheet |
557 |
$stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">"; |
$stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">"; |
558 |
|
|
|
$title_html="<h1>$title</h1>"; |
|
|
if ($subtitle) { |
|
|
$title_html.="<h2>$subtitle</h2>"; |
|
|
} |
|
|
|
|
559 |
my $slide_html=make_progress_bar($nr,$total); |
my $slide_html=make_progress_bar($nr,$total); |
560 |
|
|
561 |
print SLIDE <<END; |
# undefine body if no content is found (so that template can show |
562 |
$doctype |
# only title and sub-title |
563 |
<head> |
if ($content !~ m/\S/g) { |
564 |
<title>$talkTitle - $title</title> |
undef $content; |
565 |
$http_equiv |
} |
566 |
$stylelink |
|
567 |
</head> |
%page_data = ( |
568 |
$body |
doctype => $doctype, |
569 |
<table height="100%" width="100%"> |
talkTitle => $talkTitle, |
570 |
<tr> |
title => $title, |
571 |
<td class="header-first" valign="top"> |
subtitle => $subtitle, |
572 |
<table width="100%" border="0"> |
http_equiv => $http_equiv, |
573 |
<tr> |
stylelink => $stylelink, |
574 |
<td class="cell-logo">$logo_html</td> |
body => $body, |
575 |
<td class="cell-heading">$title_html</td> |
|
576 |
</tr> |
logoLink => $logoLink, |
577 |
</table> |
logoFile => $logoFile, |
578 |
</td> |
logoAlt => $logoAlt, |
579 |
</tr> |
logoLink2 => $logoLink2, |
580 |
<tr> |
logoFile2 => $logoFile2, |
581 |
<td height="$content_hight" class="body" valign="top"> |
logoAlt2 => $logoAlt2, |
582 |
<div class="body"> |
|
583 |
$content |
|
584 |
</div> |
content_hight => $content_hight, |
585 |
</td> |
content => $content, |
586 |
</tr> |
|
587 |
<tr> |
prev_link => $prev_link, |
588 |
<td class="footer"> |
toc_link => $toc_link, |
589 |
<table border="0" width="100%"> |
next_link => $next_link, |
590 |
<tr> |
prev_title => $prev_title, |
591 |
<td width="33%" class="footer-info"> |
toc_title => $loc_toc, |
592 |
<p> |
next_title => $next_title, |
593 |
<i>$talkTitle</i> |
|
594 |
<br>$author $date_html |
author => $author, |
595 |
</p> |
authorUrl => $authorUrl, |
596 |
</td><td width="33%" class="footer-nav"> |
author2 => $author2, |
597 |
<table border="0"> |
authorUrl2 => $authorUrl2, |
598 |
<tr> |
|
599 |
<td> |
date => $date, |
600 |
$prevlink |
|
601 |
$toclink |
slide_html => $slide_html, |
602 |
$nextlink |
|
603 |
</td> |
template => $template, |
604 |
</tr> |
); |
605 |
</table> |
|
606 |
</td><td width="33%" class="footer-count"> |
my $page; |
607 |
$slide_html |
if ($content) { |
608 |
$author2</td> |
$page= new Text::FastTemplate key => 'slide'; |
609 |
</tr> |
} else { |
610 |
</table> |
$page= new Text::FastTemplate key => 'title'; |
611 |
</td> |
} |
612 |
</tr> |
print SLIDE $page->output( \%page_data ); |
613 |
</table> |
extract_files($page->output( \%page_data )) if ($pack); |
|
</body> |
|
|
</html> |
|
|
END |
|
|
|
|
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 |
} |
} |
668 |
# clean the html of the slide |
# clean the html of the slide |
669 |
# remove all <div class="comment">blabla</div> |
# remove all <div class="comment">blabla</div> |
670 |
sub clean_html { |
sub clean_html { |
671 |
$_[0] =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs; |
my $tmp=$_[0]; |
672 |
return $_[0]; |
$tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs; |
673 |
|
$tmp =~ s,</*font[^>]+>,,ig; |
674 |
|
return $tmp; |
675 |
} |
} |
676 |
|
|
677 |
############################################################################## |
############################################################################## |
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="30%" 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 |
} |
} |
719 |
return $html; |
return $html; |
720 |
} |
} |
721 |
|
|
722 |
|
############################################################################## |
723 |
|
# remove anchors <a href...> from html (for titles) |
724 |
|
sub remove_anchor { |
725 |
|
my $tmp = $_[0]; |
726 |
|
$tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig; |
727 |
|
return $tmp; |
728 |
|
} |
729 |
|
|
730 |
|
############################################################################## |
731 |
|
# extract files referenced in presentation |
732 |
|
|
733 |
|
sub extract_files { |
734 |
|
my $tmp = $_[0]; |
735 |
|
while ($tmp =~ s/<a\s+href="*([^"\s]+)"*//ism || |
736 |
|
$tmp =~ s/<img\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 |
|
} |