49 lines
2.7 KiB
Twig
49 lines
2.7 KiB
Twig
{% macro news_post(id, text, created, user, title, comments) %}
|
|
{% if title is defined and title %}
|
|
<a href="{{ route('news.post', id) }}" class="news__head" id="p{{ id }}">{{ title }}</a>
|
|
{% endif %}
|
|
<div class="news__body">
|
|
<a class="news__poster" href="{{ route('user.profile', user.id) }}">
|
|
<div class="avatar avatar--border news__avatar" style="background-image: url('{{ route('user.avatar', user.id) }}')"></div>
|
|
<div class="news__username" style="color: {{ user.colour }}; text-shadow: 0 0 7px {% if user.colour != 'inherit' %}{{ user.colour }}{% else %}#222{% endif %}">
|
|
{{ user.username }}
|
|
</div>
|
|
</a>
|
|
<div class="bbcode">
|
|
{{ text|raw }}
|
|
</div>
|
|
</div>
|
|
<div class="clear"></div>
|
|
<div class="news__date">
|
|
Posted <time class="time-ago" datetime="{{ created.format('c') }}">{{ created.format(config('general.date_format')) }}</time>
|
|
{% if comments is defined and comments %}<a href="{{ route('news.post', id) }}#comments">{{ comments }} comment{% if comments != 1 %}s{% endif %}</a>{% endif %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro pagination(url, pages, class, name) %}
|
|
{% set separator %}{% if '%3F' in url|default('')|url_encode %}&{% else %}?{% endif %}{% endset %}
|
|
{% set current_page = get[name|default('page')]|default(1) %}
|
|
{% set url = url ~ separator ~ name|default('page') ~ "=" %}
|
|
|
|
<div class="pagination {{ class }}">
|
|
{% if pages is defined and pages|length > 1 %}
|
|
{% if current_page > 1 %}
|
|
{% if pages|length > 2 %}
|
|
<a class="input__button" href="{{ url ~ 1 }}" title="Jump to first page"><span class="fa fa-fast-backward"></span></a>
|
|
{% endif %}
|
|
<a class="input__button" href="{{ url ~ (current_page - 1) }}" title="Previous page"><span class="fa fa-step-backward"></span></a>
|
|
{% endif %}
|
|
{% for id,page in pages %}
|
|
{% if (id + 1) > (current_page - 3) and (id + 1) < (current_page + 3) %}
|
|
<a class="input__button{% if id == current_page - 1 %} input__button--current{% endif %}" href="{{ url ~ (id + 1) }}" title="Page {{ id + 1 }}">{{ id + 1 }}</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% if current_page < pages|length %}
|
|
<a class="input__button" href="{{ url ~ (current_page + 1) }}" title="Next page"><span class="fa fa-step-forward"></span></a>
|
|
{% if pages|length > 2 %}
|
|
<a class="input__button" href="{{ url ~ pages|length }}" title="Jump to last page"><span class="fa fa-fast-forward"></span></a>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
{% endmacro %}
|