misuzu/templates/news/macros.twig

83 lines
3.9 KiB
Twig

{% macro news_preview(post) %}
{% from 'macros.twig' import container_title %}
<div class="container news__preview">
{{ container_title(post.post_title, true, url('news-post', {'post': post.post_id})) }}
<div class="news__preview__container">
<div class="news__preview__content">
<div class="news__preview__text markdown">
{{ post.post_text|first_paragraph|parse_text(constant('MSZ_PARSER_MARKDOWN'))|raw }}
</div>
{% if post.user_id is not null %}
<a class="news__preview__user" href="{{ url('user-profile', {'user': post.user_id}) }}">
<div class="avatar news__preview__user__avatar" style="background-image:url('{{ url('user-avatar', {'user': post.user_id}) }}')"></div>
<div class="news__preview__user__name" style="{{ post.user_colour|html_colour }}">
{{ post.username }}
</div>
</a>
{% endif %}
</div>
<div class="news__preview__info">
<a href="{{ url('news-post', {'post': post.post_id}) }}" class="news__preview__link">
<time class="news__preview__date" datetime="{{ post.post_created|date('c') }}" title="{{ post.post_created|date('r') }}">
{{ post.post_created|time_diff }}
</time>
</a>
<a href="{{ url('news-post-comments', {'post': post.post_id}) }}" class="news__preview__link">
{{ post.post_comments < 1 ? 'No' : post.post_comments|number_format }} comment{{ post.post_comments != 1 ? 's' : '' }}
</a>
</div>
</div>
</div>
{% endmacro %}
{% macro news_post(post) %}
<div class="container news__post" style="{% if post.user_colour is not null %}{{ post.user_colour|html_colour('--accent-colour') }}{% endif %}">
<div class="news__post__info">
<div class="news__post__info__background"></div>
<div class="news__post__info__content">
{% if post.user_id is not null %}
<div class="news__post__user">
<a class="avatar news__post__avatar"
style="background-image:url('{{ url('user-avatar', {'user': post.user_id}) }}');"
href="{{ url('user-profile', {'user': post.user_id}) }}">
</a>
<div class="news__post__user__details">
<a class="news__post__username" href="{{ url('user-profile', {'user': post.user_id}) }}">{{ post.username }}</a>
</div>
</div>
{% endif %}
<a class="news__post__category" href="{{ url('news-category', {'category': post.category_id}) }}">
{{ post.category_name }}
</a>
<div class="news__post__date">
Posted
<time datetime="{{ post.post_created|date('c') }}" title="{{ post.post_created|date('r') }}">
{{ post.post_created|time_diff }}
</time>
</div>
{% if post.post_updated|date('U') > post.post_created|date('U') %}
<div class="news__post__date">
Updated
<time datetime="{{ post.post_updated|date('c') }}" title="{{ post.post_updated|date('r') }}">
{{ post.post_updated|time_diff }}
</time>
</div>
{% endif %}
</div>
</div>
<div class="news__post__text markdown">
<h1>{{ post.post_title }}</h1>
{{ post.post_text|parse_text(constant('MSZ_PARSER_MARKDOWN'))|raw }}
</div>
</div>
{% endmacro %}