contentdb/app/templates/macros/threads.html
2018-12-22 20:25:22 +00:00

77 lines
2.3 KiB
HTML

{% macro render_thread(thread, current_user) -%}
<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) }}">
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ (r.author.email or '') | gravatar }}">
</a>
</div>
<div class="col">
<div class="card">
<div class="card-header">
<a class="author {{ r.author.rank.name }}"
href="{{ url_for('user_profile_page', username=r.author.username) }}">
{{ 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>
</div>
<div class="card-body">
{{ r.comment | markdown }}
</div>
</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">
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ (current_user.email or '') | gravatar }}">
</div>
<div class="col">
<div class="card">
<div class="card-header {{ current_user.rank.name }}">
{{ current_user.display_name }}
<a name="reply"></a>
</div>
<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" required maxlength=500 name="comment" placeholder="Markdown supported"></textarea><br />
<input class="btn btn-primary" type="submit" value="Comment" />
</form>
</div>
</div>
</div>
{% endif %}
{% endmacro %}
{% macro render_threadlist(threads, list_group=False) -%}
{% if not list_group %}<ul>{% endif %}
<li {% if list_group %}class="list-group-item"{% endif %}>
{% for t in threads %}
{% 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 %}
{% if t.private %}&#x1f512; {% endif %}
<a href="{{ url_for('thread_page', id=t.id) }}">{{ t.title }}</a>
by {{ t.author.display_name }}
{% endif %}
{% else %}
<i>No threads found</i>
{% endfor %}
</li>
</ul>
{% endmacro %}