contentdb/app/templates/macros/threads.html

84 lines
2.7 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('user_profile_page', username=r.author.username) }}">
2018-12-26 00:02:49 +01:00
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
2018-12-22 21:13:43 +01:00
</a>
</div>
<div class="col">
<div class="card">
<div class="card-header">
2018-06-12 00:20:18 +02:00
<a class="author {{ r.author.rank.name }}"
href="{{ url_for('user_profile_page', username=r.author.username) }}">
2018-12-22 21:13:43 +01:00
{{ r.author.display_name }}
</a>
<a name="reply-{{ r.id }}" class="text-muted float-right"
href="{{ url_for('thread_page', id=thread.id) }}#reply-{{ r.id }}">
{{ r.created_at | datetime }}
</a>
2018-06-12 00:20:18 +02:00
</div>
2018-12-22 21:13:43 +01:00
<div class="card-body">
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>
{% if current_user.is_authenticated %}
<div class="row mt-0 mb-4 comments mx-0">
<div class="col-md-1 p-1">
2018-12-26 00:02:49 +01:00
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ current_user.getProfilePicURL() }}">
2018-12-22 21:13:43 +01:00
</div>
<div class="col">
<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 current_user.canCommentRL() %}
<form method="post" action="{{ url_for('thread_page', id=thread.id)}}" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<textarea class="form-control markdown" required maxlength=500 name="comment"></textarea><br />
<input class="btn btn-primary" type="submit" value="Comment" />
</form>
{% else %}
<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>
{% endif %}
2018-12-22 21:13:43 +01:00
</div>
</div>
</div>
{% endif %}
2018-06-11 23:49:25 +02:00
{% endmacro %}
2018-12-21 16:58:43 +01:00
{% macro render_threadlist(threads, list_group=False) -%}
{% if not list_group %}<ul>{% endif %}
2018-06-11 23:49:25 +02:00
{% for t in threads %}
2018-12-26 00:02:49 +01:00
<li {% if list_group %}class="list-group-item"{% endif %}>
{% if list_group %}
<a href="{{ url_for('thread_page', id=t.id) }}">
{% if t.private %}&#x1f512; {% endif %}
{{ t.title }}
by {{ t.author.display_name }}
</a>
{% else %}
2018-12-21 16:58:43 +01:00
{% if t.private %}&#x1f512; {% endif %}
2018-12-26 00:02:49 +01:00
<a href="{{ url_for('thread_page', id=t.id) }}">{{ t.title }}</a>
2018-12-21 16:58:43 +01:00
by {{ t.author.display_name }}
2018-12-26 00:02:49 +01:00
{% endif %}
</li>
2018-07-13 22:28:08 +02:00
{% else %}
2018-12-26 00:02:49 +01:00
<li {% if list_group %}class="list-group-item"{% endif %}><i>No threads found</i></li>
2018-06-11 23:49:25 +02:00
{% endfor %}
2018-12-26 00:02:49 +01:00
{% if not list_group %}</ul>{% endif %}
2018-06-11 23:49:25 +02:00
{% endmacro %}