mirror of
https://github.com/perlbot/perlbuut-pastebin
synced 2025-06-08 14:46:47 -04:00
Endpoints work. Now to make models work
This commit is contained in:
parent
20ed30d7b3
commit
ed911cb12e
4 changed files with 11 additions and 8 deletions
|
@ -9,6 +9,8 @@ use Mojo::Base 'Mojolicious';
|
||||||
use Mojolicious::Plugin::TtRenderer;
|
use Mojolicious::Plugin::TtRenderer;
|
||||||
use App::Config;
|
use App::Config;
|
||||||
use App::Controller::Paste;
|
use App::Controller::Paste;
|
||||||
|
use App::Controller::Eval;
|
||||||
|
use App::Controller::Apiv1;
|
||||||
|
|
||||||
sub startup {
|
sub startup {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -27,15 +29,15 @@ sub startup {
|
||||||
$self->plugin('BlogSpam' => ($cfg->{blogspam}->%*));
|
$self->plugin('BlogSpam' => ($cfg->{blogspam}->%*));
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->routes();
|
$self->setup_routes();
|
||||||
}
|
}
|
||||||
|
|
||||||
sub routes {
|
sub setup_routes {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
App::Controller::Paste->routes($self->routes);
|
App::Controller::Paste->routes($self->routes);
|
||||||
App::Controller::Eval->routes($self->routes);
|
App::Controller::Eval->routes($self->routes);
|
||||||
App::Controller::API::v1->routes($self->routes);
|
App::Controller::Apiv1->routes($self->routes);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -6,7 +6,7 @@ use warnings;
|
||||||
use Mojo::Base 'Mojolicious::Controller';
|
use Mojo::Base 'Mojolicious::Controller';
|
||||||
|
|
||||||
sub routes {
|
sub routes {
|
||||||
my ($class, $_r) = @_;
|
my ($class, $r) = @_;
|
||||||
|
|
||||||
my $route = sub {
|
my $route = sub {
|
||||||
my ($method, $route, $action) = @_;
|
my ($method, $route, $action) = @_;
|
||||||
|
|
|
@ -25,7 +25,7 @@ sub run_eval {
|
||||||
|
|
||||||
my $output = $self->eval->get_eval(undef, $code, $language);
|
my $output = $self->eval->get_eval(undef, $code, $language);
|
||||||
|
|
||||||
$c->render(json => {evalout => $output});
|
$self->render(json => {evalout => $output});
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -24,6 +24,7 @@ sub routes {
|
||||||
$route->(get => '/edit/:pasteid' => 'edit_paste');
|
$route->(get => '/edit/:pasteid' => 'edit_paste');
|
||||||
$route->(get => '/raw/:pasteid' => 'raw_paste');
|
$route->(get => '/raw/:pasteid' => 'raw_paste');
|
||||||
$route->(get => '/pastebin/:pasteid' => 'get_paste');
|
$route->(get => '/pastebin/:pasteid' => 'get_paste');
|
||||||
|
$route->(get => '/robots.txt' => 'robots'); # TODO move to static file
|
||||||
}
|
}
|
||||||
|
|
||||||
sub to_root {
|
sub to_root {
|
||||||
|
@ -64,7 +65,7 @@ sub edit_paste {
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my $pasteid = $c->param('pasteid');
|
my $pasteid = $c->param('pasteid');
|
||||||
|
|
||||||
my $row = $dbh->selectrow_hashref("SELECT * FROM posts WHERE id = ? LIMIT 1", {}, $pasteid);
|
my $row = $c->paste->get_paste($pasteid);
|
||||||
|
|
||||||
if ($row->{when}) {
|
if ($row->{when}) {
|
||||||
$c->stash({pastedata => $row->{paste}, channels =>$cfg->{announce}{channels}});
|
$c->stash({pastedata => $row->{paste}, channels =>$cfg->{announce}{channels}});
|
||||||
|
@ -80,7 +81,7 @@ sub raw_paste {
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my $pasteid = $c->param('pasteid');
|
my $pasteid = $c->param('pasteid');
|
||||||
|
|
||||||
my $row = get_paste($pasteid);
|
my $row = $c->paste->get_paste($pasteid);
|
||||||
|
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
|
@ -94,7 +95,7 @@ sub get_paste {
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my $pasteid = $c->param('pasteid');
|
my $pasteid = $c->param('pasteid');
|
||||||
|
|
||||||
my $row = get_paste($pasteid);
|
my $row = $c->paste->get_paste($pasteid);
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$c->stash($row);
|
$c->stash($row);
|
||||||
|
|
Loading…
Add table
Reference in a new issue