# 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
my $haveimagick = eval { require Image::Magick; };
{ package Image::Magick; } # to make perl compiler happy
-my $havefeed = eval { require XML::FeedPP; };
-{ package XML::FeedPP; } # to make perl compiler happy
-
my $havegeoloc = eval { require Image::ExifTool::Location; };
{ package Image::ExifTool::Location; } # to make perl compiler happy
######################################################################
my $incpath;
-my $feedobj;
my $debug = 0;
my $asktitle = 0;
my $noasktitle = 0;
-my $feed = "";
charset("utf-8");
'incpath'=>\$incpath,
'asktitle'=>\$asktitle,
'noasktitle'=>\$noasktitle,
- 'feed=s'=>\$feed,
'debug'=>\$debug)) {
&help;
}
-if ($feed && !$havefeed) {
- print STDERR "You need to install XML::FeedPP to use --feed\n";
- exit 1;
-}
-
my $term = new Term::ReadLine "Edit Title";
FsObj->new(getcwd)->iterate;
-if ($feedobj) {
- $feedobj->{-feed}->pubDate(time);
- $feedobj->{-feed}->to_file($feedobj->{-savepath});
-}
sub help {
--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 Atom feed for newly added "albums",
- enter filename, base URL, and optionally PuSH hub url,
- separated by commas. (Note: PuSH obviously does not work
- "out of the box" for static tree! You need a separate
- "watcher" script to do the publishing for you.)
__END__
exit 1;
-root=>$root,
-fullpath=>$root,
};
- # fill in -inc, -feed, -relpath
+ # fill in -inc, -relpath
initpaths($self); # we are not blessed yet, so cheat.
}
bless $self, $class;
$self->{-relpath} = $relpath;
$self->{-toppath} = substr($fullpath,0,$pos);
#print "rel=$relpath, top=$self->{-toppath}, inc=$inc\n";
- initfeed($self);
} else {
$self->{-inc} = 'NO-.INCLUDE-IN-PATH/'; # won't work anyway
- $self->{-feed} = '';
$self->{-relpath} = '';
$self->{-depth} = 0;
}
}
-sub initfeed {
- 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";
-
- $feedobj->{-savepath} = $self->{-toppath}.'/'.$feedfile;
- $feedobj->{-file} = $feedfile;
- $feedobj->{-base} = $feedbase;
- $feedobj->{-hub} = $feedhub;
- if ( -f $feedobj->{-file} ) {
- $feedobj->{-feed} = XML::FeedPP::Atom::Atom10->new(
- $feedobj->{-file});
- $feedobj->{-feed}->limit_item(15);
- } else {
- $feedobj->{-feed} = XML::FeedPP::Atom::Atom10->new;
- $feedobj->{-feed}->title("Gallery");
- $feedobj->{-feed}->description("generated by ".
- "<a href=\"http://www.average.org/mkgallery/\">".
- "mkgallery</a>");
- $feedobj->{-feed}->link($feedbase, 'type' => 'text/html', 'rel' => 'alternate');
- $feedobj->{-feed}->xmlns("xmlns:ostatus" =>
- "http://ostatus.org/schema/1.0");
- #$feedobj->{-feed}->copyright("");
- #$feedobj->{-feed}->language("en");
- #$feedobj->{-feed}->image($url, $tit, $link, $desc, $w, $h);
- }
- $self->{-feed} = $feedobj->{-feed};
-}
-
sub iterate {
my $self = shift;
my $fullpath .= $self->{-fullpath};
my $inc = $self->{-inc}.$incdir.'/';
my $title = $self->{-title};
- my $feedlink="";
- if ($feedobj) {
- $feedlink=Link({-rel=>'alternate',
- -type=>'application/atom+xml',
- -title=>'Gallery Feed',
- -href=>$feedobj->{-base}.$feedobj->{-file}});
- }
print $IND start_html(-title => $title,
-encoding=>"utf-8",
- -head=>$feedlink,
-style=>[
{-src=>$inc."gallery.css"},
{-src=>$inc."custom.css"},
close($IND) if ($IND);
undef $self->{-IND};
- if ($feedobj) {
- my $feedtitle=sprintf "%s [%d images, %d subalbums]",
- $self->{-title},
- $self->{-numofimgs},
- $self->{-numofsubs};
- my $feedlink=$feedobj->{-feed}->link.
- $self->{-relpath}."index.html";
- my $uu;
- my $us;
- UUID::generate($uu);
- UUID::unparse($uu, $us);
- $feedobj->{-feed}->add_item(
- title => $self->{-title},
- link => $feedlink,
- description => $feedtitle,
- pubDate => time,
- guid => $us,
- );
- }
}
sub startsublist {