PerlPoint-Converters
view release on metacpan or search on metacpan
print STDERR "creating slide dir $OPT_MAIN{slide_dir} ...\n" if $verbose;
mkpath($OPT_MAIN{slide_dir}, 1, oct(755)) or die "Cannot creat $OPT_MAIN{slide_dir}: $!\n";
}
$OPT_MAIN{image_dir} = $OPT_MAIN{slide_dir} unless defined $OPT_MAIN{image_dir};
if(! defined $OPT_MAIN{image_ref}){
if ($OPT_MAIN{image_dir} eq $OPT_MAIN{slide_dir}){
$OPT_MAIN{image_ref} = "."; # images are in the slides dir
} else {
if ( is_abs_path($OPT_MAIN{image_dir}) ){
$OPT_MAIN{image_ref} = $OPT_MAIN{image_dir}; # absolute path name
} else {
### we must figure out, where the image_dir is relative to the slide_dir !!!
$OPT_MAIN{image_ref} = relative_path($OPT_MAIN{image_dir}, $OPT_MAIN{slide_dir});
#TODO: remove abs_path if relative path works
$OPT_MAIN{image_ref} = return_abs_path($OPT_MAIN{image_dir});
}
}
}
$OPT_MAIN{applet_dir} = $OPT_MAIN{slide_dir} unless defined $OPT_MAIN{applet_dir};
if(! defined $OPT_MAIN{applet_ref}){
if ($OPT_MAIN{applet_dir} eq $OPT_MAIN{slide_dir}){
$OPT_MAIN{applet_ref} = "."; # applets are in the slides dir
} else {
if ( is_abs_path($OPT_MAIN{applet_dir}) ){
$OPT_MAIN{applet_ref} = $OPT_MAIN{applet_dir}; # absolute path name
} else {
### we must figure out, where the applet_dir is relative to the slide_dir !!!
#TODO: remove abs_path if relative path works
$OPT_MAIN{applet_ref} = relative_path($OPT_MAIN{applet_dir}, $OPT_MAIN{slide_dir});
$OPT_MAIN{applet_ref} = return_abs_path($OPT_MAIN{applet_dir});
}
}
}
my $style_dir = ".";
## handle style options; in this case we must load additional
## options files ...
if (defined $OPT_MAIN{style}){
# try to find the style directory
print STDERR "using style $OPT_MAIN{style}\n" if $verbose;
my $style = $OPT_MAIN{style};
my $found = 0;
foreach my $mstyle_dir (@{$OPT_MAIN{style_dir}}) {
if (-e "$mstyle_dir/$style/$style.cfg"){
$style_dir = $mstyle_dir;
$found = 1;
last;
}
}
if (! $found){
die "*** ERROR: style directory $style not found ...\n";
}
# load the options file from the style directory:
my $style_opts = "$style_dir/$style/$style.cfg";
if (! -e $style_opts) {
die "*** ERROR: cannot find options file $style_opts !\n";
}
{ local @ARGV = ( "\@$style_opts" );
argvFile();
die unless GetOptions( \%OPT_STYLE, # get new options from style
@OPTIONS
);
# merge main options into style options
# (main options have higher priority !!)
@OPT{ keys %OPT_STYLE } = values %OPT_STYLE if %OPT_STYLE;
@OPT{ keys %OPT_MAIN } = values %OPT_MAIN;
$OPT{txt_contents} = $OPT{contents_header};
$OPT{txt_index} = $OPT{index_header};
}
$style_dir = "$style_dir/$style"; ## used as prefix for all template files !!
# now copy all images from the style dir to target_dir (slide_dir):
opendir(STYLE, "$style_dir") or die "Can't open directory $style_dir: $!\n";
foreach my $img (readdir(STYLE)){
if ($img =~ /\.jpg$|\.gif$|\.png$/i) {
update_file("$style_dir/$img", "$OPT_MAIN{image_dir}/$img", $verbose, \%OPT, 0);
}
if ($img =~ /\.htm$|\.html$|\.css$/i) {
update_file("$style_dir/$img", "$OPT_MAIN{slide_dir}/$img", $verbose, \%OPT, 0);
}
}
closedir(STYLE);
} # end --style option
else {
# merge main options into %OPT
@OPT{ keys %OPT_MAIN } = values %OPT_MAIN;
$OPT{txt_contents} = $OPT{contents_header};
$OPT{txt_index} = $OPT{index_header};
}
# merge define options:
@OPT{ keys %OPT_DEFINE } = values %OPT_DEFINE;
if ($OPT{tree_applet}){ #--------------------- TreeApplet
# now update tree applet files in target directory
# first find tree applet sources
# There MUST be a subdirectoy called "applet_src" in one of the style directories
my $applet_source_dir;
foreach my $mstyle_dir (@{$OPT{style_dir}}) {
if (-d "$mstyle_dir/applet_src"){
$applet_source_dir = "$mstyle_dir/applet_src";
last;
}
}
# now update:
if (! defined $applet_source_dir){
die "*** ERROR: TreeApplet source directory not found!\n" .
" Perhaps you have not specified a --style_dir option.\n" .
" This is now mandatory if you use the tree applet.\n" .
" There must be a directory called 'applet_src' in one of your\n" .
" style collections (i. e. one of the directories which are \n" .
" specified with the --style_dir option).\n"
;
}
opendir(TR, $applet_source_dir) or die "cannot open $applet_source_dir:$!\n";
( run in 0.636 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )