Truncate threads > 500 characters in the thread list page
This commit is contained in:
parent
ff93fa1d2b
commit
77d10c8c70
|
@ -14,14 +14,24 @@ sub startup($self) {
|
||||||
$self->plugin('TagHelpers::Pagination');
|
$self->plugin('TagHelpers::Pagination');
|
||||||
$self->plugin(AssetPack => {pipes => [qw{Css Combine}]});
|
$self->plugin(AssetPack => {pipes => [qw{Css Combine}]});
|
||||||
|
|
||||||
$self->helper(pg => sub {
|
# Helpers
|
||||||
state $pg = Mojo::Pg->new($self->config->{$self->mode}{'pg_string'})
|
$self->helper(pg => sub ($c) {
|
||||||
|
state $pg = Mojo::Pg->new($c->config->{$self->mode}{'pg_string'})
|
||||||
});
|
});
|
||||||
$self->helper(thread => sub {
|
|
||||||
state $thread = PostText::Model::Thread->new(pg => shift->pg)
|
$self->helper(thread => sub ($c) {
|
||||||
|
state $thread = PostText::Model::Thread->new(pg => $c->pg)
|
||||||
});
|
});
|
||||||
$self->helper(remark => sub {
|
|
||||||
state $remark = PostText::Model::Remark->new(pg => shift->pg)
|
$self->helper(remark => sub ($c) {
|
||||||
|
state $remark = PostText::Model::Remark->new(pg => $c->pg)
|
||||||
|
});
|
||||||
|
|
||||||
|
$self->helper(truncate_text => sub ($c, $input_text) {
|
||||||
|
my $truncated_text = 500 < length($input_text)
|
||||||
|
? substr($input_text, 0, 500) . '...' : $input_text;
|
||||||
|
|
||||||
|
return $truncated_text;
|
||||||
});
|
});
|
||||||
|
|
||||||
# Finish configuring some things
|
# Finish configuring some things
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<h3 class="title"><%= $thread->{'title'} %></h3>
|
<h3 class="title"><%= $thread->{'title'} %></h3>
|
||||||
<h4 class="date"><%= $thread->{'date'} %></h4>
|
<h4 class="date"><%= $thread->{'date'} %></h4>
|
||||||
<h5 class="author"><%= $thread->{'author'} %></h5>
|
<h5 class="author"><%= $thread->{'author'} %></h5>
|
||||||
<p class="body"><%= $thread->{'body'} %></p>
|
<p class="body"><%= truncate_text $thread->{'body'} %></p>
|
||||||
<nav class="remarks">
|
<nav class="remarks">
|
||||||
<%= link_to Remark => thread_id => {thread_id => $thread->{'id'}} %>
|
<%= link_to Remark => thread_id => {thread_id => $thread->{'id'}} %>
|
||||||
<%= link_to thread_page => {thread_id => $thread->{'id'}}, begin %>
|
<%= link_to thread_page => {thread_id => $thread->{'id'}}, begin %>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user