Browse Source

+ /imgbin/latest

master
Alex 'AdUser' Z 9 years ago
parent
commit
8b69019c9a
  1. 4
      lib/LDV.pm
  2. 7
      public/css/zerobin.css
  3. 5
      templates/imgbin/create.html.ep
  4. 22
      templates/imgbin/latest.html.ep
  5. 5
      templates/imgbin/view.html.ep

4
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');

7
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;
}

5
templates/imgbin/create.html.ep

@ -15,6 +15,11 @@
<%= tag 'label' => (for => 'expire') => l('Keep for') %>:
<%= select_field 'expire' => \@times %>
</span>
% if (config->{imgbin}->{show_latest}) {
<span class="zerobin cblock">
<%= link_to l('Latest images') => "/imgbin/latest" %>
</span>
% }
</div>
<hr/>
<div>

22
templates/imgbin/latest.html.ep

@ -0,0 +1,22 @@
% layout 'default';
% title 'Imgbin -- View';
% stash 'styles' => 'zerobin';
<h1><%= l('Latest images') %></h1>
<div>
<div>
<span class="zerobin cblock">
<%= link_to l('Upload more') => "/imgbin" %>
</span>
</div>
<br/>
% 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;
<div class="img-preview">
<%= link_to $i->{url} => begin %>
<%= image $i->{path}, title => $tooltip %>
<% end %>
</div>
% }
</div>

5
templates/imgbin/view.html.ep

@ -4,6 +4,11 @@
<h1><%= l('View image') %></h1>
<div>
<div>
% if (config->{imgbin}->{show_latest}) {
<span class="zerobin cblock">
<%= link_to l('Latest images') => "/imgbin/latest" %>
</span>
% }
<span class="zerobin cblock">
<%= link_to l('Upload more') => "/imgbin" %>
</span>

Loading…
Cancel
Save