mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
UI to let people change comment sort order
This commit is contained in:
parent
6846902480
commit
7ad2781eb5
2 changed files with 16 additions and 3 deletions
|
@ -29,8 +29,10 @@ def show_post(post_id: int):
|
||||||
if community.banned:
|
if community.banned:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
sort = request.args.get('sort', 'top')
|
||||||
|
|
||||||
# If nothing has changed since their last visit, return HTTP 304
|
# If nothing has changed since their last visit, return HTTP 304
|
||||||
current_etag = f"{post.id}_{hash(post.last_active)}"
|
current_etag = f"{post.id}{sort}_{hash(post.last_active)}"
|
||||||
if current_user.is_anonymous and request_etag_matches(current_etag):
|
if current_user.is_anonymous and request_etag_matches(current_etag):
|
||||||
return return_304(current_etag)
|
return return_304(current_etag)
|
||||||
|
|
||||||
|
@ -165,7 +167,7 @@ def show_post(post_id: int):
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post_id)) # redirect to current page to avoid refresh resubmitting the form
|
return redirect(url_for('activitypub.post_ap', post_id=post_id)) # redirect to current page to avoid refresh resubmitting the form
|
||||||
else:
|
else:
|
||||||
replies = post_replies(post.id, 'top')
|
replies = post_replies(post.id, sort)
|
||||||
form.notify_author.data = True
|
form.notify_author.data = True
|
||||||
|
|
||||||
og_image = post.image.source_url if post.image_id else None
|
og_image = post.image.source_url if post.image_id else None
|
||||||
|
|
|
@ -44,8 +44,19 @@
|
||||||
<p>{{ _('Comments are disabled.') }}</p>
|
<p>{{ _('Comments are disabled.') }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if replies %}
|
{% if replies %}
|
||||||
<div class="row post_replies">
|
<div id="post_replies" class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
<div class="btn-group mt-1 mb-2">
|
||||||
|
<a href="?sort=hot#submit" title="{{ _('Sort by magic') }}" class="btn btn-sm {{ 'btn-primary' if request.args.get('sort', '') == '' or request.args.get('sort', '') == 'hot' else 'btn-outline-secondary' }}" rel="nofollow">
|
||||||
|
{{ _('Hot') }}
|
||||||
|
</a>
|
||||||
|
<a href="?sort=top#submit" title="{{ _('Comments with the most upvotes') }}" class="btn btn-sm {{ 'btn-primary' if request.args.get('sort', '') == 'top' else 'btn-outline-secondary' }}" rel="nofollow">
|
||||||
|
{{ _('Top') }}
|
||||||
|
</a>
|
||||||
|
<a href="?sort=new#submit" title="{{ _('Show newest first') }}" class="btn btn-sm {{ 'btn-primary' if request.args.get('sort', '') == 'new' else 'btn-outline-secondary' }}" rel="nofollow">
|
||||||
|
{{ _('New') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
{% macro render_comment(comment) %}
|
{% macro render_comment(comment) %}
|
||||||
<div id="comment_{{ comment['comment'].id }}" class="comment {% if comment['comment'].score <= -10 %}low_score{% endif %}
|
<div id="comment_{{ comment['comment'].id }}" class="comment {% if comment['comment'].score <= -10 %}low_score{% endif %}
|
||||||
{% if comment['comment'].author.id == post.author.id %}original_poster{% endif %}">
|
{% if comment['comment'].author.id == post.author.id %}original_poster{% endif %}">
|
||||||
|
|
Loading…
Add table
Reference in a new issue