/[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.11 by dpavlin, Tue May 8 07:51:54 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=1;
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  ##############################################################################  ##############################################################################
137  ## reading user input from $infos  ## reading user input from $infos
# Line 130  my $last_toc_title; Line 142  my $last_toc_title;
142    
143  # read parameters from infos.txt and put them in @PARAM  # read parameters from infos.txt and put them in @PARAM
144  if (open(INFOS, $infos)) {  if (open(INFOS, $infos)) {
145      print STDOUT "--- Reading parameters file $infos ---\n";          print STDOUT "--- Reading parameters file $infos ---\n";
146      local(@file,$counter);          local(@file,$counter);
147      $counter = 0;          $counter = 0;
148      @file = <INFOS>;          @file = <INFOS>;
149      @PARAM = ();          @PARAM = ();
150      do {          do {
151          if ($file[0] && $file[0] =~ /^[^#\n\r]/) {                  if ($file[0] && $file[0] =~ /^[^#\n\r]/) {
152             $file[0] =~ s/\n//;    # remove UNIX \n                          $file[0] =~ s/\n//;    # remove UNIX \n
153             $file[0] =~ s/\r//;    # remove WINDOWS \r                              $file[0] =~ s/\r//;    # remove WINDOWS \r    
154             $file[0] =~ s/ *= */=/;                          $file[0] =~ s/ *= */=/;
155             $PARAM[$counter++] = $file[0];                          $PARAM[$counter++] = $file[0];
156             print "$file[0]\n";                          print "$file[0]\n";
157          }                  }
158      } while (shift(@file));          } while (shift(@file));
159  }  }
160  ## @PARAM is now a table with the user preferences for his presentation  ## @PARAM is now a table with the user preferences for his presentation
161    
162  ## process arguments  ## process arguments
163  ## each preset variable is now re-attributed using the user preferences  ## each preset variable is now re-attributed using the user preferences
164  foreach (@PARAM) {  foreach (@PARAM) {
165      @_ = split(/ *= */,$_,2);          my ($var,$value) = split(/ *= */,$_,2);
166      $cmd="\$$_[0] = \'$_[1]\';";          $value=~s/'/\\'/g;
167      if (length $_[1] != 0) {          $cmd="\$$var = \'$value\';";
168          eval($cmd);          if ($value) {
169      }                  eval($cmd) || die "problem with eval of: $cmd";
170            } else {
171                    die "no value defined for $var";
172            }
173  }  }
174    
175  ## use charset  ## use charset
# Line 165  if ($charset) { Line 180  if ($charset) {
180          $http_equiv='';          $http_equiv='';
181  }  }
182    
   
 ## 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";  
 }  
   
183  ##############################################################################  ##############################################################################
184  ## read the raw html presentation  ## read the raw html presentation
185  ##  ##
# Line 187  if ($author2Url) { Line 187  if ($author2Url) {
187  ## copy file in memory  ## copy file in memory
188  my $sep = $/;  my $sep = $/;
189  $/ = undef;  $/ = undef;
190  if (!open(ALL, $all)) {  open(ALL, $all) || die "Error: Cannot open file: $all";
     print "Error: Cannot open file: $all\n";  
     exit 0;  
 }  
