X-Git-Url: http://www.average.org/gitweb/?p=mkgallery.git;a=blobdiff_plain;f=mkgallery.pl;h=f672b6c3895234f6665d6da8a8eda1abb566bfa2;hp=0a4988c067899577d46b7a934da5c67dbd4c7bd2;hb=a4459ef8c416655779d060838622932d26cded1b;hpb=0605e5404527fedc6da3fafbf8c7da1536aadd2c diff --git a/mkgallery.pl b/mkgallery.pl index 0a4988c..f672b6c 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id$ +my $version='$Id$'; # Recursively create image gallery index and slideshow wrappings. # Makes use of modified "slideshow" javascript by Samuel Birch @@ -74,13 +74,14 @@ if ($rssfile && ! $haverssxml) { my $term = new Term::ReadLine "Edit Title"; FsObj->new(getcwd)->iterate; +if ($rssobj) { $rssobj->{'rss'}->save($rssobj->{'file'}); } sub help { print STDERR <<__END__; usage: $0 [options] --help: print help message and exit - --incpath: do not try to find .include diretory upstream, use + --incpath: do not try to find .gallery2 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 @@ -100,24 +101,26 @@ sub new { $class = ref($this); my $parent = $this; my $name = shift; - my $fullpath = $parent->{-fullpath}.'/'.$name; $self = { -parent=>$parent, -root=>$parent->{-root}, + -toppath=>$parent->{-toppath}, + -depth=>$parent->{-depth}+1, -base=>$name, - -fullpath=>$fullpath, + -fullpath=>$parent->{-fullpath}.'/'.$name, + -relpath=>$parent->{-relpath}.'/'.$name, -inc=>'../'.$parent->{-inc}, - -rss=>'../'.$parent->{-rss}, }; } else { $class = $this; my $root=shift; $self = { + -depth=>0, -root=>$root, -fullpath=>$root, - -inc=>getinc($root), - -rss=>getrss($root), }; + # fill in -inc, -rss, -relpath + initpaths($self); # we are not blessed yet, so cheat. } bless $self, $class; if ($debug) { @@ -129,30 +132,51 @@ sub new { return $self; } -sub getinc { - my $fullpath=shift; # this is not a method +sub initpaths { + my $self=shift; # this is not a method but we cheat my $depth=20; # arbitrary max depth + my $fullpath=$self->{-fullpath}; + my $inc; + my $rss; + my $relpath; if ($incpath) { - return $incpath."/.include"; - } - - my $inc=".include"; - while ( ! -d $fullpath."/".$inc ) { - $inc = "../".$inc; - last unless ($depth-- > 0); + $inc = $incpath."/.gallery2"; + } else { + $inc=".gallery2"; + while ( ! -d $fullpath."/".$inc ) { + $inc = "../".$inc; + last unless ($depth-- > 0); + } } if ($depth > 0) { - return $inc.'/'; # prefix with trailing slash + $self->{-inc} = $inc.'/'; + my $dp=0; + my $pos; + for ($pos=index($inc,'/');$pos>=0; + $pos=index($inc,'/',$pos+1)) { + $dp++; + } + for ($pos=length($fullpath);$dp-->0 && $pos>0; + $pos=rindex($fullpath,'/',$pos-1)) {;} + my $relpath = substr($fullpath,$pos); + $relpath =~ s%^/%%; + $self->{-relpath} = $relpath; + $self->{-toppath} = substr($fullpath,0,$pos); + initrss($self); } else { - return 'NO-.INCLUDE-IN-PATH/'; # won't work anyway + $self->{-inc} = 'NO-.INCLUDE-IN-PATH/'; # won't work anyway + $self->{-rss} = ''; + $self->{-relpath} = ''; } } -sub getrss { - my $fullpath=shift; # this is not a method - my $depth=20; # arbitrary max depth +sub initrss { + my $self=shift; # this is not a method but we cheat + my $fullpath=$self->{-fullpath}; + my $depth=20; + return; return "" unless $rssfile; my $rss=$rssfile; @@ -363,7 +387,7 @@ sub edittitle { close($T); } if ($asktitle || (!$title && !$noasktitle)) { - my $prompt = $self->{-base}; + my $prompt = $self->{-relpath}; $prompt = '/' unless ($prompt); my $OUT = $term->OUT || \*STDOUT; print $OUT "Enter title for $fullpath\n"; @@ -375,7 +399,7 @@ sub edittitle { } } unless ($title) { - $title=substr($fullpath,length($self->{-root})); + $title=$self->{-relpath}; } $self->{-title}=$title; print "title in $fullpath is $title\n" if ($debug); @@ -488,14 +512,16 @@ sub makeaux { -head=>meta({-http_equiv=>'Refresh', -content=>"3; url=$fwdref"}), -style=>{-src=>$inc."gallery.css"}, - ),"\n"; + ),"\n", + comment("Created by ".$version),"\n"; } else { print $F start_html(-title=>$title, -encoding=>"utf-8", -bgcolor=>"#808080", -style=>{-src=>$inc."gallery.css"}, - ),"\n"; + ),"\n", + comment("Created by ".$version),"\n"; } print $F start_table({-class=>'navi'}),start_Tr,"\n", td(a({-href=>"../index.html"},"Index")),"\n", @@ -506,7 +532,9 @@ sub makeaux { end_Tr, end_table,"\n", center(table({-class=>'picframe'}, - Tr(td(img({-src=>$imgsrc}))))),"\n", + Tr(td(img({-src=>$imgsrc, + -class=>'standalone', + -alt=>$title}))))),"\n", end_html,"\n"; close($F); } @@ -529,10 +557,13 @@ sub makeaux { {-src=>$inc."urlparser.js"}, {-src=>$inc."infopage.js"}, ]),"\n", + comment("Created by ".$version),"\n", start_center,"\n", h1($title),"\n", table({-class=>'ipage'}, - Tr(td(img({-src=>$imgsrc})), + Tr(td(img({-src=>$imgsrc, + -class=>'thumbnail', + -alt=>$title})), td($self->infotable))), a({-href=>'../index.html',-class=>'conceal'}, 'Index'),"\n", @@ -567,27 +598,65 @@ sub startindex { print $IND start_html(-title => $title, -encoding=>"utf-8", -head=>$rsslink, - -style=>{-src=>$inc."gallery.css"}, + -style=>[ + {-src=>$inc."gallery.css"}, + {-src=>$inc."custom.css"}, + ], -script=>[ {-src=>$inc."mootools.js"}, {-src=>$inc."overlay.js"}, {-src=>$inc."urlparser.js"}, {-src=>$inc."multibox.js"}, - {-src=>$inc."slideshow.js"}, + {-src=>$inc."showwin.js"}, + {-src=>$inc."controls.js"}, + {-src=>$inc."show.js"}, {-src=>$inc."gallery.js"}, - {-code=>"var incPrefix='$inc';"} - ]), - a({-href=>"../index.html"},"UP"),"\n", - start_center,"\n", - h1($title),"\n", + ]),"\n", + comment("Created by ".$version),"\n", + start_div({-class => 'indexContainer', + -id => 'indexContainer'}), "\n"; + my $EVL; + if (open($EVL,$inc.'header.pl')) { + my $prm; + while (<$EVL>) { + $prm .= $_; + } + close($EVL); + %_ = ( + -version => $version, + -depth => $self->{-depth}, + -title => $title, + -breadcrumbs => "breadcrumbs unimplemented", + ); + print $IND eval $prm,"\n"; + } else { + print $IND a({-href=>"../index.html"},"UP"),"\n", + h1({-class=>'title'},$title),"\n", + } } sub endindex { my $self = shift; my $IND = $self->{-IND}; - print $IND end_center,end_html,"\n"; + print $IND end_div; + my $EVL; + if (open($EVL,$self->{-inc}.'footer.pl')) { + my $prm; + while (<$EVL>) { + $prm .= $_; + } + close($EVL); + %_ = ( + -version => $version, + -depth => $self->{-depth}, + -title => $self->{-title}, + -breadcrumbs => "breadcrumbs unimplemented", + ); + print $IND eval $prm,"\n"; + } + print $IND end_html,"\n"; close($IND) if ($IND); undef $self->{-IND}; @@ -609,7 +678,7 @@ sub startsublist { my $self = shift; my $IND = $self->{-IND}; - print $IND h2("Albums"),"\n",start_table,"\n"; + print $IND h2({-class=>"atitle"},"Albums"),"\n",start_table,"\n"; } sub sub_entry { @@ -636,27 +705,9 @@ sub startimglist { my $first = $self->{-firstimg}->{-base}; my $slideref = sprintf(".html/%s-slide.html",$first); - print $IND h2("Images ", - a({-href=>$slideref,-class=>'showStart',-id=>$first}, - '> slideshow')),"\n", - start_div({-id=>"slideshowWindow",-class=>"slideshowWindow"}), - div({-id=>"slideshowContainer", - -class=>"slideshowContainer"},""), - start_div({-id=>"slideshowControls", - -class=>"slideshowControls"}), - a({-href=>"#",-onClick=>"show.previous();return false;"}, - "Prev"), - a({-href=>"#",-onClick=>"show.play();return false;"}, - "Play"), - a({-href=>"#",-onClick=>"show.stop();return false;"}, - "Stop"), - a({-href=>"#",-onClick=>"show.next();return false;"}, - "Next"), - a({-href=>"#",-onClick=>"showStop();return false;"}, - "Exit"), - end_div, - end_div, - "\n"; + print $IND h2({-class=>"ititle"},"Images ", + a({-href=>$slideref,-class=>'showStart',-rel=>'i'.$first}, + '> slideshow')),"\n"; } sub img_entry { @@ -674,29 +725,32 @@ sub img_entry { print $IND a({-name=>$name}),"\n", start_table({-class=>'slide'}),start_Tr,start_td,"\n", - div({-class=>'slidetitle',-id=>$name}, + div({-class=>'slidetitle'}, "\n ",a({-href=>".html/$name-info.html", -title=>'Image Info: '.$name, -class=>'infoBox'}, $title),"\n"),"\n", - div({-class=>'slideimage',-id=>$name}, + div({-class=>'slideimage'}, "\n ",a({-href=>".html/$name-static.html", -title=>$title, -class=>'showImage', - -id=>$name}, - img({-src=>$thumb})),"\n"),"\n", - start_div({-class=>'varimages',-id=>$name}),"\n"; + -rel=>'i'.$name}, + img({-src=>$thumb, + -class=>'thumbnail', + -alt=>$title})),"\n"),"\n", + start_div({-class=>'varimages',-id=>'i'.$name,-title=>$title}),"\n"; foreach my $sz(@sizes) { my $src=$self->{$sz}->{'url'}; my $w=$self->{$sz}->{'dim'}->[0]; my $h=$self->{$sz}->{'dim'}->[1]; print $IND " ",a({-href=>$src, - -class=>"conceal ". - (($sz == 640)?"slideshowThumbnail":""), + -class=>"conceal", + -rel=>$w."x".$h, -title=>"Reduced to ".$w."x".$h}, $w."x".$h)," \n"; } print $IND " ",a({-href=>$name, + -rel=>$w."x".$h, -title=>'Original'},$w."x".$h), "\n",end_div,"\n", end_td,end_Tr,end_table,"\n";