contentdb/app/templates/macros/threads.html

284 lines
8.7 KiB
HTML
Raw Normal View History

2022-04-23 21:53:38 +02:00
{% macro render_reply(r, thread, current_user) -%}
{% from "macros/reviews.html" import render_review_vote %}
2021-08-18 23:09:41 +02:00
2018-12-22 21:13:43 +01:00
<li class="row my-2 mx-0">
<div class="col-md-1 p-1">
<a href="{{ url_for('users.profile', username=r.author.username) }}">
2023-08-25 21:49:55 +02:00
<img class="img-fluid user-photo img-thumbnail img-thumbnail-1"
src="{{ r.author.get_profile_pic_url() }}" loading="lazy">
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">
2023-08-22 20:58:43 +02:00
<a class="author {{ r.author.rank.name }} me-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 %}
2023-08-22 20:58:43 +02:00
<span class="text-muted small me-2">
2021-02-23 01:01:28 +01:00
({{ r.author.username }})
</span>
{% endif %}
{% if r.author in thread.package.maintainers %}
2023-08-22 20:58:43 +02:00
<span class="badge bg-dark">
{{ _("Maintainer") }}
</span>
{% endif %}
{% if r.author.rank == r.author.rank.BOT %}
2023-08-22 20:58:43 +02:00
<span class="badge bg-dark">
{{ r.author.rank.get_title() }}
</span>
{% endif %}
2023-08-22 20:58:43 +02:00
<a name="reply-{{ r.id }}" class="text-muted float-end"
2022-01-21 00:30:56 +01:00
href="{{ r.get_url() }}">
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.check_perm(current_user, "DELETE_REPLY") %}
2023-08-22 20:58:43 +02:00
<a class="float-end btn btn-secondary btn-sm ms-2"
href="{{ url_for('threads.delete_reply', id=thread.id, reply=r.id) }}">
<i class="fas fa-trash"></i>
</a>
{% endif %}
2022-01-21 00:30:56 +01:00
{% if current_user != r.author %}
2023-08-22 20:58:43 +02:00
<a class="float-end btn-secondary btn-sm ms-2"
2022-01-21 00:30:56 +01:00
title="{{ _('Report') }}"
href="{{ url_for('report.report', url=r.get_url()) }}">
2023-08-22 20:58:43 +02:00
<i class="fas fa-flag me-1"></i>
2022-01-21 00:30:56 +01:00
</a>
{% endif %}
{% if current_user == thread.author and thread.review and thread.first_reply == r %}
2023-08-22 20:58:43 +02:00
<a class="float-end btn btn-primary btn-sm ms-2"
href="{{ thread.review.package.get_url('packages.review') }}">
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.check_perm(current_user, "EDIT_REPLY") %}
2023-08-22 20:58:43 +02:00
<a class="float-end btn btn-primary btn-sm ms-2"
2020-07-11 04:52:56 +02:00
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 }}
2021-08-18 23:09:41 +02:00
{% if thread.first_reply == r and thread.review %}
{{ render_review_vote(thread.review, current_user, thread.get_view_url()) }}
2021-08-18 23:09:41 +02:00
{% endif %}
2018-06-12 00:11:15 +02:00
</div>
2018-12-22 21:13:43 +01:00
</div>
</div>
</li>
2022-04-23 21:53:38 +02:00
{% endmacro %}
{% macro render_status_update(r, thread, current_user) -%}
<li class="row my-2 mx-0 align-items-center">
<div class="col-md-1 p-1">
<a href="{{ url_for('users.profile', username=r.author.username) }}">
2023-08-25 21:49:55 +02:00
<img class="img-fluid user-photo img-thumbnail img-thumbnail-1"
src="{{ r.author.get_profile_pic_url() }}" loading="lazy">
2022-04-23 21:53:38 +02:00
</a>
</div>
<div class="col-auto">
<a class="author {{ r.author.rank.name }}"
href="{{ url_for('users.profile', username=r.author.username) }}">
{{ r.author.display_name }}
</a>
</div>
<div class="col pr-0 status-update">
{{ r.comment | markdown }}
</div>
<div class="col-auto">
2023-08-22 20:58:43 +02:00
<a name="reply-{{ r.id }}" class="text-muted float-end"
2022-04-23 21:53:38 +02:00
href="{{ r.get_url() }}">
{{ r.created_at | datetime }}
</a>
</div>
</li>
{% endmacro %}
{% macro render_thread(thread, current_user, form=None) -%}
<ul class="comments mt-4 mb-0">
{% for r in thread.replies %}
{% if r.is_status_update %}
{{ render_status_update(r, thread, current_user) }}
{% else %}
{{ render_reply(r, thread, current_user) }}
{% endif %}
2018-12-22 21:13:43 +01:00
{% endfor %}
</ul>
2020-07-11 02:34:51 +02:00
{% if thread.locked %}
<p class="my-0 py-4 text-center">
2023-08-22 20:58:43 +02:00
<i class="fas fa-lock me-3"></i>
2020-07-11 02:34:51 +02:00
{{ _("This thread has been locked by a moderator.") }}
</p>
{% endif %}
{% if form == False %}
<div class="row mt-1">
<div class="col-md-1 p-1"></div>
<div class="col">
2023-08-22 20:58:43 +02:00
<a class="btn btn-primary ms-3" href="{{ url_for('threads.view', id=thread.id) }}">
<i class="fas fa-reply me-1"></i>
{{ _("Reply") }}
</a>
</div>
</div>
{% endif %}
{% if current_user.is_authenticated and form != False %}
2018-12-22 21:13:43 +01:00
<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"
2023-08-25 21:49:55 +02:00
src="{{ current_user.get_profile_pic_url() }}" loading="lazy">
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
{% if not current_user.can_comment_ratelimit() %}
2020-07-11 02:34:51 +02:00
<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.check_perm(current_user, "COMMENT_THREAD") %}
2020-07-11 02:34:51 +02:00
<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>
2022-04-23 21:05:19 +02:00
{% elif form %}
2022-04-23 21:53:38 +02:00
{% from "macros/forms.html" import render_field, render_submit_field %}
<form method="post" action="{{ url_for('threads.view', id=thread.id) }}" class="card-body">
2022-04-23 21:05:19 +02:00
{{ form.hidden_tag() }}
{{ render_field(form.comment, fieldclass="form-control markdown", label="", data_enter_submit="1") }}
{{ render_submit_field(form.btn_submit) }}
2022-04-23 21:05:19 +02:00
</form>
2020-07-11 02:34:51 +02:00
{% else %}
<form method="post" action="{{ url_for('threads.view', id=thread.id)}}" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<textarea class="form-control markdown" required maxlength=2000 name="comment" data-enter-submit="1"></textarea><br />
<input class="btn btn-primary" name="btn_submit" type="submit" value="Comment" />
</form>
{% endif %}
2022-04-23 22:31:59 +02:00
{% if thread.private %}
<p class="text-muted card-body my-0 pt-0">
{{ _("You can add someone to a private thread by writing @username.") }}
</p>
{% 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 %}
2022-01-08 00:27:00 +01:00
<p class="list-group-item"><i>{{ _("No threads found") }}</i></p>
2020-12-22 13:22:52 +01:00
{% 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>
2023-04-15 03:37:58 +02:00
{% elif t.review.rating > 3 %}
<i class="fas fa-thumbs-up" style="color:#6f6;"></i>
2023-04-15 03:37:58 +02:00
{% elif t.review.rating < 3 %}
2020-12-22 13:22:52 +01:00
<i class="fas fa-thumbs-down" style="color:#f66;"></i>
2023-04-15 03:37:58 +02:00
{% else %}
<i class="fas fa-minus" style="color:#999"></i>
2020-12-22 13:22:52 +01:00
{% endif %}
2023-08-22 20:58:43 +02:00
<strong class="ms-1">
2020-12-22 13:22:52 +01:00
{{ t.title }}
</strong><br />
<span>
{{ t.author.display_name }}
</span>
2023-08-22 20:58:43 +02:00
<span class="text-muted ms-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 }}
2023-08-22 20:58:43 +02:00
<i class="fas fa-comment ms-1"></i>
2020-12-22 13:22:52 +01:00
</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>
2023-08-22 20:58:43 +02:00
<div class="col-md-2 text-muted text-end">
2022-04-26 23:50:14 +02:00
{% if t.package %}
2020-12-22 13:22:52 +01:00
<img
class="img-fluid"
style="max-height: 22px; max-width: 22px;"
src="{{ t.package.get_thumb_or_placeholder() }}" /><br />
2020-12-22 13:22:52 +01:00
2023-08-22 20:58:43 +02:00
<span class="ps-2">
2020-12-22 13:22:52 +01:00
{{ t.package.title }}
</span>
2022-04-26 23:50:14 +02:00
{% endif %}
</div>
2020-12-22 13:22:52 +01:00
</div>
2020-07-10 20:46:14 +02:00
</a>
{% else %}
2022-01-08 00:27:00 +01: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 %}