From 3364d219ce6156f74854698a7ecda95c6d45c00d Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 4 Sep 2008 06:06:26 +0000 Subject: [PATCH 01/16] add html customizaton template --- include/chrome.pm | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 include/chrome.pm diff --git a/include/chrome.pm b/include/chrome.pm new file mode 100644 index 0000000..e27fb5b --- /dev/null +++ b/include/chrome.pm @@ -0,0 +1,52 @@ +#!/usr/bin/perl +# $Id$ +# +# customizable class to generate html around the gallery index + +package Chrome; + +use strict; + +# Boilerplate. Do not change this (unless you know better). + +sub new { + my $this=shift; + my $self; + my $parm=shift; + if (ref($this)) { + die "$this::new should not be called as instance method"; + } else { + $self={ + -title => $parm->{-title}, + -depth => $parm->{-depth}, + -breadcrumbs => $parm->{-breadcrumbs}, + }; + } + bless $self,$this; + return $self; +} + +# Public methods. Replace this with what suits you. + +sub header { + my $self=shift; + return $self{-depth}? + "
UP
": + "". + "

$self{-title}

"; +} + +sub axheader { + my $self=shift; + return "

Albums

"; +} + +sub ixheader { + my $self=shift; + return "

Images

"; +} + +sub footer { + my $self=shift; + return "
"; +} -- 2.39.2 From 14f59b5697b711f20cdcaf459a36ad103531565c Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 4 Sep 2008 13:40:45 +0000 Subject: [PATCH 02/16] rollback it. will go a simpler road. --- include/chrome.pm | 52 ----------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 include/chrome.pm diff --git a/include/chrome.pm b/include/chrome.pm deleted file mode 100644 index e27fb5b..0000000 --- a/include/chrome.pm +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/perl -# $Id$ -# -# customizable class to generate html around the gallery index - -package Chrome; - -use strict; - -# Boilerplate. Do not change this (unless you know better). - -sub new { - my $this=shift; - my $self; - my $parm=shift; - if (ref($this)) { - die "$this::new should not be called as instance method"; - } else { - $self={ - -title => $parm->{-title}, - -depth => $parm->{-depth}, - -breadcrumbs => $parm->{-breadcrumbs}, - }; - } - bless $self,$this; - return $self; -} - -# Public methods. Replace this with what suits you. - -sub header { - my $self=shift; - return $self{-depth}? - "": - "". - "

$self{-title}

"; -} - -sub axheader { - my $self=shift; - return "

Albums

"; -} - -sub ixheader { - my $self=shift; - return "

Images

"; -} - -sub footer { - my $self=shift; - return "
"; -} -- 2.39.2 From 46c35837ebf71a013ec383f71e3f8f5424823334 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 4 Sep 2008 14:37:03 +0000 Subject: [PATCH 03/16] customizable header and footer --- include/custom.css | 18 ++++++++++++++++ include/footer.pl | 1 + include/gallery.css | 8 +++++++ include/header.pl | 2 ++ mkgallery.pl | 52 +++++++++++++++++++++++++++++++++++++-------- 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 include/custom.css create mode 100644 include/footer.pl create mode 100644 include/header.pl diff --git a/include/custom.css b/include/custom.css new file mode 100644 index 0000000..ba080db --- /dev/null +++ b/include/custom.css @@ -0,0 +1,18 @@ +h1.title { + text-align: center; +} + +hr.footer { + width: 80%; +} + +div.linkup { + position: absolute; + top: 0px; + right: 0px; +} + +div.genby { + font-size: small; + text-align: right; +} diff --git a/include/footer.pl b/include/footer.pl new file mode 100644 index 0000000..7fa6b8c --- /dev/null +++ b/include/footer.pl @@ -0,0 +1 @@ +"
generated by $_{-version}
"; diff --git a/include/gallery.css b/include/gallery.css index e278b30..e1ec824 100644 --- a/include/gallery.css +++ b/include/gallery.css @@ -5,6 +5,14 @@ http://www.average.org/mkgallery/ */ +h2.ititle { + text-align: center; +} + +h2.atitle { + text-align: center; +} + img.thumbnail { clear:both; border-style: inset; diff --git a/include/header.pl b/include/header.pl new file mode 100644 index 0000000..e1f9c96 --- /dev/null +++ b/include/header.pl @@ -0,0 +1,2 @@ +"

