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

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.19

  ViewVC Help
Powered by ViewVC 1.1.26