Merge remote-tracking branch 'origin/main'

This commit is contained in:
rimu 2024-12-09 09:20:02 +13:00
commit c2e92695c1
9 changed files with 56 additions and 149 deletions

View file

@ -218,7 +218,7 @@ def list_communities():
return render_template('list_communities.html', communities=communities, search=search_param, title=_('Communities'),
SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
next_url=next_url, prev_url=prev_url,
next_url=next_url, prev_url=prev_url, current_user=current_user,
topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by,
low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()),
@ -264,13 +264,13 @@ def list_local_communities():
# Pagination
communities = communities.paginate(page=page, per_page=250 if current_user.is_authenticated and not low_bandwidth else 50,
error_out=False)
next_url = url_for('main.list_communities', page=communities.next_num, sort_by=sort_by, language_id=language_id) if communities.has_next else None
prev_url = url_for('main.list_communities', page=communities.prev_num, sort_by=sort_by, language_id=language_id) if communities.has_prev and page != 1 else None
next_url = url_for('main.list_local_communities', page=communities.next_num, sort_by=sort_by, language_id=language_id) if communities.has_next else None
prev_url = url_for('main.list_local_communities', page=communities.prev_num, sort_by=sort_by, language_id=language_id) if communities.has_prev and page != 1 else None
return render_template('list_communities.html', communities=communities, search=search_param, title=_('Local Communities'),
SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
next_url=next_url, prev_url=prev_url,
next_url=next_url, prev_url=prev_url, current_user=current_user,
topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by,
low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()),
@ -311,8 +311,8 @@ def list_subscribed_communities():
# Pagination
communities = communities.paginate(page=page, per_page=250 if current_user.is_authenticated and not low_bandwidth else 50,
error_out=False)
next_url = url_for('main.list_communities', page=communities.next_num, sort_by=sort_by, language_id=language_id) if communities.has_next else None
prev_url = url_for('main.list_communities', page=communities.prev_num, sort_by=sort_by, language_id=language_id) if communities.has_prev and page != 1 else None
next_url = url_for('main.list_subscribed_communities', page=communities.next_num, sort_by=sort_by, language_id=language_id) if communities.has_next else None
prev_url = url_for('main.list_subscribed_communities', page=communities.prev_num, sort_by=sort_by, language_id=language_id) if communities.has_prev and page != 1 else None
else:
communities = []
@ -322,7 +322,7 @@ def list_subscribed_communities():
return render_template('list_communities.html', communities=communities, search=search_param, title=_('Joined Communities'),
SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
next_url=next_url, prev_url=prev_url,
next_url=next_url, prev_url=prev_url, current_user=current_user,
topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by,
low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()),
@ -366,14 +366,18 @@ def list_not_subscribed_communities():
banned_from = communities_banned_from(current_user.id)
if banned_from:
communities = communities.filter(Community.id.not_in(banned_from))
if current_user.hide_nsfw == 1:
communities = communities.filter(Community.nsfw == False)
if current_user.hide_nsfl == 1:
communities = communities.filter(Community.nsfl == False)
communities = communities.order_by(text('community.' + sort_by))
# Pagination
communities = communities.paginate(page=page, per_page=250 if current_user.is_authenticated and not low_bandwidth else 50,
error_out=False)
next_url = url_for('main.list_communities', page=communities.next_num, sort_by=sort_by, language_id=language_id) if communities.has_next else None
prev_url = url_for('main.list_communities', page=communities.prev_num, sort_by=sort_by, language_id=language_id) if communities.has_prev and page != 1 else None
next_url = url_for('main.list_not_subscribed_communities', page=communities.next_num, sort_by=sort_by, language_id=language_id) if communities.has_next else None
prev_url = url_for('main.list_not_subscribed_communities', page=communities.prev_num, sort_by=sort_by, language_id=language_id) if communities.has_prev and page != 1 else None
else:
communities = []
@ -383,7 +387,7 @@ def list_not_subscribed_communities():
return render_template('list_communities.html', communities=communities, search=search_param, title=_('Not Joined Communities'),
SUBSCRIPTION_PENDING=SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
next_url=next_url, prev_url=prev_url,
next_url=next_url, prev_url=prev_url, current_user=current_user,
topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by,
low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site)

View file

