X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=mkgallery.pl;h=8bed35cb1d594efd3fdb17cb7703751757ddb198;hp=f5b6186013ed9bdcac7c3cdc441ad579c4dabdf1;hb=HEAD;hpb=d9858398daebccc17dff00309c0f96a94a98e1f2 diff --git a/mkgallery.pl b/mkgallery.pl index f5b6186..8bed35c 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -36,7 +36,7 @@ use Term::ReadLine; use Getopt::Long; use Encode; use UUID; -#use encoding 'utf-8'; +use utf8; binmode(STDOUT, ":utf8"); my $haveimagick = eval { require Image::Magick; }; @@ -67,6 +67,7 @@ unless (GetOptions( } my $term = new Term::ReadLine "Edit Title"; +binmode($term->IN, ':utf8'); FsObj->new(getcwd)->iterate; @@ -356,9 +357,10 @@ sub edittitle { my $self = shift; my $fullpath = $self->{-fullpath}; my $title; + my $titleimage; my $T; - if (open($T,'<'.$fullpath.'/.title')) { - binmode($T, ":utf8"); + my $TI; + if (open($T,'<:encoding(utf8)', $fullpath.'/.title')) { $title = <$T>; $title =~ s/[\r\n]*$//; close($T); @@ -370,7 +372,7 @@ sub edittitle { print $OUT "Enter title for $fullpath\n"; $title = $term->readline($prompt.' >',$title); $term->addhistory($title) if ($title); - if (open($T,'>'.$fullpath.'/.title')) { + if (open($T,'>:encoding(utf8)', $fullpath.'/.title')) { print $T $title,"\n"; close($T); } @@ -379,6 +381,13 @@ sub edittitle { $title=$self->{-relpath}; } $self->{-title}=$title; + if (open($TI,'<:encoding(utf8)', $fullpath.'/.titleimage')) { + $titleimage = <$TI>; + $titleimage =~ s/[\r\n]*$//; + close($TI); + #print STDERR "found title image \"",$titleimage,"\"\n"; + $self->{-titleimage}=$titleimage; + } print "title in $fullpath is $title\n" if ($debug); } @@ -476,11 +485,10 @@ sub makeaux { $toggletext = 'Play->'; } my $F; - unless (open($F,'>'.$fn)) { + unless (open($F,'>:encoding(utf8)', $fn)) { warn "cannot open \"$fn\": $!"; next; } - binmode($F, ":utf8"); if ($refresh eq 'slide') { print $F start_html( -encoding=>"utf-8", @@ -521,11 +529,10 @@ sub makeaux { my $fn = sprintf("%s/.html/%s-info.html",$dn,$name); if (isnewer($self->{-fullpath},$fn)) { my $F; - unless (open($F,'>'.$fn)) { + unless (open($F,'>:encoding(utf8)', $fn)) { warn "cannot open \"$fn\": $!"; return; } - binmode($F, ":utf8"); my $imgsrc = sprintf("../.%s/%s",$sizes[0],$name); print $F start_html(-title=>$title, -encoding=>"utf-8", @@ -557,15 +564,15 @@ sub startindex { my $block = $self->{-fullpath}.'/.noindex'; $fn = '/dev/null' if ( -f $block ); my $IND; - unless (open($IND,'>'.$fn)) { + unless (open($IND,'>:encoding(utf8)', $fn)) { warn "cannot open $fn: $!"; return; } - binmode($IND, ":utf8"); $self->{-IND} = $IND; my $inc = $self->{-inc}.$incdir.'/'; my $title = $self->{-title}; + my $titleimage = $self->{-titleimage}; print $IND start_html(-title => $title, -encoding=>"utf-8", -style=>[ @@ -587,7 +594,7 @@ sub startindex { -id => 'indexContainer'}), "\n"; my $EVL; - if (open($EVL,$self->{-toppath}.'/'.$incdir.'/header.pl')) { + if (open($EVL, '<:encoding(utf8)', $self->{-toppath}.'/'.$incdir.'/header.pl')) { my $prm; while (<$EVL>) { $prm .= $_; @@ -597,6 +604,7 @@ sub startindex { -version => $version, -depth => $self->{-depth}, -title => $title, + -titleimage => $titleimage, -path => $self->{-fullpath}, -breadcrumbs => "breadcrumbs unimplemented", ); @@ -605,8 +613,14 @@ sub startindex { print STDERR "could not open ", $self->{-toppath}.'/'.$incdir.'/header.pl', " ($!), reverting to default header"; - print $IND a({-href=>"../index.html"},"UP"),"\n", - h1({-class=>'title'},$title),"\n", + print $IND a({-href=>"../index.html"},"UP"),"\n"; + if ($titleimage) { + print $IND img({-src=>$titleimage, + -class=>'titleimage', + -alt=>'Title Image'}),"\n"; + } + print $IND h1({-class=>'title'},$title), + br({-clear=>'all'}),"\n"; } } @@ -616,7 +630,7 @@ sub endindex { print $IND end_div; my $EVL; - if (open($EVL,$self->{-toppath}.'/'.$incdir.'/footer.pl')) { + if (open($EVL, '<:encoding(utf8)', $self->{-toppath}.'/'.$incdir.'/footer.pl')) { my $prm; while (<$EVL>) { $prm .= $_; @@ -626,6 +640,7 @@ sub endindex { -version => $version, -depth => $self->{-depth}, -title => $self->{-title}, + -titleimage => $self->{-titleimage}, -breadcrumbs => "breadcrumbs unimplemented", ); print $IND eval $prm,"\n";