{% extends 'Common/base.html.twig' %}
{% import 'Common/parts/functions.html.twig' as function %}
{% block title %}{{ 'blog.list_articles.title'|trans }} | {{ parent() }}{% endblock %}
{% block classBody %}blog {{ parent() }}{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ encore_entry_script_tags('wt_list_articles') }}
{% endblock javascripts %}
{% block contents %}
<div class="container-small" ng-controller="listArticlesCtrl">
<nav class="mb-2" aria-label="breadcrumb">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="{{path('web_init')}}">Inicio</a></li>
{% if articleCategory is defined %}
<li class="breadcrumb-item" ><a href="{{path('web_blog_list_articles')}}">Blog</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ articleCategory.title(locale)}}</li>
{% else %}
<li class="breadcrumb-item active" aria-current="page">Blog</li>
{% endif %}
</ol>
</nav>
<h1 class="my-2">{{ 'blog.list_articles.title'|trans }}</h1>
{% if articleCategory is defined %}
<h3 ><a class="text-muted" href="{{url('web_blog_list_articles_category',{ 'categorySlug': articleCategory.slug(locale)})}}">{{ articleCategory.title(locale)}}</h3>
{% endif %}
<div class="row">
{% for article in articlePage %}
<div class="col-12 my-2 py-1">
<div class="card" >
{% if article.headerImageUrl %}
<a href="{{ url('web_blog_show_article', { 'articleSlug' : article.slug(locale), '_locale': locale })}}">
<img class="card-img-top" src="{{ article.headerImageUrl | imagine_filter('whater_blog_header_list_image_1200_200') }}" title="{{ article.title(locale) }}">
</a>
{% endif %}
<div class="card-body">
<a class="text-dark" href="{{ url('web_blog_show_article', { 'articleSlug' : article.slug(locale), '_locale': locale })}}">
<h3 class="card-title">{{ article.title(locale) }}</h3>
</a>
<p class="card-text">{{ article.content(locale) | striptags | u.truncate(350) |raw }}...</p>
<div class="my-1">
<span class="">Categorias:</span>
{% for category in article.categories(locale) %}
<a class="text-muted" href="{{ url('web_blog_list_articles_category', { 'categorySlug': category.slug(locale), '_locale': locale} )}}">{{ category.title(locale) }}</a>
{% if not loop.last %} | {%endif%}
{% endfor %}
</div>
<div class="fs--1 text-muted">{{ article.publishAt | date('d-m-Y') }} - {{ article.publishAt | ago }}</div>
<div class="my-1">
{% for metaKeyword in article.metaKeywords(locale) %}
<a class="text-muted fs--1">#{{ metaKeyword | replace({' ': '-'})}}</a>
{% endfor %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% if articlePage.haveToPaginate() and articleCategory is not defined %}
<div class="row">
<div class="col-12 my-2 py-1">
<div class="d-flex justify-content-between">
{% if articlePage.hasPreviousPage() %}
<a class="btn btn-secondary" href="{{url('web_blog_list_articles',{'page':articlePage.getPreviousPage()})}}">Página anterior</a>
{% else %}
<div></div>
{% endif %}
{% if articlePage.hasNextPage() %}
<a class="btn btn-secondary" href="{{url('web_blog_list_articles',{'page':articlePage.getNextPage()})}}">Siguiente página</a>
{% else %}
<div></div>
{% endif %}
</div>
</div>
</div>
{% elseif articlePage.haveToPaginate() and articleCategory is defined %}
<div class="row">
<div class="col-12 my-2 py-1">
<div class="d-flex justify-content-between">
{% if articlePage.hasPreviousPage() %}
<a class="btn btn-secondary" href="{{url('web_blog_list_articles_category',{'categorySlug': articleCategory.slug(locale), 'page':articlePage.getPreviousPage()})}}">Página anterior</a>
{% else %}
<div></div>
{% endif %}
{% if articlePage.hasNextPage() %}
<a class="btn btn-secondary" href="{{url('web_blog_list_articles_category',{'categorySlug': articleCategory.slug(locale), 'page':articlePage.getNextPage()})}}">Siguiente página</a>
{% else %}
<div></div>
{% endif %}
</div>
</div>
</div>
{% endif %}
</div>
{#
<div class="main-content" ng-controller="listArticlesCtrl">
<div class="ui container">
<h2>{{ 'blog.list_articles.title'|trans }}</h2>
<div class="separator-line"></div>
{% if articleCategory is defined %}
<h3><a href="{{url('web_blog_list_articles_category',{ 'categorySlug': articleCategory.slug(locale)})}}">{{ articleCategory.title(locale)}}</h3>
{% endif %}
<div class="ui stackable two cards">
{% for article in articlePage %}
<div class="ui raised card no_shadow">
<div class="content">
<div class="article-image">
{% if article.headerImageUrl %}
<img class="ui small image" src="{{ article.headerImageUrl }}">
{% else %}
<img class="ui small image" src="{{asset('/assets/images/logo_v2.png')}}">
{% endif %}
</div>
<div class="header"><a href="{{ url('web_blog_show_article', { 'articleSlug' : article.slug(locale), '_locale': locale })}}">{{ article.title(locale) }}</a></div>
<div class="meta">{{ article.publishAt | ago }}</div>
<div class="extra content article-categories">
{% for category in article.categories(locale) %}
<a href="{{ url('web_blog_list_articles_category', { 'categorySlug': category.slug(locale), '_locale': locale} )}}">{{ category.title(locale) }}</a>
{% if not loop.last %} | {%endif%}
{% endfor %}
</div>
<div class="ui ">
</div>
<div class="description">
{{ article.content(locale) | striptags | u.truncate(300) |raw }}
</div>
<div class="extra content article-keywords">
{% for metaKeyword in article.metaKeywords(locale) %}
<a>#{{ metaKeyword | replace({' ': '-'})}}</a>
{% endfor %}
</div>
</div>
</div>
{% endfor %}
</div>
{% if articlePage.haveToPaginate() and articleCategory is not defined %}
<div class="ui right floated pagination">
{% if articlePage.hasPreviousPage() %}
<a class="item" href="{{url('web_blog_list_articles',{'page':articlePage.getPreviousPage()})}}">Página anterior</a>
{% endif %}
{% if articlePage.hasNextPage() %}
<a class="item" href="{{url('web_blog_list_articles',{'page':articlePage.getNextPage()})}}">Siguiente página</a>
{% endif %}
</div>
{% elseif articlePage.haveToPaginate() and articleCategory is defined %}
<div class="ui right floated pagination">
{% if articlePage.hasPreviousPage() %}
<a class="item" href="{{url('web_blog_list_articles_category',{'categorySlug': articleCategory.slug(locale), 'page':articlePage.getPreviousPage()})}}">Página anterior</a>
{% endif %}
{% if articlePage.hasNextPage() %}
<a class="item" href="{{url('web_blog_list_articles_category',{'categorySlug': articleCategory.slug(locale), 'page':articlePage.getNextPage()})}}">Siguiente página</a>
{% endif %}
</div>
{% endif %}
</div>
</div>
#}
{% endblock contents %}