diff --git a/app.pl b/app.pl index 21a484a..0c03b47 100755 --- a/app.pl +++ b/app.pl @@ -106,14 +106,13 @@ get '/pastebin/:pasteid' => sub { }; -get '/eval/:pasteid' => sub { +post '/eval' => sub { my ($c) = @_; - my $pasteid = $c->param('pasteid'); + my $data = $c->req->body_params; - my $row = $dbh->selectrow_hashref("SELECT * FROM posts WHERE id = ? LIMIT 1", {}, $pasteid); - my $code = $row->{paste} // ''; + my $code = $data->param('code') // ''; - my $output = get_eval($pasteid, $code); + my $output = get_eval(undef, $code); $c->render(json => {evalout => $output}); }; diff --git a/lib/Eval/Perlbot.pm b/lib/Eval/Perlbot.pm index a852ddf..302222b 100644 --- a/lib/Eval/Perlbot.pm +++ b/lib/Eval/Perlbot.pm @@ -16,7 +16,7 @@ use App::Memcached; sub get_eval { my ($paste_id, $code) = @_; - if (my $cached = $memd->get($paste_id)) { + if ($paste_id && (my $cached = $memd->get($paste_id))) { return $cached; } else { my $filter = POE::Filter::Reference->new(); @@ -31,7 +31,7 @@ sub get_eval { my $result = $filter->get( [ $output ] ); my $str = eval {decode("utf8", $result->[0]->[0])} // $result->[0]->[0]; $str = eval {decode("utf8", $str)} // $str; # I don't know why i need to decode this twice. shurg. - $memd->set($paste_id, $str); + $memd->set($paste_id, $str) if ($paste_id); return $str; } diff --git a/pastes.db b/pastes.db index bdbb9ff..2c3ae0d 100644 Binary files a/pastes.db and b/pastes.db differ diff --git a/templates/editor.html b/templates/editor.html index fc40a48..7e46ce9 100755 --- a/templates/editor.html +++ b/templates/editor.html @@ -49,15 +49,29 @@
-+ +
++
[% eval | html %]+