139 |
############################################################################## |
############################################################################## |
140 |
## reading user input from $infos |
## reading user input from $infos |
141 |
## |
## |
142 |
@PARAM = @ARGV; # we keep this for backward compatibility with an old version |
my @file; |
|
# of the slidemaker tool |
|
|
#when the parameters were in Makefile or make.bat |
|
143 |
|
|
144 |
# read parameters from infos.txt and put them in @PARAM |
############################################################################## |
145 |
if (open(INFOS, $infos)) { |
sub parse_infos { |
146 |
print STDERR "--- Reading parameters file $infos ---\n"; |
my @file=@_; |
|
local(@file); |
|
|
@file = <INFOS>; |
|
|
# @PARAM = (); # don't reset param, use @ARGV |
|
147 |
do { |
do { |
148 |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
if ($file[0] && $file[0] =~ /^[^#\n\r]/) { |
149 |
$file[0] =~ s/\n//; # remove UNIX \n |
$file[0] =~ s/\n//; # remove UNIX \n |
150 |
$file[0] =~ s/\r//; # remove WINDOWS \r |
$file[0] =~ s/\r//; # remove WINDOWS \r |
151 |
$file[0] =~ s/ *= */=/; |
my ($var,$value) = split(/ *= */,$file[0],2); |
152 |
push @PARAM,$file[0]; |
$value=~s/'/\\'/g; |
153 |
|
$cmd="\$$var = \'$value\';"; |
154 |
|
if (defined($value)) { |
155 |
|
eval($cmd) || warn "problem with eval of: $cmd"; |
156 |
|
} else { |
157 |
|
die "no value defined for $var"; |
158 |
|
} |
159 |
print STDERR "$file[0]\n"; |
print STDERR "$file[0]\n"; |
160 |
} |
} |
161 |
} while (shift(@file)); |
} while (shift(@file)); |
162 |
} |
} |
163 |
## @PARAM is now a table with the user preferences for his presentation |
############################################################################## |
164 |
|
|
165 |
## process arguments |
parse_infos(@ARGV); # backward compatibility and for pack |
166 |
## each preset variable is now re-attributed using the user preferences |
|
167 |
foreach (@PARAM) { |
# read parameters from infos.txt and put them in @PARAM |
168 |
my ($var,$value) = split(/ *= */,$_,2); |
if (open(INFOS, $infos)) { |
169 |
$value=~s/'/\\'/g; |
print STDERR "--- Reading parameters file $infos ---\n"; |
170 |
$cmd="\$$var = \'$value\';"; |
@file = <INFOS>; |
171 |
if ($value) { |
parse_infos(@file); |
172 |
eval($cmd) || die "problem with eval of: $cmd"; |
} |
173 |
} else { |
|
174 |
die "no value defined for $var"; |
# try to read local infos.txt for template |
175 |
} |
if (-f "$template/$infos" && open(INFOS,"$template/$infos")) { |
176 |
|
print STDERR "--- Reading template parameters file $template/$infos ---\n"; |
177 |
|
@file = <INFOS>; |
178 |
|
parse_infos(@file); |
179 |
|
close(INFOS); |
180 |
} |
} |
181 |
|
|
182 |
|
## @PARAM is now a table with the user preferences for his presentation |
183 |
|
|
184 |
## use charset |
## use charset |
185 |
|
|
186 |
if ($charset) { |
if ($charset) { |
392 |
|
|
393 |
date => $date, |
date => $date, |
394 |
|
|
395 |
toc => $loc_toc, |
toc_title => $loc_toc, |
396 |
|
template_dir => "$template/", |
397 |
); |
); |
398 |
|
|
399 |
} |
} |
410 |
$overview_data{toc_entries} = [ @toc_entries ]; |
$overview_data{toc_entries} = [ @toc_entries ]; |
411 |
|
|
412 |
my $page= new Text::FastTemplate key => 'overview'; |
my $page= new Text::FastTemplate key => 'overview'; |
413 |
|
$page_data{template_dir}='' if ($pack); |
414 |
print FOO $page->output( \%overview_data ); |
print FOO $page->output( \%overview_data ); |
415 |
|
|
416 |
close(FOO); |
close(FOO); |
587 |
toc_link => $toc_link, |
toc_link => $toc_link, |
588 |
next_link => $next_link, |
next_link => $next_link, |
589 |
prev_title => $prev_title, |
prev_title => $prev_title, |
590 |
|
toc_title => $loc_toc, |
591 |
next_title => $next_title, |
next_title => $next_title, |
592 |
|
|
593 |
author => $author, |
author => $author, |
599 |
|
|
600 |
slide_html => $slide_html, |
slide_html => $slide_html, |
601 |
|
|
602 |
|
template_dir => "$template/", |
603 |
); |
); |
604 |
|
|
605 |
my $page; |
my $page; |
608 |
} else { |
} else { |
609 |
$page= new Text::FastTemplate key => 'title'; |
$page= new Text::FastTemplate key => 'title'; |
610 |
} |
} |
611 |
|
$page_data{template_dir}='' if ($pack); |
612 |
print SLIDE $page->output( \%page_data ); |
print SLIDE $page->output( \%page_data ); |
613 |
extract_files($page->output( \%page_data )) if ($pack); |
extract_files($page->output( \%page_data )) if ($pack); |
614 |
close(SLIDE); |
close(SLIDE); |
696 |
my $pcnt_done=int($nr*100/$total); |
my $pcnt_done=int($nr*100/$total); |
697 |
my $pcnt_left=100-$pcnt_done; |
my $pcnt_left=100-$pcnt_done; |
698 |
|
|
699 |
if ($progress_bar) { |
if ($progress_bar && uc($progress_bar) ne "NO") { |
700 |
my $l=$r=" "; |
my $l=$r=" "; |
701 |
my $t="$nr of $total"; |
my $t="$nr of $total"; |
702 |
if ($pcnt_done > 50) { |
if ($pcnt_done > 50) { |
704 |
} else { |
} else { |
705 |
$r=$t; |
$r=$t; |
706 |
} |
} |
707 |
$html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr><td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td><td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td></tr></table>'; |
$html='<table border="0" width="50%" cellpadding="0" cellspacing="0" align="right"><tr>'; |
708 |
|
if ($pcnt_done != 0) { |
709 |
|
$html.='<td width="'.$pcnt_done.'%" class="pcnt-done">'.$l.'</td>'; |
710 |
|
} |
711 |
|
if ($pcnt_left != 0) { |
712 |
|
$html.='<td width="'.$pcnt_left.'%" class="pcnt-left">'.$r.'</td>'; |
713 |
|
} |
714 |
|
$html.='</tr></table>'; |
715 |
} else { |
} else { |
716 |
$html="$loc_slide $nr $loc_of $total"; |
$html="$loc_slide $nr $loc_of $total"; |
717 |
} |
} |
732 |
|
|
733 |
sub extract_files { |
sub extract_files { |
734 |
my $tmp = $_[0]; |
my $tmp = $_[0]; |
735 |
while ($tmp =~ s/<a\s+href="*([^"\s]+)"*//ism || |
while ($tmp =~ s/href="*([^"\s]+)"*//ism || |
736 |
$tmp =~ s/<img\s+src="*([^"\s]+)"*//ism) { |
$tmp =~ s/src="*([^"\s]+)"*//ism) { |
737 |
if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) { |
if ("$1" !~ m/[hf]t?tp:/ && -f "$1" && !grep(/$1/,@pack_additional)) { |
738 |
push @pack_additional,$1; |
push @pack_additional,$1; |
739 |
} |
} |