Browse Source

* /zerobin2 -> /zerobin

master
Alex 'AdUser' Z 7 years ago
parent
commit
6711871165
  1. 2
      lib/LDV.pm
  2. 8
      lib/LDV/Zerobin.pm
  3. 2
      templates/zerobin/create.html.ep
  4. 4
      templates/zerobin/view.html.ep

2
lib/LDV.pm

@ -51,7 +51,7 @@ sub startup {
} }
{ # /zerobin { # /zerobin
my $zb = $r->route('/zerobin2') -> to(controller => 'zerobin'); my $zb = $r->route('/zerobin') -> to(controller => 'zerobin');
$zb->post('/') -> to(action => 'save'); $zb->post('/') -> to(action => 'save');
$zb->get ('/') -> to(action => 'create'); $zb->get ('/') -> to(action => 'create');
$zb->route('/:time', time => qr/\d+/) $zb->route('/:time', time => qr/\d+/)

8
lib/LDV/Zerobin.pm

@ -101,7 +101,7 @@ sub view {
$self->app->log->error($@); $self->app->log->error($@);
$@ = "internal error" if ($@ =~ m|at \S+ line \d+|oi); $@ = "internal error" if ($@ =~ m|at \S+ line \d+|oi);
$self->flash({'result' => $@}); $self->flash({'result' => $@});
$self->redirect_to("/zerobin2"); $self->redirect_to("/zerobin");
return; return;
}; };
@ -148,13 +148,13 @@ sub save {
syntax => $syntax, syntax => $syntax,
}); });
$self->_content_save($time, $paste); $self->_content_save($time, $paste);
$self->redirect_to("/zerobin2/$time"); 1; $self->redirect_to("/zerobin/$time"); 1;
} or do { } or do {
chomp $@; chomp $@;
$self->app->log->error($@); $self->app->log->error($@);
$@ = "internal error" if ($@ =~ m|at \S+ line \d+|oi); $@ = "internal error" if ($@ =~ m|at \S+ line \d+|oi);
$self->flash({'result' => $@}); $self->flash({'result' => $@});
$self->redirect_to("/zerobin2"); $self->redirect_to("/zerobin");
}; };
$self->rendered; $self->rendered;
@ -183,7 +183,7 @@ sub prune {
$self->stash({result => $@}); $self->stash({result => $@});
}; };
$self->redirect_to("/zerobin2"); $self->redirect_to("/zerobin");
$self->rendered; $self->rendered;
} }

2
templates/zerobin/create.html.ep

@ -8,7 +8,7 @@
% my %opts = (id => 'paste', name => 'paste'); % my %opts = (id => 'paste', name => 'paste');
<h1>Создать запись</h1> <h1>Создать запись</h1>
<div> <div>
<%= form_for "/zerobin2" => (method => 'POST', enctype => "multipart/form-data") => begin %> <%= form_for "/zerobin" => (method => 'POST', enctype => "multipart/form-data") => begin %>
<div> <div>
<span class="zerobin"> <span class="zerobin">
<%= submit_button l('Save') %>&nbsp; <%= submit_button l('Save') %>&nbsp;

4
templates/zerobin/view.html.ep

@ -1,10 +1,10 @@
% layout 'default'; % layout 'default';
% title 'Zerobin -- View'; % title 'Zerobin -- View';
% my $paste = (stash 'paste') || {}; % my $paste = stash('paste') || {};
<h1><%= l('View paste') %></h1> <h1><%= l('View paste') %></h1>
<div> <div>
<div> <div>
<%= link_to l('Create new') => "/zerobin2", class => 'zerobin create' %> <%= link_to l('Create new') => "/zerobin", class => 'zerobin create' %>
<%= link_to l('Download') => "/zerobin/$paste->{time}.txt", class => 'zerobin download' %> <%= link_to l('Download') => "/zerobin/$paste->{time}.txt", class => 'zerobin download' %>
</div> </div>
<br/> <br/>

Loading…
Cancel
Save