191  my $buf = <ALL>;  my $buf = <ALL>;
192  close(ALL);  close(ALL);
193  $/ = $sep;  $/ = $sep;
# Line 227  print STDOUT "\n--- Processing $total sl Line 224  print STDOUT "\n--- Processing $total sl
224  ## start the slide count so we can number them  ## start the slide count so we can number them
225  $slideCount = 1;  $slideCount = 1;
226    
227    ## pre-load template slides using $template dir
228    Text::FastTemplate->defaults(
229                    path => [ $template ]
230            );
231    
232    Text::FastTemplate->preload( [
233                    { file => 'slide.html', key => 'slide' },
234                    { file => 'overview.html', key => 'overview' },
235            ]);
236    
237    ## unroll relative anchors (#something) into links with slides
238    
239    my %anchor_on_slide;
240    
241    ## step 1: record anchors
242    for($i=0; $i<$total; $i++) {
243            my $tmp = $table[($i*2)].$table[($i*2)+1];
244            while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) {
245                    $anchor_on_slide{$1}=($i+1);
246                    print "\tslide ",($i+1)," anchor: $1\n" if ($debug);
247            }
248    }
249    
250    ## step 2: fix links
251    for($i=0; $i<$total; $i++) {
252            foreach (keys %anchor_on_slide) {
253                    $table[($i*2)] =~ s,href="*#$_"*>,href="slide$anchor_on_slide{$_}\.html#$_">,gi;
254            }
255    }
256    
257  ## @table is the array containing each slide with its title  ## @table is the array containing each slide with its title
258  ## for each slide to be generated  ## for each slide to be generated
259  ## we delete each slide and its title when generated  ## we delete each slide and its title when generated
260  ## 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)
261  ## and $table[1] (for the slide content)  ## and $table[1] (for the slide content)
262    
263    undef $prev_title;
264    undef $next_title;
265    
266  do {  do {
267    
268          ## 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 278  do {
278          ## need to check if the title contains any anchor          ## need to check if the title contains any anchor
279          ## if so it needs to be removed          ## if so it needs to be removed
280          ## 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
281          $table[0] =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;          $table[0] = remove_anchor($table[0]);
282    
283          ## grab next slide title $table[2] (if there's a next slide)          ## grab next slide title $table[2] (if there's a next slide)
284          ## to be able to use in the 'next' navigation button          ## to be able to use in the 'next' navigation button
285          ## 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]
286          $next_slide_title = $table[2] if $table[2];          if ($table[2]) {
287          ## remove any anchor from the next slide title                  $next_title= remove_anchor($table[2]);
288          $next_slide_title =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/i;          }
289    
290          ## the current slide content is stored $table[1]          ## the current slide content is stored $table[1]
291          ## 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 295  do {
295    
296          ## extract slide Sub Title <h2>          ## extract slide Sub Title <h2>
297          undef $slideSubTitle;          undef $slideSubTitle;
298          if ($slideContent =~ s/<[hH]2[^>]*>([^<]+)<\/[hH]2[^>]*>//) {          if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) {
299                  $slideSubTitle=$1;                  $slideSubTitle=remove_anchor($1);
300          }          }
301    
302          ## 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 305  do {
305          ## generate the current slide          ## generate the current slide
306          ## parameters are:          ## parameters are:
307          ## 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
308          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$previous_slide_title,$next_slide_title);          &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title);
309    
310          ## 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
311          $previous_slide_title="$table[0]";          $prev_title=remove_anchor($table[0]);
312  }  }
313  ## process the next slide  ## process the next slide
314  while (shift(@table));  while (shift(@table));
# Line 313  sub openOverview Line 343  sub openOverview
343          ## here is the standard style sheet          ## here is the standard style sheet
344          $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\">";
345    
346          if ($logoFile) {          %overview_data = (
347                  $logo_html="<a href=\"$logoLink\"><img src=\"$logoFile\" alt=\"$logoAlt\" border=\"0\"></a>";                  doctype => $doctype,
348          }                  title => $title,
349                    http_equiv => $http_equiv,
350                    stylelink => $stylelink,
351                    body => $body,
352    
353                    logoLink => $logoLink,
354                    logoFile => $logoFile,
355                    logoAlt => $logoAlt,
356                    logoLink2 => $logoLink2,
357                    logoFile2 => $logoFile2,
358                    logoAlt2 => $logoAlt2,
359    
360                    talkTitle => $talkTitle,
361                    talkSubTitle => $talkSubTitle,
362    
363                    content_hight => $content_hight,
364    
365                    author => $author,
366                    authorUrl => $authorUrl,
367                    author2 => $author2,
368                    authorUrl2 => $authorUrl2,
369    
370          if ($logoFile2) {                  date => $date,
                 $logo_html.="<a href=\"$logoLink2\"><img src=\"$logoFile2\" alt=\"$logoAlt2\" border=\"0\"></a>";  
         }  
371    
372          $title_html="<h1>$talkTitle</h1>";                  toc => $loc_toc,
373          if (length $talkSubTitle != 0) {          );
                 $title_html.="<h2>$talkSubTitle</h2>";  
         }  
   
         if (length $date != 0) {  
                 $date_html="($date)";  
         }  
   
         print FOO <<END;  
 $doctype  
     <head>  
             <title>$talkTitle - $loc_toc</title>  
             $http_equiv  
             $stylelink  
      </head>  
      $body  
         <table height="100%" width="100%">  
             <tr>  
                 <td class="header-first" valign="top">  
                     <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  
