/[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.21 by dpavlin, Tue Sep 18 12:50:15 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=0;
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;
135    
136    my $pack = 0;
137    my @pack_additional;    # additional files to pack (pictures, logos...)
138    my %nesttag = init_nesttag();
139    
140  ##############################################################################  ##############################################################################
141  ## reading user input from $infos  ## reading user input from $infos
142  ##  ##
143  @PARAM = @ARGV; # we keep this for backward compatibility with an old version  my @file;
144                  # of the slidemaker tool  
145                  #when the parameters were in Makefile or make.bat  ##############################################################################
146    sub parse_infos {
147            my @file=@_;
148            do {
149                    if ($file[0] && $file[0] =~ /^[^#\n\r]/) {
150                            $file[0] =~ s/\n//;    # remove UNIX \n
151                            $file[0] =~ s/\r//;    # remove WINDOWS \r    
152                            my ($var,$value) = split(/ *= */,$file[0],2);
153                            $value=~s/'/\\'/g;
154                            $cmd="\$$var = \'$value\';";
155                            if (defined($value)) {
156                                    eval($cmd) || warn "problem with eval of: $cmd";
157                            } else {
158                                    die "no value defined for $var";
159                            }
160                            print STDERR "$file[0]\n";
161                    }
162            } while (shift(@file));
163    }
164    ##############################################################################
165    
166    parse_infos(@ARGV);     # backward compatibility and for pack
167    
168  # read parameters from infos.txt and put them in @PARAM  # read parameters from infos.txt and put them in @PARAM
169  if (open(INFOS, $infos)) {  if (open(INFOS, $infos)) {
170      print STDOUT "--- Reading parameters file $infos ---\n";          print STDERR "--- Reading parameters file $infos ---\n";
171      local(@file,$counter);          @file = <INFOS>;
172      $counter = 0;          parse_infos(@file);
     @file = <INFOS>;  
     @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));  
173  }  }
 ## @PARAM is now a table with the user preferences for his presentation  
174    
175  ## process arguments  # try to read local infos.txt for template
176  ## each preset variable is now re-attributed using the user preferences  if (-f "$template/$infos" && open(INFOS,"$template/$infos")) {
177  foreach (@PARAM) {          print STDERR "--- Reading template parameters file $template/$infos ---\n";
178          my ($var,$value) = split(/ *= */,$_,2);          @file = <INFOS>;
179          $value=~s/'/\\'/g;          parse_infos(@file);
180          $cmd="\$$var = \'$value\';";          close(INFOS);
         if ($value) {  
                 eval($cmd) || die "problem with eval of: $cmd";  
         } else {  
                 die "no value defined for $var";  
         }  
181  }  }
182    
183    ## @PARAM is now a table with the user preferences for his presentation
184    
185  ## use charset  ## use charset
186    
187  if ($charset) {  if ($charset) {
# Line 179  if ($charset) { Line 190  if ($charset) {
190          $http_equiv='';          $http_equiv='';
191  }  }
192    
193    
194  ##############################################################################  ##############################################################################
195  ## read the raw html presentation  ## read the raw html presentation
196  ##  ##
# Line 186  if ($charset) { Line 198  if ($charset) {
198  ## copy file in memory  ## copy file in memory
199  my $sep = $/;  my $sep = $/;
200  $/ = undef;  $/ = undef;
201  if (!open(ALL, $all)) {  open(ALL, $all) || die "Error: Cannot open file: $all";
     print "Error: Cannot open file: $all\n";  
     exit 0;  
 }  
