/[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.20 by dpavlin, Tue Sep 18 12:44: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 519  sub createSlide Line 530  sub createSlide
530          $status =~ s/<[^>]+>//g;          $status =~ s/<[^>]+>//g;
531          print STDERR $status;          print STDERR $status;
532    
533          &verify_html($content);    # check the html          &verify_html($content);         # check the html
534            &check_tags($content);          # check open and closed tags
535    
536          ## write to the slide          ## write to the slide
537          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 590  sub createSlide
590                  toc_link => $toc_link,                  toc_link => $toc_link,
591                  next_link => $next_link,                  next_link => $next_link,
592                  prev_title => $prev_title,                  prev_title => $prev_title,
593                    toc_title => $loc_toc,
594                  next_title => $next_title,                  next_title => $next_title,
595    
596                  author => $author,                  author => $author,
597                  authorUrl => $authorUrl,                  authorUrl => $authorUrl,
598                  author2 => $author2,                  author2 => $author2,
599                  authorUrl2 => $authorUrl2,                  author2Url => $author2Url,
600    
601                  date => $date,                  date => $date,
602    
603                  slide_html => $slide_html,                  slide_html => $slide_html,
604    
605                    template_dir => "$template/",
606          );          );
607    
608          my $page;          my $page;
# Line 597  sub createSlide Line 611  sub createSlide
611          } else {          } else {
612                  $page= new Text::FastTemplate key => 'title';                  $page= new Text::FastTemplate key => 'title';
613          }          }
614          print SLIDE $page->output( \%page_data );  
615          extract_files($page->output( \%page_data )) if ($pack);          if ($pack) {
616                    $page_data{template_dir}='';
617                    print SLIDE extract_files($page->output( \%page_data ));
618            } else {
619                    print SLIDE $page->output( \%page_data );
620            }
621    
622          close(SLIDE);          close(SLIDE);
623          return 0;          return 0;
624  }  }
# Line 684  sub make_progress_bar { Line 704  sub make_progress_bar {
704          my $pcnt_done=int($nr*100/$total);          my $pcnt_done=int($nr*100/$total);
705          my $pcnt_left=100-$pcnt_done;          my $pcnt_left=100-$pcnt_done;
706    
707          if ($progress_bar) {          if ($progress_bar && uc($progress_bar) ne "NO") {
708                  my $l=$r="&nbsp;";                  my $l=$r="&nbsp;";
709                  my $t="$nr of $total";                  my $t="$nr of $total";
710                  if ($pcnt_done > 50) {                  if ($pcnt_done > 50) {
# Line 692  sub make_progress_bar { Line 712  sub make_progress_bar {
712                  } else {                  } else {
713                          $r=$t;                          $r=$t;
714                  }                  }
715                  $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>';
716                    if ($pcnt_done != 0) {
717                            $html.='<td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td>';
718                    }
719                    if ($pcnt_left != 0) {
720                            $html.='<td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td>';
721                    }
722                    $html.='</tr></table>';
723          } else {          } else {
724                  $html="$loc_slide $nr $loc_of $total";                  $html="$loc_slide $nr $loc_of $total";
725          }          }
# Line 709  sub remove_anchor { Line 736  sub remove_anchor {
736  }  }
737    
738  ##############################################################################  ##############################################################################
739  # extract files referenced in presentation  # extract files referenced in presentation and remove dirs from slide html
740    
741  sub extract_files {  sub extract_files {
742          my $tmp = $_[0];          my $tmp = $slide = $_[0];
743          while ($tmp =~ s/<a\s+href="*([^"\s]+)"*//ism ||          while ($tmp =~ s/href="*([^"\s]+)"*//ism ||
744                  $tmp =~ s/<img\s+src="*([^"\s]+)"*//ism) {                  $tmp =~ s/src="*([^"\s]+)"*//ism) {
745                  if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {                  if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {
746                          push @pack_additional,$1;                          my $file=$1;
747                            push @pack_additional,$file;
748                            if ($file =~ m,^(.+)/([^/]+),) {
749                                    my ($d,$f) = ($1,$2);
750                                    $slide =~ s,${d}/${f},${f},g;
751                            }
752                    }
753            }
754            return $slide;
755    }
756    
757    ##############################################################################
758    # check tags in slide
759    # based on code from hindent 1.1.2 by Paul Balyoz <pab@domtools.com>
760    
761    sub init_nesttag {
762    # Tags that require their own end tag <TAG>...</TAG> we will nest them
763    # properly:   (WARNING, you must use lower-case here)
764    # All other tags (not on this list) will be ignored for indenting purposes.
765    return (
766            'html' => 1,
767            'head' => 1,
768            'body' => 1,
769            'title' => 1,
770    
771            'a' => 1,
772    
773            'table' => 1,
774            'tr' => 1,
775            'th' => 1,
776            'td' => 1,
777    
778            'form' => 1,
779            'select' => 1,
780            'textarea' => 1,
781    
782    #       'p' => 1,      Don't do this one because many people use <P> but not </P>
783            'ul' => 1,
784            'ol' => 1,
785            'dl' => 1,
786            'blockquote' => 1,
787            'center' => 1,
788            'div' => 1,
789    
790            'font' => 1,
791            'pre' => 1,
792            'tt' => 1,
793            'i' => 1,
794            'b' => 1,
795            'u' => 1,
796            'strike' => 1,
797            'big' => 1,
798            'small' => 1,
799            'sub' => 1,
800            'sup' => 1,
801            'em' => 1,
802            'strong' => 1,
803            'dfn' => 1,
804            'code' => 1,
805            'samp' => 1,
806            'kbd' => 1,
807            'var' => 1,
808            'cite' => 1,
809    
810            'h1' => 1,
811            'h2' => 1,
812            'h3' => 1,
813            'h4' => 1,
814            'h5' => 1,
815            'h6' => 1,
816    
817            'applet' => 1,
818    
819            'map' => 1,
820    
821            'frameset' => 1,
822            'noframes' => 1,
823    );
824    }
825    
826    sub check_tags {
827            my $tmp = $_[0];
828            my @tagstack;
829            my $level=0;
830    
831            while ($tmp =~ /<(.*?)>/gsm) {
832                    my $tag=$1; $tag=~s/\s.+//g;
833                    # if regular tag, push it on stack; if end-tag, pop it off stack.
834                    # but don't do any of this if it's not a special "nesting" tag!
835                    if ($tag !~ m,^/,) {
836                            if ($nesttag{lc($tag)}) {
837                                    push @tagstack,$tag;
838                                    $level++;               # remember how much for later
839                            }
840                    } else {
841                            $tag =~ s,^/,,;         # convert this end-tag to a begin-tag
842                            $tag = lc($tag);
843                            if ($nesttag{lc($tag)}) {
844                                    # throw away tags until we find a match
845                                    if ($#tagstack > -1) {
846                                            while ($tag ne lc(pop @tagstack)) {
847                                                    $level--;       # we threw away extra tags
848                                                    last if $#tagstack <= 0;
849                                            }
850                                            $level--;       # we threw away extra tags
851                                            if ($level < 0) {
852                                                    print STDERR "WARNING: more end than begin tags around </$tag> !\n";
853                                            }
854                                    }
855                            }
856                  }                  }
857          }          }
858    
859            if ($level > 0) {
860                    print STDERR "WARNING: level=$level, ", $#tagstack+1," tags left on stack after done parsing!  Specifically:\n<",join("> <",@tagstack),">\n";
861            }
862    
863  }  }
864    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.26