/[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.17 by dpavlin, Fri May 11 22:04:54 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
# Line 388  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    
# Line 427  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 528  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 593  sub createSlide Line 596  sub createSlide
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    
# Line 608  sub createSlide Line 611  sub createSlide
611          } else {          } else {
612                  $page= new Text::FastTemplate key => 'title';                  $page= new Text::FastTemplate key => 'title';
613          }          }
614          $page_data{template_dir}='' if ($pack);  
615          print SLIDE $page->output( \%page_data );          if ($pack) {
616          extract_files($page->output( \%page_data )) if ($pack);                  $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 728  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/href="*([^"\s]+)"*//ism ||          while ($tmp =~ s/href="*([^"\s]+)"*//ism ||
744                  $tmp =~ 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.17  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.26