1 |
#!/usr/local/bin/perl |
#!/usr/bin/perl |
2 |
# |
# |
3 |
# SLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org> |
# SLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org> |
4 |
# |
# |
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=1; |
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 |
############################################################################## |
############################################################################## |
137 |
## reading user input from $infos |
## reading user input from $infos |
142 |
|
|
143 |
# read parameters from infos.txt and put them in @PARAM |
# read parameters from infos.txt and put them in @PARAM |
144 |
if (open(INFOS, $infos)) { |
if (open(INFOS, $infos)) { |
145 |
print STDOUT "--- Reading parameters file $infos ---\n"; |
print STDOUT "--- Reading parameters file $infos ---\n"; |
146 |
local(@file,$counter); |
local(@file,$counter); |
147 |
$counter = 0; |
$counter = 0; |
148 |
@file = <INFOS>; |
@file = <INFOS>; |
149 |
@PARAM = (); |
@PARAM = (); |
150 |
do { |
do { |
151 |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
152 |
$file[0] =~ s/\n//; # remove UNIX \n |
$file[0] =~ s/\n//; # remove UNIX \n |
153 |
$file[0] =~ s/\r//; # remove WINDOWS \r |
$file[0] =~ s/\r//; # remove WINDOWS \r |
154 |
$file[0] =~ s/ *= */=/; |
$file[0] =~ s/ *= */=/; |
155 |
$PARAM[$counter++] = $file[0]; |
$PARAM[$counter++] = $file[0]; |
156 |
print "$file[0]\n"; |
print "$file[0]\n"; |
157 |
} |
} |
158 |
} while (shift(@file)); |
} while (shift(@file)); |
159 |
} |
} |
160 |
## @PARAM is now a table with the user preferences for his presentation |
## @PARAM is now a table with the user preferences for his presentation |
161 |
|
|
162 |
## process arguments |
## process arguments |
163 |
## each preset variable is now re-attributed using the user preferences |
## each preset variable is now re-attributed using the user preferences |
164 |
foreach (@PARAM) { |
foreach (@PARAM) { |
165 |
@_ = split(/ *= */,$_,2); |
my ($var,$value) = split(/ *= */,$_,2); |
166 |
$cmd="\$$_[0] = \'$_[1]\';"; |
$value=~s/'/\\'/g; |
167 |
if (length $_[1] != 0) { |
$cmd="\$$var = \'$value\';"; |
168 |
eval($cmd); |
if ($value) { |
169 |
} |
eval($cmd) || die "problem with eval of: $cmd"; |
170 |
|
} else { |
171 |
|
die "no value defined for $var"; |
172 |
|
} |
173 |
} |
} |
174 |
|
|
175 |
## use charset |
## use charset |
180 |
$http_equiv=''; |
$http_equiv=''; |
181 |
} |
} |
182 |
|
|
|
|
|
|
## 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"; |
|
|
} |
|
|
|
|
183 |
############################################################################## |
############################################################################## |
184 |
## read the raw html presentation |
## read the raw html presentation |
185 |
## |
## |
187 |
## copy file in memory |
## copy file in memory |
188 |
my $sep = $/; |
my $sep = $/; |
189 |
$/ = undef; |
$/ = undef; |
190 |
if (!open(ALL, $all)) { |
open(ALL, $all) || die "Error: Cannot open file: $all"; |
|
print "Error: Cannot open file: $all\n"; |
|
|
exit 0; |
|
|
} |
|
191 |
my $buf = <ALL>; |
my $buf = <ALL>; |
192 |
close(ALL); |
close(ALL); |
193 |
$/ = $sep; |
$/ = $sep; |
224 |
## start the slide count so we can number them |
## start the slide count so we can number them |
225 |
$slideCount = 1; |
$slideCount = 1; |
226 |
|
|
227 |
|
## pre-load template slides using $template dir |
228 |
|
Text::FastTemplate->defaults( |
229 |
|
path => [ $template ] |
230 |
|
); |
231 |
|
|
232 |
|
Text::FastTemplate->preload( [ |
233 |
|
{ file => 'slide.html', key => 'slide' }, |
234 |
|
{ file => 'overview.html', key => 'overview' }, |
235 |
|
]); |
236 |
|
|
237 |
|
## unroll relative anchors (#something) into links with slides |
238 |
|
|
239 |
|
my %anchor_on_slide; |
240 |
|
|
241 |
|
## step 1: record anchors |
242 |
|
for($i=0; $i<$total; $i++) { |
243 |
|
my $tmp = $table[($i*2)]; |
244 |
|
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
245 |
|
$anchor_on_slide{$1}=($i+1); |
246 |
|
print "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
247 |
|
} |
248 |
|
} |
249 |
|
|
250 |
|
## step 2: fix links |
251 |
|
for($i=0; $i<$total; $i++) { |
252 |
|
foreach (keys %anchor_on_slide) { |
253 |
|
$table[($i*2)] =~ s,href="*#$_"*>,href="slide$anchor_on_slide{$_}\.html#$_">,gi; |
254 |
|
} |
255 |
|
} |
256 |
|
|
257 |
## @table is the array containing each slide with its title |
## @table is the array containing each slide with its title |
258 |
## for each slide to be generated |
## for each slide to be generated |
259 |
## we delete each slide and its title when generated |
## we delete each slide and its title when generated |
260 |
## 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) |
261 |
## and $table[1] (for the slide content) |
## and $table[1] (for the slide content) |
262 |
|
|
263 |
|
undef $prev_title; |
264 |
|
undef $next_title; |
265 |
|
|
266 |
do { |
do { |
267 |
|
|
268 |
## get rid of the first element contained by the raw presentation array |
## get rid of the first element contained by the raw presentation array |
283 |
## grab next slide title $table[2] (if there's a next slide) |
## grab next slide title $table[2] (if there's a next slide) |
284 |
## to be able to use in the 'next' navigation button |
## to be able to use in the 'next' navigation button |
285 |
## 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] |
286 |
$next_slide_title = $table[2] if $table[2]; |
if ($table[2]) { |
287 |
## remove any anchor from the next slide title |
$next_title= $table[2]; |
288 |
$next_slide_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i; |
## remove any anchor from the next slide title |
289 |
|
$next_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i; |
290 |
|
} |
291 |
|
|
292 |
## the current slide content is stored $table[1] |
## the current slide content is stored $table[1] |
293 |
## there is an attempt to make sure it's clean HTML |
## there is an attempt to make sure it's clean HTML |
307 |
## generate the current slide |
## generate the current slide |
308 |
## parameters are: |
## parameters are: |
309 |
## 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 |
310 |
&createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$previous_slide_title,$next_slide_title); |
&createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title); |
311 |
|
|
312 |
## 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 |
313 |
$previous_slide_title="$table[0]"; |
$prev_title="$table[0]"; |
314 |
} |
} |
315 |
## process the next slide |
## process the next slide |
316 |
while (shift(@table)); |
while (shift(@table)); |
345 |
## here is the standard style sheet |
## here is the standard style sheet |
346 |
$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\">"; |
347 |
|
|
348 |
if ($logoFile) { |
%overview_data = ( |
349 |
$logo_html="<a href=\"$logoLink\"><img src=\"$logoFile\" alt=\"$logoAlt\" border=\"0\"></a>"; |
doctype => $doctype, |
350 |
} |
title => $title, |
351 |
|
http_equiv => $http_equiv, |
352 |
|
stylelink => $stylelink, |
353 |
|
body => $body, |
354 |
|
|
355 |
|
logoLink => $logoLink, |
356 |
|
logoFile => $logoFile, |
357 |
|
logoAlt => $logoAlt, |
358 |
|
logoLink2 => $logoLink2, |
359 |
|
logoFile2 => $logoFile2, |
360 |
|
logoAlt2 => $logoAlt2, |
361 |
|
|
362 |
|
talkTitle => $talkTitle, |
363 |
|
talkSubTitle => $talkSubTitle, |
364 |
|
|
365 |
|
content_hight => $content_hight, |
366 |
|
|
367 |
|
author => $author, |
368 |
|
authorUrl => $authorUrl, |
369 |
|
author2 => $author2, |
370 |
|
authorUrl2 => $authorUrl2, |
371 |
|
|
372 |
if ($logoFile2) { |
date => $date, |
|
$logo_html.="<a href=\"$logoLink2\"><img src=\"$logoFile2\" alt=\"$logoAlt2\" border=\"0\"></a>"; |
|
|
} |
|
373 |
|
|
374 |
$title_html="<h1>$talkTitle</h1>"; |
toc => $loc_toc, |
375 |
if (length $talkSubTitle != 0) { |
); |
|
$title_html.="<h2>$talkSubTitle</h2>"; |
|
|
} |
|
|
|
|
|
if (length $date != 0) { |
|
|
$date_html="($date)"; |
|
|
} |
|
|
|
|
|
print FOO <<END; |
|
|
$doctype |
|
|
<head> |
|
|
<title>$talkTitle - $loc_toc</title> |
|
|
$http_equiv |
|
|
$stylelink |
|
|
</head> |
|
|
$body |
|
|
<table height="100%" width="100%"> |
|
|
<tr> |
|
|
<td class="header-first" valign="top"> |
|
|
<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 |
|
376 |
|
|
377 |
} |
} |
378 |
## |
## |
384 |
|
|
385 |
sub closeOverview |
sub closeOverview |
386 |
{ |
{ |
387 |
my $slide_html=make_progress_bar(0,$total); |
$overview_data{slide_html} = make_progress_bar(0,$total); |
388 |
print FOO <<END; |
$overview_data{toc_entries} = [ @toc_entries ]; |
389 |
</ul> |
|
390 |
</div> |
my $page= new Text::FastTemplate key => 'overview'; |
391 |
</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 |
|
392 |
|
|
393 |
close(FOO); |
close(FOO); |
394 |
} |
} |
414 |
if ($nr % $toc_on_page == 0) { |
if ($nr % $toc_on_page == 0) { |
415 |
my $toc_nr=int($nr/$toc_on_page); |
my $toc_nr=int($nr/$toc_on_page); |
416 |
|
|
417 |
print FOO <<END; |
%item = ( |
418 |
<br><small><a accesskey=" " tabindex=" " href="index-toc$toc_nr.html">...</a></small></br> |
pre_html => $pre_ul, |
419 |
END |
accesskey => " ", # space |
420 |
|
href => "index-toc$toc_nr.html", |
421 |
|
title => "...", |
422 |
|
post_html => $post_ul, |
423 |
|
more => 1, # use style for more pages link (...) |
424 |
|
) |
425 |
|
# push @toc_entries, %item; |
426 |
|
|
427 |
&closeOverview; |
&closeOverview; |
428 |
&openOverview("$overview-toc$toc_nr"); |
&openOverview("$overview-toc$toc_nr"); |
429 |
$last_toc_title=''; |
$last_toc_title=''; |
430 |
} |
} |
431 |
|
|
432 |
$ul1=$ul2=''; |
$pre_ul=$post_ul=''; |
433 |
if ($last_toc_title eq $title) { |
if ($last_toc_title eq $title) { |
434 |
$title = $subtitle; |
$title = $subtitle; |
435 |
$ul1='<ul>'; |
$pre_ul='<ul>'; |
436 |
$ul2='</ul>'; |
$post_ul='</ul>'; |
437 |
} else { |
} else { |
438 |
$last_toc_title=$title; |
$last_toc_title=$title; |
439 |
} |
} |
441 |
# add accesskey for first 9 slides (`1' - `9') or just for first |
# add accesskey for first 9 slides (`1' - `9') or just for first |
442 |
# TOC page, and tabindex for all slides |
# TOC page, and tabindex for all slides |
443 |
if ($nr < 10 && $nr < $toc_on_page) { |
if ($nr < 10 && $nr < $toc_on_page) { |
444 |
print FOO <<END; |
$item = { |
445 |
$ul1<li><a accesskey="$nr" tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2 |
pre_html => $pre_ul, |
446 |
END |
accesskey => "$nr", |
447 |
|
tabindex => "$nr", |
448 |
|
href => "slide$nr.html", |
449 |
|
title => $title, |
450 |
|
post_html => $post_ul, |
451 |
|
more => 0, |
452 |
|
}; |
453 |
|
push @toc_entries,$item; |
454 |
} else { |
} else { |
455 |
print FOO <<END; |
%item = ( |
456 |
$ul1<li><a tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2 |
pre_html => $pre_ul, |
457 |
END |
tabindex => "$nr", |
458 |
|
href => "slide$nr.html", |
459 |
|
title => $title, |
460 |
|
post_html => $post_ul, |
461 |
|
) |
462 |
|
# push @toc_entries,\%item; |
463 |
} |
} |
464 |
} |
} |
465 |
## |
## |
474 |
# parameters are respectively the slide title, its content, |
# parameters are respectively the slide title, its content, |
475 |
# its number, the next slide title and the previous slide title |
# its number, the next slide title and the previous slide title |
476 |
|
|
477 |
my ($title,$subtitle,$content,$nr,$next_title,$prev_title) = @_; |
my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_; |
478 |
|
|
479 |
if (! $title) { |
if (! $title) { |
480 |
return 1; |
return 1; |
509 |
## write to the slide |
## write to the slide |
510 |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
511 |
|
|
512 |
my $toclink = "[ <a href=\"$overview\.html\" title=\"Contents\">Contents</a> ]"; |
my $toc_link = "$overview\.html"; |
513 |
|
|
514 |
## initialization of the navigation links |
## initialization of the navigation links |
515 |
my $nextlink = ""; |
my $next_link = ""; |
516 |
my $prevlink = ""; |
my $prev_link = ""; |
517 |
|
|
518 |
if ($nr>1) { |
if ($nr>1) { |
519 |
$prevlink = "<a href=\"slide".($nr-1).".html\" title=\"Previous\"><<</a>"; |
$prev_link = "slide".($nr-1).".html"; |
520 |
# } else { |
# } else { |
521 |
# ## 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 |
522 |
# $prevlink = "<a href=\"$overview\.html\" title=\"Previous\"><<</a>"; |
# $prev_link = "$overview\.html"; |
523 |
} |
} |
524 |
|
|
525 |
if ($nr != $total) { |
if ($nr != $total) { |
526 |
$nextlink = "<a href=\"slide".($nr+1).".html\" title=\"Next\">>></a>"; |
$next_link = "slide".($nr+1).".html"; |
527 |
} |
} |
528 |
|
|
529 |
$stylelink = ""; |
$stylelink = ""; |
530 |
# here is the standard style sheet |
# here is the standard style sheet |
531 |
$stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">"; |
$stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">"; |
532 |
|
|
|
$title_html="<h1>$title</h1>"; |
|
|
if ($subtitle) { |
|
|
$title_html.="<h2>$subtitle</h2>"; |
|
|
} |
|
|
|
|
533 |
my $slide_html=make_progress_bar($nr,$total); |
my $slide_html=make_progress_bar($nr,$total); |
534 |
|
|
535 |
print SLIDE <<END; |
%page_data = ( |
536 |
$doctype |
doctype => $doctype, |
537 |
<head> |
talkTitle => $talkTitle, |
538 |
<title>$talkTitle - $title</title> |
title => $title, |
539 |
$http_equiv |
subtitle => $subtitle, |
540 |
$stylelink |
http_equiv => $http_equiv, |
541 |
</head> |
stylelink => $stylelink, |
542 |
$body |
body => $body, |
543 |
<table height="100%" width="100%"> |
|
544 |
<tr> |
logoLink => $logoLink, |
545 |
<td class="header-first" valign="top"> |
logoFile => $logoFile, |
546 |
<table width="100%" border="0"> |
logoAlt => $logoAlt, |
547 |
<tr> |
logoLink2 => $logoLink2, |
548 |
<td class="cell-logo">$logo_html</td> |
logoFile2 => $logoFile2, |
549 |
<td class="cell-heading">$title_html</td> |
logoAlt2 => $logoAlt2, |
550 |
</tr> |
|
551 |
</table> |
|
552 |
</td> |
content_hight => $content_hight, |
553 |
</tr> |
content => $content, |
554 |
<tr> |
|
555 |
<td height="$content_hight" class="body" valign="top"> |
prev_link => $prev_link, |
556 |
<div class="body"> |
toc_link => $toc_link, |
557 |
$content |
next_link => $next_link, |
558 |
</div> |
prev_title => $prev_title, |
559 |
</td> |
next_title => $next_title, |
560 |
</tr> |
|
561 |
<tr> |
author => $author, |
562 |
<td class="footer"> |
authorUrl => $authorUrl, |
563 |
<table border="0" width="100%"> |
author2 => $author2, |
564 |
<tr> |
authorUrl2 => $authorUrl2, |
565 |
<td width="33%" class="footer-info"> |
|
566 |
<p> |
date => $date, |
567 |
<i>$talkTitle</i> |
|
568 |
<br>$author $date_html |
slide_html => $slide_html, |
569 |
</p> |
|
570 |
</td><td width="33%" class="footer-nav"> |
); |
571 |
<table border="0"> |
|
572 |
<tr> |
my $page= new Text::FastTemplate key => 'slide'; |
573 |
<td> |
print SLIDE $page->output( \%page_data ); |
|
$prevlink |
|
|
$toclink |
|
|
$nextlink |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td><td width="33%" class="footer-count"> |
|
|
$slide_html |
|
|
$author2</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</body> |
|
|
</html> |
|
|
END |
|
574 |
|
|
575 |
close(SLIDE); |
close(SLIDE); |
576 |
return 0; |
return 0; |
663 |
} else { |
} else { |
664 |
$r=$t; |
$r=$t; |
665 |
} |
} |
666 |
$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><td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td><td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td></tr></table>'; |
667 |
} else { |
} else { |
668 |
$html="$loc_slide $nr $loc_of $total"; |
$html="$loc_slide $nr $loc_of $total"; |
669 |
} |
} |