$_{-title}

". +($_{-depth}?"":"") diff --git a/mkgallery.pl b/mkgallery.pl index fffb030..ad32e66 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -105,6 +105,7 @@ sub new { $self = { -parent=>$parent, -root=>$parent->{-root}, + -depth=>$parent->{-depth}+1, -base=>$name, -fullpath=>$fullpath, -inc=>'../'.$parent->{-inc}, @@ -114,6 +115,7 @@ sub new { $class = $this; my $root=shift; $self = { + -depth=>0, -root=>$root, -fullpath=>$root, -inc=>getinc($root), @@ -575,7 +577,10 @@ 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"}, @@ -589,19 +594,48 @@ sub startindex { comment("Created by ".$version),"\n", start_div({-class => 'indexContainer', -id => 'indexContainer'}), - a({-href=>"../index.html"},"UP"),"\n", - start_center,"\n", - h1($title),"\n", "\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_div, - # "\n",'',"\n", - 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}; @@ -623,7 +657,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 { @@ -650,7 +684,7 @@ sub startimglist { my $first = $self->{-firstimg}->{-base}; my $slideref = sprintf(".html/%s-slide.html",$first); - print $IND h2("Images ", + print $IND h2({-class=>"ititle"},"Images ", a({-href=>$slideref,-class=>'showStart',-rel=>'i'.$first}, '> slideshow')),"\n"; } -- 2.39.2 From 94784b38b15864616598a9d9e24e3945fe8dd4b1 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 4 Sep 2008 14:45:53 +0000 Subject: [PATCH 04/16] document header & footer --- include/footer.pl | 11 ++++++++++- include/gallery.css | 3 +++ include/header.pl | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/footer.pl b/include/footer.pl index 7fa6b8c..1c246e3 100644 --- a/include/footer.pl +++ b/include/footer.pl @@ -1 +1,10 @@ -"
generated by $_{-version}
"; +# this gets `eval`-ed and must return a string to be included in the +# index html page at the bottom. + +# The following variables are documented: +# $_{-version} SVN release of the running script +# $_{-depth} subdir depth relative to the "top" with .gallery2 +# $_{-title} title of the current subdir (.title contents) +# $_{-breadcrumbs} not implemented at the moment + +"
generated by $_{-version}
" diff --git a/include/gallery.css b/include/gallery.css index e1ec824..44e360d 100644 --- a/include/gallery.css +++ b/include/gallery.css @@ -3,6 +3,9 @@ This is a part of mkgallery.pl suite http://www.average.org/mkgallery/ + + DO NOT EDIT THIS FILE OR FACE RISK OF PROBLEMS ON UPGRADE + Instead, include custom modifications into custom.css */ h2.ititle { diff --git a/include/header.pl b/include/header.pl index e1f9c96..62ef345 100644 --- a/include/header.pl +++ b/include/header.pl @@ -1,2 +1,11 @@ +# this gets `eval`-ed and must return a string to be included in the +# index html page at the top. + +# The following variables are documented: +# $_{-version} SVN release of the running script +# $_{-depth} subdir depth relative to the "top" with .gallery2 +# $_{-title} title of the current subdir (.title contents) +# $_{-breadcrumbs} not implemented at the moment + "

$_{-title}

". ($_{-depth}?"":"") -- 2.39.2 From a4459ef8c416655779d060838622932d26cded1b Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 4 Sep 2008 16:39:46 +0000 Subject: [PATCH 05/16] work in progress on rss generation --- include/footer.pl | 2 +- include/header.pl | 6 +++-- mkgallery.pl | 63 +++++++++++++++++++++++++++++++---------------- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/include/footer.pl b/include/footer.pl index 1c246e3..5b2aab1 100644 --- a/include/footer.pl +++ b/include/footer.pl @@ -5,6 +5,6 @@ # $_{-version} SVN release of the running script # $_{-depth} subdir depth relative to the "top" with .gallery2 # $_{-title} title of the current subdir (.title contents) -# $_{-breadcrumbs} not implemented at the moment +# $_{-path} path from the dir that contains .gallery2 "
generated by $_{-version}
" diff --git a/include/header.pl b/include/header.pl index 62ef345..e6cbdd0 100644 --- a/include/header.pl +++ b/include/header.pl @@ -5,7 +5,9 @@ # $_{-version} SVN release of the running script # $_{-depth} subdir depth relative to the "top" with .gallery2 # $_{-title} title of the current subdir (.title contents) -# $_{-breadcrumbs} not implemented at the moment +# $_{-path} path from the dir that contains .gallery2 "

$_{-title}

". -($_{-depth}?"":"") +($_{-depth}? + "": + "") diff --git a/mkgallery.pl b/mkgallery.pl index ad32e66..f672b6c 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -101,15 +101,15 @@ 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; @@ -118,9 +118,9 @@ sub new { -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) { @@ -132,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."/.gallery2"; - } - - my $inc=".gallery2"; - 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; @@ -366,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"; @@ -378,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); -- 2.39.2 From 035a5d0ef46b005f32ffacaba9ae660f9540fed5 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 4 Sep 2008 20:02:49 +0000 Subject: [PATCH 06/16] rss generation seems to work somehow --- mkgallery.pl | 95 +++++++++++++++++++++++++++++++++++++--------------- mkgalrss.pl | 92 -------------------------------------------------- 2 files changed, 68 insertions(+), 119 deletions(-) delete mode 100755 mkgalrss.pl diff --git a/mkgallery.pl b/mkgallery.pl index f672b6c..40840b7 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -44,6 +44,7 @@ my $haverssxml = eval { require XML::RSS; }; { package XML::RSS; } # to make perl compiler happy my @sizes = (160, 640, 1600); +my $incdir = ".gallery2"; ###################################################################### @@ -137,32 +138,35 @@ sub initpaths { my $depth=20; # arbitrary max depth my $fullpath=$self->{-fullpath}; my $inc; - my $rss; my $relpath; if ($incpath) { - $inc = $incpath."/.gallery2"; + $inc = $incpath; + $inc .= '/' unless ($inc =~ m%/$%); } else { - $inc=".gallery2"; - while ( ! -d $fullpath."/".$inc ) { + $inc=""; + while ( ! -d $fullpath."/".$inc."/".$incdir ) { $inc = "../".$inc; last unless ($depth-- > 0); } } if ($depth > 0) { - $self->{-inc} = $inc.'/'; + $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)) {;} + for ($pos=length($fullpath);$dp>0 && $pos>0; + $pos=rindex($fullpath,'/',$pos-1)) { + $dp--; + } my $relpath = substr($fullpath,$pos); $relpath =~ s%^/%%; $self->{-relpath} = $relpath; $self->{-toppath} = substr($fullpath,0,$pos); + #print "rel=$relpath, top=$self->{-toppath}, inc=$inc\n"; initrss($self); } else { $self->{-inc} = 'NO-.INCLUDE-IN-PATH/'; # won't work anyway @@ -174,31 +178,67 @@ sub initpaths { sub initrss { my $self=shift; # this is not a method but we cheat my $fullpath=$self->{-fullpath}; - my $depth=20; + my $inc=$self->{-inc}.$incdir.'/'; + my $conffile=$inc.'rss.conf'; + my $CONF; + + if ($rssfile) { + if (open($CONF,">".$conffile)) { + print $CONF "file: ",$rssfile,"\n"; + close($CONF); + } else { + print STDERR "could not open $conffile: $!\n"; + } + } else { + if (open($CONF,$conffile)) { + my $ln=<$CONF>; + close($CONF); + chop $ln; + my ($k,$v)=split(':', $ln); + $k =~ s/^\s*//; + $k =~ s/\s*$//; + $v =~ s/^\s*//; + $v =~ s/\s*$//; + if ($k eq 'file') { + $rssfile=$v; + } + } + } - return; - return "" unless $rssfile; + return unless ($rssfile); - my $rss=$rssfile; - while ( ! -f $fullpath."/".$rss ) { - $rss = "../".$rss; - last unless ($depth-- > 0); - } - if ($depth > 0) { - $rssobj->{'file'} = $rss; - $rssobj->{'rss'} = new XML::RSS (version=>2); - $rssobj->{'rss'}->parsefile($rss); + $rssobj->{'file'} = $self->{-toppath}.'/'.$rssfile; + $rssobj->{'rss'} = new XML::RSS (version=>'2.0'); + if ( -f $rssobj->{'file'} ) { + $rssobj->{'rss'}->parsefile($rssobj->{'file'}); my $itemstodel = @{$rssobj->{'rss'}->{'items'}} - 15; while ($itemstodel-- > 0) { pop(@{$rssobj->{'rss'}->{'items'}}) } $rssobj->{'rss'}->save($rssobj->{'file'}); - return $rss; } else { - print STDERR "There is no $rssfile in this or parent ". - "directories, you must create one with mkgalrss.pl\n"; - exit 1; + my $link=""; + for (my $pos=index($rssfile,'/');$pos>=0; + $pos=index($rssfile,'/',$pos+1)) { + $link = '../'.$link; + } + + $rssobj->{'rss'}->channel( + title=>'Gallery', + link=>$link, + description=>'Gallery Feed', + #language=>$language, + #rating=>$rating, + #copyright=>$copyright, + #pubDate=>$pubDate, + #lastBuildDate=>$lastBuild, + #docs=>$docs, + #managingEditor=>$editor, + #webMaster=>$webMaster + ); + $rssobj->{'rss'}->save($rssobj->{'file'}); } + $self->{-rss} = $rssobj->{'rss'}; } sub iterate { @@ -466,7 +506,7 @@ sub makeaux { my $dn = $self->{-parent}->{-fullpath}; my $pref = $self->{-previmg}->{-base}; my $nref = $self->{-nextimg}->{-base}; - my $inc = $self->{-inc}; + my $inc = $self->{-inc}.$incdir.'/'; my $title = $self->{-info}->{'Comment'}; $title = $name unless ($title); @@ -586,7 +626,7 @@ sub startindex { binmode($IND, ":utf8"); $self->{-IND} = $IND; - my $inc = $self->{-inc}; + my $inc = $self->{-inc}.$incdir.'/'; my $title = $self->{-title}; my $rsslink=""; if ($self->{-rss}) { @@ -642,7 +682,7 @@ sub endindex { print $IND end_div; my $EVL; - if (open($EVL,$self->{-inc}.'footer.pl')) { + if (open($EVL,$self->{-inc}.$incdir.'/footer.pl')) { my $prm; while (<$EVL>) { $prm .= $_; @@ -665,7 +705,8 @@ sub endindex { $self->{-title}, $self->{-numofimgs}, $self->{-numofsubs}; - my $rsslink=$rssobj->{'rss'}->channel('link')."index.html"; + my $rsslink=$rssobj->{'rss'}->channel('link'). + $self->{-relpath}."/index.html"; $rssobj->{'rss'}->add_item( title => $self->{-title}, link => $rsslink, diff --git a/mkgalrss.pl b/mkgalrss.pl deleted file mode 100755 index 29b4676..0000000 --- a/mkgalrss.pl +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/perl - -# $Id$ - -# Build initial (empty) RSS file for mkgallery.pl - -# Copyright (c) 2007 Eugene G. Crosser - -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. - -use strict; -use Carp; -use Term::ReadLine; -use XML::RSS; -use Getopt::Long; -use Encode; -use encoding 'utf-8'; -binmode(STDOUT, ":utf8"); - -###################################################################### - -my $debug = 0; -my $rssfile = ""; - -unless (GetOptions( - 'help'=>\&help, - 'rssfile=s'=>\$rssfile, - 'debug'=>\$debug)) { - &help; -} - -sub help { - - print STDERR <<__END__; -usage: $0 [options] - --help: print help message and exit - --debug: print a lot of debugging info to stdout as you run - --rssfile=...: name of the rss file to create -__END__ - - exit 1; -} - -unless ($rssfile) { - print STDERR "you must specify --rssfile\n"; - exit 1; -} - -my $term = new Term::ReadLine "Edit RSS Attribute"; - -my $rssobj = new XML::RSS (version=>'2.0'); -die "could not build new RSS object" unless ($rssobj); - -my $OUT = $term->OUT || \*STDOUT; -print $OUT "Enter attributes for this gallery RSS feed\n"; -my $title = $term->readline('Feed title >',''); -$term->addhistory($title) if ($title); -my $link = $term->readline('Gallery root URL >',''); -$term->addhistory($link) if ($link); -my $desc = $term->readline('Gallery description >',''); -$term->addhistory($desc) if ($desc); - -$link .= '/' unless ($link =~ m%/$%); - -$rssobj->channel( - title=>$title, - link=>$link, - description=>$desc, - #language=>$language, - #rating=>$rating, - #copyright=>$copyright, - #pubDate=>$pubDate, - #lastBuildDate=>$lastBuild, - #docs=>$docs, - #managingEditor=>$editor, - #webMaster=>$webMaster - ); -$rssobj->save($rssfile); -- 2.39.2 From 6f6d8eaf8aeb08515d5f11b224d3d5a25b092e78 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 4 Sep 2008 21:33:39 +0000 Subject: [PATCH 07/16] work in progress on rss generation --- mkgallery.pl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mkgallery.pl b/mkgallery.pl index 40840b7..bf37dde 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -109,7 +109,7 @@ sub new { -depth=>$parent->{-depth}+1, -base=>$name, -fullpath=>$parent->{-fullpath}.'/'.$name, - -relpath=>$parent->{-relpath}.'/'.$name, + -relpath=>$parent->{-relpath}.$name.'/', -inc=>'../'.$parent->{-inc}, }; } else { @@ -164,6 +164,7 @@ sub initpaths { } my $relpath = substr($fullpath,$pos); $relpath =~ s%^/%%; + $relpath .= '/' if ($relpath); $self->{-relpath} = $relpath; $self->{-toppath} = substr($fullpath,0,$pos); #print "rel=$relpath, top=$self->{-toppath}, inc=$inc\n"; @@ -179,7 +180,7 @@ sub initrss { my $self=shift; # this is not a method but we cheat my $fullpath=$self->{-fullpath}; my $inc=$self->{-inc}.$incdir.'/'; - my $conffile=$inc.'rss.conf'; + my $conffile=$self->{-toppath}.'/'.$incdir.'/rss.conf'; my $CONF; if ($rssfile) { @@ -629,11 +630,11 @@ sub startindex { my $inc = $self->{-inc}.$incdir.'/'; my $title = $self->{-title}; my $rsslink=""; - if ($self->{-rss}) { + if ($rssobj) { $rsslink=Link({-rel=>'alternate', -type=>'application/rss+xml', -title=>'RSS', - -href=>$self->{-rss}}); + -href=>$self->{-inc}.$rssfile}); } print $IND start_html(-title => $title, -encoding=>"utf-8", @@ -657,7 +658,7 @@ sub startindex { -id => 'indexContainer'}), "\n"; my $EVL; - if (open($EVL,$inc.'header.pl')) { + if (open($EVL,$self->{-toppath}.'/'.$incdir.'/header.pl')) { my $prm; while (<$EVL>) { $prm .= $_; @@ -682,7 +683,7 @@ sub endindex { print $IND end_div; my $EVL; - if (open($EVL,$self->{-inc}.$incdir.'/footer.pl')) { + if (open($EVL,$self->{-toppath}.'/'.$incdir.'/footer.pl')) { my $prm; while (<$EVL>) { $prm .= $_; @@ -706,7 +707,7 @@ sub endindex { $self->{-numofimgs}, $self->{-numofsubs}; my $rsslink=$rssobj->{'rss'}->channel('link'). - $self->{-relpath}."/index.html"; + $self->{-relpath}."index.html"; $rssobj->{'rss'}->add_item( title => $self->{-title}, link => $rsslink, -- 2.39.2 From 93b575d6b3d8d6f9a38e25e70c21fdcfa43c4755 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Fri, 5 Sep 2008 09:46:01 +0000 Subject: [PATCH 08/16] RSS generation OK, now it creates RSS file with apparently correct *relative* links It seems that client(s), at least Firefox, does not like relative links. In short, it does not work. Don't use it. --- mkgallery.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mkgallery.pl b/mkgallery.pl index bf37dde..0e3423c 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -29,6 +29,7 @@ package FsObj; use strict; use Carp; use POSIX qw/getcwd strftime/; +use HTTP::Date; use CGI qw/:html *table *Tr *td *center *div *Link/; use Image::Info qw/image_info dim/; use Term::ReadLine; @@ -179,8 +180,9 @@ sub initpaths { sub initrss { my $self=shift; # this is not a method but we cheat my $fullpath=$self->{-fullpath}; + my $toppath=$self->{-toppath}; my $inc=$self->{-inc}.$incdir.'/'; - my $conffile=$self->{-toppath}.'/'.$incdir.'/rss.conf'; + my $conffile=$toppath.'/'.$incdir.'/rss.conf'; my $CONF; if ($rssfile) { @@ -218,9 +220,16 @@ sub initrss { } $rssobj->{'rss'}->save($rssobj->{'file'}); } else { - my $link=""; - for (my $pos=index($rssfile,'/');$pos>=0; - $pos=index($rssfile,'/',$pos+1)) { + my $link; + my $p1; + my $p2; + for ($p1=0,$p2=length($toppath); + substr($rssfile,$p1,3) eq '../' && $p2>0; + $p1+=3,$p2=rindex($toppath,'/',$p2-1)) {;} + $link=substr($toppath,$p2); + $link =~ s%^/%%; + $link .= '/' if ($link); + while (($p1=index($rssfile,'/',$p1+1)) >= 0) { $link = '../'.$link; } @@ -712,6 +721,7 @@ sub endindex { title => $self->{-title}, link => $rsslink, description => $rsstitle, + pubDate => time2str(time), ); } } -- 2.39.2 From c54609fad7876eddd650ffc960d1fa463cf44845 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Fri, 5 Sep 2008 12:22:47 +0000 Subject: [PATCH 09/16] error repor when header/footer absent --- mkgallery.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mkgallery.pl b/mkgallery.pl index 0e3423c..f7ef6c3 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -681,6 +681,9 @@ sub startindex { ); print $IND eval $prm,"\n"; } else { + 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", } @@ -705,6 +708,10 @@ sub endindex { -breadcrumbs => "breadcrumbs unimplemented", ); print $IND eval $prm,"\n"; + } else { + print STDERR "could not open ", + $self->{-toppath}.'/'.$incdir.'/footer.pl', + " ($!), reverting to default empty footer"; } print $IND end_html,"\n"; -- 2.39.2 From ac56653c78029ac04ba470022e46d7169fcefbd7 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Fri, 5 Sep 2008 12:38:04 +0000 Subject: [PATCH 10/16] calculate depth against top, not against root (current dir) --- mkgallery.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkgallery.pl b/mkgallery.pl index f7ef6c3..1031da6 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -117,7 +117,6 @@ sub new { $class = $this; my $root=shift; $self = { - -depth=>0, -root=>$root, -fullpath=>$root, }; @@ -159,6 +158,7 @@ sub initpaths { $pos=index($inc,'/',$pos+1)) { $dp++; } + $self->{-depth} = $dp; for ($pos=length($fullpath);$dp>0 && $pos>0; $pos=rindex($fullpath,'/',$pos-1)) { $dp--; @@ -174,6 +174,7 @@ sub initpaths { $self->{-inc} = 'NO-.INCLUDE-IN-PATH/'; # won't work anyway $self->{-rss} = ''; $self->{-relpath} = ''; + $self->{-depth} = 0; } } -- 2.39.2 From 5527f9d9dd107c49860360979bcea661d83039e2 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Fri, 5 Sep 2008 13:12:33 +0000 Subject: [PATCH 11/16] wrong way to check if cachel exists... size of first element (with zero 'id' field) was not calculating --- include/show.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/show.js b/include/show.js index fdce267..2d5f5b1 100644 --- a/include/show.js +++ b/include/show.js @@ -284,7 +284,7 @@ var Show = new Class({ }, calcsize: function(cachel){ - if (! cachel.id) { + if (! cachel.url) { return { position: 'absolute', top: 0+'px', -- 2.39.2 From f7b9a9ba521a5b36685838e275e70e759d281177 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Fri, 5 Sep 2008 14:44:40 +0000 Subject: [PATCH 12/16] neat footer --- include/footer.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/footer.pl b/include/footer.pl index 5b2aab1..ab700c1 100644 --- a/include/footer.pl +++ b/include/footer.pl @@ -7,4 +7,4 @@ # $_{-title} title of the current subdir (.title contents) # $_{-path} path from the dir that contains .gallery2 -"
generated by $_{-version}
" +"
generated by mkgallery
" -- 2.39.2 From 06a8a4d9a7533249cfb200e0ddcaff3d76f6b41f Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 8 Jan 2009 10:23:18 +0000 Subject: [PATCH 13/16] utf encoding for another output file --- mkgallery.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mkgallery.pl b/mkgallery.pl index 1031da6..747cb6c 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -599,6 +599,7 @@ sub makeaux { 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", -- 2.39.2 From 1b0fd8048f11cfa99660819822cad6bff5ce4238 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Mon, 12 Jan 2009 19:12:45 +0000 Subject: [PATCH 14/16] google maps link for geotagged photos --- include/gallery.css | 13 +++++++++++++ include/smallglobe.png | Bin 0 -> 445 bytes mkgallery.pl | 33 +++++++++++++++++++++++++++------ 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 include/smallglobe.png diff --git a/include/gallery.css b/include/gallery.css index 44e360d..96800a8 100644 --- a/include/gallery.css +++ b/include/gallery.css @@ -292,3 +292,16 @@ table.picframe { color: #FFF; text-align: left; } + +div.slideimage { + position: relative; +} + +div.geoloc { + position: absolute; + right: 0px; + top: 0px; + width: 14px; + height: 14px; + background: url(smallglobe.png) no-repeat; +} diff --git a/include/smallglobe.png b/include/smallglobe.png new file mode 100644 index 0000000000000000000000000000000000000000..0f135ffe14bafb1bfa0814dc26807923c948849a GIT binary patch literal 445 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT0xamSQK*5Dp-y;YjHK@;M7UB8!1^ zDF`z@KE$31WJs2{MwA5SrEalo zF){a&q4ym}0oD)q<=Pi4c)`BGV4IVdwKl7xXKH?-fJ;tLB+Hfl#B@y##z5|ab{VRR zDkdZ>R1^@pc$r!BNlf?b?*E7XA2_t(^Sv{-=c+$nQ*6*-`p4lI_qoS;8@Qttd>@Lx zyXeHcf3c%-R&cC~4_kt{hp9}GZ2ZTT{KlC)eRVNO#wxLjq8)n|CMgCIW zdd^cn?wk$%pt%2?fJ_-XP!WJ*>QK3*U={-fullpath}; return 0 unless ( -f $fullpath ); + + if ($havegeoloc) { + my $exif = new Image::ExifTool; + $exif->ExtractInfo($fullpath); + my ($la,$lo) = $exif->GetLocation(); + if ($la && $lo) { + $self->{-geoloc} = [$la,$lo]; + } + } + my $info = image_info($fullpath); if (my $error = $info->{error}) { if (($error !~ "Unrecognized file format") && @@ -785,20 +798,28 @@ sub img_entry { $self->{-parent}->{-numofimgs}++; print $IND a({-name=>$name}),"\n", - start_table({-class=>'slide'}),start_Tr,start_td,"\n", - div({-class=>'slidetitle'}, + start_table({-class=>'slide'}),start_Tr,start_td,"\n"; + print $IND div({-class=>'slidetitle'}, "\n ",a({-href=>".html/$name-info.html", -title=>'Image Info: '.$name, -class=>'infoBox'}, $title),"\n"),"\n", - div({-class=>'slideimage'}, - "\n ",a({-href=>".html/$name-static.html", + start_div({-class=>'slideimage'}); + if ($self->{-geoloc}) { + my ($la,$lo) = @{$self->{-geoloc}}; + print $IND a({-href=>"http://maps.google.com/". + "?q=$la,$lo&ll=$la,$lo", + -title=>"$la,$lo", + -class=>'geoloc'}, + div({-class=>'geoloc'},"G")),"\n"; + } + print $IND a({-href=>".html/$name-static.html", -title=>$title, -class=>'showImage', -rel=>'i'.$name}, img({-src=>$thumb, -class=>'thumbnail', - -alt=>$title})),"\n"),"\n", + -alt=>$title})),"\n",end_div, start_div({-class=>'varimages',-id=>'i'.$name,-title=>$title}),"\n"; foreach my $sz(@sizes) { my $src=$self->{$sz}->{'url'}; -- 2.39.2 From 2c5979448de3845d3a813638968220db02b1a2b6 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Mon, 12 Jan 2009 19:19:09 +0000 Subject: [PATCH 15/16] empty text content of globe div --- mkgallery.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkgallery.pl b/mkgallery.pl index bcd6a00..bd20c8c 100755 --- a/mkgallery.pl +++ b/mkgallery.pl @@ -811,7 +811,7 @@ sub img_entry { "?q=$la,$lo&ll=$la,$lo", -title=>"$la,$lo", -class=>'geoloc'}, - div({-class=>'geoloc'},"G")),"\n"; + div({-class=>'geoloc'},"")),"\n"; } print $IND a({-href=>".html/$name-static.html", -title=>$title, -- 2.39.2 From f75245bbbc16c9c801f7497daae4836633ed3c7d Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Mon, 23 Feb 2009 22:04:37 +0000 Subject: [PATCH 16/16] typos fixed, todo trimmed --- README | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/README b/README index 354dfd5..61adcea 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ README document for mkgallery script - Copyright (c) 2006 Eugene G. Crosser + Copyright (c) 2006-2009 Eugene G. Crosser This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -23,15 +23,15 @@ mkgallery.pl traverses directory tree starting from current directory downwards, and in each directory creates an index.html file with the list of subdirectories and the list of image files in the directory. -Fielsystem objects starting with '.' are not processed. For every +Filesystem objects starting with '.' are not processed. For every directory, a file ".title" is checked, and created if absent, with the -title for this album. Two subdirectories are created with scaled down -versions of the images: ".640" and ".160", and a direcotory named ".html" -containging slideshow pages (and info pages for non-javascript clients). +title for this album. Subdirectories are created with scaled down +versions of the images, and a directory named ".html" containging +slideshow pages (and info pages for non-javascript clients). For the thing to work, you must create a subdirectory named ".gallery2" at the root of your image gallery, or somewhere upstairs in the -document tree, and put there files from the subdirectory "include" +document tree, and put there the files from the "include" subdirectory of this distribution. Then, chdir to the root of your gallery and run "mkgallery.pl" script. First time, you will be asked to enter titles for all subdirectories ("Albums"); if you wish to recreate the titles, @@ -53,7 +53,7 @@ command-line options: First must be created with mkgalrss.pl script. The only way to specify titles for individual pictures is to write -comments into the image files. +comments into the image files (in UTF-8 encoding). "mkindex.pl" is a simple script that is completely unrelated to the gallery (theoretically). If your tree starts with YYYY/DD (four @@ -71,11 +71,10 @@ Homepage: http://www.average.org/mkgallery/ TODO: -- implement header and footer insertion - make index.html depend of .title and directory timestamps -- rebuild htmls in .html when directory timestamp chnges (images added) -- make links in the rss file relative +- rebuild htmls in .html when directory timestamp changes (images added) +- make links in the rss file work - try to make showwin "Extending: Element" and get rid of domelement() - dummy getter and getCoordinates() replacement function + dummy getter and getCoordinates() replacement function (?) Eugene Crosser -- 2.39.2