/[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

Annotation of /burst.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations)
Thu May 10 07:08:50 2001 UTC (22 years, 10 months ago) by dpavlin
Branch: MAIN
Changes since 1.14: +8 -1 lines
File MIME type: text/plain
small improvment in visual representation of progress bar

1 dpavlin 1.5 #!/usr/bin/perl
2 dpavlin 1.1 #
3 dpavlin 1.9 # PLies Copyright 2001 Dobrica Pavlinusic <dpavlin@rot13.org>
4 dpavlin 1.1 #
5     # this tool is based on SlideMaker and XLSies tool
6     # split a all.htm into slide*.htm
7     #
8     # For more information please see presentation about this tool on
9     # http://www.rot13.org/~dpavlin/presentations/XLSies_to_PLies/
10     #
11     # Copyright 1999 World Wide Web Consortium,
12     # (Massachusetts Institute of Technology, Institut
13     # National de Recherche en Informatique et en
14     # Automatique, Keio University). All Rights Reserved.
15     # This program is distributed under the W3C's
16     # Intellectual Property License. This program is
17     # distributed in the hope that it will be useful, but
18     # WITHOUT ANY WARRANTY; without even the implied
19     # warranty of MERCHANTABILITY or FITNESS FOR A
20     # PARTICULAR PURPOSE. See W3C License
21     # http://www.w3.org/Consortium/Legal/ for more details.
22     #
23     #
24     ##############################################################################
25     #
26     # slidemaker credits:
27     #
28     # Stephan Montigaud - stephan@w3.org
29     # created 970601
30     # modified by Pierre Fillault
31     # check the documentation at http://www.w3.org/Talks/YYMMsub/
32     #
33     # modified 19990505 Bert Bos: ALT text of prev/next arrows is now
34     # "prev"/"next" rather than the title of the prev/next slide; looks better
35     # in lynx.
36     #
37     # version: 4.14 - 19990719
38     # $Id: w3cburst.pl,v 1.41 1999/11/02 17:25:50 charles Exp $
39     #
40     #
41     # XLSies credits:
42     #
43     # Sami Lempinen - lempinen@iki.fi
44     # http://www.snowman.sgic.fi/ssl/xslies/
45 dpavlin 1.5 #
46     # Text::FastTemplate:
47     # Robert Lehr - bozzio@the-lehrs.com
48    
49     use Text::FastTemplate;
50 dpavlin 1.1
51     ##############################################################################
52     ## default values of variables
53     ##
54    
55 dpavlin 1.7 ## show debug output
56 dpavlin 1.14 my $debug=0;
57 dpavlin 1.7
58 dpavlin 1.1 ## default DOCTYPE added on the slides
59     $doctype = '<html xmlns="http://www.w3.org/TR/REC-html40">';
60    
61     ## name of raw HTML file containing the slides
62     $all = 'all.htm';
63    
64     ## table of content built from all.htm - also first page of the presentation
65     ## this is only the basename as we need to generate one toc for each style sheets
66     ## the main toc will not bear any more so the server can understand a request for '/'
67     ## the next ones will bear a number corresponding to the slide index
68     #$overview = 'Overview';
69     $overview = 'index';
70    
71     ## name of the file containing the parameters of the presentation
72     $infos = 'infos.txt';
73    
74     ## link to the logo printed on all the slides
75     $logoLink = '';
76    
77     ## default location of the logo - works when slidemaker is used as a package
78     $logoFile = '';
79    
80     ### localization
81     $loc_toc = "Table of contents";
82     $loc_by = "by";
83     $loc_amp = "&amp;"; # author separator
84     $loc_slide = "Slide";
85     $loc_of = "of"; # $loc_slide nr $loc_of total
86    
87     ## alternate representation of the logo
88     $logoAlt = '';
89    
90     ## default values set to none
91     $logoLink2 = ''; # link to a potential second reference
92     $logoFile2 = ''; # location of a second logo
93     $logoAlt2 = ''; # alternate representation of the second logo
94    
95     ## default accesskeys for navigation icons used in the slides
96     $prevKey = 'P'; # accesskey for previous slide
97     $nextKey = 'N'; # accesskey for next slide
98     $tocKey = 'C'; # accesskey for table of contents
99     $styleKey = 'S'; # accesskey for changing style sheets
100    
101     ## default author name
102     $author = 'Staff';
103    
104     ## default presentation title
105     $talkTitle = 'Talk';
106    
107     ## standard style sheets
108     $cssStandard = '../PLies/css/default.css';
109    
110 dpavlin 1.5 ## template name
111     $template = '../PLies/default';
112    
113 dpavlin 1.1 ## default charset use in meta tag http-equiv (undef to skip)
114     #$charset = 'ISO-8859-1';
115    
116     ## default <body> tag
117     $body = '<body>';
118    
119     ## number of entries on each TOC page
120     $toc_on_page = 10;
121    
122     ## use progress bar
123     $progress_bar = 1;
124    
125 dpavlin 1.2 ## content hight for each slide
126     $content_hight = "70%";
127    
128 dpavlin 1.1 ## end of default values for the presentation
129     ##############################################################################
130    
131     ## globals
132     my $last_toc_title;
133 dpavlin 1.5 my %page_data;
134     my %overview_data;
135 dpavlin 1.1
136 dpavlin 1.13 my $pack = 0;
137     my @pack_additional; # additional files to pack (pictures, logos...)
138    
139 dpavlin 1.1 ##############################################################################
140     ## reading user input from $infos
141     ##
142     @PARAM = @ARGV; # we keep this for backward compatibility with an old version
143     # of the slidemaker tool
144     #when the parameters were in Makefile or make.bat
145    
146     # read parameters from infos.txt and put them in @PARAM
147     if (open(INFOS, $infos)) {
148 dpavlin 1.13 print STDERR "--- Reading parameters file $infos ---\n";
149     local(@file);
150 dpavlin 1.7 @file = <INFOS>;
151 dpavlin 1.13 # @PARAM = (); # don't reset param, use @ARGV
152 dpavlin 1.7 do {
153     if ($file[0] && $file[0] =~ /^[^#\n\r]/) {
154     $file[0] =~ s/\n//; # remove UNIX \n
155     $file[0] =~ s/\r//; # remove WINDOWS \r
156     $file[0] =~ s/ *= */=/;
157 dpavlin 1.13 push @PARAM,$file[0];
158     print STDERR "$file[0]\n";
159 dpavlin 1.7 }
160     } while (shift(@file));
161 dpavlin 1.1 }
162     ## @PARAM is now a table with the user preferences for his presentation
163    
164     ## process arguments
165     ## each preset variable is now re-attributed using the user preferences
166     foreach (@PARAM) {
167 dpavlin 1.5 my ($var,$value) = split(/ *= */,$_,2);
168     $value=~s/'/\\'/g;
169     $cmd="\$$var = \'$value\';";
170     if ($value) {
171     eval($cmd) || die "problem with eval of: $cmd";
172     } else {
173     die "no value defined for $var";
174     }
175 dpavlin 1.1 }
176    
177     ## use charset
178    
179     if ($charset) {
180     $http_equiv='<meta http-equiv="Content-type" content="text/html; charset='.$charset.'">';
181     } else {
182     $http_equiv='';
183     }
184    
185 dpavlin 1.13
186 dpavlin 1.1 ##############################################################################
187     ## read the raw html presentation
188     ##
189    
190     ## copy file in memory
191     my $sep = $/;
192     $/ = undef;
193 dpavlin 1.7 open(ALL, $all) || die "Error: Cannot open file: $all";
194 dpavlin 1.1 my $buf = <ALL>;
195 dpavlin 1.12 $buf =~ s/\r//g; # remove WINDOWS \r
196 dpavlin 1.1 close(ALL);
197     $/ = $sep;
198    
199     ## Remove comments from the raw presentation
200     ## they do not need to show up on the slides
201     $buf =~ s/<!--.*?-->//sgo;
202    
203 dpavlin 1.13 ## if $pack is set, output name of css (for inclusion in archive), but
204     ## reset $cssStandard only to filename (without path)
205    
206     if ($pack) {
207     push @pack_additional,$cssStandard;
208     $cssStandard =~ s/^.*\/([^\/]+)$/$1/g;
209     }
210    
211 dpavlin 1.1 ## the slidemaker tool assumes that each slide is self contained between 2 sets of h1 tags
212     ## if not it will generate a rather weird output
213     ## split using <h1...> and </h1...> as separator (ignores attributes!)
214     ## h1 or H1 can be used
215     @table = split(/<\/?[hH]1[^>]*>/, $buf);
216    
217     ## compute the total number of slides
218     $total = $#table / 2;
219     if ($#table % 2 != 0) {
220     $total = ($#table +1)/2;
221     }
222    
223     ##
224     ## raw presentation has been read successfully
225     ##############################################################################
226    
227     ##############################################################################
228     ## processing the slides
229    
230 dpavlin 1.13 print STDERR "\n--- Processing $total slides ---\n";
231 dpavlin 1.1
232     ## generate the header table of content of the presentation
233     ## which is also the first page of the talk
234     &openOverview($overview);
235    
236     ## start the slide count so we can number them
237     $slideCount = 1;
238    
239 dpavlin 1.5 ## pre-load template slides using $template dir
240     Text::FastTemplate->defaults(
241     path => [ $template ]
242     );
243    
244     Text::FastTemplate->preload( [
245     { file => 'slide.html', key => 'slide' },
246     { file => 'overview.html', key => 'overview' },
247 dpavlin 1.12 { file => 'title.html', key => 'title' },
248 dpavlin 1.5 ]);
249 dpavlin 1.1
250 dpavlin 1.7 ## unroll relative anchors (#something) into links with slides
251    
252     my %anchor_on_slide;
253    
254     ## step 1: record anchors
255     for($i=0; $i<$total; $i++) {
256 dpavlin 1.9 my $tmp = $table[($i*2)].$table[($i*2)+1];
257 dpavlin 1.7 while ($tmp =~ s,<a +name="*([^>"]+)"*>,,i) {
258     $anchor_on_slide{$1}=($i+1);
259 dpavlin 1.13 print STDERR "\tslide ",($i+1)," anchor: $1\n" if ($debug);
260 dpavlin 1.7 }
261     }
262    
263     ## step 2: fix links
264     for($i=0; $i<$total; $i++) {
265     foreach (keys %anchor_on_slide) {
266     $table[($i*2)] =~ s,href="*#$_"*>,href="slide$anchor_on_slide{$_}\.html#$_">,gi;
267     }
268     }
269    
270 dpavlin 1.1 ## @table is the array containing each slide with its title
271     ## for each slide to be generated
272     ## we delete each slide and its title when generated
273     ## so that the current slide and its title are always at $table[0] (for the title)
274     ## and $table[1] (for the slide content)
275 dpavlin 1.7
276     undef $prev_title;
277     undef $next_title;
278    
279 dpavlin 1.1 do {
280    
281     ## get rid of the first element contained by the raw presentation array
282     shift(@table);
283     ## then $table[0] is the title of the slide to be generated
284     $table[0] =~ s/\n+/ /g; ## replace return character by a white space
285     $table[0] =~ s/\r+/ /g; ## replace lf character by a white space
286     $table[0] =~ s/ +/ /g; ## concatenate several white spaces to only one
287     $table[0] =~ s/^ //; ## remove all the starting white spaces in the title
288     $table[0] =~ s/ $//; ## remove all trailing white spaces in the title
289     ## $slideTitle preserves link(s) in the title
290     $slideTitle = $table[0];
291     ## need to check if the title contains any anchor
292     ## if so it needs to be removed
293     ## because the title is being used in the table of content to link to the corresponding slide
294 dpavlin 1.8 $table[0] = remove_anchor($table[0]);
295 dpavlin 1.1
296     ## grab next slide title $table[2] (if there's a next slide)
297     ## to be able to use in the 'next' navigation button
298     ## keep in mind that $table[1] contains the slide corresponding to the title $table[0]
299 dpavlin 1.7 if ($table[2]) {
300 dpavlin 1.8 $next_title= remove_anchor($table[2]);
301 dpavlin 1.7 }
302 dpavlin 1.1
303     ## the current slide content is stored $table[1]
304     ## there is an attempt to make sure it's clean HTML
305     ## Pierre Fillault's note: use same piece of as used in http://www.w3.org/Web/Tools/CvsCommitScripting
306     ## to make use of the validation service
307     $slideContent = &clean_html($table[1]) ;
308    
309     ## extract slide Sub Title <h2>
310     undef $slideSubTitle;
311 dpavlin 1.8 if ($slideContent =~ s/<[hH]2[^>]*>(.+)<\/[hH]2[^>]*>//sm) {
312     $slideSubTitle=remove_anchor($1);
313 dpavlin 1.1 }
314    
315     ## add the title of the current slide to the table of content
316     &addTitle($slideTitle,$slideSubTitle,$slideCount);
317    
318     ## generate the current slide
319     ## parameters are:
320     ## title of the slide, its content, the slide number, the title of the previous slide and the title of the next slide
321 dpavlin 1.7 &createSlide($slideTitle,$slideSubTitle,$slideContent ,$slideCount++,$prev_title,$next_title);
322 dpavlin 1.1
323     ## save the title of the previous slide to be displayed in the 'previous' navigation button
324 dpavlin 1.8 $prev_title=remove_anchor($table[0]);
325 dpavlin 1.1 }
326     ## process the next slide
327     while (shift(@table));
328    
329     ## close the table of content
330     &closeOverview;
331    
332     ## generate more toc with the all the style sheets
333     ## as there's no way of loading a style sheet
334     ## except dynamically, but that would be slow
335     ## and would not work on all platforms (ie would fail on Joe's laptop)
336     &generateTOC;
337    
338 dpavlin 1.13 ## print additional files to pack
339     print STDOUT join("\n",@pack_additional) if ($pack);
340 dpavlin 1.1
341 dpavlin 1.13 print STDERR "--- Finished ---\n";
342 dpavlin 1.1 exit 0;
343     ##
344     ## end of the slidemaker main program
345     ##############################################################################
346    
347    
348     ##############################################################################
349     ## generate the header of the table of content
350    
351     sub openOverview
352     {
353     ## open the file to write to
354     open(FOO, ">$_[0].html") || die "can't open $_[0].html: $!";
355 dpavlin 1.13 push @pack_additional,"$_[0].html" if ($pack);
356 dpavlin 1.1
357     ## the style sheet used in the table of content is
358     $stylelink = "";
359     ## here is the standard style sheet
360     $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\" media=\"screen\">";
361    
362 dpavlin 1.5 %overview_data = (
363     doctype => $doctype,
364     title => $title,
365     http_equiv => $http_equiv,
366     stylelink => $stylelink,
367     body => $body,
368    
369     logoLink => $logoLink,
370     logoFile => $logoFile,
371     logoAlt => $logoAlt,
372 dpavlin 1.7 logoLink2 => $logoLink2,
373     logoFile2 => $logoFile2,
374     logoAlt2 => $logoAlt2,
375 dpavlin 1.5
376     talkTitle => $talkTitle,
377     talkSubTitle => $talkSubTitle,
378    
379     content_hight => $content_hight,
380    
381     author => $author,
382     authorUrl => $authorUrl,
383     author2 => $author2,
384     authorUrl2 => $authorUrl2,
385 dpavlin 1.1
386 dpavlin 1.5 date => $date,
387 dpavlin 1.1
388 dpavlin 1.5 toc => $loc_toc,
389     );
390 dpavlin 1.1
391     }
392     ##
393     ## the beginning of the table of content has been generated and saved
394     ##############################################################################
395    
396     ##############################################################################
397     ## generate the footer of the table of content
398    
399     sub closeOverview
400     {
401 dpavlin 1.5 $overview_data{slide_html} = make_progress_bar(0,$total);
402     $overview_data{toc_entries} = [ @toc_entries ];
403    
404     my $page= new Text::FastTemplate key => 'overview';
405     print FOO $page->output( \%overview_data );
406 dpavlin 1.1
407     close(FOO);
408     }
409     ##
410     ## the toc has been completed and saved
411     ##############################################################################
412    
413     ##############################################################################
414     ## add an item in the toc
415    
416     sub addTitle
417     {
418     my ($title,$subtitle,$nr) = @_;
419     $title =~ s/\r//ig; # remove the windows CR+LF
420     $title =~ s/<[^>]+>//g;
421    
422     if (! $title) {
423     return 1;
424     }
425    
426     # split TOC entries to multiple pages
427    
428     if ($nr % $toc_on_page == 0) {
429     my $toc_nr=int($nr/$toc_on_page);
430    
431 dpavlin 1.10 $item = {
432 dpavlin 1.5 pre_html => $pre_ul,
433     accesskey => " ", # space
434     href => "index-toc$toc_nr.html",
435     title => "...",
436     post_html => $post_ul,
437     more => 1, # use style for more pages link (...)
438 dpavlin 1.10 };
439     push @toc_entries, $item;
440 dpavlin 1.5
441 dpavlin 1.1 &closeOverview;
442 dpavlin 1.10 undef @toc_entries;
443 dpavlin 1.1 &openOverview("$overview-toc$toc_nr");
444     $last_toc_title='';
445     }
446    
447 dpavlin 1.5 $pre_ul=$post_ul='';
448 dpavlin 1.11 if ($last_toc_title eq $title && $subtitle) {
449 dpavlin 1.1 $title = $subtitle;
450 dpavlin 1.5 $pre_ul='<ul>';
451     $post_ul='</ul>';
452 dpavlin 1.1 } else {
453     $last_toc_title=$title;
454     }
455    
456     # add accesskey for first 9 slides (`1' - `9') or just for first
457     # TOC page, and tabindex for all slides
458     if ($nr < 10 && $nr < $toc_on_page) {
459 dpavlin 1.5 $item = {
460     pre_html => $pre_ul,
461     accesskey => "$nr",
462     tabindex => "$nr",
463     href => "slide$nr.html",
464     title => $title,
465     post_html => $post_ul,
466     more => 0,
467     };
468     push @toc_entries,$item;
469 dpavlin 1.1 } else {
470 dpavlin 1.10 $item = {
471 dpavlin 1.5 pre_html => $pre_ul,
472     tabindex => "$nr",
473     href => "slide$nr.html",
474     title => $title,
475     post_html => $post_ul,
476 dpavlin 1.10 };
477     push @toc_entries,$item;
478 dpavlin 1.1 }
479     }
480     ##
481     ##############################################################################
482    
483     ##############################################################################
484     ## generate the current slide
485    
486     sub createSlide
487     {
488    
489     # parameters are respectively the slide title, its content,
490     # its number, the next slide title and the previous slide title
491    
492 dpavlin 1.7 my ($title,$subtitle,$content,$nr,$prev_title,$next_title) = @_;
493 dpavlin 1.1
494     if (! $title) {
495     return 1;
496     }
497    
498     # work the slide title, the previous and next titles
499     chomp $title;
500     $title =~ s/\r//ig; # remove the windows CR+LF
501     $next_title =~ s/\r//ig;
502     $prev_title =~ s/\r//ig;
503    
504     # Remove any tags from the prev & next titles
505     $next_title =~ s/<[^>]+>//g;
506     $prev_title =~ s/<[^>]+>//g;
507     $title =~ s/<[^>]+>//g;
508    
509     # Replace double quotes
510     # $title =~ s/"/&#34;/g;
511     $next_title =~ s/"/&#34;/g;
512     $prev_title =~ s/"/&#34;/g;
513    
514     # work the slide content
515     $content =~ s/<\/body>//i; # remove if any
516     $content =~ s/<\/html>//i; # remove if any
517    
518     $status = sprintf "Slide %2d: %s %s\n", $nr, $title, $subtitle;
519     $status =~ s/<[^>]+>//g;
520 dpavlin 1.13 print STDERR $status;
521 dpavlin 1.1
522     &verify_html($content); # check the html
523    
524     ## write to the slide
525     open(SLIDE, ">slide$nr.html") || die "can't save slide$nr.html: $!";
526 dpavlin 1.13 push @pack_additional,"slide$nr.html" if ($pack);
527 dpavlin 1.1
528 dpavlin 1.7 my $toc_link = "$overview\.html";
529 dpavlin 1.1
530     ## initialization of the navigation links
531 dpavlin 1.7 my $next_link = "";
532     my $prev_link = "";
533 dpavlin 1.1
534     if ($nr>1) {
535 dpavlin 1.7 $prev_link = "slide".($nr-1).".html";
536 dpavlin 1.1 # } else {
537     # ## add a link back to the toc for the first slide --CMN 19991102
538 dpavlin 1.7 # $prev_link = "$overview\.html";
539 dpavlin 1.1 }
540    
541     if ($nr != $total) {
542 dpavlin 1.7 $next_link = "slide".($nr+1).".html";
543 dpavlin 1.1 }
544    
545     $stylelink = "";
546     # here is the standard style sheet
547     $stylelink .= "<link href=\"$cssStandard\" rel=\"stylesheet\" type=\"text/css\" title=\"Talk\">";
548    
549     my $slide_html=make_progress_bar($nr,$total);
550    
551 dpavlin 1.12 # undefine body if no content is found (so that template can show
552     # only title and sub-title
553     if ($content !~ m/\S/g) {
554     undef $content;
555     }
556    
557 dpavlin 1.5 %page_data = (
558     doctype => $doctype,
559     talkTitle => $talkTitle,
560     title => $title,
561 dpavlin 1.7 subtitle => $subtitle,
562 dpavlin 1.5 http_equiv => $http_equiv,
563     stylelink => $stylelink,
564     body => $body,
565    
566 dpavlin 1.7 logoLink => $logoLink,
567     logoFile => $logoFile,
568     logoAlt => $logoAlt,
569     logoLink2 => $logoLink2,
570     logoFile2 => $logoFile2,
571     logoAlt2 => $logoAlt2,
572    
573    
574 dpavlin 1.5 content_hight => $content_hight,
575     content => $content,
576 dpavlin 1.7
577     prev_link => $prev_link,
578     toc_link => $toc_link,
579     next_link => $next_link,
580     prev_title => $prev_title,
581     next_title => $next_title,
582    
583 dpavlin 1.5 author => $author,
584 dpavlin 1.7 authorUrl => $authorUrl,
585     author2 => $author2,
586     authorUrl2 => $authorUrl2,
587    
588     date => $date,
589    
590 dpavlin 1.5 slide_html => $slide_html,
591    
592     );
593    
594 dpavlin 1.12 my $page;
595     if ($content) {
596     $page= new Text::FastTemplate key => 'slide';
597     } else {
598     $page= new Text::FastTemplate key => 'title';
599     }
600 dpavlin 1.5 print SLIDE $page->output( \%page_data );
601 dpavlin 1.13 extract_files($page->output( \%page_data )) if ($pack);
602 dpavlin 1.1 close(SLIDE);
603     return 0;
604     }
605    
606     ##############################################################################
607     ## generate all the toc of contents needed for each css choosen by the user
608     ## the default toc is not numbered so it can be served by a request to '/'
609     ## (ie it remains Overview.html whereas the other toc are called Overview_#.html)
610    
611     sub generateTOC {
612    
613     ## read the general toc
614     open(FOO, "<$overview.html");
615     @TOC = <FOO>;
616     close(FOO);
617     $toc = "@TOC";
618    
619     ## for each user CSS file
620     ## starting after the default css
621     for ($css=1;$css<$nbCssStandard;$css++) {
622    
623     ## create new TOC
624     $newTOC = $toc;
625    
626     ## the links on the toc need also to be modified
627     ## to link to the correct slides
628     $newTOC =~ s/<a accesskey=\"(\d)\" tabindex=\"(\d+)\" href=\"slide(\d+)-\d+\.html\">/<a accesskey=\"$1\" tabindex=\"$2\" href=\"slide$3-$css\.html">/ig;
629     $newTOC =~ s/<a tabindex=\"(\d+)\" href=\"slide(\d+)-\d+\.html\">/<a tabindex=\"$1\" href=\"slide$2-$css\.html">/ig;
630    
631     ## write to new TOC
632     $outfile = $overview."-".$css.".html";
633     open(OUT, ">$outfile");
634     print OUT $newTOC;
635     close(OUT)
636     }
637    
638    
639     }
640    
641     ##############################################################################
642     # check that the html of the slide
643     # is correct (ALT tags, ...)
644     # This procedure produces only warning
645     sub verify_html {
646    
647     if ($_[0] =~ /<img([^>]*)>/im) {
648     if (!($1 =~ /ALT=/im)) {
649 dpavlin 1.13 print STDERR "WARNING: <IMG> without ALT\n";
650     print STDERR " <IMG$1>\n" ;
651 dpavlin 1.1 }
652     }
653     }
654    
655     ##############################################################################
656     # clean the html of the slide
657     # remove all <div class="comment">blabla</div>
658     sub clean_html {
659 dpavlin 1.10 my $tmp=$_[0];
660     $tmp =~ s/<div\s+class\s*=\s*(?:comment[\s>]|\"comment\").*?<\/div>//igs;
661     $tmp =~ s,</*font[^>]+>,,ig;
662     return $tmp;
663 dpavlin 1.1 }
664    
665     ##############################################################################
666     # make transparent 1x1 gif (for layout tricks)
667     sub make_dotgif {
668     @dot_gif=(71,73,70,56,57,97,1,0,1,0,128,0,0,192,192,192,0,0,0,33,
669     249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
670     open(GIF,"> $_[0]") || die "can't write gif $_[0]: $!";
671     my $dotgif;
672     foreach (@dot_gif) {
673     $dotgif.=chr($_);
674     }
675     print GIF $dotgif;
676     close(GIF);
677     }
678    
679     ##############################################################################
680     # make slide progress bar
681     sub make_progress_bar {
682     my ($nr,$total) = @_;
683    
684     my $pcnt_done=int($nr*100/$total);
685     my $pcnt_left=100-$pcnt_done;
686    
687     if ($progress_bar) {
688     my $l=$r="&nbsp;";
689     my $t="$nr of $total";
690     if ($pcnt_done > 50) {
691     $l=$t;
692     } else {
693     $r=$t;
694     }
695 dpavlin 1.15 $html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr>';
696     if ($pcnt_done != 0) {
697     $html.='<td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td>';
698     }
699     if ($pcnt_left != 0) {
700     $html.='<td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td>';
701     }
702     $html.='</tr></table>';
703 dpavlin 1.1 } else {
704     $html="$loc_slide $nr $loc_of $total";
705     }
706    
707     return $html;
708     }
709    
710 dpavlin 1.8 ##############################################################################
711 dpavlin 1.13 # remove anchors <a href...> from html (for titles)
712 dpavlin 1.8 sub remove_anchor {
713 dpavlin 1.10 my $tmp = $_[0];
714     $tmp =~ s/(.*)<A[^>]*>(.*)<\/A>(.*)/$1$2$3/ig;
715     return $tmp;
716 dpavlin 1.13 }
717    
718     ##############################################################################
719     # extract files referenced in presentation
720    
721     sub extract_files {
722     my $tmp = $_[0];
723     while ($tmp =~ s/<a\s+href="*([^"\s]+)"*//ism ||
724     $tmp =~ s/<img\s+src="*([^"\s]+)"*//ism) {
725     if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) {
726     push @pack_additional,$1;
727     }
728     }
729 dpavlin 1.8 }

  ViewVC Help
Powered by ViewVC 1.1.26