|
|
@ -118,6 +118,35 @@ sub save { |
|
|
|
$self->rendered(); |
|
|
|
$self->rendered(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub latest { |
|
|
|
|
|
|
|
my ($self) = @_; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eval { |
|
|
|
|
|
|
|
my @images = (); |
|
|
|
|
|
|
|
my $root = $self->app->config->{imgbin}->{root}; |
|
|
|
|
|
|
|
opendir(my $DH, $root) |
|
|
|
|
|
|
|
or die("opendir: $!\n"); |
|
|
|
|
|
|
|
my @items = grep { m/\d+\.json/oi } readdir($DH); |
|
|
|
|
|
|
|
closedir($DH); |
|
|
|
|
|
|
|
@items = map { m/(\d+)\.json/oi } @items; |
|
|
|
|
|
|
|
@items = sort { $b <=> $a } @items; |
|
|
|
|
|
|
|
my $json = Mojo::JSON->new; |
|
|
|
|
|
|
|
foreach my $time (splice(@items, 0, 10)) { |
|
|
|
|
|
|
|
my $data = Mojo::Asset::File->new(path => $self->_data_path($time)); |
|
|
|
|
|
|
|
my $image = $json->decode($data->slurp); |
|
|
|
|
|
|
|
$image->{path} = $self->_thumb_path($time); |
|
|
|
|
|
|
|
$image->{url} = sprintf '/imgbin/%d', $time; |
|
|
|
|
|
|
|
push @images, $image; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$self->stash(images => \@images); |
|
|
|
|
|
|
|
$self->render(); |
|
|
|
|
|
|
|
} or do { |
|
|
|
|
|
|
|
$self->flash(error => $@); |
|
|
|
|
|
|
|
$self->redirect_to('/imgbin'); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sub prune { |
|
|
|
sub prune { |
|
|
|
my ($self) = @_; |
|
|
|
my ($self) = @_; |
|
|
|
|
|
|
|
|
|
|
|