X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=mkgallery.pl;h=5c02e0b83995e8fbbe765854689865f2e67603d2;hp=6ca18eb5a0c199ab1af887a733bf71a1545108f9;hb=209e09b423ba90321f9322e5f06db3017d0b0c01;hpb=bac4775c14b8b2161c0866e621a31ee6eae63f35 diff --git a/mkgallery.pl b/mkgallery.pl index 6ca18eb..5c02e0b 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -33,6 +33,9 @@ use CGI qw/:html *table *Tr *center *div/; use Image::Info qw/image_info dim/; use Term::ReadLine; use Getopt::Long; +use Encode; +use encoding 'utf-8'; +binmode(STDOUT, ":utf8"); my $haveimagick = eval { require Image::Magick; }; { package Image::Magick; } # to make perl compiler happy @@ -41,18 +44,42 @@ my @sizes = (160, 640); ###################################################################### +my $incpath; my $debug = 0; my $asktitle = 0; my $noasktitle = 0; -GetOptions('asktitle'=>\$asktitle, +charset("utf-8"); + +unless (GetOptions( + 'help'=>\&help, + 'incpath'=>\$incpath, + 'asktitle'=>\$asktitle, 'noasktitle'=>\$noasktitle, - 'debug'=>\$debug); + 'debug'=>\$debug)) { + &help; +} my $term = new Term::ReadLine "Edit Title"; FsObj->new(getcwd)->iterate; +sub help { + + print STDERR <<__END__; +usage: $0 [options] + --help: print help message and exit + --incpath: do not try to find .include diretory upstream, use + specified path (absolute or relavive). Use with causion. + --debug: print a lot of debugging info to stdout as you run + --asktitle: ask to edit album titles even if there are ".title" files + --noasktitle: don't ask to enter album titles even where ".title" + files are absent. Use partial directory names as titles. +__END__ + + exit 1; +} + sub new { my $this = shift; my $class; @@ -92,6 +119,10 @@ sub getinc { my $fullpath=shift; # this is not a method my $depth=20; # arbitrary max depth + if ($incpath) { + return $incpath."/.include"; + } + my $inc=".include"; while ( ! -d $fullpath."/".$inc ) { $inc = "../".$inc; @@ -370,7 +401,7 @@ sub makeaux { my $title = $self->{-info}->{'Comment'}; $title = $name unless ($title); - print "slide: \"$pref\"->\"$name\"->\"$nref\"\n" if ($debug); + print "slide: \"$title\": \"$pref\"->\"$name\"->\"$nref\"\n" if ($debug); # slideshow for my $refresh('static', 'slide') { @@ -403,8 +434,10 @@ sub makeaux { warn "cannot open \"$fn\": $!"; next; } + binmode($F, ":utf8"); if ($refresh eq 'slide') { print $F start_html( + -encoding=>"utf-8", -title=>$title, -bgcolor=>"#808080", -head=>meta({-http_equiv=>'Refresh', @@ -414,6 +447,7 @@ sub makeaux { } else { print $F start_html(-title=>$title, + -encoding=>"utf-8", -bgcolor=>"#808080", -style=>{-src=>$inc."gallery.css"}, ),"\n"; @@ -445,6 +479,7 @@ sub makeaux { } my $imgsrc = sprintf("../.%s/%s",$sizes[0],$name); print $F start_html(-title=>$title, + -encoding=>"utf-8", -style=>{-src=>$inc."gallery.css"},),"\n", start_center,"\n", h1($title),"\n", @@ -468,11 +503,13 @@ sub startindex { warn "cannot open $fn: $!"; return; } + binmode($IND, ":utf8"); $self->{-IND} = $IND; my $inc = $self->{-inc}; my $title = $self->{-title}; print $IND start_html(-title => $title, + -encoding=>"utf-8", -style=>{-src=>[$inc."gallery.css", $inc."lightbox.css"]}, -script=>[{-code=>"var incPrefix='$inc';"},