2018-05-18 03:20:27 +02:00
{% macro forum_category_listing ( forums , title ) %}
{% from _self import forum_category_entry %}
<div class="container forum__listing">
<div class="container__title"> {{ title }} </div>
2018-08-11 18:46:39 +02:00
<div class="forum__listing__forums">
2018-05-18 03:20:27 +02:00
{% if forums | length > 0 %}
{% for forum in forums %}
{{ forum_category_entry ( forum ) }}
{% endfor %}
{% else %}
<div class="forum__listing__none">
This category is empty.
</div>
{% endif %}
</div>
</div>
{% endmacro %}
2018-08-23 22:06:48 +02:00
{% macro forum_category_buttons ( forum , perms ) %}
2018-05-20 22:12:45 +02:00
<div class="forum__actions forum__actions__content">
2018-08-23 22:06:48 +02:00
{% if perms | perms_check ( constant ( 'MSZ_FORUM_PERM_CREATE_TOPIC' ) ) %}
<a href="/forum/posting.php?f= {{ forum .forum_id }} " class="input__button forum__actions__button">New Topic</a>
{% endif %}
2018-05-20 22:12:45 +02:00
</div>
{% endmacro %}
2018-05-24 02:38:42 +02:00
{% macro forum_category_entry ( forum , forum_unread , forum_type , forum_icon ) %}
2018-05-20 22:12:45 +02:00
{% set forum_type = forum_type | default ( null ) %}
2018-05-24 02:38:42 +02:00
{% set forum_unread = forum_unread | default ( forum .forum_unread | default ( false ) ) ? 'unread' : 'read' %}
2018-05-20 22:12:45 +02:00
{% set forum_icon = forum_icon | default ( 'https://static.flash.moe/images/forum-icons/forum-%s-%s.png' ) %}
2018-05-18 03:20:27 +02:00
2018-05-20 22:12:45 +02:00
{% if forum_type is null %}
2018-05-18 03:20:27 +02:00
{% if forum .forum_archived is defined and forum .forum_archived %}
2018-05-20 22:12:45 +02:00
{% set forum_type = 'archive' %}
{% elseif forum .forum_type is defined and forum .forum_type != 0 %}
2018-05-18 03:20:27 +02:00
{% if forum .forum_type == 2 %}
2018-05-20 22:12:45 +02:00
{% set forum_type = 'link' %}
2018-05-18 03:20:27 +02:00
{% elseif forum .forum_type == 1 %}
2018-05-20 22:12:45 +02:00
{% set forum_type = 'category' %}
2018-05-18 03:20:27 +02:00
{% endif %}
2018-05-20 22:12:45 +02:00
{% else %}
{% set forum_type = 'default' %}
2018-05-18 03:20:27 +02:00
{% endif %}
{% endif %}
<div class="forum__listing__entry">
2018-05-24 02:38:42 +02:00
<img src=" {{ forum_icon | format ( forum_type , forum_unread ) }} " alt=" {{ forum_unread }} " class="forum__listing__entry__icon">
2018-05-18 03:20:27 +02:00
<div class="forum__listing__entry__info">
2018-05-21 21:08:40 +02:00
<div class="forum__listing__entry__title">
<a href="/forum/forum.php?f= {{ forum .forum_id }} " class="forum__listing__entry__title__link"> {{ forum .forum_name }} </a>
</div>
2018-05-18 03:20:27 +02:00
<div class="forum__listing__entry__description">
{{ forum .forum_description | nl2br }}
2018-05-19 02:51:31 +02:00
</div>
2018-05-21 21:08:40 +02:00
2018-05-19 02:51:31 +02:00
{% if forum .forum_subforums is defined and forum .forum_subforums | length > 0 %}
<div class="forum__listing__entry__subforums">
2018-05-18 03:20:27 +02:00
{% for subforum in forum .forum_subforums %}
2018-05-24 02:38:42 +02:00
<a href="/forum/forum.php?f= {{ subforum .forum_id }} "
class="forum__listing__entry__subforum {% if subforum .forum_unread %} forum__listing__entry__subforum--unread {% endif %} ">
{{ subforum .forum_name }}
</a>
2018-05-18 03:20:27 +02:00
{% endfor %}
2018-05-19 02:51:31 +02:00
</div>
{% endif %}
2018-05-18 03:20:27 +02:00
</div>
2018-05-22 04:09:53 +02:00
{% if forum .forum_type == 2 %}
{% if forum .forum_link_clicks is not null %}
<div class="forum__listing__entry__stats">
<div class="forum__listing__entry__topics" title="Clicks"> {{ forum .forum_link_clicks | number_format }} </div>
2018-05-21 21:08:40 +02:00
</div>
2018-05-22 04:09:53 +02:00
{% endif %}
2018-05-26 22:33:05 +02:00
{% elseif forum .forum_type != 1 %}
2018-05-22 04:09:53 +02:00
<div class="forum__listing__entry__stats">
<div class="forum__listing__entry__topics" title="Topics"> {{ forum .forum_topic_count | number_format }} </div>
<div class="forum__listing__entry__posts" title="Posts"> {{ forum .forum_post_count | number_format }} </div>
</div>
{% endif %}
2018-05-26 22:33:05 +02:00
{% if forum .forum_type == 0 or forum .forum_link_clicks is not null %}
<div class="forum__listing__entry__activity {% if forum .forum_link_clicks is not null %} forum__listing__entry__activity--empty {% endif %} ">
2018-05-22 04:09:53 +02:00
{% if forum .forum_type != 2 %}
{% if forum .recent_topic_id is null %}
<div class="forum__listing__entry__activity__none">
There are no posts in this forum yet.
</div>
{% else %}
<div class="forum__listing__entry__activity__details">
<div class="forum__listing__entry__activity__title">
<a class="forum__listing__entry__activity__title__link"
href="/forum/topic.php?p= {{ forum .recent_post_id }} #p {{ forum .recent_post_id }} ">
2018-05-26 22:33:05 +02:00
{{ forum .recent_topic_title }}
2018-05-22 04:09:53 +02:00
</a>
</div>
<div class="forum__listing__entry__activity__info">
{% if forum .recent_post_user_id is not null %}
by <a
href="/profile.php?u= {{ forum .recent_post_user_id }} "
2018-07-06 03:28:06 +02:00
style=" {{ forum .recent_post_user_colour | html_colour }} "
2018-05-22 04:09:53 +02:00
class="forum__listing__entry__activity__user"> {{ forum .recent_post_username }} </a>,
{% endif %}
2018-05-26 23:36:15 +02:00
<time
datetime=" {{ forum .recent_post_created | date ( 'c' ) }} "
title=" {{ forum .recent_post_created | date ( 'r' ) }} "> {{ forum .recent_post_created | time_diff }} </time>
2018-05-22 04:09:53 +02:00
</div>
</div>
2018-05-21 21:08:40 +02:00
{% if forum .recent_post_user_id is not null %}
2018-05-22 04:09:53 +02:00
<a
2018-05-21 21:08:40 +02:00
href="/profile.php?u= {{ forum .recent_post_user_id }} "
2018-05-22 04:09:53 +02:00
class="avatar forum__listing__entry__activity__avatar"
style="background-image:url('/profile.php?u= {{ forum .recent_post_user_id }} &m=avatar')">
</a>
2018-05-21 21:08:40 +02:00
{% endif %}
2018-05-22 04:09:53 +02:00
{% endif %}
2018-05-21 21:08:40 +02:00
{% endif %}
2018-05-22 04:09:53 +02:00
</div>
{% endif %}
2018-05-18 03:20:27 +02:00
</div>
{% endmacro %}
2018-05-22 01:05:25 +02:00
{% macro forum_topic_buttons ( topic ) %}
<div class="forum__actions forum__actions__content">
2018-05-23 03:41:57 +02:00
<a href="#reply"
class="input__button forum__actions__button"
onclick="openContainer('reply')">Reply</a>
2018-05-22 01:05:25 +02:00
</div>
{% endmacro %}
2018-05-23 03:41:57 +02:00
{% macro forum_topic_locked ( locked , archived ) %}
{% if locked is not null or archived %}
<div class="forum__topic__locked">
<div class="forum__topic__locked__icon"></div>
<div class="forum__topic__locked__text">
{% if archived %}
This topic has been <span class="forum__topic__locked__time">archived</span>.
{% else %}
2018-05-26 23:36:15 +02:00
This topic was locked <time
class="forum__topic__locked__time"
datetime=" {{ locked | date ( 'c' ) }} "
title=" {{ locked | date ( 'r' ) }} "> {{ locked | time_diff }} </time>.
2018-05-23 03:41:57 +02:00
{% endif %}
</div>
</div>
{% endif %}
{% endmacro %}
2018-05-18 03:20:27 +02:00
{% macro forum_topic_listing ( topics ) %}
{% from _self import forum_topic_entry %}
<div class="container forum__topics">
<div class="container__title">Topics</div>
2018-08-11 18:46:39 +02:00
<div class="forum__topics__listing">
2018-05-18 03:20:27 +02:00
{% if topics | length > 0 %}
{% for topic in topics %}
{{ forum_topic_entry ( topic ) }}
{% endfor %}
{% else %}
<div class="forum__topics__none">
There are no topics in this forum.
</div>
{% endif %}
</div>
</div>
{% endmacro %}
2018-05-24 02:38:42 +02:00
{% macro forum_topic_entry ( topic , topic_type , topic_unread , topic_icon ) %}
2018-05-20 03:16:29 +02:00
{% set topic_type = topic_type | default ( null ) %}
2018-05-24 02:38:42 +02:00
{% set topic_unread = topic_unread | default ( topic .topic_unread | default ( false ) ) ? 'unread' : 'read' %}
2018-05-20 03:16:29 +02:00
{% set topic_icon = topic_icon | default ( 'https://static.flash.moe/images/topic-icons/topic-%s-%s.png' ) %}
{% if topic_type is null %}
{% if topic .topic_deleted is defined and topic .topic_deleted is not null %}
{% set topic_type = 'deleted' %}
{% elseif topic .topic_type is defined and topic .topic_type != 0 %}
{% if topic .topic_type == 2 %}
{% set topic_type = 'announcement' %}
{% elseif topic .topic_type == 1 %}
{% set topic_type = 'pinned' %}
{% endif %}
2018-05-23 03:41:57 +02:00
{% elseif topic .topic_locked is defined and topic .topic_locked is not null %}
2018-05-20 03:16:29 +02:00
{% set topic_type = 'locked' %}
{% else %}
{% set topic_type = 'default' %}
{% endif %}
{% endif %}
2018-05-18 03:20:27 +02:00
2018-05-20 03:16:29 +02:00
<div class="forum__topics__entry forum__topics__entry-- {{ topic_type }} ">
2018-05-24 02:38:42 +02:00
<img src=" {{ topic_icon | format ( topic_type , topic_unread ) }} " alt=" {{ topic_unread }} " class="forum__topics__entry__icon">
2018-05-20 03:16:29 +02:00
<div class="forum__topics__entry__info">
2018-05-24 02:38:42 +02:00
<div class="forum__topics__entry__info__title forum__topics__entry__info__title-- {{ topic_unread }} ">
2018-05-20 03:16:29 +02:00
<a href="/forum/topic.php?t= {{ topic .topic_id }} " class="forum__topics__entry__info__title__link"> {{ topic .topic_title }} </a>
2018-05-18 03:20:27 +02:00
</div>
2018-05-21 18:37:17 +02:00
<div class="forum__topics__entry__info__author">
{% if topic .author_id is not null %}
by <a
href="/profile.php?u= {{ topic .author_id }} "
class="forum__topics__entry__info__author__name"
2018-07-06 03:28:06 +02:00
style=" {{ topic .author_colour | html_colour }} "> {{ topic .author_name }} </a>,
2018-05-21 18:37:17 +02:00
{% endif %}
2018-05-26 23:36:15 +02:00
<time datetime=" {{ topic .topic_created | date ( 'c' ) }} " title=" {{ topic .topic_created | date ( 'r' ) }} "> {{ topic .topic_created | time_diff }} </time>
2018-05-21 18:37:17 +02:00
</div>
2018-05-18 03:20:27 +02:00
</div>
2018-05-20 03:16:29 +02:00
<div class="forum__topics__entry__stats">
2018-05-21 04:28:51 +02:00
<div class="forum__topics__entry__stat forum__topics__entry__stat--posts" title="Posts">
{{ topic .topic_post_count | number_format }}
2018-05-20 03:16:29 +02:00
</div>
2018-05-21 04:28:51 +02:00
<div class="forum__topics__entry__stat forum__topics__entry__stat--views" title="Views">
{{ topic .topic_view_count | number_format }}
2018-05-20 03:16:29 +02:00
</div>
2018-05-18 03:20:27 +02:00
</div>
2018-05-20 22:12:45 +02:00
<div class="forum__topics__entry__activity">
2018-05-21 21:15:08 +02:00
<div class="forum__topics__entry__activity__info">
<div class="forum__topics__entry__activity__datetime">
<a href="/forum/topic.php?p= {{ topic .response_id }} #p {{ topic .response_id }} " class="forum__topics__entry__activity__datetime__link">
2018-05-26 23:36:15 +02:00
<time
datetime=" {{ topic .response_created | date ( 'c' ) }} "
title=" {{ topic .response_created | date ( 'r' ) }} "> {{ topic .response_created | time_diff }} </time>
2018-05-20 22:12:45 +02:00
</a>
</div>
2018-05-21 21:15:08 +02:00
{% if topic .respondent_id is not null %}
<div class="forum__topics__entry__activity__author">
2018-07-06 03:28:06 +02:00
by <a href="/profile.php?u= {{ topic .respondent_id }} " class="forum__topics__entry__activity__author__name" style=" {{ topic .respondent_colour | html_colour }} ">
2018-05-21 21:15:08 +02:00
{{ topic .respondent_name }}
</a>
</div>
{% endif %}
</div>
{% if topic .respondent_id is not null %}
<a
href="/profile.php?u= {{ topic .respondent_id }} "
class="avatar forum__topics__entry__activity__avatar"
style="background-image:url('/profile.php?u= {{ topic .respondent_id }} &m=avatar')">
</a>
2018-05-20 22:12:45 +02:00
{% endif %}
</div>
</div>
{% endmacro %}
{% macro forum_post_listing ( posts , opening_post_id ) %}
{% from _self import forum_post_entry %}
2018-05-22 01:05:25 +02:00
{% for post in posts %}
{{ forum_post_entry ( post , post .post_id == opening_post_id ) }}
{% endfor %}
2018-05-20 22:12:45 +02:00
{% endmacro %}
2018-05-22 01:05:25 +02:00
{% macro forum_post_entry ( post , is_original_post , is_original_poster ) %}
{% set is_original_post = is_original_post | default ( false ) %}
{% set is_original_poster = is_original_poster | default ( false ) %}
2018-05-20 22:12:45 +02:00
2018-05-21 04:28:51 +02:00
<div class="forum__post" id="p {{ post .post_id }} ">
2018-05-26 22:33:05 +02:00
{% if post .poster_id is not null %}
<div class="forum__post__author">
2018-05-22 01:05:25 +02:00
<a class="forum__post__author__link" href="/profile.php?u= {{ post .poster_id }} ">
<div
class="avatar forum__post__author__avatar"
style="background-image:url('/profile.php?u= {{ post .poster_id }} &m=avatar');">
</div>
<div
class="forum__post__author__username"
2018-07-06 03:28:06 +02:00
style=" {{ post .poster_colour | html_colour }} "> {{ post .poster_name }} </div>
2018-05-22 01:05:25 +02:00
</a>
<div class="forum__post__author__joined">
2018-05-26 23:36:15 +02:00
joined <time datetime=" {{ post .poster_joined | date ( 'c' ) }} " title=" {{ post .poster_joined | date ( 'r' ) }} "> {{ post .poster_joined | time_diff }} </time>
2018-05-21 04:28:51 +02:00
</div>
2018-05-26 22:33:05 +02:00
</div>
{% else %}
<div class="forum__post__author forum__post__author--deleted">
<div class="forum__post__author__link">
<div class="forum__post__author__username">Deleted User</div>
2018-05-22 01:05:25 +02:00
</div>
2018-05-26 22:33:05 +02:00
</div>
{% endif %}
2018-05-21 04:28:51 +02:00
<div class="forum__post__content">
<div class="forum__post__content__info">
<a class="forum__post__content__info__link" href="/forum/topic.php?t= {{ post .topic_id }} #p {{ post .post_id }} ">
2018-05-26 23:36:15 +02:00
<time datetime=" {{ post .post_created | date ( 'c' ) }} " title=" {{ post .post_created | date ( 'r' ) }} "> {{ post .post_created | time_diff }} </time>
2018-05-21 04:28:51 +02:00
</a>
<a class="forum__post__content__info__link" href="/forum/topic.php?p= {{ post .post_id }} #p {{ post .post_id }} ">
# {{ post .post_id }}
</a>
</div>
<div class="forum__post__content__text">
2018-05-24 21:31:48 +02:00
{% if post .post_parse == 2 %}
2018-07-17 21:12:51 +02:00
{{ post .post_text | escape | parse_text ( 'md' ) | raw }}
2018-05-24 21:31:48 +02:00
{% elseif post .post_parse == 1 %}
2018-07-17 21:12:51 +02:00
{{ post .post_text | escape | parse_text ( 'bb' ) | raw }}
2018-05-24 21:31:48 +02:00
{% else %}
{{ post .post_text | escape }}
{% endif %}
2018-05-21 04:28:51 +02:00
</div>
2018-05-20 22:12:45 +02:00
</div>
2018-05-18 03:20:27 +02:00
</div>
{% endmacro %}
2018-05-22 03:26:47 +02:00
{% macro forum_posting_form ( title , target_id , is_reply , element_id ) %}
{% set is_reply = is_reply ? true : false %}
2018-05-22 04:09:53 +02:00
<form {% if element_id is defined %} id=" {{ element_id }} " {% endif %}
2018-05-22 03:26:47 +02:00
class="container forum__posting"
method="post"
action="/forum/posting.php">
<div class="container__title">
{{ title }}
</div>
2018-08-11 18:46:39 +02:00
<div class="forum__posting__content">
2018-05-22 03:26:47 +02:00
<input type="hidden" name="post[ {{ is_reply ? 'topic' : 'forum' }} ]" value=" {{ target_id }} ">
2018-05-23 03:41:57 +02:00
{ #<div class="forum__posting__errors">
<p class="forum__posting__error">Error: Your post contained too much text, shorten it a bit or split it out in two posts.</p>
</div>#}
2018-05-22 03:26:47 +02:00
{% if not is_reply %}
<div class="forum__posting__title">
<input class="input__text forum__posting__title__input" type="text" name="post[title]" placeholder="Topic title">
</div>
{% endif %}
<div class="forum__posting__text">
<textarea class="input__textarea forum__posting__text__input" name="post[text]"></textarea>
</div>
<div class="forum__posting__buttons">
2018-08-15 15:26:56 +02:00
<button class="input__button" name="csrf" value=" {{ csrf_token ( ) }} ">Submit</button>
2018-05-22 03:26:47 +02:00
</div>
</div>
</form>
{% endmacro %}