53 lines
1.7 KiB
Plaintext
53 lines
1.7 KiB
Plaintext
% use Data::Dumper;
|
|
% use DateTime::Format::ISO8601;
|
|
%
|
|
% use Mojo::DOM;
|
|
% use Mojo::Util;
|
|
%
|
|
% use BurguillosInfo::Posts;
|
|
%
|
|
% layout 'default', current_slug => $current_category->{slug};
|
|
% title $current_category->{title};
|
|
<div class="description">
|
|
<h2><%= $current_category->{title} %></h2>
|
|
<%== $current_category->{description} %>
|
|
% my $children_categories = $current_category->{children};
|
|
% if (@$children_categories) {
|
|
<h3>Quizás te interese.</h3>
|
|
% for my $child_category (@$children_categories) {
|
|
<p><a href="/<%=$child_category->{slug}%>"><%==$child_category->{title}%></a></p>
|
|
% }
|
|
% }
|
|
<h3>Artículos</h3>
|
|
<div class="articles">
|
|
% my ($category_posts) = BurguillosInfo::Posts->new->RetrieveAllPostsForCategory($current_category->{slug});
|
|
% unless (@$category_posts) {
|
|
<p>Parece que aun no hay artículos.</p>
|
|
% }
|
|
% for my $post (@$category_posts) {
|
|
<a href="/posts/<%=$post->{slug}%>">
|
|
<article><%
|
|
my $date_article = DateTime::Format::ISO8601->parse_datetime($post->{date});
|
|
$date_article->set_time_zone('Europe/Madrid');
|
|
%><p class="date"><%= ''.$date_article %></p><%
|
|
if (defined $post->{image}) {
|
|
%><img alt="Portada de <%=$post->{title}%>" src="<%=$post->{image}%>"/><%
|
|
}
|
|
%><h4><%=$post->{title}%></h4><%
|
|
my $xml = Mojo::DOM->new($post->{content});
|
|
my $text = $xml->all_text;
|
|
if (length($text) > 120) {
|
|
$text = substr($text, 0, 100).'...';
|
|
}
|
|
%><p><%=$text%></p><p class="author">Escrito por <%=$post->{author}%></p></article>
|
|
</a>
|
|
% }
|
|
|
|
</div>
|
|
<h3>Suscribete a esta categoría.</h3>
|
|
|
|
<a class="suscribe-category-rss" href="/<%=$current_category->{slug}%>.rss">
|
|
<img src="/img/rss.svg" alt="Icono de suscripción rss"/>
|
|
</a>
|
|
</div>
|