summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-03-01 21:43:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-03-01 21:43:21 +0100
commitef76ccd91ecddafb953554b6d4847a651e338d99 (patch)
tree6b73e6684152b1fcdc5b8048af82437dd66924de /lib
parent23d772e5dbbdc400785981b977e99a6808d731ed (diff)
Make options intuitive for both GetOptions-passing and manual setup
Diffstat (limited to 'lib')
-rwxr-xr-xlib/App/Dthumb.pm38
1 files changed, 22 insertions, 16 deletions
diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm
index c4b7102..ecde021 100755
--- a/lib/App/Dthumb.pm
+++ b/lib/App/Dthumb.pm
@@ -47,7 +47,7 @@ use Cwd;
use Image::Imlib2;
our @EXPORT_OK = ();
-our $VERSION = '0.1';
+our $VERSION = '0.2';
=head1 METHODS
@@ -111,30 +111,32 @@ Default: false
sub new {
- my ($obj, $conf) = @_;
+ my ($obj, %conf) = @_;
my $ref = {};
- $conf->{size} //= 200;
- $conf->{spacing} //= 1.1;
- $conf->{quality} //= 75;
- $conf->{title} //= (split(qr{/}, cwd()))[-1];
- $conf->{lightbox} = !$conf->{'no-lightbox'};
- $conf->{names} = !$conf->{'no-names'};
+ $conf{size} //= 200;
+ $conf{spacing} //= 1.1;
+ $conf{quality} //= 75;
+ $conf{title} //= (split(qr{/}, cwd()))[-1];
+ $conf{file_index} //= 'index.xhtml';
+ $conf{dir_thumbs} //= '.thumbs';
+ $conf{dir_data} //= '.dthumb';
+
- $ref->{config} = $conf;
+ # helpers to directly pass GetOptions results
+ $conf{lightbox} //= !$conf{'no-lightbox'};
+ $conf{names} //= !$conf{'no-names'};
+
+ $ref->{config} = \%conf;
$ref->{data} = App::Dthumb::Data->new();
$ref->{data}->set_vars(
- title => $conf->{title},
- width => $conf->{size} * $conf->{spacing} . 'px',
- height => $conf->{size} * $conf->{spacing} . 'px',
+ title => $conf{title},
+ width => $conf{size} * $conf{spacing} . 'px',
+ height => $conf{size} * $conf{spacing} . 'px',
);
- $ref->{config}->{file_index} = 'index.xhtml';
- $ref->{config}->{dir_thumbs} = '.thumbs';
- $ref->{config}->{dir_data} = '.dthumb';
-
$ref->{html} = $ref->{data}->get('html_start');
return bless($ref, $obj);
@@ -364,6 +366,10 @@ sub write_out_html {
close($fh);
}
+sub version {
+ return $VERSION;
+}
+
1;
__END__