1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut-pastebin synced 2025-06-07 14:17:26 -04:00

Should be working now, except announcement

This commit is contained in:
Ryan Voots 2017-04-24 20:52:23 -04:00
parent a30d19b19f
commit ccb4e90463
4 changed files with 9 additions and 6 deletions

View file

@ -25,7 +25,7 @@ sub api_get_paste {
my $c = shift;
my $pasteid = $c->param('pasteid');
my $row = get_paste($pasteid);
my $row = $c->paste->get_paste($pasteid);
if ($row) {
my $data = {
@ -51,7 +51,7 @@ sub api_post_paste {
my @args = map {($c->param($_))} qw/paste username description channel expire language/;
my $id = insert_pastebin(@args);
my $id = $c->paste->insert_pastebin(@args);
my ($code, $who, $desc, $channel) = @args;
# TODO select which one based on config

View file

@ -63,6 +63,7 @@ sub post_paste {
sub edit_paste {
my $c = shift;
my $pasteid = $c->param('pasteid');
my $row = $c->paste->get_paste($pasteid);
@ -71,7 +72,7 @@ sub edit_paste {
$c->stash({pastedata => $row->{paste}, channels =>$cfg->{announce}{channels}});
$c->stash({page_tmpl => 'editor.html'});
$c->render('page');
$c->render(template => 'page');
} else {
return $c->reply->not_found;
}
@ -100,7 +101,7 @@ sub get_paste {
if ($row) {
$c->stash($row);
$c->stash({page_tmpl => 'viewer.html'});
$c->stash({eval => get_eval($pasteid, $row->{paste}, $row->{lang})});
$c->stash({eval => $c->eval->get_eval($pasteid, $row->{paste}, $row->{lang})});
$c->stash({paste_id => $pasteid});
$c->render('page');

View file

@ -1,4 +1,4 @@
package Eval::Perlbot;
package App::Model::Eval;
use strict;
use warnings;

View file

@ -5,6 +5,7 @@ use warnings;
use DBI;
use Mojo::Base '-base';
use DateTime;
# TODO config for dbname
has 'dbh' => sub {DBI->connect("dbi:SQLite:dbname=pastes.db", "", "", {RaiseError => 1, sqlite_unicode => 1})};
@ -28,7 +29,8 @@ sub insert_pastebin {
}
sub get_paste {
my ($self, $pasteid) = shift;
my ($self, $pasteid) = @_;
my $dbh = $self->dbh;
my $row = $dbh->selectrow_hashref(q{
SELECT p.*