/[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.7 by dpavlin, Sat May 5 19:20:27 2001 UTC revision 1.12 by dpavlin, Tue May 8 12:14:35 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 189  my $sep = $/; Line 189  my $sep = $/;
189  $/ = undef;  $/ = undef;
190  open(ALL, $all) || die "Error: Cannot open file: $all";  open(ALL, $all) || die "Error: Cannot open file: $all";
191  my $buf = <ALL>;  my $buf = <ALL>;
192    $buf =~ s/\r//g;        # remove WINDOWS \r    
193  close(ALL);  close(ALL);
194  $/ = $sep;  $/ = $sep;
195    
# Line 232  Text::FastTemplate->defaults( Line 233  Text::FastTemplate->defaults(
233  Text::FastTemplate->preload( [  Text::FastTemplate->preload( [
234                  { file => 'slide.html', key => 'slide' },                  { file => 'slide.html', key => 'slide' },
235                  { file => 'overview.html', key => 'overview' },                  { file => 'overview.html', key => 'overview' },
236                    { file => 'title.html', key => 'title' },
237          ]);          ]);
238    
239  ## unroll relative anchors (#something) into links with slides  ## unroll relative anchors (#something) into links with slides
# Line 240  my %anchor_on_slide; Line 242  my %anchor_on_slide;
242    
243  ## step 1: record anchors  ## step 1: record anchors
244  for($i=0; $i<$total; $i++) {  for($i=0; $i<$total; $i++) {
245          my $tmp = $table[($i*2)];          my $tmp = $table[($i*2)].$table[($i*2)+1];
246          while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) {          while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) {
247                  $anchor_on_slide{$1}=($i+1);                  $anchor_on_slide{$1}=($i+1);
248                  print "\tslide ",($i+1)," anchor: $1\n" if ($debug);                  print "\tslide ",($i+1)," anchor: $1\n" if ($debug);
# Line 278  do { Line 280  do {
280          ## need to check if the title contains any anchor          ## need to check if the title contains any anchor
281          ## if so it needs to be removed          ## if so it needs to be removed
282          ## 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
283          $table[0] =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;          $table[0] = remove_anchor($table[0]);
284    
285          ## grab next slide title $table[2] (if there's a next slide)          ## grab next slide title $table[2] (if there's a next slide)
286          ## to be able to use in the 'next' navigation button          ## to be able to use in the 'next' navigation button
287          ## 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]
288          if ($table[2]) {          if ($table[2]) {
289                  $next_title= $table[2];                  $next_title= remove_anchor($table[2]);
                 ## remove any anchor from the next slide title  
                 $next_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;  
290          }          }
291    
292          ## the current slide content is stored $table[1]          ## the current slide content is stored $table[1]
# Line 297  do { Line 297  do {
297    
298          ## extract slide Sub Title <h2>          ## extract slide Sub Title <h2>
299          undef $slideSubTitle;          undef $slideSubTitle;
300          if ($slideContent =~ s/<[hH]2[^>]*>([^<]+)<\/[hH]2[^>]*>//) {          if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) {
301                  $slideSubTitle=$1;                  $slideSubTitle=remove_anchor($1);
302          }          }
303    
304          ## 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 310  do { Line 310  do {
310          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title);          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title);
311    
312          ## 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
313          $prev_title="$table[0]";          $prev_title=remove_anchor($table[0]);
314  }  }
315  ## process the next slide  ## process the next slide
316  while (shift(@table));  while (shift(@table));
# Line 414  sub addTitle Line 414  sub addTitle
414          if ($nr % $toc_on_page == 0) {          if ($nr % $toc_on_page == 0) {
415                  my $toc_nr=int($nr/$toc_on_page);                  my $toc_nr=int($nr/$toc_on_page);
416    
417                  %item = (                  $item = {
418                          pre_html => $pre_ul,                          pre_html => $pre_ul,
419                          accesskey => " ",       # space                          accesskey => " ",       # space
420                          href => "index-toc$toc_nr.html",                          href => "index-toc$toc_nr.html",
421                          title => "...",                          title => "...",
422                          post_html => $post_ul,                          post_html => $post_ul,
423                          more => 1,      # use style for more pages link (...)                          more => 1,      # use style for more pages link (...)
424                  )                  };
425  #               push @toc_entries, %item;                  push @toc_entries, $item;
426    
427                  &closeOverview;                  &closeOverview;
428                    undef @toc_entries;
429                  &openOverview("$overview-toc$toc_nr");                  &openOverview("$overview-toc$toc_nr");
430                  $last_toc_title='';                  $last_toc_title='';
431          }          }
432    
433          $pre_ul=$post_ul='';          $pre_ul=$post_ul='';
434          if ($last_toc_title eq $title) {          if ($last_toc_title eq $title && $subtitle) {
435                  $title = $subtitle;                  $title = $subtitle;
436                  $pre_ul='<ul>';                  $pre_ul='<ul>';
437                  $post_ul='</ul>';                  $post_ul='</ul>';
# Line 452  sub addTitle Line 453  sub addTitle
453                  };                  };
454                  push @toc_entries,$item;                  push @toc_entries,$item;
455          } else {          } else {
456                  %item = (                  $item = {
457                          pre_html => $pre_ul,                          pre_html => $pre_ul,
458                          tabindex => "$nr",                          tabindex => "$nr",
459                          href => "slide$nr.html",                          href => "slide$nr.html",
460                          title => $title,                          title => $title,
461                          post_html => $post_ul,                          post_html => $post_ul,
462                  )                  };
463  #               push @toc_entries,\%item;                  push @toc_entries,$item;
464          }          }
465  }  }
466  ##  ##
# Line 532  sub createSlide Line 533  sub createSlide
533    
534          my $slide_html=make_progress_bar($nr,$total);          my $slide_html=make_progress_bar($nr,$total);
535    
536            # undefine body if no content is found (so that template can show
537            # only title and sub-title
538            if ($content !~ m/\S/g) {
539                    undef $content;
540            }
541    
542          %page_data = (          %page_data = (
543                  doctype => $doctype,                  doctype => $doctype,
544                  talkTitle => $talkTitle,                  talkTitle => $talkTitle,
# Line 569  sub createSlide Line 576  sub createSlide
576    
577          );          );
578    
579          my $page= new Text::FastTemplate key => 'slide';          my $page;
580            if ($content) {
581                    $page= new Text::FastTemplate key => 'slide';
582            } else {
583                    $page= new Text::FastTemplate key => 'title';
584            }
585          print SLIDE $page->output( \%page_data );          print SLIDE $page->output( \%page_data );
586    
587          close(SLIDE);          close(SLIDE);
# Line 629  sub verify_html { Line 641  sub verify_html {
641  # clean the html of the slide  # clean the html of the slide
642  # remove all <div class="comment">blabla</div>  # remove all <div class="comment">blabla</div>
643  sub clean_html {  sub clean_html {
644      $_[0] =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;          my $tmp=$_[0];
645      return $_[0];          $tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;
646            $tmp =~ s,</*font[^>]+>,,ig;
647            return $tmp;
648  }  }
649    
650  ##############################################################################  ##############################################################################
# Line 671  sub make_progress_bar { Line 685  sub make_progress_bar {
685          return $html;          return $html;
686  }  }
687    
688    ##############################################################################
689    # make slide progress bar
690    sub remove_anchor {
691            my $tmp = $_[0];
692            $tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
693            return $tmp;
694    }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.26