202  my $buf = <ALL>;  my $buf = <ALL>;
203    $buf =~ s/\r//g;        # remove WINDOWS \r    
204  close(ALL);  close(ALL);
205  $/ = $sep;  $/ = $sep;
206    
# Line 198  $/ = $sep; Line 208  $/ = $sep;
208  ## they do not need to show up on the slides  ## they do not need to show up on the slides
209  $buf =~ s/<!--.*?-->//sgo;  $buf =~ s/<!--.*?-->//sgo;
210    
211    ## if $pack is set, output name of css (for inclusion in archive), but
212    ## reset $cssStandard only to filename (without path)
213    
214    if ($pack) {
215            push @pack_additional,$cssStandard;
216            $cssStandard =~ s/^.*\/([^\/]+)$/$1/g;
217    }
218    
219  ## the slidemaker tool assumes that each slide is self contained between 2 sets of h1 tags  ## the slidemaker tool assumes that each slide is self contained between 2 sets of h1 tags
220  ## if not it will generate a rather weird output  ## if not it will generate a rather weird output
221  ## split using <h1...> and </h1...> as separator (ignores attributes!)  ## split using <h1...> and </h1...> as separator (ignores attributes!)
# Line 217  if ($#table % 2 != 0) { Line 235  if ($#table % 2 != 0) {
235  ##############################################################################  ##############################################################################
236  ## processing the slides  ## processing the slides
237    
238  print STDOUT "\n--- Processing $total slides ---\n";  print STDERR "\n--- Processing $total slides ---\n";
239    
240  ## generate the header table of content of the presentation  ## generate the header table of content of the presentation
241  ## which is also the first page of the talk  ## which is also the first page of the talk
# Line 234  Text::FastTemplate->defaults( Line 252  Text::FastTemplate->defaults(
252  Text::FastTemplate->preload( [  Text::FastTemplate->preload( [
253                  { file => 'slide.html', key => 'slide' },                  { file => 'slide.html', key => 'slide' },
254                  { file => 'overview.html', key => 'overview' },                  { file => 'overview.html', key => 'overview' },
255                    { file => 'title.html', key => 'title' },
256          ]);          ]);
257    
258    ## unroll relative anchors (#something) into links with slides
259    
260    my %anchor_on_slide;
261    
262    ## step 1: record anchors
263    for($i=0; $i<$total; $i++) {
264            my $tmp = $table[($i*2)].$table[($i*2)+1];
265            while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) {
266                    $anchor_on_slide{$1}=($i+1);
267                    print STDERR "\tslide ",($i+1)," anchor: $1\n" if ($debug);
268            }
269    }
270    
271    ## step 2: fix links
272    for($i=0; $i<$total; $i++) {
273            foreach (keys %anchor_on_slide) {
274                    $table[($i*2)] =~ s,href="*#$_"*>,href="slide$anchor_on_slide{$_}\.html#$_">,gi;
275            }
276    }
277    
278  ## @table is the array containing each slide with its title  ## @table is the array containing each slide with its title
279  ## for each slide to be generated  ## for each slide to be generated
280  ## we delete each slide and its title when generated  ## we delete each slide and its title when generated
281  ## 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)
282  ## and $table[1] (for the slide content)  ## and $table[1] (for the slide content)
283    
284    undef $prev_title;
285    undef $next_title;
286    
287  do {  do {
288    
289          ## 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 299  do {
299          ## need to check if the title contains any anchor          ## need to check if the title contains any anchor
300          ## if so it needs to be removed          ## if so it needs to be removed
301          ## 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
302          $table[0] =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;          $table[0] = remove_anchor($table[0]);
303    
304          ## grab next slide title $table[2] (if there's a next slide)          ## grab next slide title $table[2] (if there's a next slide)
305          ## to be able to use in the 'next' navigation button          ## to be able to use in the 'next' navigation button
306          ## 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]
307          $next_slide_title = $table[2] if $table[2];          if ($table[2]) {
308          ## remove any anchor from the next slide title                  $next_title= remove_anchor($table[2]);
309          $next_slide_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;          }
310    
311          ## the current slide content is stored $table[1]          ## the current slide content is stored $table[1]
312          ## 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 316  do {
316    
317          ## extract slide Sub Title <h2>          ## extract slide Sub Title <h2>
318          undef $slideSubTitle;          undef $slideSubTitle;
319          if ($slideContent =~ s/<[hH]2[^>]*>([^<]+)<\/[hH]2[^>]*>//) {          if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) {
320                  $slideSubTitle=$1;                  $slideSubTitle=remove_anchor($1);
321          }          }
322    
323          ## 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 326  do {
326          ## generate the current slide          ## generate the current slide
327          ## parameters are:          ## parameters are:
328          ## 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
329          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$previous_slide_title,$next_slide_title);          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title);
330    
331          ## 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
332          $previous_slide_title="$table[0]";          $prev_title=remove_anchor($table[0]);
333  }  }
334  ## process the next slide  ## process the next slide
335  while (shift(@table));  while (shift(@table));
# Line 300  while (shift(@table)); Line 343  while (shift(@table));
343  ## and would not work on all platforms (ie would fail on Joe's laptop)  ## and would not work on all platforms (ie would fail on Joe's laptop)
344  &generateTOC;  &generateTOC;
345    
346    ## print additional files to pack
347    print STDOUT join("\n",@pack_additional) if ($pack);
348    
349  print STDOUT "--- Finished ---\n";  print STDERR "--- Finished ---\n";
350  exit 0;  exit 0;
351  ##  ##
352  ## end of the slidemaker main program  ## end of the slidemaker main program
# Line 315  sub openOverview Line 360  sub openOverview
360  {  {
361          ## open the file to write to          ## open the file to write to
362          open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!";          open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!";
363            push @pack_additional,"$_[0].html" if ($pack);
364    
365          ## the style sheet used in the table of content is          ## the style sheet used in the table of content is
366          $stylelink = "";          $stylelink = "";
# Line 331  sub openOverview Line 377  sub openOverview
377                  logoLink => $logoLink,                  logoLink => $logoLink,
378                  logoFile => $logoFile,                  logoFile => $logoFile,
379                  logoAlt => $logoAlt,                  logoAlt => $logoAlt,
380                    logoLink2 => $logoLink2,
381                    logoFile2 => $logoFile2,
382                    logoAlt2 => $logoAlt2,
383    
384                  talkTitle => $talkTitle,                  talkTitle => $talkTitle,
385                  talkSubTitle => $talkSubTitle,                  talkSubTitle => $talkSubTitle,
# Line 340  sub openOverview Line 389  sub openOverview
389                  author => $author,                  author => $author,
390                  authorUrl => $authorUrl,                  authorUrl => $authorUrl,
391                  author2 => $author2,                  author2 => $author2,
392                  authorUrl2 => $authorUrl2,                  author2Url => $author2Url,
393    
394                  date => $date,                  date => $date,
395    
396                  toc => $loc_toc,                  toc_title => $loc_toc,
397                    template_dir => "$template/",
398          );          );
399    
400  }  }
# Line 360  sub closeOverview Line 410  sub closeOverview
410          $overview_data{slide_html} = make_progress_bar(0,$total);          $overview_data{slide_html} = make_progress_bar(0,$total);
411          $overview_data{toc_entries} = [ @toc_entries ];          $overview_data{toc_entries} = [ @toc_entries ];
412    
         print "---",$#toc_entries;  
         use Data::Dumper;  
         print Dumper([ @toc_entries ]);  
   
