From 0fba132b842566063b0e7361c9260ae6d31ab3de Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 24 Mar 2017 17:45:32 +0100 Subject: also allow indexing/listing of non-image files --- bin/dthumb | 1 + lib/App/Dthumb.pm | 30 ++++++++++++++++++++++-------- share/unknown.png | Bin 0 -> 6873 bytes 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 share/unknown.png diff --git a/bin/dthumb b/bin/dthumb index ab56865..f7ea418 100755 --- a/bin/dthumb +++ b/bin/dthumb @@ -23,6 +23,7 @@ our $VERSION = '0.2'; GetOptions( $opt, qw{ + all|a help|h no-names|n quality|q=i diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm index 6e4eeaf..a478c7d 100755 --- a/lib/App/Dthumb.pm +++ b/lib/App/Dthumb.pm @@ -56,8 +56,12 @@ sub read_directories { if ( $file =~ m{ ^ [.] }x ) { next; } + if ( $file eq 'index.html' ) { + next; + } if ( -f "${imgdir}/${file}" - and $file =~ qr{ [.] (png | jp e? g) $ }iox ) + and + ( $self->{config}{all} or $file =~ m{ [.] (png | jp e? g) $ }ix ) ) { push( @files, $file ); } @@ -68,7 +72,7 @@ sub read_directories { if ( -d $thumbdir ) { for my $file ( read_dir($thumbdir) ) { - if ( $file =~ qr{^ [^.] }ox and not -f "${imgdir}/${file}" ) { + if ( $file =~ m{^ [^.] }ox and not -f "${imgdir}/${file}" ) { push( @old_thumbs, $file ); } } @@ -127,13 +131,13 @@ sub create_thumbnail_html { $self->{html} .= "
\n"; if ( -d $file ) { - $self->{html} - .= sprintf( -"\t\n" + $self->{html} .= sprintf( + "\t\n" . "\t\t\"%s\"\n", - ($file) x 2, $file, ); + ($file) x 3, + ); } - else { + elsif ( $file =~ m{ [.] (png | jp e? g) $ }ix ) { $self->{html} .= sprintf( "\t\n" . "\t\t\"%s\"\n", @@ -142,6 +146,13 @@ sub create_thumbnail_html { ($file) x 2, ); } + else { + $self->{html} .= sprintf( + "\t\n" + . "\t\t\"%s\"\n", + ($file) x 3, + ); + } if ( $self->{config}->{names} or -d $file ) { $self->{html} .= sprintf( @@ -168,7 +179,10 @@ sub create_thumbnail_image { { return; } - if ( -d $file ) { + if ( -d $file + or $self->{config}{all} + and not( $file =~ m{ [.] (png | jp e? g) $ }ix ) ) + { return; } diff --git a/share/unknown.png b/share/unknown.png new file mode 100644 index 0000000..50a2969 Binary files /dev/null and b/share/unknown.png differ -- cgit v1.2.3