/[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.1.1.1 by dpavlin, Tue Apr 17 08:35:10 2001 UTC revision 1.20 by dpavlin, Tue Sep 18 12:44:15 2001 UTC
# Line 1  Line 1 
1  #!/usr/local/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 42  Line 42 
42  #  #
43  # Sami Lempinen - lempinen@iki.fi  # Sami Lempinen - lempinen@iki.fi
44  # http://www.snowman.sgic.fi/ssl/xslies/  # http://www.snowman.sgic.fi/ssl/xslies/
45    #
46    # Text::FastTemplate:
47    # Robert Lehr - bozzio@the-lehrs.com
48    
49  make_dotgif("pero.gif");  use Text::FastTemplate;
50    
51  ##############################################################################  ##############################################################################
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 101  $talkTitle = 'Talk'; Line 107  $talkTitle = 'Talk';
107  ## standard style sheets  ## standard style sheets
108  $cssStandard = '../PLies/css/default.css';  $cssStandard = '../PLies/css/default.css';
109    
110    ## template name
111    $template = '../PLies/default';
112    
113  ## default charset use in meta tag http-equiv (undef to skip)  ## default charset use in meta tag http-equiv (undef to skip)
114  #$charset = 'ISO-8859-1';  #$charset = 'ISO-8859-1';
115    
# Line 113  $toc_on_page = 10; Line 122  $toc_on_page = 10;
122  ## use progress bar  ## use progress bar
123  $progress_bar = 1;  $progress_bar = 1;
124    
125    ## content hight for each slide
126    $content_hight = "70%";
127    
128  ## end of default values for the presentation  ## end of default values for the presentation
129  ##############################################################################  ##############################################################################
130    
131  ## globals  ## globals
 my $logo_html;  
 my $date_html;  
132  my $last_toc_title;  my $last_toc_title;
133    my %page_data;
134    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      @_ = split(/ *= */,$_,2);          @file = <INFOS>;
179      $cmd="\$$_[0] = \'$_[1]\';";          parse_infos(@file);
180      if (length $_[1] != 0) {          close(INFOS);
         eval($cmd);  
     }  
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 166  if ($charset) { Line 191  if ($charset) {
191  }  }
192    
193    
 ## build an html string for the author variable  
 ## containing the presentation author name linked to  
 ## a location of his choice  
 if ($authorUrl) {  
     $author = "<a href=\"$authorUrl\">$author</a>";  
 }  
   
 ## same string is built if there is a second author for the presentation  
 if ($author2Url) {  
     $author2 = "<br><a href=\"$author2Url\">$author2</a>";  
 } elsif ($author2) {  
     $author2 = "<br>$author2";  
 }  
   
194  ##############################################################################  ##############################################################################
195  ## read the raw html presentation  ## read the raw html presentation
196  ##  ##
# Line 187  if ($author2Url) { Line 198  if ($author2Url) {
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 199  $/ = $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 218  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 227  print STDOUT "\n--- Processing $total sl Line 244  print STDOUT "\n--- Processing $total sl
244  ## start the slide count so we can number them  ## start the slide count so we can number them
245  $slideCount = 1;  $slideCount = 1;
246    
247    ## pre-load template slides using $template dir
248    Text::FastTemplate->defaults(
249                    path => [ $template ]
250            );
251    
252    Text::FastTemplate->preload( [
253                    { file => 'slide.html', key => 'slide' },
254                    { 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 248  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 265  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 275  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 292  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 307  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 = "";
367          ## here is the standard style sheet          ## here is the standard style sheet
368          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\" media=\"screen\">";          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\" media=\"screen\">";
369    
370          if ($logoFile) {          %overview_data = (
371                  $logo_html="<a href=\"$logoLink\"><img src=\"$logoFile\" alt=\"$logoAlt\" border=\"0\"></a>";                  doctype => $doctype,
372          }                  title => $title,
373                    http_equiv => $http_equiv,
374          if ($logoFile2) {                  stylelink => $stylelink,
375                  $logo_html.="<a href=\"$logoLink2\"><img src=\"$logoFile2\" alt=\"$logoAlt2\" border=\"0\"></a>";                  body => $body,
376          }  
377                    logoLink => $logoLink,
378          $title_html="<h1>$talkTitle</h1>";                  logoFile => $logoFile,
379          if (length $talkSubTitle != 0) {                  logoAlt => $logoAlt,
380                  $title_html.="<h2>$talkSubTitle</h2>";                  logoLink2 => $logoLink2,
381          }                  logoFile2 => $logoFile2,
382                    logoAlt2 => $logoAlt2,
383          if (length $date != 0) {  
384                  $date_html="($date)";                  talkTitle => $talkTitle,
385          }                  talkSubTitle => $talkSubTitle,
386    
387          print FOO <<END;                  content_hight => $content_hight,
388  $doctype  
389      <head>                  author => $author,
390              <title>$talkTitle - $loc_toc</title>                  authorUrl => $authorUrl,
391              $http_equiv                  author2 => $author2,
392              $stylelink                  author2Url => $author2Url,
393       </head>  
394       $body                  date => $date,
395          <table height="100%" width="100%">  
396              <tr>                  toc_title => $loc_toc,
397                  <td class="header-first" valign="top">                  template_dir => "$template/",
398                      <table width="100%" border="0">          );
                         <tr>  
                             <td class="cell-logo">$logo_html</td>  
                             <td class="cell-heading">$title_html</td>  
                         </tr>  
                     </table>  
                 </td>  
             </tr>  
             <tr>  
                 <td height="80%" class="body" valign="top">  
                     <div class="body">  
                         <h3>$loc_toc</h3>  
                         <ul>  
 END  
399    
400  }  }
401  ##  ##
# Line 366  END Line 407  END
407    
408  sub closeOverview  sub closeOverview
409  {  {
410          my $slide_html=make_progress_bar(0,$total);          $overview_data{slide_html} = make_progress_bar(0,$total);
411          print FOO <<END;          $overview_data{toc_entries} = [ @toc_entries ];
412                          </ul>  
413                      </div>          my $page= new Text::FastTemplate key => 'overview';
414                  </td>          $page_data{template_dir}='' if ($pack);
415              </tr>          print FOO $page->output( \%overview_data );
             <tr>  
                 <td class="footer">  
                     <table border="0" width="100%">  
                         <tr>  
                             <td width="33%" class="footer-info">  
                                 <p>  
                                     <i>$talkTitle</i>  
                                     <br>$author $date_html  
                                 </p>  
                             </td><td width="33%" class="footer-nav">  
                                 <table border="0">  
                                     <tr>  
                                         <td>  
         [ <a href="slide1.html">On with the show</a> ]  
                                         </td>  
                                     </tr>  
                                 </table>  
                             </td><td width="33%" class="footer-count">  
                                 $slide_html  
                                 $author2</td>  
                         </tr>  
                     </table>  
                 </td>  
             </tr>  
         </table>  
     </body>  
 </html>  
 END  
416    
417          close(FOO);          close(FOO);
418  }  }
# Line 415  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 425  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                  print FOO <<END;                  $item = {
443  <br><small><a accesskey=" " tabindex=" " href="index-toc$toc_nr.html">...</a></small></br>                          pre_html => $pre_ul,
444  END                          accesskey => " ",       # space
445                            href => "index-toc$toc_nr.html",
446                            title => "...",
447                            post_html => $post_ul,
448                            more => 1,      # use style for more pages link (...)
449                    };
450                    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          $ul1=$ul2='';          $pre_ul=$post_ul='';
459          if ($last_toc_title eq $title) {          if ($last_toc_title eq $title && $subtitle) {
460                  $title = $subtitle;                  $title = $subtitle;
461                  $ul1='<ul>';                  $pre_ul='<ul>';
462                  $ul2='</ul>';                  $post_ul='</ul>';
463          } else {          } else {
464                  $last_toc_title=$title;                  $last_toc_title=$title;
465          }          }
# Line 445  END Line 467  END
467          # add accesskey for first 9 slides (`1' - `9') or just for first          # add accesskey for first 9 slides (`1' - `9') or just for first
468          # TOC page, and tabindex for all slides          # TOC page, and tabindex for all slides
469          if ($nr < 10 && $nr < $toc_on_page) {          if ($nr < 10 && $nr < $toc_on_page) {
470                  print FOO <<END;                  $item = {
471  $ul1<li><a accesskey="$nr" tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2                          pre_html => $pre_ul,
472  END                          accesskey => "$nr",
473                            tabindex => "$nr",
474                            href => "slide$nr.html",
475                            title => $title,
476                            post_html => $post_ul,
477                            more => 0,
478                    };
479                    push @toc_entries,$item;
480          } else {          } else {
481                  print FOO <<END;                  $item = {
482  $ul1<li><a tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2                          pre_html => $pre_ul,
483  END                          tabindex => "$nr",
484                            href => "slide$nr.html",
485                            title => $title,
486                            post_html => $post_ul,
487                    };
488                    push @toc_entries,$item;
489          }          }
490  }  }
491  ##  ##
# Line 466  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 494  sub createSlide Line 528  sub createSlide
528    
529          $status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle;          $status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle;
530          $status =~ s/<[^>]+>//g;          $status =~ s/<[^>]+>//g;
531          print STDOUT $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: $!";
538            push @pack_additional,"slide$nr.html" if ($pack);
539    
540          my $toclink = "[ <a href=\"$overview\.html\" title=\"Contents\">Contents</a> ]";          my $toc_link = "$overview\.html";
541    
542          ## initialization of the navigation links          ## initialization of the navigation links
543          my $nextlink = "";          my $next_link = "";
544          my $prevlink = "";          my $prev_link = "";
545    
546          if ($nr>1) {          if ($nr>1) {
547                  $prevlink = "<a href=\"slide".($nr-1).".html\" title=\"Previous\">&lt;&lt;</a>";                  $prev_link = "slide".($nr-1).".html";
548  #       } else {  #       } else {
549  #       ## 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
550  #               $prevlink = "<a href=\"$overview\.html\" title=\"Previous\">&lt;&lt;</a>";  #               $prev_link = "$overview\.html";
551          }          }
552    
553          if ($nr != $total) {          if ($nr != $total) {
554                  $nextlink = "<a href=\"slide".($nr+1).".html\" title=\"Next\">&gt;&gt;</a>";                  $next_link = "slide".($nr+1).".html";
555          }          }
556    
557          $stylelink = "";          $stylelink = "";
558          # here is the standard style sheet          # here is the standard style sheet
559          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";
560    
         $title_html="<h1>$title</h1>";  
         if ($subtitle) {  
                 $title_html.="<h2>$subtitle</h2>";  
         }  
   
