Make max post length configurable
This commit is contained in:
parent
f3edd88ee7
commit
bb2ce292ed
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
threads_per_page => 5,
|
||||
remarks_per_page => 5,
|
||||
threads_per_page => 5,
|
||||
remarks_per_page => 5,
|
||||
body_max_length => 8_000,
|
||||
secrets => ['t0p_s3cr3t'],
|
||||
development => {
|
||||
pg_string =>
|
||||
|
|
|
@ -15,15 +15,16 @@ sub by_id($self) {
|
|||
}
|
||||
|
||||
sub create($self) {
|
||||
my $thread_id = $self->param('thread_id');
|
||||
my $remark_id = $self->param('remark_id');
|
||||
my $thread_id = $self->param('thread_id');
|
||||
my $remark_id = $self->param('remark_id');
|
||||
my $body_limit = $self->config->{'body_max_length'} || 4_000;
|
||||
my ($v, $draft);
|
||||
|
||||
$v = $self->validation if $self->req->method eq 'POST';
|
||||
|
||||
if ($v && $v->has_data) {
|
||||
$v->required('author' )->size(1, 63);
|
||||
$v->required('body' )->size(2, 4000);
|
||||
$v->required('author' )->size(1, 63);
|
||||
$v->required('body' )->size(2, $body_limit);
|
||||
$v->optional('bump' );
|
||||
$v->optional('preview');
|
||||
|
||||
|
@ -65,7 +66,8 @@ sub create($self) {
|
|||
$self->stash(
|
||||
thread => $thread,
|
||||
last_remark => $last_remark,
|
||||
draft => $draft
|
||||
draft => $draft,
|
||||
body_limit => $body_limit
|
||||
);
|
||||
|
||||
$self->stash(status => 404, error => 'Thread not found 🤷')
|
||||
|
|
|
@ -5,14 +5,15 @@ use Date::Format;
|
|||
use XML::RSS;
|
||||
|
||||
sub create($self) {
|
||||
my $body_limit = $self->config->{'body_max_length'} || 4_000;
|
||||
my ($v, $draft);
|
||||
|
||||
$v = $self->validation if $self->req->method eq 'POST';
|
||||
|
||||
if ($v && $v->has_data) {
|
||||
$v->required('author' )->size(1, 63);
|
||||
$v->required('title' )->size(1, 127);
|
||||
$v->required('body' )->size(2, 4000);
|
||||
$v->required('author' )->size(1, 63);
|
||||
$v->required('title' )->size(1, 127);
|
||||
$v->required('body' )->size(2, $body_limit);
|
||||
$v->optional('preview');
|
||||
|
||||
if ($v->has_error) {
|
||||
|
@ -42,7 +43,10 @@ sub create($self) {
|
|||
}
|
||||
}
|
||||
|
||||
$self->stash(draft => $draft);
|
||||
$self->stash(
|
||||
draft => $draft,
|
||||
body_limit => $body_limit
|
||||
);
|
||||
|
||||
return $self->render;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<%= label_for body => 'Text' %>
|
||||
<%= text_area body => (
|
||||
id => 'body',
|
||||
maxlength => 4000,
|
||||
maxlength => $body_limit,
|
||||
minlength => 2,
|
||||
required => undef,
|
||||
rows => 6,
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<%= label_for body => 'Text' %>
|
||||
<%= text_area body => (
|
||||
id => 'body',
|
||||
maxlength => 4000,
|
||||
maxlength => $body_limit,
|
||||
minlength => 2,
|
||||
required => undef,
|
||||
rows => 6
|
||||
|
|
Loading…
Reference in a new issue