From 8930e4a6409554de98e979be618b3aa08ffe69cd Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Mon, 13 Jan 2025 16:23:45 +0100 Subject: [PATCH 1/5] htmx user_preview: redirect back --- app/templates/base.html | 8 ++++++-- app/user/routes.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/templates/base.html b/app/templates/base.html index fa066b25..87951b47 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -1,4 +1,4 @@ -{% macro render_username(user, add_domain=True) -%} +{% macro render_username(user, add_domain=True, htmx_redirect_back_to=None) -%} {% if user.deleted -%} {% if current_user.is_authenticated and current_user.is_admin() -%} @@ -34,7 +34,11 @@ {% endif -%} {% endif -%}
/preview') def user_preview(user_id): user = User.query.get_or_404(user_id) + return_to = request.args.get('return_to') if (user.deleted or user.banned) and current_user.is_anonymous: abort(404) - return render_template('user/user_preview.html', user=user) + return render_template('user/user_preview.html', user=user, return_to=return_to) @bp.route('/user/lookup//') From ea102b9b85ffb3377de48d3fd871661a1206d97a Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Mon, 13 Jan 2025 16:30:28 +0100 Subject: [PATCH 2/5] add user note button to profile preview popup --- app/templates/user/edit_note.html | 4 ++++ app/templates/user/user_preview.html | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/app/templates/user/edit_note.html b/app/templates/user/edit_note.html index 5f003e0e..083f3bdc 100644 --- a/app/templates/user/edit_note.html +++ b/app/templates/user/edit_note.html @@ -42,6 +42,10 @@
{{ render_form(form) }} + {% if return_to -%} +

+ {{ _('Back') }} + {% endif -%}
{{ _('This note appears next to their username. It\'s meant just for you and not displayed to anyone else.') }}
diff --git a/app/templates/user/user_preview.html b/app/templates/user/user_preview.html index cba88076..dd0dae27 100644 --- a/app/templates/user/user_preview.html +++ b/app/templates/user/user_preview.html @@ -52,6 +52,11 @@ + {% if current_user.is_authenticated -%} + + {% endif -%} From 4bcd218b8a523c23e11cc0b5ce6dd73c0eb151fa Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Mon, 13 Jan 2025 16:35:02 +0100 Subject: [PATCH 3/5] add back navigation for user preview --- app/templates/post/_post_full.html | 2 +- app/templates/post/_post_reply_teaser.html | 2 +- app/templates/post/_post_teaser.html | 2 +- app/templates/post/_post_teaser_masonry.html | 2 +- app/templates/post/post_teaser/_title.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/templates/post/_post_full.html b/app/templates/post/_post_full.html index bb343f60..bd6a9986 100644 --- a/app/templates/post/_post_full.html +++ b/app/templates/post/_post_full.html @@ -17,7 +17,7 @@

{% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) -%} {% endif -%}submitted by - {{ render_username(post.author) }} + {{ render_username(post.author, htmx_redirect_back_to=request.url) }} {% if post.edited_at -%} edited

{% if post.type == POST_TYPE_IMAGE -%} diff --git a/app/templates/post/_post_reply_teaser.html b/app/templates/post/_post_reply_teaser.html index 43a6544d..a58bb184 100644 --- a/app/templates/post/_post_reply_teaser.html +++ b/app/templates/post/_post_reply_teaser.html @@ -28,7 +28,7 @@
by - {{ render_username(post_reply.author) }} + {{ render_username(post_reply.author, htmx_redirect_back_to=request.url + '#comment_' + str(post_reply.id)) }} {% if post_reply.author.id == post_reply.post.author.id -%} [OP] {% endif -%} diff --git a/app/templates/post/_post_teaser.html b/app/templates/post/_post_teaser.html index 52f6b042..da4aba42 100644 --- a/app/templates/post/_post_teaser.html +++ b/app/templates/post/_post_teaser.html @@ -9,7 +9,7 @@ {# do nothing - blocked by keyword filter #} {% else -%}