package Memories;
use strict;
our $VERSION = "1.2";
-use Maypole::Application qw(Upload Authentication::UserSessionCookie -Debug);
+use Maypole::Application qw(Upload Authentication::UserSessionCookie);
use HTML::TagCloud;
use URI;
use Memories::Config;
return DECLINED if $self->path =~/static|store/; # XXX
$r->get_user;
if (!$r->user and $self->path =~ /upload/) { $r->template("login"); }
+ # Don't let 'em go until they've fixed it
+ warn "Quarantine is : ".$r->session->{quarantined};
+ if ($r->session->{quarantined} and $self->path !~ /js$/) {
+ $r->table("photo"); $r->action("quarantine");
+ $r->model_class("Memories::Photo");
+ }
return OK;
}
my ($self, $r) = @_;
my $upload = $r->{ar}->upload("photo");
# Check $self->type
- my @photos = $self->upload_jpeg($upload->tempname, ($r->params->{title}||basename($upload->filename)), $r->params->{tags}, $r);
+ my @photos = ($self->upload_jpeg($upload->tempname, ($r->params->{title}||basename($upload->filename)), $r->params->{tags}, $r));
my @quarantined = grep { !$_->tags } @photos;
+ warn "Quarantined these photos: ".join(",", map {$_->id} @quarantined);
# Set it up to go again
+ if (@quarantined) {
+ $r->{session}{quarantined} = join ",", sort map { $_->id} @quarantined;
+ warn "Setting quarantineined to: ".( join ",", sort map { $_->id} @quarantined);
+ $r->objects(\@quarantined);
+ $r->template("quarantine");
+ return;
+ }
$r->objects(\@photos);
- $r->template("view");
+ if (@photos > 1) { $r->template("list") }
+ else { $r->template("view"); }
$r->message("Thanks for the upload!");
- # Deal with the quarantined
+}
+
+sub quarantine :Exported {
+ my ($self, $r) = @_;
+ my @quarantined = split /,/, $r->{session}{quarantined};
+ my %q = map { $_ => 1 } @quarantined;
+ warn "Before we had these quarantined: @{[ keys %q ]}";
+ for (map /(\d+)/,grep /tags\d+/, keys %{$r->{params}}) {
+ my $tags = $r->{params}{"tags$_"};
+ warn "Got tags for $_: <$tags>";
+ next unless $tags;
+ if (my $photo = $self->retrieve($_)) {
+ $photo->add_tags($tags);
+ delete $q{$_};
+ }
+ }
+ $r->{session}{quarantined} = join ",", sort keys %q;
+ warn "After, we have these quarantined: @{[ keys %q ]}";
+ warn "And we set session to $r->{session}{quarantined}";
+ if (!$r->{session}{quarantined}) {
+ $r->template("list");
+ $r->objects([ map { $self->retrieve($_) } @quarantined ]);
+ } else {
+ $r->objects([ map { $self->retrieve($_) } sort keys %q ]);
+ }
}
sub upload_jpeg {
my ($self, $filename, $title, $tags, $r) = @_;
- my $quarantine;
my $photo = $self->create({
uploader => $r->user,
uploaded => Time::Piece->new(),
--- /dev/null
+[% INCLUDE header %]
+[% PROCESS macros %]
+<h1> Quarantined photos </h1>
+
+<p> The following photos need to be tagged. Sorry to be anal about this,
+but we really need to have photos tagged if we're going to be able to
+find them in the future. You won't be able to do anything, anything at
+all, until we've resolved this. Please, please put some tags in the
+boxes below. (You can make it easier for yourself in the future by
+adding IPTC tags to your photos in your photo management software.)
+</p>
+
+<div id="suggestionlist"> </div>
+<form action="[%base%]/photo/quarantine/" method="post">
+<table class="userlist">
+[% WHILE objects.size > 0 %]
+[% SET triple = objects.splice(0,3) %]
+ <tr>
+ [% FOR photo = triple %]
+ <td>
+ [% minithumb(photo, 1) %]
+ <br>
+ <input name="tags[%photo.id%]" id="tags[%photo.id%]">
+ <script type="text/javascript">
+ addHandler(document.getElementById("tags[%photo.id%]")) </script>
+ </td>
+ [% END %]
+ </tr>
+[% END %]
+</table>
+<input type="submit" value="Tag it!">
+</form>
+
+[% INCLUDE pager %]
+[% INCLUDE footer %]