/[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.14 by dpavlin, Tue May 8 23:03:03 2001 UTC revision 1.21 by dpavlin, Tue Sep 18 12:50:15 2001 UTC
# Line 135  my %overview_data; Line 135  my %overview_data;
135    
136  my $pack = 0;  my $pack = 0;
137  my @pack_additional;    # additional files to pack (pictures, logos...)  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;
                 # of the slidemaker tool  
                 #when the parameters were in Makefile or make.bat  
144    
145  # read parameters from infos.txt and put them in @PARAM  ##############################################################################
146  if (open(INFOS, $infos)) {  sub parse_infos {
147          print STDERR "--- Reading parameters file $infos ---\n";          my @file=@_;
         local(@file);  
         @file = <INFOS>;  
 #       @PARAM = ();    # don't reset param, use @ARGV  
148          do {          do {
149                  if ($file[0] && $file[0] =~ /^[^#\n\r]/) {                  if ($file[0] && $file[0] =~ /^[^#\n\r]/) {
150                          $file[0] =~ s/\n//;    # remove UNIX \n                          $file[0] =~ s/\n//;    # remove UNIX \n
151                          $file[0] =~ s/\r//;    # remove WINDOWS \r                              $file[0] =~ s/\r//;    # remove WINDOWS \r    
152                          $file[0] =~ s/ *= */=/;                          my ($var,$value) = split(/ *= */,$file[0],2);
153                          push @PARAM,$file[0];                          $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";                          print STDERR "$file[0]\n";
161                  }                  }
162          } while (shift(@file));          } while (shift(@file));
163  }  }
164  ## @PARAM is now a table with the user preferences for his presentation  ##############################################################################
165    
166  ## process arguments  parse_infos(@ARGV);     # backward compatibility and for pack
167  ## each preset variable is now re-attributed using the user preferences  
168  foreach (@PARAM) {  # read parameters from infos.txt and put them in @PARAM
169          my ($var,$value) = split(/ *= */,$_,2);  if (open(INFOS, $infos)) {
170          $value=~s/'/\\'/g;          print STDERR "--- Reading parameters file $infos ---\n";
171          $cmd="\$$var = \'$value\';";          @file = <INFOS>;
172          if ($value) {          parse_infos(@file);
173                  eval($cmd) || die "problem with eval of: $cmd";  }
174          } else {  
175                  die "no value defined for $var";  # try to read local infos.txt for template
176          }  if (-f "$template/$infos" && open(INFOS,"$template/$infos")) {
177            print STDERR "--- Reading template parameters file $template/$infos ---\n";
178            @file = <INFOS>;
179            parse_infos(@file);
180            close(INFOS);
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 381  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 402  sub closeOverview Line 411  sub closeOverview
411          $overview_data{toc_entries} = [ @toc_entries ];          $overview_data{toc_entries} = [ @toc_entries ];
412    
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 418  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 515  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 STDERR $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: $!";
# Line 578  sub createSlide Line 591  sub createSlide
591                  toc_link => $toc_link,                  toc_link => $toc_link,
592                  next_link => $next_link,                  next_link => $next_link,
593                  prev_title => $prev_title,                  prev_title => $prev_title,
594                    toc_title => $loc_toc,
595                  next_title => $next_title,                  next_title => $next_title,
596    
597                  author => $author,                  author => $author,
598                  authorUrl => $authorUrl,                  authorUrl => $authorUrl,
599                  author2 => $author2,                  author2 => $author2,
600                  authorUrl2 => $authorUrl2,                  author2Url => $author2Url,
601    
602                  date => $date,                  date => $date,
603    
604                  slide_html => $slide_html,                  slide_html => $slide_html,
605    
606                    template_dir => "$template/",
607          );          );
608    
609          my $page;          my $page;
# Line 597  sub createSlide Line 612  sub createSlide
612          } else {          } else {
613                  $page= new Text::FastTemplate key => 'title';                  $page= new Text::FastTemplate key => 'title';
614          }          }
615          print SLIDE $page->output( \%page_data );  
616          extract_files($page->output( \%page_data )) if ($pack);          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;
625  }  }
# Line 684  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 692  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 709  sub remove_anchor { Line 737  sub remove_anchor {
737  }  }
738    
739  ##############################################################################  ##############################################################################
740  # extract files referenced in presentation  # extract files referenced in presentation and remove dirs from slide html
741    
742  sub extract_files {  sub extract_files {
743          my $tmp = $_[0];          my $tmp = $slide = $_[0];
744          while ($tmp =~ s/<a\s+href="*([^"\s]+)"*//ism ||          while ($tmp =~ s/href="*([^"\s]+)"*//ism ||
745                  $tmp =~ s/<img\s+src="*([^"\s]+)"*//ism) {                  $tmp =~ s/src="*([^"\s]+)"*//ism) {
746                  if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {                  if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {
747                          push @pack_additional,$1;                          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.14  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.26