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 |
## |
## |
145 |
|
|
146 |
# read parameters from infos.txt and put them in @PARAM |
# read parameters from infos.txt and put them in @PARAM |
147 |
if (open(INFOS, $infos)) { |
if (open(INFOS, $infos)) { |
148 |
print STDOUT "--- Reading parameters file $infos ---\n"; |
print STDERR "--- Reading parameters file $infos ---\n"; |
149 |
local(@file,$counter); |
local(@file); |
|
$counter = 0; |
|
150 |
@file = <INFOS>; |
@file = <INFOS>; |
151 |
@PARAM = (); |
# @PARAM = (); # don't reset param, use @ARGV |
152 |
do { |
do { |
153 |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
154 |
$file[0] =~ s/\n//; # remove UNIX \n |
$file[0] =~ s/\n//; # remove UNIX \n |
155 |
$file[0] =~ s/\r//; # remove WINDOWS \r |
$file[0] =~ s/\r//; # remove WINDOWS \r |
156 |
$file[0] =~ s/ *= */=/; |
$file[0] =~ s/ *= */=/; |
157 |
$PARAM[$counter++] = $file[0]; |
push @PARAM,$file[0]; |
158 |
print "$file[0]\n"; |
print STDERR "$file[0]\n"; |
159 |
} |
} |
160 |
} while (shift(@file)); |
} while (shift(@file)); |
161 |
} |
} |
182 |
$http_equiv=''; |
$http_equiv=''; |
183 |
} |
} |
184 |
|
|
185 |
|
|
186 |
############################################################################## |
############################################################################## |
187 |
## read the raw html presentation |
## read the raw html presentation |
188 |
## |
## |
192 |
$/ = undef; |
$/ = undef; |
193 |
open(ALL, $all) || die "Error: Cannot open file: $all"; |
open(ALL, $all) || die "Error: Cannot open file: $all"; |
194 |
my $buf = <ALL>; |
my $buf = <ALL>; |
195 |
|
$buf =~ s/\r//g; # remove WINDOWS \r |
196 |
close(ALL); |
close(ALL); |
197 |
$/ = $sep; |
$/ = $sep; |
198 |
|
|
200 |
## they do not need to show up on the slides |
## they do not need to show up on the slides |
201 |
$buf =~ s/<!--.*?-->//sgo; |
$buf =~ s/<!--.*?-->//sgo; |
202 |
|
|
203 |
|
## if $pack is set, output name of css (for inclusion in archive), but |
204 |
|
## reset $cssStandard only to filename (without path) |
205 |
|
|
206 |
|
if ($pack) { |
207 |
|
push @pack_additional,$cssStandard; |
208 |
|
$cssStandard =~ s/^.*\/([^\/]+)$/$1/g; |
209 |
|
} |
210 |
|
|
211 |
## 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 |
212 |
## if not it will generate a rather weird output |
## if not it will generate a rather weird output |
213 |
## split using <h1...> and </h1...> as separator (ignores attributes!) |
## split using <h1...> and </h1...> as separator (ignores attributes!) |
227 |
############################################################################## |
############################################################################## |
228 |
## processing the slides |
## processing the slides |
229 |
|
|
230 |
print STDOUT "\n--- Processing $total slides ---\n"; |
print STDERR "\n--- Processing $total slides ---\n"; |
231 |
|
|
232 |
## generate the header table of content of the presentation |
## generate the header table of content of the presentation |
233 |
## which is also the first page of the talk |
## which is also the first page of the talk |
244 |
Text::FastTemplate->preload( [ |
Text::FastTemplate->preload( [ |
245 |
{ file => 'slide.html', key => 'slide' }, |
{ file => 'slide.html', key => 'slide' }, |
246 |
{ file => 'overview.html', key => 'overview' }, |
{ file => 'overview.html', key => 'overview' }, |
247 |
|
{ file => 'title.html', key => 'title' }, |
248 |
]); |
]); |
249 |
|
|
250 |
## unroll relative anchors (#something) into links with slides |
## unroll relative anchors (#something) into links with slides |
256 |
my $tmp = $table[($i*2)].$table[($i*2)+1]; |
my $tmp = $table[($i*2)].$table[($i*2)+1]; |
257 |
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) { |
258 |
$anchor_on_slide{$1}=($i+1); |
$anchor_on_slide{$1}=($i+1); |
259 |
print "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
print STDERR "\tslide ",($i+1)," anchor: $1\n" if ($debug); |
260 |
} |
} |
261 |
} |
} |
262 |
|
|
335 |
## 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) |
336 |
&generateTOC; |
&generateTOC; |
337 |
|
|
338 |
|
## print additional files to pack |
339 |
|
print STDOUT join("\n",@pack_additional) if ($pack); |
340 |
|
|
341 |
print STDOUT "--- Finished ---\n"; |
print STDERR "--- Finished ---\n"; |
342 |
exit 0; |
exit 0; |
343 |
## |
## |
344 |
## end of the slidemaker main program |
## end of the slidemaker main program |
352 |
{ |
{ |
353 |
## open the file to write to |
## open the file to write to |
354 |
open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!"; |
open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!"; |
355 |
|
push @pack_additional,"$_[0].html" if ($pack); |
356 |
|
|
357 |
## the style sheet used in the table of content is |
## the style sheet used in the table of content is |
358 |
$stylelink = ""; |
$stylelink = ""; |
517 |
|
|
518 |
$status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle; |
$status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle; |
519 |
$status =~ s/<[^>]+>//g; |
$status =~ s/<[^>]+>//g; |
520 |
print STDOUT $status; |
print STDERR $status; |
521 |
|
|
522 |
&verify_html($content); # check the html |
&verify_html($content); # check the html |
523 |
|
|
524 |
## write to the slide |
## write to the slide |
525 |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; |
526 |
|
push @pack_additional,"slide$nr.html" if ($pack); |
527 |
|
|
528 |
my $toc_link = "$overview\.html"; |
my $toc_link = "$overview\.html"; |
529 |
|
|
548 |
|
|
549 |
my $slide_html=make_progress_bar($nr,$total); |
my $slide_html=make_progress_bar($nr,$total); |
550 |
|
|
551 |
|
# undefine body if no content is found (so that template can show |
552 |
|
# only title and sub-title |
553 |
|
if ($content !~ m/\S/g) { |
554 |
|
undef $content; |
555 |
|
} |
556 |
|
|
557 |
%page_data = ( |
%page_data = ( |
558 |
doctype => $doctype, |
doctype => $doctype, |
559 |
talkTitle => $talkTitle, |
talkTitle => $talkTitle, |
591 |
|
|
592 |
); |
); |
593 |
|
|
594 |
my $page= new Text::FastTemplate key => 'slide'; |
my $page; |
595 |
|
if ($content) { |
596 |
|
$page= new Text::FastTemplate key => 'slide'; |
597 |
|
} else { |
598 |
|
$page= new Text::FastTemplate key => 'title'; |
599 |
|
} |
600 |
print SLIDE $page->output( \%page_data ); |
print SLIDE $page->output( \%page_data ); |
601 |
|
extract_files($page->output( \%page_data )) if ($pack); |
602 |
close(SLIDE); |
close(SLIDE); |
603 |
return 0; |
return 0; |
604 |
} |
} |
646 |
|
|
647 |
if ($_[0] =~ /<img([^>]*)>/im) { |
if ($_[0] =~ /<img([^>]*)>/im) { |
648 |
if (!($1 =~ /ALT=/im)) { |
if (!($1 =~ /ALT=/im)) { |
649 |
print STDOUT "WARNING: <IMG> without ALT\n"; |
print STDERR "WARNING: <IMG> without ALT\n"; |
650 |
print STDOUT " <IMG$1>\n" ; |
print STDERR " <IMG$1>\n" ; |
651 |
} |
} |
652 |
} |
} |
653 |
} |
} |
701 |
} |
} |
702 |
|
|
703 |
############################################################################## |
############################################################################## |
704 |
# make slide progress bar |
# remove anchors <a href...> from html (for titles) |
705 |
sub remove_anchor { |
sub remove_anchor { |
706 |
my $tmp = $_[0]; |
my $tmp = $_[0]; |
707 |
$tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig; |
$tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig; |
708 |
return $tmp; |
return $tmp; |
709 |
} |
} |
710 |
|
|
711 |
|
############################################################################## |
712 |
|
# extract files referenced in presentation |
713 |
|
|
714 |
|
sub extract_files { |
715 |
|
my $tmp = $_[0]; |
716 |
|
while ($tmp =~ s/<a\s+href="*([^"\s]+)"*//ism || |
717 |
|
$tmp =~ s/<img\s+src="*([^"\s]+)"*//ism) { |
718 |
|
if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) { |
719 |
|
push @pack_additional,$1; |
720 |
|
} |
721 |
|
} |
722 |
|
} |