/[PLies]/burst.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /burst.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by dpavlin, Sat May 5 03:31:31 2001 UTC revision 1.9 by dpavlin, Sat May 5 19:48:33 2001 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl  #!/usr/bin/perl
2  #  #
3  # SLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org>  # PLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org>
4  #  #
5  # this tool is based on SlideMaker and XLSies tool  # this tool is based on SlideMaker and XLSies tool
6  # split a all.htm into slide*.htm  # split a all.htm into slide*.htm
# Line 52  use Text::FastTemplate; Line 52  use Text::FastTemplate;
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    
# Line 126  $content_hight = "70%"; Line 129  $content_hight = "70%";
129  ##############################################################################  ##############################################################################
130    
131  ## globals  ## globals
 my $logo_html;  
 my $date_html;  
132  my $last_toc_title;  my $last_toc_title;
133  my %page_data;  my %page_data;
134  my %overview_data;  my %overview_data;
# Line 141  my %overview_data; Line 142  my %overview_data;
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    
# Line 186  if ($charset) { Line 187  if ($charset) {
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;
# Line 236  Text::FastTemplate->preload( [ Line 234  Text::FastTemplate->preload( [
234                  { file => 'overview.html', key => 'overview' },                  { 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)].$table[($i*2)+1];
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
# Line 256  do { Line 278  do {
278          ## need to check if the title contains any anchor          ## need to check if the title contains any anchor
279          ## if so it needs to be removed          ## if so it needs to be removed
280          ## because the title is being used in the table of content to link to the corresponding slide          ## because the title is being used in the table of content to link to the corresponding slide
281          $table[0] =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;          $table[0] = remove_anchor($table[0]);
282    
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= remove_anchor($table[2]);
288          $next_slide_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;          }
289    
290          ## the current slide content is stored $table[1]          ## the current slide content is stored $table[1]
291          ## there is an attempt to make sure it's clean HTML          ## there is an attempt to make sure it's clean HTML
# Line 273  do { Line 295  do {
295    
296          ## extract slide Sub Title <h2>          ## extract slide Sub Title <h2>
297          undef $slideSubTitle;          undef $slideSubTitle;
298          if ($slideContent =~ s/<[hH]2[^>]*>([^<]+)<\/[hH]2[^>]*>//) {          if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) {
299                  $slideSubTitle=$1;                  $slideSubTitle=remove_anchor($1);
300          }          }
301    
302          ## add the title of the current slide to the table of content          ## add the title of the current slide to the table of content
# Line 283  do { Line 305  do {
305          ## generate the current slide          ## generate the current slide
306          ## parameters are:          ## parameters are:
307          ## 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
308          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$previous_slide_title,$next_slide_title);          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title);
309    
310          ## 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
311          $previous_slide_title="$table[0]";          $prev_title=remove_anchor($table[0]);
312  }  }
313  ## process the next slide  ## process the next slide
314  while (shift(@table));  while (shift(@table));
# Line 331  sub openOverview Line 353  sub openOverview
353                  logoLink => $logoLink,                  logoLink => $logoLink,
354                  logoFile => $logoFile,                  logoFile => $logoFile,
355                  logoAlt => $logoAlt,                  logoAlt => $logoAlt,
356                    logoLink2 => $logoLink2,
357                    logoFile2 => $logoFile2,
358                    logoAlt2 => $logoAlt2,
359    
360                  talkTitle => $talkTitle,                  talkTitle => $talkTitle,
361                  talkSubTitle => $talkSubTitle,                  talkSubTitle => $talkSubTitle,
# Line 360  sub closeOverview Line 385  sub closeOverview
385          $overview_data{slide_html} = make_progress_bar(0,$total);          $overview_data{slide_html} = make_progress_bar(0,$total);
386          $overview_data{toc_entries} = [ @toc_entries ];          $overview_data{toc_entries} = [ @toc_entries ];
387    
         print "---",$#toc_entries;  
         use Data::Dumper;  
         print Dumper([ @toc_entries ]);  
   
