contentdb/app/templates/macros/threads.html

209 lines
6.2 KiB
HTML
Raw Normal View History

2018-06-11 23:49:25 +02:00
{% macro render_thread(thread, current_user) -%}
2018-12-22 21:13:43 +01:00
<ul class="comments mt-4 mb-0">
{% for r in thread.replies %}
<li class="row my-2 mx-0">
<div class="col-md-1 p-1">
<a href="{{ url_for('users.profile', username=r.author.username) }}">
2020-12-05 02:51:50 +01:00
<img class="img-fluid user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
2018-12-22 21:13:43 +01:00
</a>
</div>
2020-07-11 02:34:51 +02:00
<div class="col pr-0">
2018-12-22 21:13:43 +01:00
<div class="card">
<div class="card-header">
<a class="author {{ r.author.rank.name }} mr-3"
href="{{ url_for('users.profile', username=r.author.username) }}">
2018-12-22 21:13:43 +01:00
{{ r.author.display_name }}
</a>
2021-02-23 01:01:28 +01:00
{% if r.author.username != r.author.display_name %}
<span class="text-muted small mr-2">
({{ r.author.username }})
</span>
{% endif %}
{% if r.author in thread.package.maintainers %}
<span class="badge badge-dark">
{{ _("Maintainer") }}
</span>
{% endif %}
{% if r.author.rank == r.author.rank.BOT %}
<span class="badge badge-dark">
{{ r.author.rank.getTitle() }}
</span>
{% endif %}
2018-12-22 21:13:43 +01:00
<a name="reply-{{ r.id }}" class="text-muted float-right"
href="{{ url_for('threads.view', id=thread.id) }}#reply-{{ r.id }}">
2018-12-22 21:13:43 +01:00
{{ r.created_at | datetime }}
</a>
2018-06-12 00:20:18 +02:00
</div>
2018-12-22 21:13:43 +01:00
2021-02-23 01:01:28 +01:00
<div class="card-body markdown">
{% if r.checkPerm(current_user, "DELETE_REPLY") %}
<a class="float-right btn btn-secondary btn-sm ml-2"
href="{{ url_for('threads.delete_reply', id=thread.id, reply=r.id) }}">
<i class="fas fa-trash"></i>
</a>
{% endif %}
2020-07-11 04:52:56 +02:00
{% if current_user == thread.author and thread.review and thread.replies[0] == r %}
<a class="float-right btn btn-primary btn-sm ml-2"
href="{{ thread.review.package.getReviewURL() }}">
2021-02-28 06:16:15 +01:00
<i class="fas fa-pen"></i>
2020-07-11 04:52:56 +02:00
</a>
{% elif r.checkPerm(current_user, "EDIT_REPLY") %}
<a class="float-right btn btn-primary btn-sm ml-2"
href="{{ url_for('threads.edit_reply', id=thread.id, reply=r.id) }}">
2021-02-28 06:16:15 +01:00
<i class="fas fa-pen"></i>
2020-07-11 04:52:56 +02:00
</a>
{% endif %}
2018-07-28 15:07:29 +02:00
{{ r.comment | markdown }}
2018-06-12 00:11:15 +02:00
</div>
2018-12-22 21:13:43 +01:00
</div>
</div>
</li>
{% endfor %}
</ul>
2020-07-11 02:34:51 +02:00
{% if thread.locked %}
<p class="my-0 py-4 text-center">
<i class="fas fa-lock mr-3"></i>
{{ _("This thread has been locked by a moderator.") }}
</p>
{% endif %}
2018-12-22 21:13:43 +01:00
{% if current_user.is_authenticated %}
<div class="row mt-0 mb-4 comments mx-0">
<div class="col-md-1 p-1">
2021-02-23 01:46:16 +01:00
<img class="img-fluid user-photo img-thumbnail img-thumbnail-1"
src="{{ current_user.getProfilePicURL() }}">
2018-12-22 21:13:43 +01:00
</div>
2021-02-23 01:46:16 +01:00
<div class="col pr-0">
2018-12-22 21:13:43 +01:00
<div class="card">
<div class="card-header {{ current_user.rank.name }}">
{{ current_user.display_name }}
<a name="reply"></a>
</div>
2018-06-11 23:49:25 +02:00
2020-07-11 02:34:51 +02:00
{% if not current_user.canCommentRL() %}
<div class="card-body">
<textarea class="form-control" readonly disabled>{{ _("Please wait before commenting again.") }}</textarea><br />
<input class="btn btn-primary" type="submit" disabled value="Comment" />
</div>
{% elif not thread.checkPerm(current_user, "COMMENT_THREAD") %}
<div class="card-body">
{% if thread.locked %}
<textarea class="form-control" readonly disabled>{{ _("This thread has been locked.") }}</textarea><br />
{% else %}
<textarea class="form-control" readonly disabled>{{ _("You don't have permission to post.") }}</textarea><br />
{% endif %}
<input class="btn btn-primary" type="submit" disabled value="Comment" />
</div>
{% else %}
<form method="post" action="{{ url_for('threads.view', id=thread.id)}}" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
2020-07-29 18:33:12 +02:00
<textarea class="form-control markdown" required maxlength=2000 name="comment"></textarea><br />
<input class="btn btn-primary" type="submit" value="Comment" />
</form>
{% endif %}
2018-12-22 21:13:43 +01:00
</div>
</div>
</div>
{% endif %}
2018-06-11 23:49:25 +02:00
{% endmacro %}
2020-12-22 13:22:52 +01:00
{% macro render_compact_threadlist(threads) -%}
2020-07-10 20:46:14 +02:00
{% for t in threads %}
<a class="list-group-item list-group-item-action"
href="{{ url_for('threads.view', id=t.id) }}">
2020-12-22 13:22:52 +01:00
{% if t.private %}&#x1f512; {% endif %}
<strong>{{ t.title }}</strong>
by {{ t.author.display_name }}
</a>
{% else %}
<p class="list-group-item"><i>No threads found</i></p>
{% endfor %}
{% endmacro %}
2020-07-10 20:46:14 +02:00
2020-12-22 13:22:52 +01:00
{% macro render_threadlist(threads) -%}
<div class="list-group-item">
<div class="row text-muted">
<span class="col-md">
{{ _("Thread") }}
</span>
2020-07-10 21:06:26 +02:00
2020-12-22 13:54:48 +01:00
<span class="col-md-3">
2020-12-22 13:22:52 +01:00
{{ _("Last Reply") }}
</span>
<span class="col-md-2"></span>
</div>
</div>
2020-07-10 20:46:14 +02:00
2020-12-22 13:22:52 +01:00
{% for t in threads %}
{% set replies = t.replies.count() - 1 %}
<a class="list-group-item list-group-item-action"
href="{{ url_for('threads.view', id=t.id) }}">
<div class="row">
<div class="col-md">
{% if not t.review and t.private %}
<i class="fas fa-lock" style="color:#ffac33;"></i>
{% elif not t.review %}
<i class="fas fa-comment-alt" style="color:#666;"></i>
{% elif t.review.recommends %}
<i class="fas fa-thumbs-up" style="color:#6f6;"></i>
{% else %}
<i class="fas fa-thumbs-down" style="color:#f66;"></i>
{% endif %}
<strong class="ml-1">
{{ t.title }}
</strong><br />
<span>
{{ t.author.display_name }}
</span>
<span class="text-muted ml-3">
2020-07-10 21:06:26 +02:00
{{ t.created_at | datetime }}
2020-12-22 13:22:52 +01:00
</span>
2020-12-22 13:54:48 +01:00
</div>
{% if replies > 0 %}
<span class="col-md-auto text-muted">
2020-12-22 13:22:52 +01:00
{{ replies }}
<i class="fas fa-comment ml-1"></i>
</span>
2020-12-22 13:54:48 +01:00
{% endif %}
2020-12-22 13:22:52 +01:00
2020-12-22 13:54:48 +01:00
<div class="col-md-3">
2020-12-22 13:22:52 +01:00
{% if replies > 0 %}
{% set latest = t.get_latest_reply() %}
<span>
{{ latest.author.display_name }}
</span><br />
<span class="text-muted">
{{ latest.created_at | datetime }}
</span>
{% endif %}
</div>
{% if t.package %}
<div class="col-md-2 text-muted text-right">
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
2021-01-29 21:21:17 +01:00
src="{{ t.package.getThumbnailOrPlaceholder() }}" /><br />
2020-12-22 13:22:52 +01:00
<span class="pl-2">
{{ t.package.title }}
</span>
</div>
{% endif %}
</div>
2020-07-10 20:46:14 +02:00
</a>
{% else %}
2020-07-11 00:18:40 +02:00
<p class="list-group-item"><i>No threads found</i></p>
2020-07-10 20:46:14 +02:00
{% endfor %}
2018-06-11 23:49:25 +02:00
{% endmacro %}