561          my $slide_html=make_progress_bar($nr,$total);          my $slide_html=make_progress_bar($nr,$total);
562    
563          print SLIDE <<END;          # undefine body if no content is found (so that template can show
564  $doctype          # only title and sub-title
565      <head>          if ($content !~ m/\S/g) {
566              <title>$talkTitle - $title</title>                  undef $content;
567              $http_equiv          }
568              $stylelink  
569       </head>          %page_data = (
570       $body                  doctype => $doctype,
571          <table height="100%" width="100%">                  talkTitle => $talkTitle,
572              <tr>                  title => $title,
573                  <td class="header-first" valign="top">                  subtitle => $subtitle,
574                      <table width="100%" border="0">                  http_equiv => $http_equiv,
575                          <tr>                  stylelink => $stylelink,
576                              <td class="cell-logo">$logo_html</td>                  body => $body,
577                              <td class="cell-heading">$title_html</td>  
578                          </tr>                  logoLink => $logoLink,
579                      </table>                  logoFile => $logoFile,
580                  </td>                  logoAlt => $logoAlt,
581              </tr>                  logoLink2 => $logoLink2,
582              <tr>                  logoFile2 => $logoFile2,
583                  <td height="80%" class="body" valign="top">                  logoAlt2 => $logoAlt2,
584                      <div class="body">  
585  $content  
586                      </div>                  content_hight => $content_hight,
587                  </td>                  content => $content,
588              </tr>  
589              <tr>                  prev_link => $prev_link,
590                  <td class="footer">                  toc_link => $toc_link,
591                      <table border="0" width="100%">                  next_link => $next_link,
592                          <tr>                  prev_title => $prev_title,
593                              <td width="33%" class="footer-info">                  toc_title => $loc_toc,
594                                  <p>                  next_title => $next_title,
595                                      <i>$talkTitle</i>  
596                                      <br>$author $date_html                  author => $author,
597                                  </p>                  authorUrl => $authorUrl,
598                              </td><td width="33%" class="footer-nav">                  author2 => $author2,
599                                  <table border="0">                  author2Url => $author2Url,
600                                      <tr>  
601                                          <td>                  date => $date,
602  $prevlink  
603  $toclink                  slide_html => $slide_html,
604  $nextlink  
605                                          </td>                  template_dir => "$template/",
606                                      </tr>          );
607                                  </table>  
608                              </td><td width="33%" class="footer-count">          my $page;
609                                  $slide_html          if ($content) {
610                                  $author2</td>                  $page= new Text::FastTemplate key => 'slide';
611                          </tr>          } else {
612                      </table>                  $page= new Text::FastTemplate key => 'title';
613                  </td>          }
614              </tr>  
615          </table>          if ($pack) {
616      </body>                  $page_data{template_dir}='';
617  </html>                  print SLIDE extract_files($page->output( \%page_data ));
618  END          } else {
619                    print SLIDE $page->output( \%page_data );
620            }
621    
622          close(SLIDE);          close(SLIDE);
623          return 0;          return 0;
# Line 633  sub verify_html { Line 666  sub verify_html {
666    
667      if ($_[0] =~ /<img([^>]*)>/im) {      if ($_[0] =~ /<img([^>]*)>/im) {
668          if (!($1 =~ /ALT=/im)) {          if (!($1 =~ /ALT=/im)) {
669              print STDOUT "WARNING: <IMG> without ALT\n";              print STDERR "WARNING: <IMG> without ALT\n";
670              print STDOUT "         <IMG$1>\n" ;              print STDERR "         <IMG$1>\n" ;
671          }          }
672      }      }
673  }  }
# Line 643  sub verify_html { Line 676  sub verify_html {
676  # clean the html of the slide  # clean the html of the slide
677  # remove all <div class="comment">blabla</div>  # remove all <div class="comment">blabla</div>
678  sub clean_html {  sub clean_html {
679      $_[0] =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;          my $tmp=$_[0];
680      return $_[0];          $tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;
681            $tmp =~ s,</*font[^>]+>,,ig;
682            return $tmp;
683  }  }
684    
685  ##############################################################################  ##############################################################################
# Line 669  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 677  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="30%" 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 685  sub make_progress_bar { Line 727  sub make_progress_bar {
727          return $html;          return $html;
728  }  }
729    
730    ##############################################################################
731    # remove anchors <a href...> from html (for titles)
732    sub remove_anchor {
733            my $tmp = $_[0];
734            $tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
735            return $tmp;
736    }
737    
738    ##############################################################################
739    # extract files referenced in presentation and remove dirs from slide html
740    
741    sub extract_files {
742            my $tmp = $slide = $_[0];
743            while ($tmp =~ s/href="*([^"\s]+)"*//ism ||
744                    $tmp =~ s/src="*([^"\s]+)"*//ism) {
745                    if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {
746                            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.1.1.1  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.26