diff --git a/lib/PearlBee/Helpers/Util.pm b/lib/PearlBee/Helpers/Util.pm index f549fabd..31384cd7 100644 --- a/lib/PearlBee/Helpers/Util.pm +++ b/lib/PearlBee/Helpers/Util.pm @@ -72,51 +72,4 @@ Generate a valid slug kind name =cut -sub map_posts { - my (@posts) = @_; - - # map info (utf8 compliance) - my @mapped_posts = (); - foreach my $post (@posts) { - my $el; - map { - $el->{$_} = eval { $post->$_ } - } ( - 'title', 'content', - 'id', 'slug', - 'description', 'cover', - 'created_date', 'status', - 'user_id', 'nr_of_comments' - ); - - # extract a sample from the content (first words) - my $chunk = 600; - my $post_content = $el->{content}; - -=aaa - $el->{content} = substr($post_content, 0, $chunk); - $el->{content} =~ s/([,\s\.])*[^,\s\.]*$/ /is; # make sure we do not split inside of a word - $el->{content} =~ s/\W*$//is; # make sure we do not split inside of a word - - $el->{content} .= ' ...'; -=cut - - # get post author - $el->{user}->{username} = $post->user->username; - $el->{user}->{id} = $post->user->id; - - # add post categories - foreach my $category ( $post->post_categories ) { - my $details; - $details->{category}->{name} = $category->category->name; - $details->{category}->{slug} = $category->category->slug; - push( @{ $el->{post_categories} }, $details ); - } - - push( @mapped_posts, $el ); - } - - return @mapped_posts; -} - 1; diff --git a/lib/PearlBee/Posts.pm b/lib/PearlBee/Posts.pm index fe4a9c83..b22ece29 100644 --- a/lib/PearlBee/Posts.pm +++ b/lib/PearlBee/Posts.pm @@ -4,7 +4,6 @@ package PearlBee::Posts; use Dancer2 appname => 'PearlBee'; use Dancer2::Plugin::DBIC; -use PearlBee::Helpers::Util qw; use PearlBee::Helpers::Pagination qw; use PearlBee::Helpers::Captcha; @@ -31,16 +30,13 @@ prefix '/posts' => sub { my @popular = resultset('View::PopularPosts')->search( {}, { rows => 3 } ); - # extract demo posts info - my @mapped_posts = map_posts(@posts); - # Calculate the next and previous page link my $total_pages = get_total_pages( $nr_of_posts, $nr_of_rows ); my ( $previous_link, $next_link ) = get_previous_next_link( $page, $total_pages ); template 'index' => { - posts => \@mapped_posts, + posts => \@posts, recent => \@recent, popular => \@popular, tags => \@tags,