Improve thread list style

This commit is contained in:
rubenwardy 2020-07-10 19:46:14 +01:00
parent 436a4cce2b
commit d91f537bdd
4 changed files with 33 additions and 22 deletions

View File

@ -41,6 +41,8 @@ def list_all():
pid = get_int_or_abort(pid) pid = get_int_or_abort(pid)
query = query.filter_by(package_id=pid) query = query.filter_by(package_id=pid)
query = query.order_by(db.desc(Thread.created_at))
return render_template("threads/list.html", threads=query.all()) return render_template("threads/list.html", threads=query.all())

View File

@ -60,24 +60,31 @@
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro render_threadlist(threads, list_group=False) -%} {% macro render_threadlist(threads, compact=False) -%}
{% if not list_group %}<ul>{% endif %} {% for t in threads %}
{% for t in threads %} <a class="list-group-item list-group-item-action"
<li {% if list_group %}class="list-group-item"{% endif %}> href="{{ url_for('threads.view', id=t.id) }}">
{% if list_group %} {% if not compact %}
<a href="{{ url_for('threads.view', id=t.id) }}"> <span class="text-muted float-right">
{% if t.private %}&#x1f512; {% endif %} {{ t.created_at | datetime }}
{{ t.title }} </span>
by {{ t.author.display_name }}
</a> <span class="mr-2">
{% else %} {% if not t.review %}
{% if t.private %}&#x1f512; {% endif %} <i class="fas fa-comment-alt" style="color:#666;"></i>
<a href="{{ url_for('threads.view', id=t.id) }}">{{ t.title }}</a> {% elif t.review.recommends %}
by {{ t.author.display_name }} <i class="fas fa-thumbs-up" style="color:#6f6;"></i>
{% endif %} {% else %}
</li> <i class="fas fa-thumbs-down" style="color:#f66;"></i>
{% else %} {% endif %}
<li {% if list_group %}class="list-group-item"{% endif %}><i>No threads found</i></li> </span>
{% endfor %} {% endif %}
{% if not list_group %}</ul>{% endif %}
{% if t.private %}&#x1f512; {% endif %}
<strong>{{ t.title }}</strong>
by {{ t.author.display_name }}
</a>
{% else %}
<p>{% if list_group %}class="list-group-item"{% endif %}><i>No threads found</i></p>
{% endfor %}
{% endmacro %} {% endmacro %}

View File

@ -409,7 +409,7 @@
</div> </div>
<ul class="list-group list-group-flush"> <ul class="list-group list-group-flush">
{% from "macros/threads.html" import render_threadlist %} {% from "macros/threads.html" import render_threadlist %}
{{ render_threadlist(threads, list_group=True) }} {{ render_threadlist(threads, compact=True) }}
</ul> </ul>
</div> </div>

View File

@ -8,5 +8,7 @@ Threads
<h1>Threads</h1> <h1>Threads</h1>
{% from "macros/threads.html" import render_threadlist %} {% from "macros/threads.html" import render_threadlist %}
{{ render_threadlist(threads) }} <div class="list-group">
{{ render_threadlist(threads) }}
</div>
{% endblock %} {% endblock %}