You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
805 B
48 lines
805 B
7 years ago
|
package CMTD::Main;
|
||
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
use utf8;
|
||
|
|
||
|
use Mojo::Base 'Mojolicious::Controller';
|
||
|
|
||
|
sub index {
|
||
|
my $self = shift;
|
||
|
|
||
|
$self->render(text => 'Go away!');
|
||
|
}
|
||
|
|
||
|
sub captcha {
|
||
|
}
|
||
|
|
||
|
sub c_list {
|
||
|
}
|
||
|
|
||
|
sub c_add {
|
||
|
my ($self) = @_;
|
||
|
|
||
|
unless (my $ref = $self->referrer and ref $ref eq 'HASH') {
|
||
|
$self->res->code(400);
|
||
|
$self->render(text => "Can't detect referred page");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
unless (my $site = $self->app->sites->{ $ref->{site} }) {
|
||
|
$self->res->code(400);
|
||
|
$self->render(text => "No such site");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
eval {
|
||
|
} or do {
|
||
|
chomp $@;
|
||
|
my $msg = sprintf "Error when listing comments for %s/%s: %s",
|
||
|
$ref->{site}, $ref->{pid}, $@;
|
||
|
$self->app->log->error($msg);
|
||
|
$self->res->code(500);
|
||
|
$self->render(text => 'Internal error');
|
||
|
};
|
||
|
}
|
||
|
|
||
|
1;
|