]> www.average.org Git - mkgallery.git/blobdiff - mkgallery.pl
remove rss reference, update todo
[mkgallery.git] / mkgallery.pl
index de6b92065611c5a7caa8e22edcccd7bd4156ad7f..1132a7f0c292868763104fd7e77d363714948ca9 100755 (executable)
@@ -6,7 +6,7 @@ my $version='$Id$';
 # Makes use of modified "slideshow" javascript by Samuel Birch
 # http://www.phatfusion.net/slideshow/
 
-# Copyright (c) 2006-2008 Eugene G. Crosser
+# Copyright (c) 2006-2013 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
@@ -35,18 +35,13 @@ use Image::Info qw/image_info dim/;
 use Term::ReadLine;
 use Getopt::Long;
 use Encode;
+use UUID;
 #use encoding 'utf-8';
 binmode(STDOUT, ":utf8");
 
 my $haveimagick = eval { require Image::Magick; };
 { package Image::Magick; }     # to make perl compiler happy
 
-my $haverss = eval { require XML::RSS; };
-{ package XML::RSS; }          # to make perl compiler happy
-
-my $haveatom = eval { require XML::Atom; };
-{ package XML::Atom; }         # to make perl compiler happy
-
 my $havegeoloc = eval { require Image::ExifTool::Location; };
 { package Image::ExifTool::Location; } # to make perl compiler happy
 
@@ -56,11 +51,9 @@ my $incdir = ".gallery2";
 ######################################################################
 
 my $incpath;
-my $rssobj;
 my $debug = 0;
 my $asktitle = 0;
 my $noasktitle = 0;
-my $feed = "";
 
 charset("utf-8");
 
@@ -69,20 +62,13 @@ unless (GetOptions(
                'incpath'=>\$incpath,
                'asktitle'=>\$asktitle,
                'noasktitle'=>\$noasktitle,
-               'feed=s'=>\$feed,
                'debug'=>\$debug)) {
        &help;
 }
 
-if ($feed && ! ($haverss || $haveatom)) {
-       print STDERR "You need to get XML::RSS and/or XML::Atom to use --feed\n";
-       exit 1;
-}
-
 my $term = new Term::ReadLine "Edit Title";
 
 FsObj->new(getcwd)->iterate;
-if ($rssobj) { $rssobj->{-rss}->save($rssobj->{-savepath}); }
 
 sub help {
 
@@ -95,7 +81,6 @@ usage: $0 [options]
  --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.
- --feed=...:   build RSS feed for newly added "albums", give name of rss file
 __END__
 
        exit 1;
@@ -126,7 +111,7 @@ sub new {
                                -root=>$root,
                                -fullpath=>$root,
                        };
-               # fill in -inc, -rss, -relpath
+               # fill in -inc, -relpath
                initpaths($self); # we are not blessed yet, so cheat.
        }
        bless $self, $class;
@@ -175,77 +160,13 @@ sub initpaths {
                $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
-               $self->{-rss} = '';
                $self->{-relpath} = '';
                $self->{-depth} = 0;
        }
 }
 
-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=$toppath.'/'.$incdir.'/feed.conf';
-       my $CONF;
-
-       if (! $incpath) {
-               if ($feed) {
-                       if (open($CONF,">".$conffile)) {
-                               print $CONF $feed,"\n";
-                               close($CONF);
-                       } else {
-                               print STDERR "could not open $conffile: $!\n";
-                       }
-               } else {
-                       if (open($CONF,$conffile)) {
-                               $feed=<$CONF>;
-                               close($CONF);
-                               chop $feed;
-                       }
-               }
-       }
-
-       return unless ($feed);
-
-       my ($feedfile, $feedbase, $feedhub) = split(',', $feed);
-       $feedbase .= '/' unless ($feedbase =~ /\/$/);
-       print "($feedfile, $feedbase, $feedhub)\n";
-
-       $rssobj->{-savepath} = $self->{-toppath}.'/'.$feedfile;
-       $rssobj->{-file} = $feedfile;
-       $rssobj->{-base} = $feedbase;
-       $rssobj->{-hub} = $feedhub;
-       $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->{-savepath});
-       } else {
-               $rssobj->{-rss}->channel(
-                       title=>'Gallery',
-                       link=>$feedbase,
-                       description=>'Gallery Feed',
-                       #language=>$language,
-                       #rating=>$rating,
-                       #copyright=>$copyright,
-                       #pubDate=>$pubDate,
-                       #lastBuildDate=>$lastBuild,
-                       #docs=>$docs,
-                       #managingEditor=>$editor,
-                       #webMaster=>$webMaster
-               );
-               $rssobj->{-rss}->save($rssobj->{-savepath});
-       }
-       $self->{-rss} = $rssobj->{-rss};
-}
-
 sub iterate {
        my $self = shift;
        my $fullpath .= $self->{-fullpath};
@@ -435,7 +356,9 @@ sub edittitle {
        my $self = shift;
        my $fullpath = $self->{-fullpath};
        my $title;
+       my $titleimage;
        my $T;
+       my $TI;
        if (open($T,'<'.$fullpath.'/.title')) {
                binmode($T, ":utf8");
                $title = <$T>;
@@ -458,6 +381,14 @@ sub edittitle {
                $title=$self->{-relpath};
        }
        $self->{-title}=$title;
+       if (open($TI,'<'.$fullpath.'/.titleimage')) {
+               binmode($TI, ":utf8");
+               $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);
 }
 
@@ -645,16 +576,9 @@ sub startindex {
 
        my $inc = $self->{-inc}.$incdir.'/';
        my $title = $self->{-title};
-       my $rsslink="";
-       if ($rssobj) {
-               $rsslink=Link({-rel=>'alternate',
-                               -type=>'application/rss+xml',
-                               -title=>'Gallery Feed',
-                               -href=>$rssobj->{-base}.$rssobj->{-file}});
-       }
+       my $titleimage = $self->{-titleimage};  
        print $IND start_html(-title => $title,
                        -encoding=>"utf-8",
-                       -head=>$rsslink,
                        -style=>[
                                {-src=>$inc."gallery.css"},
                                {-src=>$inc."custom.css"},
@@ -684,6 +608,7 @@ sub startindex {
                        -version        => $version,
                        -depth          => $self->{-depth},
                        -title          => $title,
+                       -titleimage     => $titleimage,
                        -path           => $self->{-fullpath},
                        -breadcrumbs    => "breadcrumbs unimplemented",
                );
@@ -692,8 +617,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";
        }
 }
 
@@ -713,6 +644,7 @@ sub endindex {
                        -version        => $version,
                        -depth          => $self->{-depth},
                        -title          => $self->{-title},
+                       -titleimage     => $self->{-titleimage},
                        -breadcrumbs    => "breadcrumbs unimplemented",
                );
                print $IND eval $prm,"\n";
@@ -725,20 +657,6 @@ sub endindex {
 
        close($IND) if ($IND);
        undef $self->{-IND};
-       if ($rssobj) {
-               my $rsstitle=sprintf "%s [%d images, %d subalbums]",
-                               $self->{-title},
-                               $self->{-numofimgs},
-                               $self->{-numofsubs};
-               my $rsslink=$rssobj->{-rss}->channel('link').
-                       $self->{-relpath}."index.html";
-               $rssobj->{-rss}->add_item(
-                       title           => $self->{-title},
-                       link            => $rsslink,
-                       description     => $rsstitle,
-                       pubDate         => time2str(time),
-               );
-       }
 }
 
 sub startsublist {