File templatedir.patch of Package bbgallery
diff -uNr bbgallery/mkgallery.pl bbgallery-1.2.3/mkgallery.pl
--- bbgallery-1.2.3/mkgallery.pl 2004-06-27 16:07:06.000000000 +0200
+++ bbgallery/mkgallery.pl 2006-11-04 03:24:08.000000000 +0100
@@ -82,13 +82,14 @@
metalinkurl => 'index.html', # meta link destination
order => 'order.txt', # file containing ordered image list
jhead => 'exifinfo -t 0x0132 ', # path to program to generate title (date/time)
- extension => 'html' # extension for HTML files
+ extension => 'html', # extension for HTML files
+ template_dir => '/usr/lib/bbgallery/template' # where template files are kept
};
my %P = %{$P};
-my $version = "%%%VERSION%%%"; # Version Number
-my $instprefix = "%%%INSTPREFIX%%%";
-my $template_dir = "$instprefix/lib/bbgallery/template";
+my $version = "%%%VERSION%%%"; # Version Number
+my $instprefix = "%%%INSTPREFIX%%%";
+# my $P{template_dir} = "$instprefix/lib/bbgallery/template";
# ----------------------------------------------------------------------
# S U B R O U T I N E S
# ----------------------------------------------------------------------
@@ -329,8 +330,8 @@
$param->{META_URL} = $P{metalink} ? "../index.$P{extension}" : 0;
$param->{GAL_TOTAL} = scalar@galleries;
- if ( -f "$template_dir/$P{template}/meta.tmpl" && open IMG, ">$P{img_dir}/index.$P{extension}" ) {
- my $tmpl = HTML::Template->new(filename => "$template_dir/$P{template}/meta.tmpl",
+ if ( -f "$P{template_dir}/$P{template}/meta.tmpl" && open IMG, ">$P{img_dir}/index.$P{extension}" ) {
+ my $tmpl = HTML::Template->new(filename => "$P{template_dir}/$P{template}/meta.tmpl",
die_on_bad_params => 0,
cache => 1);
$tmpl->param ( $param );
@@ -341,14 +342,14 @@
}
# copy icon files, stylesheets, etc to html dir
- if ( opendir ( D, "$template_dir/$P{template}" ) ) {
+ if ( opendir ( D, "$P{template_dir}/$P{template}" ) ) {
my @files = readdir D;
closedir D;
foreach my $file ( @files ) {
next if ( $file =~ /\~$/ );
next if ( $file =~ /tmpl$/ );
next if ( $file =~ /^\./ );
- system "cp $template_dir/$P{template}/$file \"$P{img_dir}/$file\"";
+ system "cp $P{template_dir}/$P{template}/$file \"$P{img_dir}/$file\"";
}
}
@@ -463,7 +464,7 @@
my $ml_hdr = ( $P{metalink} ) ? "<link rel=\"start\" type=\"text/html\" HREF=\"../index.$P{extension}\">" : '';
- my $tmpl = HTML::Template->new( filename => "$template_dir/$P{template}/image.tmpl",
+ my $tmpl = HTML::Template->new( filename => "$P{template_dir}/$P{template}/image.tmpl",
die_on_bad_params => 0,
cache => 1);
@@ -497,8 +498,8 @@
print IMG $tmpl->output();
close ( IMG );
- if ( -f "$template_dir/$P{template}/slideshow.tmpl" && open IMG, ">$filename_sl" ) {
- my $tmpl = HTML::Template->new(filename => "$template_dir/$P{template}/slideshow.tmpl",
+ if ( -f "$P{template_dir}/$P{template}/slideshow.tmpl" && open IMG, ">$filename_sl" ) {
+ my $tmpl = HTML::Template->new(filename => "$P{template_dir}/$P{template}/slideshow.tmpl",
die_on_bad_params => 0,
cache => 1);
$tmpl->param ( $param );
@@ -598,8 +599,8 @@
$param->{FIRST_URL} = ( $this == 0 ) ? 0 : "index_0.$P{extension}";
$param->{LAST_URL} = ( $this == $total ) ? 0 : "index_$total.$P{extension}";
- if ( -f "$template_dir/$P{template}/index.tmpl" && open IND, ">$P{img_dir}/html/index_$this.$P{extension}" ) {
- my $tmpl = HTML::Template->new(filename => "$template_dir/$P{template}/index.tmpl",
+ if ( -f "$P{template_dir}/$P{template}/index.tmpl" && open IND, ">$P{img_dir}/html/index_$this.$P{extension}" ) {
+ my $tmpl = HTML::Template->new(filename => "$P{template_dir}/$P{template}/index.tmpl",
die_on_bad_params => 0,
cache => 1);
$tmpl->param ( $param );
@@ -710,9 +711,13 @@
$c{short_dsc} = 0;
last;
};
+ ( /^--template-dir/ ) && do {
+ $c{template_dir} = $ARGV[++$i];
+ last;
+ };
( /^--template/ || /^-T$/ ) && do {
$c{template} = $ARGV[++$i];
- if ( ! -d "$template_dir/$c{template}" ) {
+ if ( ! -d "$P{template_dir}/$c{template}" ) {
print "Sorry but a template '$c{template}' doesn't exist.\n\nTerminating...\n";
exit 1;
}
@@ -772,6 +777,7 @@
-t --title <s> Use <s> as title [Gallery]
-d --directory <s> Create gallery for images in directory <s> [.]
-T --template <s> Name of templates to use [default]
+ --template-dir <s> Directory where template exists
-w --wait <n> Delay between slides in slide show is set to
<n> seconds [15]
-M --meta Create meta index instead of image and index
@@ -831,7 +837,7 @@
print "Using '$P{jhead} <imagefile>' to get image title\n" if ( $P{jhead} && $P{verbose} );
# check if we have templates
-unless ( -d "$template_dir/$P{template}" ) {
+unless ( -d "$P{template_dir}/$P{template}" ) {
print "ERROR: Templates not found: $P{template}\n";
exit 1;
}
@@ -916,14 +922,14 @@
}
# copy image files etc to html dir
- if ( opendir ( D, "$template_dir/$P{template}" ) ) {
+ if ( opendir ( D, "$P{template_dir}/$P{template}" ) ) {
my @files = readdir D;
closedir D;
foreach my $file ( @files ) {
next if ( $file =~ /\~$/ );
next if ( $file =~ /tmpl$/ );
next if ( $file =~ /^\./ );
- system "cp $template_dir/$P{template}/$file \"$P{img_dir}/html/$file\"";
+ system "cp $P{template_dir}/$P{template}/$file \"$P{img_dir}/html/$file\"";
}
}