439 lines
23 KiB
Twig
439 lines
23 KiB
Twig
{% macro forum_category_listing(forums, title) %}
|
|
{% from _self import forum_category_entry %}
|
|
{% from 'macros.twig' import container_title %}
|
|
|
|
<div class="container forum__categories" {% if forums.info.id is defined %}id="f{{ forums.info.id }}"{% endif %}
|
|
{% if forums.colour is defined and forums.colour is not null %}style="--accent-colour: {{ forums.colour }}"{% endif %}>
|
|
{{ container_title(
|
|
'<span class="'
|
|
~ forums.info.iconForDisplay|default(forums.children is defined ? 'fas fa-folder fa-fw' : 'fas fa-folder fa-fw')
|
|
~ '"></span> '
|
|
~ forums.info.name|default(title|default('Forums'))
|
|
) }}
|
|
|
|
{% set children = forums.children is defined ? forums.children : forums %}
|
|
{% if children is iterable and children|length > 0 %}
|
|
<div class="forum__categories__list">
|
|
{% for forum in children %}
|
|
{{ forum_category_entry(forum) }}
|
|
{% endfor %}
|
|
</div>
|
|
{% else %}
|
|
<div class="forum__categories__empty">
|
|
This category is empty.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_header(title, breadcrumbs, omit_last_breadcrumb, title_url, actions) %}
|
|
<div class="container forum__header">
|
|
{% if breadcrumbs is iterable and breadcrumbs|length > 0 %}
|
|
<div class="forum__header__breadcrumbs">
|
|
<a href="{{ url('forum-index') }}" class="forum__header__breadcrumb">Forums</a>
|
|
{% for category in breadcrumbs|reverse %}
|
|
<div class="forum__header__breadcrumb__separator">
|
|
<i class="fas fa-chevron-right"></i>
|
|
</div>
|
|
{% if not (omit_last_breadcrumb|default(false) and category == breadcrumbs|first) %}
|
|
<a href="{{ category.hasParent ? url('forum-category', {'forum': category.id}) : url('forum-category-root', {'forum': 'f' ~ category.id}) }}" class="forum__header__breadcrumb">{{ category.name }}</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if title|length > 0 %}
|
|
{% if title_url|length > 0 %}
|
|
<a class="forum__header__title" href="{{ title_url }}">
|
|
{{ title }}
|
|
</a>
|
|
{% else %}
|
|
<div class="forum__header__title forum__header__title--fill">
|
|
{{ title }}
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% if actions is iterable and actions|length > 0 %}
|
|
<div class="forum__header__actions">
|
|
{% for action in actions %}
|
|
{% if action.display is not defined or action.display %}
|
|
<a class="{{ html_classes('forum__header__action', action.class|default('')) }}" {% if action.method is defined %}href="javascript:;" data-method="{{ action.method }}" data-url="{{ action.url }}"{% if action.disableWith is defined %} data-disable-with="{{ action.disableWith }}"{% endif %}{% if action.disableWithTarget is defined %} data-disable-with-target="{{ action.disableWithTarget }}"{% endif %}{% if action.withCsrf|default(false) %} data-with-csrf="1"{% endif %}{% if action.refreshOnSuccess|default(false) %} data-refresh-on-success="1"{% endif %}{% if action.redirectOnSuccess is defined and action.redirectOnSuccess is not empty %} data-redirect-on-success="{{ action.redirectOnSuccess }}"{% endif %}{% if action.confirm is defined %} data-confirm="{{ action.confirm }}"{% endif %}{% else %}href="{{ action.url }}"{% endif %}>
|
|
{{ action.html|raw }}
|
|
</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_category_tools(info, perms, pagination_info) %}
|
|
{% from 'macros.twig' import pagination %}
|
|
|
|
{% set is_locked = info.archived %}
|
|
{% set can_topic = not is_locked and perms.can_create_topic %}
|
|
{% set pag = pagination(pagination_info, 'forum-category', {'forum': info.id}) %}
|
|
|
|
{% if can_topic or pag|trim|length > 0 %}
|
|
<div class="container forum__actions">
|
|
<div class="forum__actions__buttons">
|
|
{% if can_topic %}
|
|
<a href="{{ url('forum-topic-new', {'forum': info.id}) }}" class="input__button forum__actions__button">New Topic</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="forum__actions__pagination">
|
|
{{ pag }}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_tools(info, pagination_info, can_reply) %}
|
|
{% from 'macros.twig' import pagination %}
|
|
|
|
{% set pag = pagination(pagination_info, 'forum-topic', {'topic': info.id}) %}
|
|
|
|
{% if can_reply or pag|trim|length > 0 %}
|
|
<div class="container forum__actions">
|
|
<div class="forum__actions__buttons">
|
|
{% if can_reply %}
|
|
<a href="{{ url('forum-reply-new', {'topic': info.id}) }}" class="input__button">Reply</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="forum__actions__pagination">
|
|
{{ pag }}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_category_entry(forum) %}
|
|
{% from 'macros.twig' import avatar %}
|
|
|
|
<div class="forum__category"{% if forum.colour is not null %} style="--accent-colour: {{ forum.colour }}"{% endif %}>
|
|
<a href="{{ url('forum-category', {'forum': forum.info.id}) }}" class="forum__category__link"></a>
|
|
|
|
<div class="forum__category__container">
|
|
<div class="forum__category__icon forum__category__icon--{{ forum.unread ? 'unread' : 'read' }}">
|
|
<span class="{{ forum.info.iconForDisplay }}"></span>
|
|
</div>
|
|
|
|
<div class="forum__category__details">
|
|
<div class="forum__category__title">
|
|
{{ forum.info.name }}
|
|
</div>
|
|
|
|
{% if forum.info.description|length > 0 %}
|
|
<div class="forum__category__description">
|
|
{{ forum.info.description|nl2br }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if forum.children|length > 0 %}
|
|
<div class="forum__category__subforums">
|
|
{% for child in forum.children %}
|
|
<a href="{{ url('forum-category', {'forum': child.info.id}) }}"
|
|
class="forum__category__subforum{% if child.unread %} forum__category__subforum--unread{% endif %}">
|
|
{{ child.info.name }}
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if forum.info.isLink %}
|
|
{% if forum.info.linkClicks is not null %}
|
|
<div class="forum__category__stats">
|
|
<div class="forum__category__stat" title="Clicks">{{ forum.info.linkClicks|number_format }}</div>
|
|
</div>
|
|
{% endif %}
|
|
{% elseif forum.info.mayHaveChildren %}
|
|
<div class="forum__category__stats">
|
|
<div class="forum__category__stat" title="Topics">{{ forum.info.topicsCount|number_format }}</div>
|
|
<div class="forum__category__stat" title="Posts">{{ forum.info.postsCount|number_format }}</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if forum.info.mayHaveTopics or forum.info.linkClicks is not null %}
|
|
<div class="forum__category__activity{% if forum.info.linkClicks is not null %} forum__category__activity--empty{% endif %}">
|
|
{% if not forum.info.isLink %}
|
|
{% if forum.lastPost is defined %}
|
|
<div class="forum__category__activity__details">
|
|
<a class="forum__category__activity__post"
|
|
href="{{ url('forum-post', {'post': forum.lastPost.info.id, 'post_fragment': 'p' ~ forum.lastPost.info.id}) }}">
|
|
{{ forum.lastPost.topicInfo.title }}
|
|
</a>
|
|
|
|
<div class="forum__category__activity__info">
|
|
{% if forum.lastPost.user is defined %}
|
|
<a href="{{ url('user-profile', {'user': forum.lastPost.user.id}) }}" class="forum__category__username"
|
|
style="--user-colour: {{ forum.lastPost.colour }}">{{ forum.lastPost.user.name }}</a>
|
|
{% endif %}
|
|
<time datetime="{{ forum.lastPost.info.createdTime|date('c') }}" title="{{ forum.lastPost.info.createdTime|date('r') }}">{{ forum.lastPost.info.createdTime|time_format }}</time>
|
|
</div>
|
|
</div>
|
|
|
|
{% if forum.lastPost.user is defined %}
|
|
<a href="{{ url('user-profile', {'user': forum.lastPost.user.id}) }}" class="avatar forum__category__avatar">
|
|
{{ avatar(forum.lastPost.user.id, 40, forum.lastPost.user.name) }}
|
|
</a>
|
|
{% endif %}
|
|
{% else %}
|
|
<div class="forum__category__activity__none">
|
|
There are no posts in this forum yet.
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_notice(icon, body) %}
|
|
<div class="container forum__status">
|
|
<div class="forum__status__icon">
|
|
<div class="forum__status__icon__background"></div>
|
|
<i class="fas fa-{{ icon }}"></i>
|
|
</div>
|
|
<div class="forum__status__text">
|
|
{{ body|raw }}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_redirect(redirect) %}
|
|
{% from _self import forum_topic_notice %}
|
|
{% if redirect is not empty %}
|
|
{% set body %}
|
|
This topic redirects to <span class="forum__status__emphasis"><a href="{{ redirect.linkTarget }}" class="link">{{ redirect.linkTarget }}</a></span>.
|
|
{% endset %}
|
|
{{ forum_topic_notice('share', body) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_locked(locked, archived) %}
|
|
{% from _self import forum_topic_notice %}
|
|
{% if locked is not null or archived %}
|
|
{% set body %}
|
|
{% if archived %}
|
|
This topic has been <span class="forum__status__emphasis">archived</span>.
|
|
{% else %}
|
|
This topic was locked
|
|
<time class="forum__status__emphasis"
|
|
datetime="{{ locked|date('c') }}"
|
|
title="{{ locked|date('r') }}">{{ locked|time_format }}</time>.
|
|
{% endif %}
|
|
{% endset %}
|
|
{{ forum_topic_notice(archived ? 'archive' : 'lock', body) }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_listing(topics, title) %}
|
|
{% from _self import forum_topic_entry %}
|
|
{% from 'macros.twig' import container_title %}
|
|
|
|
<div class="container forum__topics">
|
|
{{ container_title('<i class="fas fa-comments fa-fw"></i> ' ~ title|default('Topics')) }}
|
|
|
|
<div class="forum__topics__list">
|
|
{% if topics|length > 0 %}
|
|
{% for topic in topics %}
|
|
{{ forum_topic_entry(topic) }}
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="forum__topics__empty">
|
|
There are no topics in this forum.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_topic_entry(topic) %}
|
|
{% from 'macros.twig' import avatar %}
|
|
|
|
<div class="forum__topic{% if topic.info.deleted %} forum__topic--deleted{% elseif topic.info.locked and not topic.info.isImportant %} forum__topic--locked{% endif %}">
|
|
<a href="{{ url('forum-topic', {'topic': topic.info.id}) }}" class="forum__topic__link"></a>
|
|
|
|
<div class="forum__topic__container">
|
|
<div class="forum__topic__icon forum__topic__icon--{{ topic.unread ? 'unread' : 'read' }}">
|
|
<i class="{{ topic.info.iconForDisplay(topic.unread) }} fa-fw"></i>
|
|
|
|
{% if topic.participated %}
|
|
<div class="forum__topic__icon__participated" title="You have posted in this topic"></div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="forum__topic__details">
|
|
<div class="forum__topic__title">
|
|
<span class="forum__topic__title__inner">
|
|
{{ topic.info.title }}
|
|
</span>
|
|
</div>
|
|
|
|
<div class="forum__topic__info">
|
|
{% if topic.user is defined %}
|
|
by <a href="{{ url('user-profile', {'user': topic.user.id}) }}" class="forum__topic__username" style="--user-colour: {{ topic.colour }}">{{ topic.user.name }}</a>,
|
|
{% endif %}
|
|
<time datetime="{{ topic.info.createdTime|date('c') }}" title="{{ topic.info.createdTime|date('r') }}">{{ topic.info.createdTime|time_format }}</time>
|
|
</div>
|
|
|
|
{% set topic_pages = (topic.info.postsCount / 10)|round(0, 'ceil') %}
|
|
{% if topic_pages|default(0) > 1 %}
|
|
<div class="forum__topic__pagination">
|
|
{% set topic_pages_start_end = min(3, topic_pages) %}
|
|
{% for i in 1..topic_pages_start_end %}
|
|
<a href="{{ url('forum-topic', {'topic': topic.info.id, 'page': i}) }}" class="forum__topic__pagination__item">
|
|
{{ i }}
|
|
</a>
|
|
{% endfor %}
|
|
{% if topic_pages > 3 %}
|
|
{% if topic_pages > 6 %}
|
|
<div class="forum__topic__pagination__separator">
|
|
<i class="fas fa-ellipsis-h"></i>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% set topic_pages_end_start = max(4, min(topic_pages, topic_pages - 2)) %}
|
|
{% for i in topic_pages_end_start..topic_pages %}
|
|
<a href="{{ url('forum-topic', {'topic': topic.info.id, 'page': i}) }}" class="forum__topic__pagination__item">
|
|
{{ i }}
|
|
</a>
|
|
{% endfor %}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="forum__topic__stats">
|
|
<div class="forum__topic__stat" title="Posts">{{ topic.info.postsCount|number_format }}</div>
|
|
<div class="forum__topic__stat" title="Views">{{ topic.info.viewsCount|number_format }}</div>
|
|
</div>
|
|
|
|
<div class="forum__topic__activity">
|
|
<div class="forum__topic__activity__details">
|
|
{% if topic.lastPost is defined %}
|
|
{% if topic.lastPost.user is defined %}
|
|
<a href="{{ url('user-profile', {'user': topic.lastPost.user.id}) }}" class="forum__topic__username" style="--user-colour: {{ topic.lastPost.colour }}">{{ topic.lastPost.user.name }}</a>
|
|
{% endif %}
|
|
<a class="forum__topic__activity__post" href="{{ url('forum-post', {'post': topic.lastPost.info.id, 'post_fragment': 'p' ~ topic.lastPost.info.id}) }}">
|
|
<time datetime="{{ topic.lastPost.info.createdTime|date('c') }}" title="{{ topic.lastPost.info.createdTime|date('r') }}">{{ topic.lastPost.info.createdTime|time_format }}</time>
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if topic.lastPost is defined and topic.lastPost.user is defined %}
|
|
<a href="{{ url('user-profile', {'user': topic.lastPost.user.id}) }}" class="forum__topic__avatar">
|
|
{{ avatar(topic.lastPost.user.id, 30, topic.lastPost.user.name) }}
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro forum_post_listing(posts, user_id, perms) %}
|
|
{% from _self import forum_post_entry %}
|
|
|
|
{% for post in posts %}
|
|
{{ forum_post_entry(post, user_id, perms) }}
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
{% macro forum_post_entry(post, user_id, perms) %}
|
|
{% from 'macros.twig' import avatar %}
|
|
|
|
{% set viewer_is_author = user_id == post.user.id|default(null) %}
|
|
{% set can_edit = perms.can_edit_any_post|default(false) or (viewer_is_author and perms.can_edit_post|default(false)) %}
|
|
{% set can_delete = not post.isOriginalPost and (perms.can_delete_any_post|default(false) or (viewer_is_author and perms.can_delete_post|default(false) and post.info.canBeDeleted)) %}
|
|
|
|
<div class="container forum__post{% if post.info.deleted %} forum__post--deleted{% endif %}" id="p{{ post.info.id }}"{% if post.colour is defined %} style="--accent-colour: {{ post.colour }}"{% endif %}>
|
|
<div class="forum__post__info">
|
|
<div class="forum__post__info__background"></div>
|
|
<div class="forum__post__info__content">
|
|
{% if post.user is defined %}
|
|
<a class="forum__post__avatar" href="{{ url('user-profile', {'user': post.user.id}) }}">
|
|
{{ avatar(post.user.id, 120, post.user.name) }}
|
|
</a>
|
|
|
|
<a class="forum__post__username" href="{{ url('user-profile', {'user': post.user.id}) }}">{{ post.user.name }}</a>
|
|
|
|
{% if post.user.title|length > 0 %}
|
|
<div class="forum__post__usertitle">{{ post.user.title }}</div>
|
|
{% endif %}
|
|
|
|
<div class="forum__post__icons">
|
|
<div class="flag flag--{{ post.user.countryCode|lower }}" title="{{ post.user.countryCode|country_name }}"></div>
|
|
{% if post.postsCount is defined %}<div class="forum__post__posts-count">{{ post.postsCount|number_format }} posts</div>{% endif %}
|
|
</div>
|
|
|
|
{% if post.isOriginalPoster %}
|
|
<div class="forum__post__badge forum__post__badge--original-poster">
|
|
<div class="forum__post__badge__desktop">Original Poster</div>
|
|
<div class="forum__post__badge__mobile">OP</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="forum__post__joined">
|
|
joined <time datetime="{{ post.user.createdTime|date('c') }}" title="{{ post.user.createdTime|date('r') }}">{{ post.user.createdTime|time_format }}</time>
|
|
</div>
|
|
{% else %}
|
|
<div class="forum__post__username">Deleted User</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="forum__post__content">
|
|
{% set post_link = url(post.isOriginalPost ? 'forum-topic' : 'forum-post', {'topic': post.info.topicId, 'post': post.info.id, 'post_fragment': 'p%d'|format(post.info.id)}) %}
|
|
|
|
<div class="forum__post__details">
|
|
<a class="forum__post__datetime" href="{{ post_link }}">
|
|
<time datetime="{{ post.info.createdTime|date('c') }}" title="{{ post.info.createdTime|date('r') }}">{{ post.info.createdTime|time_format }}</time>
|
|
{% if post.info.edited %}
|
|
(edited <time datetime="{{ post.info.editedTime|date('c') }}" title="{{ post.info.editedTime|date('r') }}">{{ post.info.editedTime|time_format }}</time>)
|
|
{% endif %}
|
|
</a>
|
|
|
|
<a class="forum__post__id" href="{{ post_link }}">
|
|
#{{ post.info.id }}
|
|
</a>
|
|
</div>
|
|
|
|
<div class="forum__post__text{% if post.info.isBodyMarkdown %} markdown{% endif %}">
|
|
{{ post.info.body|escape|parse_text(post.info.bodyFormat)|raw }}
|
|
</div>
|
|
|
|
{% if perms.can_create_post|default(false) or can_edit or can_delete %}
|
|
<div class="forum__post__actions">
|
|
{% if post.info.deleted %}
|
|
<button class="forum__post__action forum__post__action--restore" data-method="POST" data-url="{{ url('forum-post-restore', {'post': post.info.id}) }}" data-refresh-on-success="1" data-with-csrf="1" data-disable-with="Restoring..." data-disable-with-target=".js-action-text" data-confirm="Are you sure you want to restore this post?"><i class="fas fa-magic fa-fw"></i> <span class="js-action-text">Restore</span></button>
|
|
<button class="forum__post__action forum__post__action--nuke" data-method="POST" data-url="{{ url('forum-post-nuke', {'post': post.info.id}) }}" data-redirect-on-success="{{ url('forum-topic', { topic: post.info.topicId }) }}" data-with-csrf="1" data-disable-with="Nuking..." data-disable-with-target=".js-action-text" data-confirm="Are you sure you want to PERMANENTLY DELETE this post?"><i class="fas fa-radiation-alt fa-fw"></i> <span class="js-action-text">Permanently Delete</span></button>
|
|
{% else %}
|
|
{# if perms.can_create_post|default(false) %}
|
|
<a href="{{ url('forum-post-quote', {'post': post.info.id}) }}" class="forum__post__action forum__post__action--quote"><i class="fas fa-quote-left fa-fw"></i> Quote</a>
|
|
{% endif #}
|
|
{% if can_edit %}
|
|
<a href="{{ url('forum-post-edit', {'post': post.info.id}) }}" class="forum__post__action forum__post__action--edit"><i class="fas fa-edit fa-fw"></i> Edit</a>
|
|
{% endif %}
|
|
{% if can_delete %}
|
|
<button class="forum__post__action forum__post__action--delete" data-method="DELETE" data-url="{{ url('forum-post-delete', {'post': post.info.id}) }}" data-redirect-on-success="{{ perms.can_delete_any_post ? url('forum-post', { post: post.info.id }) : url('forum-topic', { topic: post.info.topicId }) }}" data-with-csrf="1" data-disable-with="Deleting..." data-disable-with-target=".js-action-text" data-confirm="Are you sure you want to delete this post?"><i class="fas fa-trash-alt fa-fw"></i> <span class="js-action-text">Delete</span></button>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if post.info.shouldDisplaySignature and post.signature is defined %}
|
|
{% set signature_body = post.signature.body|escape|parse_text(post.signature.bodyFormat|default('')) %}
|
|
{% if signature_body|trim|length > 0 %}
|
|
<div class="forum__post__signature{% if post.signature.isBodyMarkdown %} markdown{% endif %}">
|
|
{{ signature_body|raw }}
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|