From f031a3971aa32839917afb8c6b4ac2878f70b545 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 2 Nov 2014 10:56:59 +0100 Subject: re-add shadowbox support note that the shadowbox source cannot be redistributed due to its license. --- lib/App/Dthumb/Data.pm.PL | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'lib/App/Dthumb/Data.pm.PL') 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} ; -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 Ederf@chaosdorf.deE =cut __DATA__ - -- cgit v1.2.3