misuzu/templates/news/macros.twig

95 lines
4.3 KiB
Twig
Raw Normal View History

2018-04-16 00:33:54 +00:00
{% macro news_preview(post) %}
2019-09-28 19:21:23 +00:00
{% from 'macros.twig' import container_title, avatar %}
2018-10-22 19:53:21 +00:00
<div class="container news__preview" style="{% if post.user_colour is not null %}{{ post.user_colour|html_colour }}{% endif %}">
<div class="news__preview__info">
<div class="news__preview__info__background"></div>
<div class="news__preview__info__content">
2018-07-15 02:15:12 +00:00
{% if post.user_id is not null %}
<div class="news__preview__user">
2019-09-28 19:21:23 +00:00
<a class="news__preview__avatar" href="{{ url('user-profile', {'user': post.user_id}) }}">
{{ avatar(post.user_id, 60, post.username) }}
</a>
<div class="news__preview__user__details">
<a class="news__preview__username" href="{{ url('user-profile', {'user': post.user_id}) }}">{{ post.username }}</a>
2018-07-15 02:15:12 +00:00
</div>
</div>
2018-07-15 02:15:12 +00:00
{% endif %}
<a class="news__preview__category" href="{{ url('news-category', {'category': post.category_id}) }}">
{{ post.category_name }}
</a>
<div class="news__preview__date">
Posted
<time datetime="{{ post.post_created|date('c') }}" title="{{ post.post_created|date('r') }}">
{{ post.post_created|time_diff }}
</time>
</div>
</div>
</div>
<div class="news__preview__content markdown">
<h1>{{ post.post_title }}</h1>
<div class="news__preview__text">
{{ post.post_text|first_paragraph|parse_text(constant('MSZ_PARSER_MARKDOWN'))|raw }}
</div>
<div class="news__preview__links">
<a href="{{ url('news-post', {'post': post.post_id}) }}" class="news__preview__link">Continue reading</a>
2019-01-24 20:54:24 +00:00
<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>
2018-04-16 00:33:54 +00:00
</div>
</div>
</div>
{% endmacro %}
2018-12-11 01:20:18 +00:00
{% macro news_post(post) %}
2019-09-28 19:21:23 +00:00
{% from 'macros.twig' import avatar %}
2018-12-11 01:20:18 +00:00
<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">
2019-09-28 19:21:23 +00:00
<a class="news__post__avatar" href="{{ url('user-profile', {'user': post.user_id}) }}">
{{ avatar(post.user_id, 60, post.username) }}
2018-12-11 01:20:18 +00:00
</a>
<div class="news__post__user__details">
2019-01-24 20:54:24 +00:00
<a class="news__post__username" href="{{ url('user-profile', {'user': post.user_id}) }}">{{ post.username }}</a>
2018-12-11 01:20:18 +00:00
</div>
</div>
{% endif %}
2019-01-24 20:54:24 +00:00
<a class="news__post__category" href="{{ url('news-category', {'category': post.category_id}) }}">
2018-12-11 01:20:18 +00:00
{{ 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 %}