@ -1344,6 +1344,7 @@ time {
.comment {
clear: both;
margin-left: 15px;
padding-left: 0px;
padding-top: 8px;
}
.comment .limit_height {

View file

@ -998,6 +998,7 @@ time {
.comment {
clear: both;
margin-left: 15px;
padding-left: 0px;
padding-top: 8px;
.limit_height {

View file

@ -33,7 +33,7 @@
<h2 class="mt-4" id="comments">Deleted comments</h2>
<div class="post_list">
{% for post_reply in post_replies.items %}
{% with teaser=True, disable_voting=True, no_collapse=True %}
{% with teaser=True, disable_voting=True, no_collapse=True, show_deleted=True %}
{% include 'post/_post_reply_teaser.html' %}
{% endwith %}
<hr />

View file

@ -19,7 +19,7 @@
<h2 class="mt-4" id="comments">Downvoted comments</h2>
<div class="post_list">
{% for post_reply in post_replies.items %}
{% with teaser=True, disable_voting=True, no_collapse=True %}
{% with teaser=True, disable_voting=True, no_collapse=True, show_deleted=True %}
{% include 'post/_post_reply_teaser.html' %}
{% endwith %}
<hr />

View file

@ -16,12 +16,14 @@
<a href="/communities/local" aria-label="{{ _('Communities on this server') }}" class="btn {{ 'btn-primary' if request.path == '/communities/local' else 'btn-outline-secondary' }}">
{{ _('Local') }}
</a>
{% if current_user.is_authenticated -%}
<a href="/communities/subscribed" aria-label="{{ _('Joined communities') }}" class="btn {{ 'btn-primary' if request.path == '/communities/subscribed' else 'btn-outline-secondary' }}">
{{ _('Joined') }}
</a>
<a href="/communities/notsubscribed" aria-label="{{ _('Not Joined communities') }}" class="btn {{ 'btn-primary' if request.path == '/communities/notsubscribed' else 'btn-outline-secondary' }}">
{{ _('Not Joined') }}
</a>
{% endif -%}
</div>
</div>
<div class="col-auto">

View file

@ -2,6 +2,8 @@
teaser: Renders just a teaser
disable_voting: Disable voting buttons (to prevent mass downvoting)
no_collapse: Don't collapse for admin and moderator views
show_deleted: Show deleted content (for admin views)
children: replies to this reply
#}
{% if current_user.is_authenticated -%}
{% set collapsed = ((post_reply.score <= current_user.reply_collapse_threshold) or post_reply.deleted)
@ -9,7 +11,7 @@
{% else -%}
{% set collapsed = (post_reply.score <= -10) and not no_collapse -%}
{% endif -%}
<div class="container comment{% if post_reply.score <= -10 %} low_score{% endif %}" id="comment_{{ post_reply.id }}">
<div class="container comment{% if post_reply.score and post_reply.score <= -10 %} low_score{% endif %}{% if post_reply.author.id == post_reply.post.author.id %} original_poster{% endif %}" id="comment_{{ post_reply.id }}"{% if post_reply.language_id and post_reply.language.code != 'en' %} lang="{{ post_reply.language.code }}"{% endif %} aria-level="{{ post_reply.depth+1 }}" role="treeitem">
{% if not post_reply.author.indexable -%}<!--googleoff: all-->{% endif -%}
{% if teaser -%}
<div class="row">
@ -52,7 +54,15 @@
<div class="row comment_body hidable{% if post_reply.reports and current_user.is_authenticated and post_reply.post.community.is_moderator(current_user) %} reported{% endif %}">
<div class="col-12">
{% if post_reply.deleted and not show_deleted -%}
{% if post_reply.deleted_by is none or post_reply.deleted_by != post_reply.user_id -%}
<p>Deleted by moderator</p>
{% else -%}
<p>Deleted by author</p>
{% endif -%}
{% else -%}
{{ post_reply.body_html | community_links | safe }}
{% endif -%}
</div>
</div>
<div class="comment_actions hidable">
@ -76,7 +86,7 @@
{% endif -%}
</div>
<div class="notify_toggle">
{% if current_user.is_authenticated -%}
{% if current_user.is_authenticated and current_user.verified -%}
{% with comment=dict(comment=post_reply) -%}
{% include "post/_reply_notification_toggle.html" -%}
{% endwith -%}
@ -87,6 +97,23 @@
{% endif -%}
</div>
{% if not post_reply.author.indexable -%}<!--googleon all-->{% endif -%}
{% if children -%}
<div class="replies hidable" role="group">
{% if not THREAD_CUTOFF_DEPTH or post_reply.depth <= THREAD_CUTOFF_DEPTH -%}
{% for reply in children -%}
{% with post_reply=reply['comment'], children=reply['replies'] %}
{% include 'post/_post_reply_teaser.html' %}
{% endwith %}
{% endfor -%}
{% else -%}
<div class="continue_thread hidable">
<a href="{{ url_for('post.continue_discussion', post_id=post_reply.post.id, comment_id=post_reply.id, _anchor='replies') }}">Continue thread</a>
</div>
{% endif -%}
</div>
{% endif -%}
{% if collapsed -%}
<script nonce="{{ session['nonce'] }}" type="text/javascript">
if (typeof(toBeHidden) === 'undefined') {

View file

@ -12,68 +12,11 @@
<p><a href="{{ url_for('activitypub.post_ap', post_id=post.id, _anchor='replies') }}">Back to main discussion</a></p>
<div class="row post_replies">
<div class="col">
{% macro render_comment(comment) %}
<div id="comment_{{ comment['comment'].id }}" class="comment {% if comment['comment'].author.id == post.author.id %}original_poster{% endif %}" role="treeitem"
{% if comment['comment'].language_id and comment['comment'].language.code != 'en' %} lang="{{ comment['comment'].language.code }}"{% endif %}>
<div class="limit_height">
<div class="comment_author">
{% with collapsed = comment['comment'].score < -10 -%}
{{ render_username(comment['comment'].author) }}
{% endwith -%}
{% if comment['comment'].author.id == post.author.id %}<span title="Submitter of original post" aria-label="submitter" class="small">[OP] </span>{% endif %}
<span class="text-muted small">{{ comment['comment'].posted_at_localized(locale) }}{% if comment['comment'].edited_at %}, edited {{ arrow.get(comment['comment'].edited_at).humanize(locale=locale) }} {% endif %}</span>
<a class="unhide" href="#"><span class="fe fe-expand"></span></a>
{% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user)%}
<span class="red fe fe-report" title="{{ _('Reported. Check comment for issues.') }}"></span>
{% endif %}
</div>
<div class="comment_body hidable {% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user) %}reported{% endif %}">
{% if comment['comment'].deleted -%}
{% if comment['comment'].deleted_by is none or comment['comment'].deleted_by != comment['comment'].user_id -%}
<p>Deleted by moderator</p>
{% else -%}
<p>Deleted by author</p>
{% endif -%}
{% else -%}
{{ comment['comment'].body_html | community_links | safe }}
{% endif -%}
</div>
</div>
<div class="comment_actions hidable">
{% if post.comments_enabled %}
<a href="{{ url_for('post.add_reply', post_id=post.id, comment_id=comment['comment'].id) }}" rel="nofollow"><span class="fe fe-reply"></span> reply</a>
{% endif %}
<div class="voting_buttons_new">
{% with comment=comment['comment'] %}
{% include "post/_comment_voting_buttons.html" %}
{% endwith %}
</div>
<div class="hide_button">
{% if comment['comment'].score <= -10 %}
<a href='#'><span class="fe fe-expand"></span></a>
{% else %}
<a href='#'><span class="fe fe-collapse"></span></a>
{% endif %}
</div>
<div class="notify_toggle">
{% if current_user.is_authenticated and current_user.verified and current_user.id == comment['comment'].author.id %}
{% include "post/_reply_notification_toggle.html" %}
{% endif %}
</div>
<a href="{{ url_for('post.post_reply_options', post_id=post.id, comment_id=comment['comment'].id) }}" class="comment_actions_link" rel="nofollow"><span class="fe fe-options" title="Options"> </span></a>
</div>
{% if comment['replies'] %}
<div class="replies hidable" role="group">
{% for reply in comment['replies'] %}
{{ render_comment(reply) | safe }}
{% endfor %}
</div>
{% endif %}
</div>
{% endmacro %}
<div id="replies" class="comments" role="tree">
{% for reply in replies %}
{{ render_comment(reply) | safe }}
{% with post_reply=reply['comment'], children=reply['replies'] %}
{% include 'post/_post_reply_teaser.html' %}
{% endwith %}
{% endfor %}
</div>
</div>

View file

@ -73,83 +73,12 @@
{{ _('New') }}
</a>
</div>
{% macro render_comment(comment) -%}
<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'].language_id and comment['comment'].language.code != 'en' -%} lang="{{ comment['comment'].language.code }}"{% endif %}
aria-level="{{ comment['comment'].depth + 1 }}" role="treeitem" aria-expanded="true" tabindex="0">
<div class="limit_height">{% if not comment['comment'].author.indexable -%}<!--googleoff: all-->{% endif -%}
<div class="comment_author">
{% with collapsed = (comment['comment'].score < reply_collapse_threshold or comment['comment'].deleted) -%}
{{ render_username(comment['comment'].author) }}
{% endwith -%}
{% if comment['comment'].author.id == post.author.id -%}<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small">[OP] </span>{% endif -%}
<a href="#comment_{{ comment['comment'].id }}" class="text-muted small" aria_label="{{ _('When: ') }}">{{ comment['comment'].posted_at_localized(locale) }}{% if comment['comment'].edited_at -%}, edited {{ arrow.get(comment['comment'].edited_at).humanize(locale=locale) }} {% endif -%}</a>
<a class="unhide" href="#"><span class="fe fe-expand"></span></a>
{% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user)%}
<span class="red fe fe-report" title="{{ _('Reported. Check comment for issues.') }}"></span>
{% endif -%}
</div>
<div class="comment_body hidable {% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user) -%}reported{% endif -%}">
{% if comment['comment'].deleted -%}
{% if comment['comment'].deleted_by is none or comment['comment'].deleted_by != comment['comment'].user_id -%}
<p>Deleted by moderator</p>
{% else -%}
<p>Deleted by author</p>
{% endif -%}
{% else -%}
{{ comment['comment'].body_html | community_links | safe }}
{% endif -%}
</div>{% if not comment['comment'].author.indexable -%}<!--googleon: all-->{% endif -%}
</div>
<div class="comment_actions hidable">
{% if post.comments_enabled -%}
<a href="{{ url_for('post.add_reply', post_id=post.id, comment_id=comment['comment'].id) }}" rel="nofollow noindex"><span class="fe fe-reply"></span> reply</a>
{% endif -%}
<div class="voting_buttons_new">
{% with comment=comment['comment'] -%}
{% include "post/_comment_voting_buttons.html" -%}
{% endwith -%}
</div>
<div class="hide_button">
{% if comment['comment'].score <= reply_collapse_threshold or comment['comment'].deleted -%}
<a href='#'><span class="fe fe-expand"></span></a>
{% else -%}
<a href='#'><span class="fe fe-collapse"></span></a>
{% endif -%}
</div>
<div class="notify_toggle">
{% if current_user.is_authenticated and current_user.verified -%}
{% include "post/_reply_notification_toggle.html" -%}
{% endif -%}
</div>
<a href="{{ url_for('post.post_reply_options', post_id=post.id, comment_id=comment['comment'].id) }}" class="comment_actions_link" rel="nofollow noindex" aria-label="{{ _('Comment options') }}"><span class="fe fe-options" title="Options"> </span></a>
</div>
{% if comment['replies'] -%}
{% if comment['comment'].depth <= THREAD_CUTOFF_DEPTH -%}
<div class="replies hidable" role="group">
{% for reply in comment['replies'] -%}
{{ render_comment(reply) | safe }}
{% endfor -%}
</div>
{% else -%}
<div class="continue_thread hidable">
<a href="{{ url_for('post.continue_discussion', post_id=post.id, comment_id=comment['comment'].id, _anchor='replies') }}">
Continue thread</a>
</div>
{% endif -%}
{% endif -%}
</div>
{% if comment['comment'].score <= reply_collapse_threshold or comment['comment'].deleted -%}
<script nonce="{{ session['nonce'] }}" type="text/javascript">
toBeHidden.push({{ comment['comment'].id }});
</script>
{% endif -%}
{% endmacro -%}
<div id="replies" class="comments" role="tree" aria-label="{{ _('Comments') }}" aria-expanded="true">
{% for reply in replies -%}
{{ render_comment(reply) | safe }}
{% with post_reply=reply['comment'], children=reply['replies'] %}
{% include 'post/_post_reply_teaser.html' %}
{% endwith %}
{% endfor -%}
</div>
</div>