--- burst.pl 2001/05/05 20:21:29 1.10 +++ burst.pl 2001/05/08 23:03:03 1.14 @@ -53,7 +53,7 @@ ## ## show debug output -my $debug=1; +my $debug=0; ## default DOCTYPE added on the slides $doctype = ''; @@ -133,6 +133,9 @@ my %page_data; my %overview_data; +my $pack = 0; +my @pack_additional; # additional files to pack (pictures, logos...) + ############################################################################## ## reading user input from $infos ## @@ -142,18 +145,17 @@ # read parameters from infos.txt and put them in @PARAM if (open(INFOS, $infos)) { - print STDOUT "--- Reading parameters file $infos ---\n"; - local(@file,$counter); - $counter = 0; + print STDERR "--- Reading parameters file $infos ---\n"; + local(@file); @file = ; - @PARAM = (); +# @PARAM = (); # don't reset param, use @ARGV 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"; + push @PARAM,$file[0]; + print STDERR "$file[0]\n"; } } while (shift(@file)); } @@ -180,6 +182,7 @@ $http_equiv=''; } + ############################################################################## ## read the raw html presentation ## @@ -189,6 +192,7 @@ $/ = undef; open(ALL, $all) || die "Error: Cannot open file: $all"; my $buf = ; +$buf =~ s/\r//g; # remove WINDOWS \r close(ALL); $/ = $sep; @@ -196,6 +200,14 @@ ## they do not need to show up on the slides $buf =~ s///sgo; +## if $pack is set, output name of css (for inclusion in archive), but +## reset $cssStandard only to filename (without path) + +if ($pack) { + push @pack_additional,$cssStandard; + $cssStandard =~ s/^.*\/([^\/]+)$/$1/g; +} + ## the slidemaker tool assumes that each slide is self contained between 2 sets of h1 tags ## if not it will generate a rather weird output ## split using and as separator (ignores attributes!) @@ -215,7 +227,7 @@ ############################################################################## ## processing the slides -print STDOUT "\n--- Processing $total slides ---\n"; +print STDERR "\n--- Processing $total slides ---\n"; ## generate the header table of content of the presentation ## which is also the first page of the talk @@ -232,6 +244,7 @@ Text::FastTemplate->preload( [ { file => 'slide.html', key => 'slide' }, { file => 'overview.html', key => 'overview' }, + { file => 'title.html', key => 'title' }, ]); ## unroll relative anchors (#something) into links with slides @@ -243,7 +256,7 @@ my $tmp = $table[($i*2)].$table[($i*2)+1]; while ($tmp =~ s,,,i) { $anchor_on_slide{$1}=($i+1); - print "\tslide ",($i+1)," anchor: $1\n" if ($debug); + print STDERR "\tslide ",($i+1)," anchor: $1\n" if ($debug); } } @@ -322,8 +335,10 @@ ## and would not work on all platforms (ie would fail on Joe's laptop) &generateTOC; +## print additional files to pack +print STDOUT join("\n",@pack_additional) if ($pack); -print STDOUT "--- Finished ---\n"; +print STDERR "--- Finished ---\n"; exit 0; ## ## end of the slidemaker main program @@ -337,6 +352,7 @@ { ## open the file to write to open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!"; + push @pack_additional,"$_[0].html" if ($pack); ## the style sheet used in the table of content is $stylelink = ""; @@ -429,7 +445,7 @@ } $pre_ul=$post_ul=''; - if ($last_toc_title eq $title) { + if ($last_toc_title eq $title && $subtitle) { $title = $subtitle; $pre_ul='
    '; $post_ul='
'; @@ -501,12 +517,13 @@ $status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle; $status =~ s/<[^>]+>//g; - print STDOUT $status; + print STDERR $status; &verify_html($content); # check the html ## write to the slide open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; + push @pack_additional,"slide$nr.html" if ($pack); my $toc_link = "$overview\.html"; @@ -531,6 +548,12 @@ my $slide_html=make_progress_bar($nr,$total); + # undefine body if no content is found (so that template can show + # only title and sub-title + if ($content !~ m/\S/g) { + undef $content; + } + %page_data = ( doctype => $doctype, talkTitle => $talkTitle, @@ -568,9 +591,14 @@ ); - my $page= new Text::FastTemplate key => 'slide'; + my $page; + if ($content) { + $page= new Text::FastTemplate key => 'slide'; + } else { + $page= new Text::FastTemplate key => 'title'; + } print SLIDE $page->output( \%page_data ); - + extract_files($page->output( \%page_data )) if ($pack); close(SLIDE); return 0; } @@ -618,8 +646,8 @@ if ($_[0] =~ /]*)>/im) { if (!($1 =~ /ALT=/im)) { - print STDOUT "WARNING: without ALT\n"; - print STDOUT " \n" ; + print STDERR "WARNING: without ALT\n"; + print STDERR " \n" ; } } } @@ -673,9 +701,22 @@ } ############################################################################## -# make slide progress bar +# remove anchors
from html (for titles) sub remove_anchor { my $tmp = $_[0]; $tmp =~ s/(.*)]*>(.*)<\/A>(.*)/$1$2$3/ig; return $tmp; } + +############################################################################## +# extract files referenced in presentation + +sub extract_files { + my $tmp = $_[0]; + while ($tmp =~ s/