summaryrefslogtreecommitdiff
path: root/lib/App
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App')
-rwxr-xr-xlib/App/Dthumb.pm30
-rw-r--r--lib/App/Dthumb/Data.pm.PL34
2 files changed, 40 insertions, 24 deletions
diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm
index a287f32..1b26b13 100755
--- a/lib/App/Dthumb.pm
+++ b/lib/App/Dthumb.pm
@@ -29,8 +29,13 @@ sub new {
$conf{dir_thumbs} = "$conf{dir_images}/.thumbs";
# helpers to directly pass GetOptions results
- $conf{lightbox} //= ( $conf{'no-lightbox'} ? 0 : 1 );
- $conf{names} //= ( $conf{'no-names'} ? 0 : 1 );
+ $conf{lightbox} //= (
+ (
+ $conf{'no-lightbox'}
+ or $conf{shadowbox}
+ ) ? 0 : 1
+ );
+ $conf{names} //= ( $conf{'no-names'} ? 0 : 1 );
$ref->{config} = \%conf;
@@ -43,8 +48,12 @@ sub new {
);
if ( $conf{lightbox} ) {
- $ref->{data}
- ->set_vars( lightbox => $ref->{data}->get('html_lightbox.dthumb'), );
+ $ref->{data}->set_vars(
+ lightbox => $ref->{data}->get('lightbox/html_load.dthumb'), );
+ }
+ elsif ( $conf{shadowbox} ) {
+ $ref->{data}->set_vars(
+ lightbox => $ref->{data}->get('shadowbox/html_load.dthumb'), );
}
$ref->{html} = $ref->{data}->get('html_start.dthumb');
@@ -94,14 +103,15 @@ sub create_files {
my $datadir = $self->{config}->{dir_data};
my @files;
- if ( not -d $thumbdir ) {
- mkdir($thumbdir);
- }
- if ( not -d $datadir ) {
- mkdir($datadir);
+ for my $dir ( $thumbdir, $datadir, "${datadir}/lightbox",
+ "${datadir}/shadowbox" )
+ {
+ if ( not -d $dir ) {
+ mkdir($dir);
+ }
}
- if ( $self->{config}->{lightbox} ) {
+ if ( $self->{config}->{lightbox} or $self->{config}->{shadowbox} ) {
@files = $self->{data}->list_archived();
}
else {
diff --git a/lib/App/Dthumb/Data.pm.PL b/lib/App/Dthumb/Data.pm.PL
index 3c74b9c..b2d0a33 100644
--- a/lib/App/Dthumb/Data.pm.PL
+++ b/lib/App/Dthumb/Data.pm.PL
@@ -2,39 +2,46 @@
use strict;
use warnings;
use 5.010;
-use autodie;
+use File::Slurp qw(read_dir);
use MIME::Base64 qw(encode_base64);
my ($out_file) = @ARGV;
-open(my $out_fh, '>', $out_file);
-opendir(my $share_dh, 'share');
+open( my $out_fh, '>', $out_file );
+opendir( my $share_dh, 'share' );
+opendir( my $share_lb_dh, 'share/lightbox' );
+opendir( my $share_sb_dh, 'share/shadowbox' );
print {$out_fh} <DATA>;
-for my $file (readdir($share_dh)) {
- if (substr($file, 0, 1) eq q{.}) {
+for my $file (
+ read_dir( 'share', prefix => 1 ),
+ read_dir( 'share/lightbox', prefix => 1 ),
+ read_dir( 'share/shadowbox', prefix => 1 )
+ )
+{
+
+ if ( -d $file ) {
next;
}
- open(my $fh, '<', "share/${file}");
+ open( my $fh, '<', $file );
my $content = do { local $/ = undef; <$fh> };
close($fh);
- if ($file =~ qr{ [.] (png | gif) $ }ox) {
+ if ( $file =~ qr{ [.] (png | gif) $ }ox ) {
$content = encode_base64($content);
}
- printf {$out_fh} (
- "______[ %s ]______\n%s\n",
- $file,
- $content,
- );
+ $file =~ s{ ^ share/ }{}x;
+
+ printf {$out_fh} ( "______[ %s ]______\n%s\n", $file, $content, );
}
closedir($share_dh);
+closedir($share_lb_dh);
+closedir($share_sb_dh);
close($out_fh);
-
__DATA__
package App::Dthumb::Data;
@@ -195,4 +202,3 @@ Copyright (C) 2011 by Daniel Friesel E<lt>derf@chaosdorf.deE<gt>
=cut
__DATA__
-