|
|
@ -5,7 +5,7 @@ use warnings; |
|
|
|
use utf8; |
|
|
|
use utf8; |
|
|
|
|
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious::Controller'; |
|
|
|
use Mojo::Base 'Mojolicious::Controller'; |
|
|
|
use Mojo::JSON; |
|
|
|
use JSON qw(encode_json decode_json); |
|
|
|
use Mojo::Asset::File; |
|
|
|
use Mojo::Asset::File; |
|
|
|
use Imager; |
|
|
|
use Imager; |
|
|
|
|
|
|
|
|
|
|
@ -46,7 +46,7 @@ sub view { |
|
|
|
my $path = $self->_data_path($time); |
|
|
|
my $path = $self->_data_path($time); |
|
|
|
my $data = Mojo::Asset::File->new(path => $path); |
|
|
|
my $data = Mojo::Asset::File->new(path => $path); |
|
|
|
$data->cleanup(0); |
|
|
|
$data->cleanup(0); |
|
|
|
my $json = Mojo::JSON->new->decode($data->slurp); |
|
|
|
my $json = decode_json($data->slurp); |
|
|
|
$json->{path} = $self->_image_path($time, $json->{format}); |
|
|
|
$json->{path} = $self->_image_path($time, $json->{format}); |
|
|
|
|
|
|
|
|
|
|
|
$self->stash(image => $json); 1; |
|
|
|
$self->stash(image => $json); 1; |
|
|
@ -106,7 +106,7 @@ sub save { |
|
|
|
$upload->move_to($self->_image_path($time, $json->{format}, 'fullpath')); |
|
|
|
$upload->move_to($self->_image_path($time, $json->{format}, 'fullpath')); |
|
|
|
|
|
|
|
|
|
|
|
my $data = Mojo::Asset::File->new(path => $self->_data_path($time)); |
|
|
|
my $data = Mojo::Asset::File->new(path => $self->_data_path($time)); |
|
|
|
$data->add_chunk(Mojo::JSON->new->encode($json)); |
|
|
|
$data->add_chunk(encode_json($json)); |
|
|
|
$data->move_to($self->_data_path($time)); |
|
|
|
$data->move_to($self->_data_path($time)); |
|
|
|
|
|
|
|
|
|
|
|
$self->redirect_to("/imgbin/$time"); |
|
|
|
$self->redirect_to("/imgbin/$time"); |
|
|
@ -132,10 +132,9 @@ sub latest { |
|
|
|
closedir($DH); |
|
|
|
closedir($DH); |
|
|
|
@items = map { m/(\d+)\.json/oi } @items; |
|
|
|
@items = map { m/(\d+)\.json/oi } @items; |
|
|
|
@items = sort { $b <=> $a } @items; |
|
|
|
@items = sort { $b <=> $a } @items; |
|
|
|
my $json = Mojo::JSON->new; |
|
|
|
|
|
|
|
foreach my $time (splice(@items, 0, 10)) { |
|
|
|
foreach my $time (splice(@items, 0, 10)) { |
|
|
|
my $data = Mojo::Asset::File->new(path => $self->_data_path($time)); |
|
|
|
my $data = Mojo::Asset::File->new(path => $self->_data_path($time)); |
|
|
|
my $image = $json->decode($data->slurp); |
|
|
|
my $image = decode_json($data->slurp); |
|
|
|
$image->{path} = $self->_thumb_path($time); |
|
|
|
$image->{path} = $self->_thumb_path($time); |
|
|
|
$image->{url} = sprintf '/imgbin/%d', $time; |
|
|
|
$image->{url} = sprintf '/imgbin/%d', $time; |
|
|
|
push @images, $image; |
|
|
|
push @images, $image; |
|
|
|