/[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.6 by dpavlin, Sat May 5 18:23:39 2001 UTC revision 1.10 by dpavlin, Sat May 5 20:21:29 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 387  sub addTitle Line 412  sub addTitle
412          if ($nr % $toc_on_page == 0) {          if ($nr % $toc_on_page == 0) {
413                  my $toc_nr=int($nr/$toc_on_page);                  my $toc_nr=int($nr/$toc_on_page);
414    
415                  %item = (                  $item = {
416                          pre_html => $pre_ul,                          pre_html => $pre_ul,
417                          accesskey => " ",       # space                          accesskey => " ",       # space
418                          href => "index-toc$toc_nr.html",                          href => "index-toc$toc_nr.html",
419                          title => "...",                          title => "...",
420                          post_html => $post_ul,                          post_html => $post_ul,
421                          more => 1,      # use style for more pages link (...)                          more => 1,      # use style for more pages link (...)
422                  )                  };
423  #               push @toc_entries, %item;                  push @toc_entries, $item;
424    
425                  &closeOverview;                  &closeOverview;
426                    undef @toc_entries;
427                  &openOverview("$overview-toc$toc_nr");                  &openOverview("$overview-toc$toc_nr");
428                  $last_toc_title='';                  $last_toc_title='';
429          }          }
# Line 425  sub addTitle Line 451  sub addTitle
451                  };                  };
452                  push @toc_entries,$item;                  push @toc_entries,$item;
453          } else {          } else {
454                  %item = (                  $item = {
455                          pre_html => $pre_ul,                          pre_html => $pre_ul,
456                          tabindex => "$nr",                          tabindex => "$nr",
457                          href => "slide$nr.html",                          href => "slide$nr.html",
458                          title => $title,                          title => $title,
459                          post_html => $post_ul,                          post_html => $post_ul,
460                  )                  };
461  #               push @toc_entries,\%item;                  push @toc_entries,$item;
462          }          }
463  }  }
464  ##  ##
# Line 447  sub createSlide Line 473  sub createSlide
473          # parameters are respectively the slide title, its content,          # parameters are respectively the slide title, its content,
474          # its number, the next slide title and the previous slide title          # its number, the next slide title and the previous slide title
475    
476          my ($title,$subtitle,$content,$nr,$next_title,$prev_title) = @_;          my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_;
477    
478          if (! $title) {          if (! $title) {
479                  return 1;                  return 1;
# Line 482  sub createSlide Line 508  sub createSlide
508          ## write to the slide          ## write to the slide
509          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";
510    
511          my $toclink = "[ <a href=\"$overview\.html\" title=\"Contents\">Contents</a> ]";          my $toc_link = "$overview\.html";
512    
513          ## initialization of the navigation links          ## initialization of the navigation links
514          my $nextlink = "";          my $next_link = "";
515          my $prevlink = "";          my $prev_link = "";
516    
517          if ($nr>1) {          if ($nr>1) {
518                  $prevlink = "<a href=\"slide".($nr-1).".html\" title=\"Previous\">&lt;&lt;</a>";                  $prev_link = "slide".($nr-1).".html";
519  #       } else {  #       } else {
520  #       ## 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
521  #               $prevlink = "<a href=\"$overview\.html\" title=\"Previous\">&lt;&lt;</a>";  #               $prev_link = "$overview\.html";
522          }          }
523    
524          if ($nr != $total) {          if ($nr != $total) {
525                  $nextlink = "<a href=\"slide".($nr+1).".html\" title=\"Next\">&gt;&gt;</a>";                  $next_link = "slide".($nr+1).".html";
526          }          }
527    
528          $stylelink = "";          $stylelink = "";
529          # here is the standard style sheet          # here is the standard style sheet
530          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";
531    
         $title_html="<h1>$title</h1>";  
         if ($subtitle) {  
                 $title_html.="<h2>$subtitle</h2>";  
         }  
   
532          my $slide_html=make_progress_bar($nr,$total);          my $slide_html=make_progress_bar($nr,$total);
533    
534          %page_data = (          %page_data = (
535                  doctype => $doctype,                  doctype => $doctype,
536                  talkTitle => $talkTitle,                  talkTitle => $talkTitle,
537                  title => $title,                  title => $title,
538                    subtitle => $subtitle,
539                  http_equiv => $http_equiv,                  http_equiv => $http_equiv,
540                  stylelink => $stylelink,                  stylelink => $stylelink,
541                  body => $body,                  body => $body,
542    
543                  logo_html => $logo_html,                  logoLink => $logoLink,
544                  title_html => $title_html,                  logoFile => $logoFile,
545                    logoAlt => $logoAlt,
546                    logoLink2 => $logoLink2,
547                    logoFile2 => $logoFile2,
548                    logoAlt2 => $logoAlt2,
549    
550    
551                  content_hight => $content_hight,                  content_hight => $content_hight,
552                  content => $content,                  content => $content,
553    
554                    prev_link => $prev_link,
555                    toc_link => $toc_link,
556                    next_link => $next_link,
557                    prev_title => $prev_title,
558                    next_title => $next_title,
559    
560                  author => $author,                  author => $author,
561                  date_html => $date_html,                  authorUrl => $authorUrl,
562                  prevlink => $prevlink,                  author2 => $author2,
563                  toclink => $toclink,                  authorUrl2 => $authorUrl2,
564                  nextlink => $nextlink,  
565                    date => $date,
566    
567                  slide_html => $slide_html,                  slide_html => $slide_html,
                 author2 => $author2  
568    
569          );          );
570    
# Line 592  sub verify_html { Line 628  sub verify_html {
628  # clean the html of the slide  # clean the html of the slide
629  # remove all <div class="comment">blabla</div>  # remove all <div class="comment">blabla</div>
630  sub clean_html {  sub clean_html {
631      $_[0] =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;          my $tmp=$_[0];
632      return $_[0];          $tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;
633            $tmp =~ s,</*font[^>]+>,,ig;
634            return $tmp;
635  }  }
636    
637  ##############################################################################  ##############################################################################
# Line 634  sub make_progress_bar { Line 672  sub make_progress_bar {
672          return $html;          return $html;
673  }  }
674    
675    ##############################################################################
676    # make slide progress bar
677    sub remove_anchor {
678            my $tmp = $_[0];
679            $tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
680            return $tmp;
681    }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.26