Cleaned up forum templates.
This commit is contained in:
parent
5ec7dddd0e
commit
dd8ec7c8dd
2 changed files with 104 additions and 240 deletions
|
@ -314,7 +314,7 @@ class ForumCategoriesRoutes implements RouteHandler, UrlSource {
|
|||
$topic->lastPost->colour = $this->usersCtx->getUserColour($topic->lastPost->user);
|
||||
}
|
||||
} catch(RuntimeException $ex) {
|
||||
$topic->lastPost = null;
|
||||
unset($topic->lastPost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,20 @@
|
|||
{% macro forum_category_listing(forums, title, colour, id, icon) %}
|
||||
{% macro forum_category_listing(forums, title) %}
|
||||
{% from _self import forum_category_entry %}
|
||||
{% from 'macros.twig' import container_title %}
|
||||
|
||||
{% if forums.info is defined %}
|
||||
{% set title = forums.info.name|default('Forums') %}
|
||||
{% set icon = forums.info.iconForDisplay|default('fas fa-folder fa-fw') %}
|
||||
{% set colour = forums.colour|default(null) %}
|
||||
{% set id = forums.info.id is defined ? 'f' ~ forums.info.id : '' %}
|
||||
{% set forums = forums.children %}
|
||||
{% elseif forums.children is defined %}
|
||||
{% set title = 'Forums' %}
|
||||
{% set icon = 'fas fa-folder fa-fw' %}
|
||||
{% set colour = null %}
|
||||
{% set id = '' %}
|
||||
{% set forums = forums.children %}
|
||||
{% else %}
|
||||
{% set title = title|default('Forums') %}
|
||||
{% set icon = icon|default('fas fa-folder fa-fw') %}
|
||||
{% set colour = colour|default(null) %}
|
||||
{% set id = id|default('') %}
|
||||
{% endif %}
|
||||
<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'))
|
||||
) }}
|
||||
|
||||
<div class="container forum__categories" {% if id|length > 0 %}id="{{ id }}"{% endif %}
|
||||
{% if colour is not null %}style="--accent-colour: {{ colour }}"{% endif %}>
|
||||
{{ container_title('<span class="' ~ icon ~ '"></span> ' ~ title) }}
|
||||
|
||||
{% if forums|length > 0 %}
|
||||
{% 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 forums %}
|
||||
{% for forum in children %}
|
||||
{{ forum_category_entry(forum) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -84,23 +71,15 @@
|
|||
{% macro forum_category_tools(info, perms, pagination_info) %}
|
||||
{% from 'macros.twig' import pagination %}
|
||||
|
||||
{% if info.forum_id is defined %}
|
||||
{% set forum_id = info.forum_id %}
|
||||
{% set is_archived = info.forum_archived != 0 %}
|
||||
{% else %}
|
||||
{% set forum_id = info.id %}
|
||||
{% set is_archived = info.archived %}
|
||||
{% endif %}
|
||||
|
||||
{% set is_locked = is_archived %}
|
||||
{% set is_locked = info.archived %}
|
||||
{% set can_topic = not is_locked and perms.can_create_topic %}
|
||||
{% set pag = pagination(pagination_info, 'forum-category', {'forum': forum_id}) %}
|
||||
{% 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': forum_id}) }}" class="input__button forum__actions__button">New Topic</a>
|
||||
<a href="{{ url('forum-topic-new', {'forum': info.id}) }}" class="input__button forum__actions__button">New Topic</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
@ -131,132 +110,75 @@
|
|||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro forum_category_entry(forum, forum_unread, forum_icon) %}
|
||||
{% macro forum_category_entry(forum) %}
|
||||
{% from 'macros.twig' import avatar %}
|
||||
|
||||
{% if forum.info is defined %}
|
||||
{% set forum_id = forum.info.id %}
|
||||
{% set forum_name = forum.info.name %}
|
||||
{% set forum_desc = forum.info.description|default('') %}
|
||||
{% set forum_is_link = forum.info.isLink %}
|
||||
{% set forum_may_have_children = forum.info.mayHaveChildren %}
|
||||
{% set forum_link_clicks = forum.info.linkClicks %}
|
||||
{% set forum_count_topics = forum.info.topicsCount %}
|
||||
{% set forum_count_posts = forum.info.postsCount %}
|
||||
{% set forum_show_activity = forum.info.mayHaveTopics or forum.info.linkClicks is not null %}
|
||||
{% set forum_unread = forum.unread %}
|
||||
{% set forum_colour = forum.colour %}
|
||||
|
||||
{% set forum_has_recent_post = forum.lastPost is defined %}
|
||||
{% set children = forum.children %}
|
||||
|
||||
{% if forum_has_recent_post %}
|
||||
{% set forum_recent_post_id = forum.lastPost.info.id %}
|
||||
{% set forum_recent_topic_title = forum.lastPost.topicInfo.title %}
|
||||
{% set forum_recent_post_created = forum.lastPost.info.createdTime %}
|
||||
|
||||
{% set forum_has_recent_post_user = forum_has_recent_post and forum.lastPost.user is defined %}
|
||||
{% if forum_has_recent_post_user %}
|
||||
{% set forum_recent_post_user_id = forum.lastPost.user.id %}
|
||||
{% set forum_recent_post_user_name = forum.lastPost.user.name %}
|
||||
{% set forum_recent_post_user_colour = '--user-colour: ' ~ forum.lastPost.colour %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if forum_icon is empty %}
|
||||
{% set forum_icon = forum.info.iconForDisplay %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% set forum_id = null %}
|
||||
{% set forum_name = 'Forums' %}
|
||||
{% set forum_desc = null %}
|
||||
{% set forum_is_link = false %}
|
||||
{% set forum_may_have_children = true %}
|
||||
{% set forum_count_topics = 0 %}
|
||||
{% set forum_count_posts = 0 %}
|
||||
{% set forum_show_activity = false %}
|
||||
{% set forum_unread = false %}
|
||||
{% set forum_colour = null %}
|
||||
{% set forum_has_recent_post = false %}
|
||||
{% set children = forum %}
|
||||
{% endif %}
|
||||
|
||||
<div class="forum__category"{% if forum_colour is not null %} style="--accent-colour: {{ forum_colour }}"{% endif %}>
|
||||
<a href="{{ url('forum-category', {'forum': forum_id}) }}" class="forum__category__link"></a>
|
||||
<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_icon }}"></span>
|
||||
<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_name }}
|
||||
{{ forum.info.name }}
|
||||
</div>
|
||||
|
||||
{% if forum_desc is not null %}
|
||||
{% if forum.info.description|length > 0 %}
|
||||
<div class="forum__category__description">
|
||||
{{ forum_desc|nl2br }}
|
||||
{{ forum.info.description|nl2br }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if children|length > 0 %}
|
||||
{% if forum.children|length > 0 %}
|
||||
<div class="forum__category__subforums">
|
||||
{% for child in children %}
|
||||
{% if child.info is defined %}
|
||||
{% set child_id = child.info.id %}
|
||||
{% set child_name = child.info.name %}
|
||||
{% set child_unread = child.unread %}
|
||||
{% else %}
|
||||
{% set child_id = child.forum_id %}
|
||||
{% set child_name = child.forum_name %}
|
||||
{% set child_unread = child.forum_unread %}
|
||||
{% endif %}
|
||||
|
||||
<a href="{{ url('forum-category', {'forum': child_id}) }}"
|
||||
class="forum__category__subforum{% if child_unread %} forum__category__subforum--unread{% endif %}">
|
||||
{{ child_name }}
|
||||
{% 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_is_link %}
|
||||
{% if forum_link_clicks is not null %}
|
||||
{% if forum.info.isLink %}
|
||||
{% if forum.info.linkClicks is not null %}
|
||||
<div class="forum__category__stats">
|
||||
<div class="forum__category__stat" title="Clicks">{{ forum_link_clicks|number_format }}</div>
|
||||
<div class="forum__category__stat" title="Clicks">{{ forum.info.linkClicks|number_format }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% elseif forum_may_have_children %}
|
||||
{% elseif forum.info.mayHaveChildren %}
|
||||
<div class="forum__category__stats">
|
||||
<div class="forum__category__stat" title="Topics">{{ forum_count_topics|number_format }}</div>
|
||||
<div class="forum__category__stat" title="Posts">{{ forum_count_posts|number_format }}</div>
|
||||
<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_show_activity %}
|
||||
<div class="forum__category__activity{% if forum_link_clicks is not null %} forum__category__activity--empty{% endif %}">
|
||||
{% if not forum_is_link %}
|
||||
{% if forum_has_recent_post %}
|
||||
{% 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_recent_post_id, 'post_fragment': 'p' ~ forum_recent_post_id}) }}">
|
||||
{{ forum_recent_topic_title }}
|
||||
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_has_recent_post_user %}
|
||||
<a href="{{ url('user-profile', {'user': forum_recent_post_user_id}) }}" class="forum__category__username"
|
||||
style="{{ forum_recent_post_user_colour }}">{{ forum_recent_post_user_name }}</a>
|
||||
{% 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_recent_post_created|date('c') }}" title="{{ forum_recent_post_created|date('r') }}">{{ forum_recent_post_created|time_format }}</time>
|
||||
<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_has_recent_post_user %}
|
||||
<a href="{{ url('user-profile', {'user': forum_recent_post_user_id}) }}" class="avatar forum__category__avatar">
|
||||
{{ avatar(forum_recent_post_user_id, 40, forum_recent_post_user_name) }}
|
||||
{% 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 %}
|
||||
|
@ -331,54 +253,17 @@
|
|||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro forum_topic_entry(topic, topic_icon, topic_unread) %}
|
||||
{% macro forum_topic_entry(topic) %}
|
||||
{% from 'macros.twig' import avatar %}
|
||||
|
||||
{% set topic_id = topic.info.id %}
|
||||
{% set topic_title = topic.info.title %}
|
||||
{% set topic_participated = topic.participated %}
|
||||
{% set topic_count_posts = topic.info.postsCount %}
|
||||
{% set topic_count_views = topic.info.viewsCount %}
|
||||
{% set topic_created = topic.info.createdTime %}
|
||||
{% set topic_locked = topic.info.locked %}
|
||||
{% set topic_deleted = topic.info.deleted %}
|
||||
{% set topic_pages = (topic.info.postsCount / 10)|round(0, 'ceil') %}
|
||||
|
||||
{% set has_topic_author = topic.user is defined %}
|
||||
{% if has_topic_author %}
|
||||
{% set topic_author_id = topic.user.id %}
|
||||
{% set topic_author_name = topic.user.name %}
|
||||
{% set topic_author_colour = '--user-colour: ' ~ topic.colour %}
|
||||
{% endif %}
|
||||
|
||||
{% set has_reply = topic.lastPost is defined and topic.lastPost is not null %}
|
||||
{% if has_reply %}
|
||||
{% set reply_id = topic.lastPost.info.id %}
|
||||
{% set reply_created = topic.lastPost.info.createdTime %}
|
||||
|
||||
{% set has_reply_author = topic.lastPost.user is defined %}
|
||||
{% if has_reply_author %}
|
||||
{% set reply_author_id = topic.lastPost.user.id %}
|
||||
{% set reply_author_name = topic.lastPost.user.name %}
|
||||
{% set reply_author_colour = '--user-colour: ' ~ topic.lastPost.colour %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% set topic_unread = topic.unread %}
|
||||
{% set topic_important = topic.info.isImportant %}
|
||||
|
||||
{% if topic_icon is null %}
|
||||
{% set topic_icon = topic.info.iconForDisplay(topic.unread) %}
|
||||
{% endif %}
|
||||
|
||||
<div class="forum__topic{% if topic_deleted %} forum__topic--deleted{% elseif topic_locked and not topic_important %} forum__topic--locked{% endif %}">
|
||||
<a href="{{ url('forum-topic', {'topic': topic_id}) }}" class="forum__topic__link"></a>
|
||||
<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_icon }} fa-fw"></i>
|
||||
<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 %}
|
||||
{% if topic.participated %}
|
||||
<div class="forum__topic__icon__participated" title="You have posted in this topic"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -386,22 +271,23 @@
|
|||
<div class="forum__topic__details">
|
||||
<div class="forum__topic__title">
|
||||
<span class="forum__topic__title__inner">
|
||||
{{ topic_title }}
|
||||
{{ topic.info.title }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="forum__topic__info">
|
||||
{% if has_topic_author %}
|
||||
by <a href="{{ url('user-profile', {'user': topic_author_id}) }}" class="forum__topic__username" style="{{ topic_author_colour }}">{{ topic_author_name }}</a>,
|
||||
{% 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_created|date('c') }}" title="{{ topic_created|date('r') }}">{{ topic_created|time_format }}</time>
|
||||
<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_id, 'page': i}) }}" class="forum__topic__pagination__item">
|
||||
<a href="{{ url('forum-topic', {'topic': topic.info.id, 'page': i}) }}" class="forum__topic__pagination__item">
|
||||
{{ i }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@ -414,7 +300,7 @@
|
|||
|
||||
{% 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_id, 'page': i}) }}" class="forum__topic__pagination__item">
|
||||
<a href="{{ url('forum-topic', {'topic': topic.info.id, 'page': i}) }}" class="forum__topic__pagination__item">
|
||||
{{ i }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@ -424,25 +310,25 @@
|
|||
</div>
|
||||
|
||||
<div class="forum__topic__stats">
|
||||
<div class="forum__topic__stat" title="Posts">{{ topic_count_posts|number_format }}</div>
|
||||
<div class="forum__topic__stat" title="Views">{{ topic_count_views|number_format }}</div>
|
||||
<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 has_reply %}
|
||||
{% if has_reply_author %}
|
||||
<a href="{{ url('user-profile', {'user': reply_author_id}) }}" class="forum__topic__username" style="{{ reply_author_colour }}">{{ reply_author_name }}</a>
|
||||
{% 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': reply_id, 'post_fragment': 'p' ~ reply_id}) }}">
|
||||
<time datetime="{{ reply_created|date('c') }}" title="{{ reply_created|date('r') }}">{{ reply_created|time_format }}</time>
|
||||
<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 has_reply and has_reply_author %}
|
||||
<a href="{{ url('user-profile', {'user': reply_author_id}) }}" class="forum__topic__avatar">
|
||||
{{ avatar(reply_author_id, 30, reply_author_name) }}
|
||||
{% 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>
|
||||
|
@ -461,56 +347,31 @@
|
|||
{% macro forum_post_entry(post, user_id, perms) %}
|
||||
{% from 'macros.twig' import avatar %}
|
||||
|
||||
{% set post_id = post.info.id %}
|
||||
{% set post_created = post.info.createdTime %}
|
||||
{% set post_edited = post.info.editedTime %}
|
||||
{% set post_is_deleted = post.info.deleted %}
|
||||
{% set post_is_op = post.isOriginalPost %}
|
||||
{% set post_body = post.info.body|escape|parse_text(post.info.bodyFormat) %}
|
||||
{% set post_is_markdown = post.info.isBodyMarkdown %}
|
||||
{% set post_show_signature = post.info.shouldDisplaySignature %}
|
||||
{% set post_can_be_deleted = post.info.canBeDeleted %}
|
||||
{% set topic_id = post.info.topicId %}
|
||||
|
||||
{% set has_author = post.user is defined %}
|
||||
{% if has_author %}
|
||||
{% set author_id = post.user.id %}
|
||||
{% set author_name = post.user.name %}
|
||||
{% set author_title = post.user.title %}
|
||||
{% set author_colour = '--accent-colour:' ~ post.colour %}
|
||||
{% set author_country = post.user.countryCode %}
|
||||
{% set author_created = post.user.createdTime %}
|
||||
{% set author_posts_count = post.postsCount %}
|
||||
{% set author_is_op = post.isOriginalPoster %}
|
||||
{% set signature_body = post.signature.body|default('')|escape|parse_text(post.signature.bodyFormat|default('')) %}
|
||||
{% set signature_is_markdown = post.signature.isBodyMarkdown|default(false) %}
|
||||
{% endif %}
|
||||
|
||||
{% set viewer_is_author = has_author and user_id == author_id %}
|
||||
{% 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_is_op and (perms.can_delete_any_post|default(false) or (viewer_is_author and perms.can_delete_post|default(false) and post_can_be_deleted)) %}
|
||||
{% 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_is_deleted %} forum__post--deleted{% endif %}" id="p{{ post_id }}"{% if author_colour is defined%} style="{{ author_colour }}"{% endif %}>
|
||||
<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 has_author %}
|
||||
<a class="forum__post__avatar" href="{{ url('user-profile', {'user': author_id}) }}">
|
||||
{{ avatar(author_id, 120, author_name) }}
|
||||
{% 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': author_id}) }}">{{ author_name }}</a>
|
||||
<a class="forum__post__username" href="{{ url('user-profile', {'user': post.user.id}) }}">{{ post.user.name }}</a>
|
||||
|
||||
{% if author_title|length > 0 %}
|
||||
<div class="forum__post__usertitle">{{ author_title }}</div>
|
||||
{% 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--{{ author_country|lower }}" title="{{ author_country|country_name }}"></div>
|
||||
{% if author_posts_count is not null %}<div class="forum__post__posts-count">{{ author_posts_count|number_format }} posts</div>{% endif %}
|
||||
<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 author_is_op %}
|
||||
{% 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>
|
||||
|
@ -518,7 +379,7 @@
|
|||
{% endif %}
|
||||
|
||||
<div class="forum__post__joined">
|
||||
joined <time datetime="{{ author_created|date('c') }}" title="{{ author_created|date('r') }}">{{ author_created|time_format }}</time>
|
||||
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>
|
||||
|
@ -527,48 +388,51 @@
|
|||
</div>
|
||||
|
||||
<div class="forum__post__content">
|
||||
{% set post_link = url(post_is_op ? 'forum-topic' : 'forum-post', {'topic': topic_id, 'post': post_id, 'post_fragment': 'p%d'|format(post_id)}) %}
|
||||
{% 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_created|date('c') }}" title="{{ post_created|date('r') }}">{{ post_created|time_format }}</time>
|
||||
{% if post_edited is not null %}
|
||||
(edited <time datetime="{{ post_edited|date('c') }}" title="{{ post_edited|date('r') }}">{{ post_edited|time_format }}</time>)
|
||||
<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_id }}
|
||||
#{{ post.info.id }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="forum__post__text{% if post_is_markdown %} markdown{% endif %}">
|
||||
{{ post_body|raw }}
|
||||
<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_is_deleted %}
|
||||
<button class="forum__post__action forum__post__action--restore" data-method="POST" data-url="{{ url('forum-post-restore', {'post': post_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_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>
|
||||
{% 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_id}) }}" class="forum__post__action forum__post__action--quote"><i class="fas fa-quote-left fa-fw"></i> Quote</a>
|
||||
<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_id}) }}" class="forum__post__action forum__post__action--edit"><i class="fas fa-edit fa-fw"></i> Edit</a>
|
||||
<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_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>
|
||||
<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_show_signature and signature_body is defined and signature_body|length > 0 %}
|
||||
<div class="forum__post__signature{% if signature_is_markdown %} markdown{% endif %}">
|
||||
{{ signature_body|raw }}
|
||||
</div>
|
||||
{% 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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue