|
|
@ -28,11 +28,41 @@ sub captcha { |
|
|
|
chomp $@; |
|
|
|
chomp $@; |
|
|
|
$self->app->log->error("error when showing captcha: $@"); |
|
|
|
$self->app->log->error("error when showing captcha: $@"); |
|
|
|
$self->res->code(500); |
|
|
|
$self->res->code(500); |
|
|
|
$self->render(text => 'internal error'); |
|
|
|
$self->render(text => "internal error\n"); |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sub c_list { |
|
|
|
sub c_list { |
|
|
|
|
|
|
|
my ($self) = @_; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $ref = $self->referrer; |
|
|
|
|
|
|
|
unless ($ref and ref($ref) eq 'HASH') { |
|
|
|
|
|
|
|
$self->res->code(400); |
|
|
|
|
|
|
|
$self->render(text => "can't detect referred page\n"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eval { |
|
|
|
|
|
|
|
if (my $sid = $self->app->sid_by_name($ref->{site})) { |
|
|
|
|
|
|
|
my @cm = (); |
|
|
|
|
|
|
|
if (my $pid = $self->app->pid_by_hash($sid, $hash)) { |
|
|
|
|
|
|
|
my @tm = $self->app->comments_by_pid($pid); |
|
|
|
|
|
|
|
# TODO: processing |
|
|
|
|
|
|
|
@cm = @tm; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$self->render(json => \@cm); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$self->res->code(400); |
|
|
|
|
|
|
|
$self->render(text => "no such site\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} 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\n"); |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sub c_add { |
|
|
|
sub c_add { |
|
|
|