388          my $page= new Text::FastTemplate key => 'overview';          my $page= new Text::FastTemplate key => 'overview';
389          print FOO $page->output( \%overview_data );          print FOO $page->output( \%overview_data );
390    
# Line 451  sub createSlide Line 472  sub createSlide
472          # parameters are respectively the slide title, its content,          # parameters are respectively the slide title, its content,
473          # its number, the next slide title and the previous slide title          # its number, the next slide title and the previous slide title
474    
475          my ($title,$subtitle,$content,$nr,$next_title,$prev_title) = @_;          my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_;
476    
477          if (! $title) {          if (! $title) {
478                  return 1;                  return 1;
# Line 486  sub createSlide Line 507  sub createSlide
507          ## write to the slide          ## write to the slide
508          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";
509    
510          my $toclink = "[ <a href=\"$overview\.html\" title=\"Contents\">Contents</a> ]";          my $toc_link = "$overview\.html";
511    
512          ## initialization of the navigation links          ## initialization of the navigation links
513          my $nextlink = "";          my $next_link = "";
514          my $prevlink = "";          my $prev_link = "";
515    
516          if ($nr>1) {          if ($nr>1) {
517                  $prevlink = "<a href=\"slide".($nr-1).".html\" title=\"Previous\">&lt;&lt;</a>";                  $prev_link = "slide".($nr-1).".html";
518  #       } else {  #       } else {
519  #       ## 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
520  #               $prevlink = "<a href=\"$overview\.html\" title=\"Previous\">&lt;&lt;</a>";  #               $prev_link = "$overview\.html";
521          }          }
522    
523          if ($nr != $total) {          if ($nr != $total) {
524                  $nextlink = "<a href=\"slide".($nr+1).".html\" title=\"Next\">&gt;&gt;</a>";                  $next_link = "slide".($nr+1).".html";
525          }          }
526    
527          $stylelink = "";          $stylelink = "";
528          # here is the standard style sheet          # here is the standard style sheet
529          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";
530    
         $title_html="<h1>$title</h1>";  
         if ($subtitle) {  
                 $title_html.="<h2>$subtitle</h2>";  
         }  
   
531          my $slide_html=make_progress_bar($nr,$total);          my $slide_html=make_progress_bar($nr,$total);
532    
533          %page_data = (          %page_data = (
534                  doctype => $doctype,                  doctype => $doctype,
535                  talkTitle => $talkTitle,                  talkTitle => $talkTitle,
536                  title => $title,                  title => $title,
537                    subtitle => $subtitle,
538                  http_equiv => $http_equiv,                  http_equiv => $http_equiv,
539                  stylelink => $stylelink,                  stylelink => $stylelink,
540                  body => $body,                  body => $body,
541    
542                  logo_html => $logo_html,                  logoLink => $logoLink,
543                  title_html => $title_html,                  logoFile => $logoFile,
544                    logoAlt => $logoAlt,
545                    logoLink2 => $logoLink2,
546                    logoFile2 => $logoFile2,
547                    logoAlt2 => $logoAlt2,
548    
549    
550                  content_hight => $content_hight,                  content_hight => $content_hight,
551                  content => $content,                  content => $content,
552    
553                    prev_link => $prev_link,
554                    toc_link => $toc_link,
555                    next_link => $next_link,
556                    prev_title => $prev_title,
557                    next_title => $next_title,
558    
559                  author => $author,                  author => $author,
560                  date_html => $date_html,                  authorUrl => $authorUrl,
561                  prevlink => $prevlink,                  author2 => $author2,
562                  toclink => $toclink,                  authorUrl2 => $authorUrl2,
563                  nextlink => $nextlink,  
564                    date => $date,
565    
566                  slide_html => $slide_html,                  slide_html => $slide_html,
                 author2 => $author2  
567    
568          );          );
569    
# Line 638  sub make_progress_bar { Line 669  sub make_progress_bar {
669          return $html;          return $html;
670  }  }
671    
672    ##############################################################################
673    # make slide progress bar
674    sub remove_anchor {
675            my $foo = $_[0];
676            $foo=~s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
677            return $foo;
678    }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.26