From aa06a1f43466f870fffcdf024ee24b52a53c4e24 Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Thu, 5 Dec 2024 13:11:40 +0100 Subject: [PATCH 1/3] replace macro render_comment --- app/static/styles.css | 1 + app/static/styles.scss | 1 + app/templates/admin/deleted_posts.html | 2 +- app/templates/admin/spam_posts.html | 2 +- app/templates/post/_post_reply_teaser.html | 33 ++++++++- app/templates/post/continue_discussion.html | 63 +---------------- app/templates/post/post.html | 77 +-------------------- 7 files changed, 40 insertions(+), 139 deletions(-) diff --git a/app/static/styles.css b/app/static/styles.css index 060a97ee..6dd24f06 100644 --- a/app/static/styles.css +++ b/app/static/styles.css @@ -1343,6 +1343,7 @@ time { .comment { clear: both; margin-left: 15px; + padding-left: 0px; padding-top: 8px; } .comment .limit_height { diff --git a/app/static/styles.scss b/app/static/styles.scss index 9b69b5ab..667ae4fd 100644 --- a/app/static/styles.scss +++ b/app/static/styles.scss @@ -997,6 +997,7 @@ time { .comment { clear: both; margin-left: 15px; + padding-left: 0px; padding-top: 8px; .limit_height { diff --git a/app/templates/admin/deleted_posts.html b/app/templates/admin/deleted_posts.html index bf4cef49..75164833 100644 --- a/app/templates/admin/deleted_posts.html +++ b/app/templates/admin/deleted_posts.html @@ -33,7 +33,7 @@

Deleted comments

{% 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 %}
diff --git a/app/templates/admin/spam_posts.html b/app/templates/admin/spam_posts.html index 8c3c98eb..cc9f3a15 100644 --- a/app/templates/admin/spam_posts.html +++ b/app/templates/admin/spam_posts.html @@ -19,7 +19,7 @@

Downvoted comments

{% 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 %}
diff --git a/app/templates/post/_post_reply_teaser.html b/app/templates/post/_post_reply_teaser.html index 29ceb0f2..f0637cd7 100644 --- a/app/templates/post/_post_reply_teaser.html +++ b/app/templates/post/_post_reply_teaser.html @@ -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 -%} -
+
{% if not post_reply.author.indexable -%}{% endif -%} {% if teaser -%}
@@ -52,7 +54,15 @@
- {{ post_reply.body_html | community_links | safe }} + {% if post_reply.deleted and not show_deleted -%} + {% if post_reply.deleted_by is none or post_reply.deleted_by != post_reply.user_id -%} +

Deleted by moderator

+ {% else -%} +

Deleted by author

+ {% endif -%} + {% else -%} + {{ post_reply.body_html | community_links | safe }} + {% endif -%}
@@ -76,7 +86,7 @@ {% endif -%}
- {% 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 -%}
{% if not post_reply.author.indexable -%}{% endif -%} + + {% if children -%} +
+ {% 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 -%} + + {% endif -%} +
+ {% endif -%} + {% if collapsed -%} - {% endif -%} - {% endmacro -%}
{% for reply in replies -%} - {{ render_comment(reply) | safe }} + {% with post_reply=reply['comment'], children=reply['replies'] %} + {% include 'post/_post_reply_teaser.html' %} + {% endwith %} {% endfor -%}
From 7305b6072cf064ec16e88a28690ba687c93cb2bc Mon Sep 17 00:00:00 2001 From: aroberts-fox Date: Sat, 7 Dec 2024 12:06:00 -0500 Subject: [PATCH 2/3] Only show joined, not joined buttons to logged in users --- app/main/routes.py | 12 ++++++++---- app/templates/list_communities.html | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/main/routes.py b/app/main/routes.py index 2356b3cf..b23ca282 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -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()), @@ -270,7 +270,7 @@ def list_local_communities(): 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()), @@ -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,6 +366,10 @@ 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)) @@ -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) diff --git a/app/templates/list_communities.html b/app/templates/list_communities.html index 6ae9f83a..98416594 100644 --- a/app/templates/list_communities.html +++ b/app/templates/list_communities.html @@ -16,12 +16,14 @@ {{ _('Local') }} + {% if current_user.is_authenticated -%} {{ _('Joined') }} {{ _('Not Joined') }} + {% endif -%}
From 272e9bc860d9084daedba4472e50b39cf13eaaa4 Mon Sep 17 00:00:00 2001 From: aroberts-fox Date: Sat, 7 Dec 2024 15:48:49 -0500 Subject: [PATCH 3/3] fix pagination next/back url_for paths --- app/main/routes.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/main/routes.py b/app/main/routes.py index b23ca282..9a5ecbb7 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -264,8 +264,8 @@ 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, @@ -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 = [] @@ -376,8 +376,8 @@ def list_not_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_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 = []