diff --git a/lib/LDV.pm b/lib/LDV.pm index d0b84bd..512a306 100644 --- a/lib/LDV.pm +++ b/lib/LDV.pm @@ -55,14 +55,16 @@ sub startup { } { # /imgbin + my $conf = $self->app->config->{imgbin}; my $ib = $r->route('/imgbin') -> to(controller => 'imgbin'); $ib->post('/') -> to(action => 'save'); $ib->get ('/') -> to(action => 'create'); $ib->route('/:time', time => qr/\d+/) ->via('GET') -> to(action => 'view'); #$ib->get('/prune') -> to(action => 'prune'); + $ib->get ('/latest') -> to(action => 'latest') + if ($conf->{show_latest}); - my $conf = $self->app->config->{imgbin}; mkdir $self->app->home->rel_dir($conf->{root}); mkdir $self->app->home->rel_file('public/images'); mkdir $self->app->home->rel_file('public/images/full'); diff --git a/public/css/zerobin.css b/public/css/zerobin.css index 9c3dbbd..8035b05 100644 --- a/public/css/zerobin.css +++ b/public/css/zerobin.css @@ -19,3 +19,10 @@ textarea#paste { pre code { background-color: #777777; } + +/* imgbin */ +div.img-preview { + margin: 5px; + display: inline-block; + vertical-align: top; +} diff --git a/templates/imgbin/create.html.ep b/templates/imgbin/create.html.ep index 39c7e87..4de34db 100644 --- a/templates/imgbin/create.html.ep +++ b/templates/imgbin/create.html.ep @@ -15,6 +15,11 @@ <%= tag 'label' => (for => 'expire') => l('Keep for') %>: <%= select_field 'expire' => \@times %> +% if (config->{imgbin}->{show_latest}) { + + <%= link_to l('Latest images') => "/imgbin/latest" %> + +% }
diff --git a/templates/imgbin/latest.html.ep b/templates/imgbin/latest.html.ep new file mode 100644 index 0000000..270a240 --- /dev/null +++ b/templates/imgbin/latest.html.ep @@ -0,0 +1,22 @@ +% layout 'default'; +% title 'Imgbin -- View'; +% stash 'styles' => 'zerobin'; +

<%= l('Latest images') %>

+
+
+ + <%= link_to l('Upload more') => "/imgbin" %> + +
+
+% my $images = stash('images') || []; +% foreach my $i (@{ $images }) { +% my $tooltip = sprintf "%s / %dx%d / %.1f kb", +% $i->{name}, $i->{width}, $i->{height}, $i->{size} / 1024; +
+ <%= link_to $i->{url} => begin %> + <%= image $i->{path}, title => $tooltip %> + <% end %> +
+% } +
diff --git a/templates/imgbin/view.html.ep b/templates/imgbin/view.html.ep index c54083b..982b39d 100644 --- a/templates/imgbin/view.html.ep +++ b/templates/imgbin/view.html.ep @@ -4,6 +4,11 @@

<%= l('View image') %>

+% if (config->{imgbin}->{show_latest}) { + + <%= link_to l('Latest images') => "/imgbin/latest" %> + +% } <%= link_to l('Upload more') => "/imgbin" %>