374    
375  }  }
376  ##  ##
# Line 366  END Line 382  END
382    
383  sub closeOverview  sub closeOverview
384  {  {
385          my $slide_html=make_progress_bar(0,$total);          $overview_data{slide_html} = make_progress_bar(0,$total);
386          print FOO <<END;          $overview_data{toc_entries} = [ @toc_entries ];
387                          </ul>  
388                      </div>          my $page= new Text::FastTemplate key => 'overview';
389                  </td>          print FOO $page->output( \%overview_data );
             </tr>  
             <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  
390    
391          close(FOO);          close(FOO);
392  }  }
# Line 425  sub addTitle Line 412  sub addTitle
412          if ($nr % $toc_on_page == 0) {          if ($nr % $toc_on_page == 0) {
413                  my $toc_nr=int($nr/$toc_on_page);                  my $toc_nr=int($nr/$toc_on_page);
414    
415                  print FOO <<END;                  $item = {
416  <br><small><a accesskey=" " tabindex=" " href="index-toc$toc_nr.html">...</a></small></br>                          pre_html => $pre_ul,
417  END                          accesskey => " ",       # space
418                            href => "index-toc$toc_nr.html",
419                            title => "...",
420                            post_html => $post_ul,
421                            more => 1,      # use style for more pages link (...)
422                    };
423                    push @toc_entries, $item;
424    
425                  &closeOverview;                  &closeOverview;
426                    undef @toc_entries;
427                  &openOverview("$overview-toc$toc_nr");                  &openOverview("$overview-toc$toc_nr");
428                  $last_toc_title='';                  $last_toc_title='';
429          }          }
430    
431          $ul1=$ul2='';          $pre_ul=$post_ul='';
432          if ($last_toc_title eq $title) {          if ($last_toc_title eq $title && $subtitle) {
433                  $title = $subtitle;                  $title = $subtitle;
434                  $ul1='<ul>';                  $pre_ul='<ul>';
435                  $ul2='</ul>';                  $post_ul='</ul>';
436          } else {          } else {
437                  $last_toc_title=$title;                  $last_toc_title=$title;
438          }          }
# Line 445  END Line 440  END
440          # add accesskey for first 9 slides (`1' - `9') or just for first          # add accesskey for first 9 slides (`1' - `9') or just for first
441          # TOC page, and tabindex for all slides          # TOC page, and tabindex for all slides
442          if ($nr < 10 && $nr < $toc_on_page) {          if ($nr < 10 && $nr < $toc_on_page) {
443                  print FOO <<END;                  $item = {
444  $ul1<li><a accesskey="$nr" tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2                          pre_html => $pre_ul,
445  END                          accesskey => "$nr",
446                            tabindex => "$nr",
447                            href => "slide$nr.html",
448                            title => $title,
449                            post_html => $post_ul,
450                            more => 0,
451                    };
452                    push @toc_entries,$item;
453          } else {          } else {
454                  print FOO <<END;                  $item = {
455  $ul1<li><a tabindex="$nr" href="slide$nr.html">$title</a></li>$ul2                          pre_html => $pre_ul,
456  END                          tabindex => "$nr",
457                            href => "slide$nr.html",
458                            title => $title,
459                            post_html => $post_ul,
460                    };
461                    push @toc_entries,$item;
462          }          }
463  }  }
464  ##  ##
# Line 466  sub createSlide Line 473  sub createSlide
473          # parameters are respectively the slide title, its content,          # parameters are respectively the slide title, its content,
474          # its number, the next slide title and the previous slide title          # its number, the next slide title and the previous slide title
475    
476          my ($title,$subtitle,$content,$nr,$next_title,$prev_title) = @_;          my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_;
477    
478          if (! $title) {          if (! $title) {
479                  return 1;                  return 1;
# Line 501  sub createSlide Line 508  sub createSlide
508          ## write to the slide          ## write to the slide
509          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";          open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";
510    
511          my $toclink = "[ <a href=\"$overview\.html\" title=\"Contents\">Contents</a> ]";          my $toc_link = "$overview\.html";
512    
513          ## initialization of the navigation links          ## initialization of the navigation links
514          my $nextlink = "";          my $next_link = "";
515          my $prevlink = "";          my $prev_link = "";
516    
517          if ($nr>1) {          if ($nr>1) {
518                  $prevlink = "<a href=\"slide".($nr-1).".html\" title=\"Previous\">&lt;&lt;</a>";                  $prev_link = "slide".($nr-1).".html";
519  #       } else {  #       } else {
520  #       ## 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
521  #               $prevlink = "<a href=\"$overview\.html\" title=\"Previous\">&lt;&lt;</a>";  #               $prev_link = "$overview\.html";
522          }          }
523    
524          if ($nr != $total) {          if ($nr != $total) {
525                  $nextlink = "<a href=\"slide".($nr+1).".html\" title=\"Next\">&gt;&gt;</a>";                  $next_link = "slide".($nr+1).".html";
526          }          }
527    
528          $stylelink = "";          $stylelink = "";
529          # here is the standard style sheet          # here is the standard style sheet
530          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";          $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";
531    
         $title_html="<h1>$title</h1>";  
         if ($subtitle) {  
                 $title_html.="<h2>$subtitle</h2>";  
         }  
   
532          my $slide_html=make_progress_bar($nr,$total);          my $slide_html=make_progress_bar($nr,$total);
533    
534          print SLIDE <<END;          %page_data = (
535  $doctype                  doctype => $doctype,
536      <head>                  talkTitle => $talkTitle,
537              <title>$talkTitle - $title</title>                  title => $title,
538              $http_equiv                  subtitle => $subtitle,
539              $stylelink                  http_equiv => $http_equiv,
540       </head>                  stylelink => $stylelink,
541       $body                  body => $body,
542          <table height="100%" width="100%">  
543              <tr>                  logoLink => $logoLink,
544                  <td class="header-first" valign="top">                  logoFile => $logoFile,
545                      <table width="100%" border="0">                  logoAlt => $logoAlt,
546                          <tr>                  logoLink2 => $logoLink2,
547                              <td class="cell-logo">$logo_html</td>                  logoFile2 => $logoFile2,
548                              <td class="cell-heading">$title_html</td>                  logoAlt2 => $logoAlt2,
549                          </tr>  
550                      </table>  
551                  </td>                  content_hight => $content_hight,
552              </tr>                  content => $content,
553              <tr>  
554                  <td height="80%" class="body" valign="top">                  prev_link => $prev_link,
555                      <div class="body">                  toc_link => $toc_link,
556  $content                  next_link => $next_link,
557                      </div>                  prev_title => $prev_title,
558                  </td>                  next_title => $next_title,
559              </tr>  
560              <tr>                  author => $author,
561                  <td class="footer">                  authorUrl => $authorUrl,
562                      <table border="0" width="100%">                  author2 => $author2,
563                          <tr>                  authorUrl2 => $authorUrl2,
564                              <td width="33%" class="footer-info">  
565                                  <p>                  date => $date,
566                                      <i>$talkTitle</i>  
567                                      <br>$author $date_html                  slide_html => $slide_html,
568                                  </p>  
569                              </td><td width="33%" class="footer-nav">          );
570                                  <table border="0">  
571                                      <tr>          my $page= new Text::FastTemplate key => 'slide';
572                                          <td>          print SLIDE $page->output( \%page_data );
 $prevlink  
 $toclink  
 $nextlink  
                                         </td>  
                                     </tr>  
                                 </table>  
                             </td><td width="33%" class="footer-count">  
                                 $slide_html  
                                 $author2</td>  
                         </tr>  
                     </table>  
                 </td>  
             </tr>  
         </table>  
     </body>  
 </html>  
 END  
573    
574          close(SLIDE);          close(SLIDE);
575          return 0;          return 0;
# Line 643  sub verify_html { Line 628  sub verify_html {
628  # clean the html of the slide  # clean the html of the slide
629  # remove all <div class="comment">blabla</div>  # remove all <div class="comment">blabla</div>
630  sub clean_html {  sub clean_html {
631      $_[0] =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;          my $tmp=$_[0];
632      return $_[0];          $tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;
633            $tmp =~ s,</*font[^>]+>,,ig;
634            return $tmp;
635  }  }
636    
637  ##############################################################################  ##############################################################################
# Line 677  sub make_progress_bar { Line 664  sub make_progress_bar {
664                  } else {                  } else {
665                          $r=$t;                          $r=$t;
666                  }                  }
667                  $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><td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td><td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td></tr></table>';
668          } else {          } else {
669                  $html="$loc_slide $nr $loc_of $total";                  $html="$loc_slide $nr $loc_of $total";
670          }          }
# Line 685  sub make_progress_bar { Line 672  sub make_progress_bar {
672          return $html;          return $html;
673  }  }
674    
675    ##############################################################################
676    # make slide progress bar
677    sub remove_anchor {
678            my $tmp = $_[0];
679            $tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
680            return $tmp;
681    }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.26