413          my $page= new Text::FastTemplate key => 'overview';          my $page= new Text::FastTemplate key => 'overview';
414            $page_data{template_dir}='' if ($pack);
415          print FOO $page->output( \%overview_data );          print FOO $page->output( \%overview_data );
416    
417          close(FOO);          close(FOO);
# Line 381  sub addTitle Line 428  sub addTitle
428          my ($title,$subtitle,$nr) = @_;          my ($title,$subtitle,$nr) = @_;
429          $title =~ s/\r//ig;      # remove the windows CR+LF          $title =~ s/\r//ig;      # remove the windows CR+LF
430          $title =~ s/<[^>]+>//g;          $title =~ s/<[^>]+>//g;
431            $subtitle =~ s/<[^>]+>//g;
432    
433          if (! $title) {          if (! $title) {
434                  return 1;                  return 1;
# Line 391  sub addTitle Line 439  sub addTitle
439          if ($nr % $toc_on_page == 0) {          if ($nr % $toc_on_page == 0) {
440                  my $toc_nr=int($nr/$toc_on_page);                  my $toc_nr=int($nr/$toc_on_page);
441    
442                  %item = (                  $item = {
443                          pre_html => $pre_ul,                          pre_html => $pre_ul,
444                          accesskey => " ",       # space                          accesskey => " ",       # space
445                          href => "index-toc$toc_nr.html",                          href => "index-toc$toc_nr.html",
446                          title => "...",                          title => "...",
447                          post_html => $post_ul,                          post_html => $post_ul,
448                          more => 1,      # use style for more pages link (...)                          more => 1,      # use style for more pages link (...)
449                  )                  };
450  #               push @toc_entries, %item;                  push @toc_entries, $item;
451    
452                  &closeOverview;                  &closeOverview;
453                    undef @toc_entries;
454                  &openOverview("$overview-toc$toc_nr");                  &openOverview("$overview-toc$toc_nr");
455                  $last_toc_title='';                  $last_toc_title='';
456          }          }
457    
458          $pre_ul=$post_ul='';          $pre_ul=$post_ul='';
459          if ($last_toc_title eq $title) {          if ($last_toc_title eq $title && $subtitle) {
460                  $title = $subtitle;                  $title = $subtitle;
461                  $pre_ul='<ul>';                  $pre_ul='<ul>';
462                  $post_ul='</ul>';                  $post_ul='</ul>';
# Line 429  sub addTitle Line 478  sub addTitle
478                  };                  };
479                  push @toc_entries,$item;                  push @toc_entries,$item;
480          } else {          } else {
481                  %item = (                  $item = {
482                          pre_html => $pre_ul,                          pre_html => $pre_ul,
483                          tabindex => "$nr",                          tabindex => "$nr",
484                          href => "slide$nr.html",                          href => "slide$nr.html",
485                          title => $title,                          title => $title,
486                          post_html => $post_ul,                          post_html => $post_ul,
487                  )                  };
488  #               push @toc_entries,\%item;                  push @toc_entries,$item;
489          }          }
490  }  }
491  ##  ##
# Line 451  sub createSlide Line 500  sub createSlide
500          # parameters are respectively the slide title, its content,          # parameters are respectively the slide title, its content,
501          # its number, the next slide title and the previous slide title          # its number, the next slide title and the previous slide title
502    
503          my ($title,$subtitle,$content,$nr,$next_title,$prev_title) = @_;          my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_;
504    
505          if (! $title) {          if (! $title) {
506                  return 1;                  return 1;
# Line 477  sub createSlide Line 526  sub createSlide
526          $content =~ s/<\/body>//i; # remove if any          $content =~ s/<\/body>//i; # remove if any
527          $content =~ s/<\/html>//i; # remove if any          $content =~ s/<\/html>//i; # remove if any
528    
529          $status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle;          $status = sprintf "Slide %2d: %s %s", $nr, $title, $subtitle;
530          $status =~ s/<[^>]+>//g;          $status =~ s/<[^>]+>//g;
531          print STDOUT $status;          $status =~ s/[\n\r]+/ /g;
532            print STDERR "$status\n";
533    
534          &verify_html($content);    # check the html          &verify_html($content);         # check the html
535            &check_tags($content);          # check open and closed tags
536    
537          ## write to the slide          ## write to the slide
538          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";
539            push @pack_additional,"slide$nr.html" if ($pack);
540    
541          my $toclink = "[ <a href=\"$overview\.html\" title=\"Contents\">Contents</a> ]";          my $toc_link = "$overview\.html";
542    
543          ## initialization of the navigation links          ## initialization of the navigation links
544          my $nextlink = "";          my $next_link = "";
545          my $prevlink = "";          my $prev_link = "";
546    
547          if ($nr>1) {          if ($nr>1) {
548                  $prevlink = "<a href=\"slide".($nr-1).".html\" title=\"Previous\">&lt;&lt;</a>";                  $prev_link = "slide".($nr-1).".html";
549  #       } else {  #       } else {
550  #       ## 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
551  #               $prevlink = "<a href=\"$overview\.html\" title=\"Previous\">&lt;&lt;</a>";  #               $prev_link = "$overview\.html";
552          }          }
553    
554          if ($nr != $total) {          if ($nr != $total) {
555                  $nextlink = "<a href=\"slide".($nr+1).".html\" title=\"Next\">&gt;&gt;</a>";                  $next_link = "slide".($nr+1).".html";
556          }          }
557    
558          $stylelink = "";          $stylelink = "";
559          # here is the standard style sheet          # here is the standard style sheet
560          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";
561    
         $title_html="<h1>$title</h1>";  
         if ($subtitle) {  
                 $title_html.="<h2>$subtitle</h2>";  
         }  
   
562          my $slide_html=make_progress_bar($nr,$total);          my $slide_html=make_progress_bar($nr,$total);
563    
564            # undefine body if no content is found (so that template can show
565            # only title and sub-title
566            if ($content !~ m/\S/g) {
567                    undef $content;
568            }
569    
570          %page_data = (          %page_data = (
571                  doctype => $doctype,                  doctype => $doctype,
572                  talkTitle => $talkTitle,                  talkTitle => $talkTitle,
573                  title => $title,                  title => $title,
574                    subtitle => $subtitle,
575                  http_equiv => $http_equiv,                  http_equiv => $http_equiv,
576                  stylelink => $stylelink,                  stylelink => $stylelink,
577                  body => $body,                  body => $body,
578    
579                  logo_html => $logo_html,                  logoLink => $logoLink,
580                  title_html => $title_html,                  logoFile => $logoFile,
581                    logoAlt => $logoAlt,
582                    logoLink2 => $logoLink2,
583                    logoFile2 => $logoFile2,
584                    logoAlt2 => $logoAlt2,
585    
586    
587                  content_hight => $content_hight,                  content_hight => $content_hight,
588                  content => $content,                  content => $content,
589    
590                    prev_link => $prev_link,
591                    toc_link => $toc_link,
592                    next_link => $next_link,
593                    prev_title => $prev_title,
594                    toc_title => $loc_toc,
595                    next_title => $next_title,
596    
597                  author => $author,                  author => $author,
598                  date_html => $date_html,                  authorUrl => $authorUrl,
599                  prevlink => $prevlink,                  author2 => $author2,
600                  toclink => $toclink,                  author2Url => $author2Url,
601                  nextlink => $nextlink,  
602                    date => $date,
603    
604                  slide_html => $slide_html,                  slide_html => $slide_html,
                 author2 => $author2  
605    
606                    template_dir => "$template/",
607          );          );
608    
609          my $page= new Text::FastTemplate key => 'slide';          my $page;
610          print SLIDE $page->output( \%page_data );          if ($content) {
611                    $page= new Text::FastTemplate key => 'slide';
612            } else {
613                    $page= new Text::FastTemplate key => 'title';
614            }
615    
616            if ($pack) {
617                    $page_data{template_dir}='';
618                    print SLIDE extract_files($page->output( \%page_data ));
619            } else {
620                    print SLIDE $page->output( \%page_data );
621            }
622    
623          close(SLIDE);          close(SLIDE);
624          return 0;          return 0;
# Line 586  sub verify_html { Line 667  sub verify_html {
667    
668      if ($_[0] =~ /<img([^>]*)>/im) {      if ($_[0] =~ /<img([^>]*)>/im) {
669          if (!($1 =~ /ALT=/im)) {          if (!($1 =~ /ALT=/im)) {
670              print STDOUT "WARNING: <IMG> without ALT\n";              print STDERR "WARNING: <IMG> without ALT\n";
671              print STDOUT "         <IMG$1>\n" ;              print STDERR "         <IMG$1>\n" ;
672          }          }
673      }      }
674  }  }
# Line 596  sub verify_html { Line 677  sub verify_html {
677  # clean the html of the slide  # clean the html of the slide
678  # remove all <div class="comment">blabla</div>  # remove all <div class="comment">blabla</div>
679  sub clean_html {  sub clean_html {
680      $_[0] =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;          my $tmp=$_[0];
681      return $_[0];          $tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;
682            $tmp =~ s,</*font[^>]+>,,ig;
683            return $tmp;
684  }  }
685    
686  ##############################################################################  ##############################################################################
# Line 622  sub make_progress_bar { Line 705  sub make_progress_bar {
705          my $pcnt_done=int($nr*100/$total);          my $pcnt_done=int($nr*100/$total);
706          my $pcnt_left=100-$pcnt_done;          my $pcnt_left=100-$pcnt_done;
707    
708          if ($progress_bar) {          if ($progress_bar && uc($progress_bar) ne "NO") {
709                  my $l=$r="&nbsp;";                  my $l=$r="&nbsp;";
710                  my $t="$nr of $total";                  my $t="$nr of $total";
711                  if ($pcnt_done > 50) {                  if ($pcnt_done > 50) {
# Line 630  sub make_progress_bar { Line 713  sub make_progress_bar {
713                  } else {                  } else {
714                          $r=$t;                          $r=$t;
715                  }                  }
716                  $html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr><td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td><td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td></tr></table>';                  $html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr>';
717                    if ($pcnt_done != 0) {
718                            $html.='<td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td>';
719                    }
720                    if ($pcnt_left != 0) {
721                            $html.='<td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td>';
722                    }
723                    $html.='</tr></table>';
724          } else {          } else {
725                  $html="$loc_slide $nr $loc_of $total";                  $html="$loc_slide $nr $loc_of $total";
726          }          }
# Line 638  sub make_progress_bar { Line 728  sub make_progress_bar {
728          return $html;          return $html;
729  }  }
730    
731    ##############################################################################
732    # remove anchors <a href...> from html (for titles)
733    sub remove_anchor {
734            my $tmp = $_[0];
735            $tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
736            return $tmp;
737    }
738    
739    ##############################################################################
740    # extract files referenced in presentation and remove dirs from slide html
741    
742    sub extract_files {
743            my $tmp = $slide = $_[0];
744            while ($tmp =~ s/href="*([^"\s]+)"*//ism ||
745                    $tmp =~ s/src="*([^"\s]+)"*//ism) {
746                    if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {
747                            my $file=$1;
748                            push @pack_additional,$file;
749                            if ($file =~ m,^(.+)/([^/]+),) {
750                                    my ($d,$f) = ($1,$2);
751                                    $slide =~ s,${d}/${f},${f},g;
752                            }
753                    }
754            }
755            return $slide;
756    }
757    
758    ##############################################################################
759    # check tags in slide
760    # based on code from hindent 1.1.2 by Paul Balyoz <pab@domtools.com>
761    
762    sub init_nesttag {
763    # Tags that require their own end tag <TAG>...</TAG> we will nest them
764    # properly:   (WARNING, you must use lower-case here)
765    # All other tags (not on this list) will be ignored for indenting purposes.
766    return (
767            'html' => 1,
768            'head' => 1,
769            'body' => 1,
770            'title' => 1,
771    
772            'a' => 1,
773    
774            'table' => 1,
775            'tr' => 1,
776            'th' => 1,
777            'td' => 1,
778    
779            'form' => 1,
780            'select' => 1,
781            'textarea' => 1,
782    
783    #       'p' => 1,      Don't do this one because many people use <P> but not </P>
784            'ul' => 1,
785            'ol' => 1,
786            'dl' => 1,
787            'blockquote' => 1,
788            'center' => 1,
789            'div' => 1,
790    
791            'font' => 1,
792            'pre' => 1,
793            'tt' => 1,
794            'i' => 1,
795            'b' => 1,
796            'u' => 1,
797            'strike' => 1,
798            'big' => 1,
799            'small' => 1,
800            'sub' => 1,
801            'sup' => 1,
802            'em' => 1,
803            'strong' => 1,
804            'dfn' => 1,
805            'code' => 1,
806            'samp' => 1,
807            'kbd' => 1,
808            'var' => 1,
809            'cite' => 1,
810    
811            'h1' => 1,
812            'h2' => 1,
813            'h3' => 1,
814            'h4' => 1,
815            'h5' => 1,
816            'h6' => 1,
817    
818            'applet' => 1,
819    
820            'map' => 1,
821    
822            'frameset' => 1,
823            'noframes' => 1,
824    );
825    }
826    
827    sub check_tags {
828            my $tmp = $_[0];
829            my @tagstack;
830            my $level=0;
831    
832            while ($tmp =~ /<(.*?)>/gsm) {
833                    my $tag=$1; $tag=~s/\s.+//g;
834                    # if regular tag, push it on stack; if end-tag, pop it off stack.
835                    # but don't do any of this if it's not a special "nesting" tag!
836                    if ($tag !~ m,^/,) {
837                            if ($nesttag{lc($tag)}) {
838                                    push @tagstack,$tag;
839                                    $level++;               # remember how much for later
840                            }
841                    } else {
842                            $tag =~ s,^/,,;         # convert this end-tag to a begin-tag
843                            $tag = lc($tag);
844                            if ($nesttag{lc($tag)}) {
845                                    # throw away tags until we find a match
846                                    if ($#tagstack > -1) {
847                                            while ($tag ne lc(pop @tagstack)) {
848                                                    $level--;       # we threw away extra tags
849                                                    last if $#tagstack <= 0;
850                                            }
851                                            $level--;       # we threw away extra tags
852                                            if ($level < 0) {
853                                                    print STDERR "WARNING: more end than begin tags around </$tag> !\n";
854                                            }
855                                    }
856                            }
857                    }
858            }
859    
860            if ($level > 0) {
861                    print STDERR "WARNING: level=$level, ", $#tagstack+1," tags left on stack after done parsing!  Specifically:\n<",join("> <",@tagstack),">\n";
862            }
863    
864    }
865    

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

  ViewVC Help
Powered by ViewVC 1.1.26