diff --git a/lib/LDV.pm b/lib/LDV.pm index 512a306..fa8b968 100644 --- a/lib/LDV.pm +++ b/lib/LDV.pm @@ -14,7 +14,7 @@ sub startup { $self->plugin(Config => {file => $config}); $self->app->mode('production'); - $self->app->secret($self->app->config->{secret}); + $self->app->secrets([ $self->app->config->{secret} ]); $self->app->attr(email => sub { require LDV::Email; diff --git a/lib/LDV/Imgbin.pm b/lib/LDV/Imgbin.pm index 114eb74..28047d1 100644 --- a/lib/LDV/Imgbin.pm +++ b/lib/LDV/Imgbin.pm @@ -5,7 +5,7 @@ use warnings; use utf8; use Mojo::Base 'Mojolicious::Controller'; -use Mojo::JSON; +use JSON qw(encode_json decode_json); use Mojo::Asset::File; use Imager; @@ -46,7 +46,7 @@ sub view { my $path = $self->_data_path($time); my $data = Mojo::Asset::File->new(path => $path); $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}); $self->stash(image => $json); 1; @@ -106,7 +106,7 @@ sub save { $upload->move_to($self->_image_path($time, $json->{format}, 'fullpath')); 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)); $self->redirect_to("/imgbin/$time"); @@ -132,10 +132,9 @@ sub latest { 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); + my $image = decode_json($data->slurp); $image->{path} = $self->_thumb_path($time); $image->{url} = sprintf '/imgbin/%d', $time; push @images, $image;