--- burst.pl 2001/05/05 03:31:31 1.5 +++ burst.pl 2001/05/05 19:20:27 1.7 @@ -52,6 +52,9 @@ ## default values of variables ## +## show debug output +my $debug=1; + ## default DOCTYPE added on the slides $doctype = ''; @@ -126,8 +129,6 @@ ############################################################################## ## globals -my $logo_html; -my $date_html; my $last_toc_title; my %page_data; my %overview_data; @@ -141,20 +142,20 @@ # 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; - @file = ; - @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)); + print STDOUT "--- Reading parameters file $infos ---\n"; + local(@file,$counter); + $counter = 0; + @file = ; + @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)); } ## @PARAM is now a table with the user preferences for his presentation @@ -186,10 +187,7 @@ ## copy file in memory my $sep = $/; $/ = undef; -if (!open(ALL, $all)) { - print "Error: Cannot open file: $all\n"; - exit 0; -} +open(ALL, $all) || die "Error: Cannot open file: $all"; my $buf = ; close(ALL); $/ = $sep; @@ -236,11 +234,35 @@ { file => 'overview.html', key => 'overview' }, ]); +## unroll relative anchors (#something) into links with slides + +my %anchor_on_slide; + +## step 1: record anchors +for($i=0; $i<$total; $i++) { + my $tmp = $table[($i*2)]; + while ($tmp =~ s,,,i) { + $anchor_on_slide{$1}=($i+1); + print "\tslide ",($i+1)," anchor: $1\n" if ($debug); + } +} + +## step 2: fix links +for($i=0; $i<$total; $i++) { + foreach (keys %anchor_on_slide) { + $table[($i*2)] =~ s,href="*#$_"*>,href="slide$anchor_on_slide{$_}\.html#$_">,gi; + } +} + ## @table is the array containing each slide with its title ## for each slide to be generated ## we delete each slide and its title when generated ## so that the current slide and its title are always at $table[0] (for the title) ## and $table[1] (for the slide content) + +undef $prev_title; +undef $next_title; + do { ## get rid of the first element contained by the raw presentation array @@ -261,9 +283,11 @@ ## grab next slide title $table[2] (if there's a next slide) ## to be able to use in the 'next' navigation button ## keep in mind that $table[1] contains the slide corresponding to the title $table[0] - $next_slide_title = $table[2] if $table[2]; - ## remove any anchor from the next slide title - $next_slide_title =~ s/(.*)]*>(.*)<\/A>(.*)/$1$2$3/i; + if ($table[2]) { + $next_title= $table[2]; + ## remove any anchor from the next slide title + $next_title =~ s/(.*)]*>(.*)<\/A>(.*)/$1$2$3/i; + } ## the current slide content is stored $table[1] ## there is an attempt to make sure it's clean HTML @@ -283,10 +307,10 @@ ## generate the current slide ## parameters are: ## title of the slide, its content, the slide number, the title of the previous slide and the title of the next slide - &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$previous_slide_title,$next_slide_title); + &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title); ## save the title of the previous slide to be displayed in the 'previous' navigation button - $previous_slide_title="$table[0]"; + $prev_title="$table[0]"; } ## process the next slide while (shift(@table)); @@ -331,6 +355,9 @@ logoLink => $logoLink, logoFile => $logoFile, logoAlt => $logoAlt, + logoLink2 => $logoLink2, + logoFile2 => $logoFile2, + logoAlt2 => $logoAlt2, talkTitle => $talkTitle, talkSubTitle => $talkSubTitle, @@ -360,10 +387,6 @@ $overview_data{slide_html} = make_progress_bar(0,$total); $overview_data{toc_entries} = [ @toc_entries ]; - print "---",$#toc_entries; - use Data::Dumper; - print Dumper([ @toc_entries ]); - my $page= new Text::FastTemplate key => 'overview'; print FOO $page->output( \%overview_data ); @@ -451,7 +474,7 @@ # parameters are respectively the slide title, its content, # its number, the next slide title and the previous slide title - my ($title,$subtitle,$content,$nr,$next_title,$prev_title) = @_; + my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_; if (! $title) { return 1; @@ -486,53 +509,63 @@ ## write to the slide open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!"; - my $toclink = "[ Contents ]"; + my $toc_link = "$overview\.html"; ## initialization of the navigation links - my $nextlink = ""; - my $prevlink = ""; + my $next_link = ""; + my $prev_link = ""; if ($nr>1) { - $prevlink = "<<"; + $prev_link = "slide".($nr-1).".html"; # } else { # ## add a link back to the toc for the first slide --CMN 19991102 -# $prevlink = "<<"; +# $prev_link = "$overview\.html"; } if ($nr != $total) { - $nextlink = ">>"; + $next_link = "slide".($nr+1).".html"; } $stylelink = ""; # here is the standard style sheet $stylelink .= ""; - $title_html="

$title

"; - if ($subtitle) { - $title_html.="

$subtitle

"; - } - my $slide_html=make_progress_bar($nr,$total); %page_data = ( doctype => $doctype, talkTitle => $talkTitle, title => $title, + subtitle => $subtitle, http_equiv => $http_equiv, stylelink => $stylelink, body => $body, - logo_html => $logo_html, - title_html => $title_html, + logoLink => $logoLink, + logoFile => $logoFile, + logoAlt => $logoAlt, + logoLink2 => $logoLink2, + logoFile2 => $logoFile2, + logoAlt2 => $logoAlt2, + + content_hight => $content_hight, content => $content, + + prev_link => $prev_link, + toc_link => $toc_link, + next_link => $next_link, + prev_title => $prev_title, + next_title => $next_title, + author => $author, - date_html => $date_html, - prevlink => $prevlink, - toclink => $toclink, - nextlink => $nextlink, + authorUrl => $authorUrl, + author2 => $author2, + authorUrl2 => $authorUrl2, + + date => $date, + slide_html => $slide_html, - author2 => $author2 );