--- burst.pl 2001/05/05 18:23:39 1.6 +++ burst.pl 2001/05/05 20:21:29 1.10 @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# SLies Copyright 2001 Dobrica Pavlinusic +# PLies Copyright 2001 Dobrica Pavlinusic # # this tool is based on SlideMaker and XLSies tool # split a all.htm into slide*.htm @@ -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)].$table[($i*2)+1]; + 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 @@ -256,14 +278,14 @@ ## need to check if the title contains any anchor ## if so it needs to be removed ## because the title is being used in the table of content to link to the corresponding slide - $table[0] =~ s/(.*)]*>(.*)<\/A>(.*)/$1$2$3/i; + $table[0] = remove_anchor($table[0]); ## 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= remove_anchor($table[2]); + } ## the current slide content is stored $table[1] ## there is an attempt to make sure it's clean HTML @@ -273,8 +295,8 @@ ## extract slide Sub Title

undef $slideSubTitle; - if ($slideContent =~ s/<[hH]2[^>]*>([^<]+)<\/[hH]2[^>]*>//) { - $slideSubTitle=$1; + if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) { + $slideSubTitle=remove_anchor($1); } ## add the title of the current slide to the table of content @@ -283,10 +305,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=remove_anchor($table[0]); } ## process the next slide while (shift(@table)); @@ -331,6 +353,9 @@ logoLink => $logoLink, logoFile => $logoFile, logoAlt => $logoAlt, + logoLink2 => $logoLink2, + logoFile2 => $logoFile2, + logoAlt2 => $logoAlt2, talkTitle => $talkTitle, talkSubTitle => $talkSubTitle, @@ -387,17 +412,18 @@ if ($nr % $toc_on_page == 0) { my $toc_nr=int($nr/$toc_on_page); - %item = ( + $item = { pre_html => $pre_ul, accesskey => " ", # space href => "index-toc$toc_nr.html", title => "...", post_html => $post_ul, more => 1, # use style for more pages link (...) - ) -# push @toc_entries, %item; + }; + push @toc_entries, $item; &closeOverview; + undef @toc_entries; &openOverview("$overview-toc$toc_nr"); $last_toc_title=''; } @@ -425,14 +451,14 @@ }; push @toc_entries,$item; } else { - %item = ( + $item = { pre_html => $pre_ul, tabindex => "$nr", href => "slide$nr.html", title => $title, post_html => $post_ul, - ) -# push @toc_entries,\%item; + }; + push @toc_entries,$item; } } ## @@ -447,7 +473,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; @@ -482,53 +508,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 ); @@ -592,8 +628,10 @@ # clean the html of the slide # remove all
blabla
sub clean_html { - $_[0] =~ s/]|\"comment\").*?<\/div>//igs; - return $_[0]; + my $tmp=$_[0]; + $tmp =~ s/]|\"comment\").*?<\/div>//igs; + $tmp =~ s,]+>,,ig; + return $tmp; } ############################################################################## @@ -634,3 +672,10 @@ return $html; } +############################################################################## +# make slide progress bar +sub remove_anchor { + my $tmp = $_[0]; + $tmp =~ s/(.*)]*>(.*)<\/A>(.*)/$1$2$3/ig; + return $tmp; +}