Merge remote-tracking branch 'origin/main'

# Conflicts:
#	app/templates/base.html
This commit is contained in:
rimu 2025-01-16 16:39:16 +13:00
commit 192b6470f7
11 changed files with 38 additions and 21 deletions

View file

@ -612,7 +612,7 @@ div.navbar {
}
.card {
max-width: 350px;
max-width: 380px;
margin-left: auto;
margin-right: auto;
}

View file

@ -175,7 +175,7 @@ div.navbar {
}
.card {
max-width: 350px;
max-width: 380px;
margin-left: auto;
margin-right: auto;

View file

@ -1,4 +1,4 @@
{% macro render_username(user, add_domain=True) -%}
{% macro render_username(user, add_domain=True, htmx_redirect_back_to=None) -%}
<span class="render_username">
{% if user.deleted -%}
{% if current_user.is_authenticated and current_user.is_admin() -%}
@ -13,6 +13,16 @@
{% endif -%}
{{ user.display_name() }}{% if add_domain and not user.is_local() %}<span class="text-muted">@{{ user.ap_domain }}</span>{% endif %}
</a>
<div class="d-none user_preview" id="preview_{{ user.id }}"
{% if htmx_redirect_back_to -%}
hx-get="{{ url_for('user.user_preview', user_id=user.id, return_to=htmx_redirect_back_to) }}"
{% else %}
hx-get="{{ url_for('user.user_preview', user_id=user.id) }}"
{% endif %}
hx-trigger="intersect once"
hx-target="this"
hx-swap="innerHTML"
></div>
{% if user.created_recently() -%}
<span class="fe fe-new-account" title="New account"> </span>
{% endif -%}
@ -33,12 +43,6 @@
<span class="user_note" title="{{ _('User note: %(note)s', note=user_note) }}">[{{ user_note | truncate(12, True) }}]</span>
{% endif -%}
{% endif -%}
<span class="d-none user_preview" id="preview_{{ user.id }}"
hx-get="{{ url_for('user.user_preview', user_id=user.id) }}"
hx-trigger="intersect once"
hx-target="this"
hx-swap="innerHTML"
></span>
{% endif -%}
</span>
{% endmacro -%}

View file

@ -14,12 +14,12 @@
<p><a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="Go to image">{{ post.url|shorten_url }}
<span class="fe fe-external"></span></a></p>
{% endif -%}
<p>{% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) -%}
<div>{% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) -%}
<span class="red fe fe-report" title="{{ _('Reported. Check post for issues.') }}"></span>
{% endif -%}<small>submitted <time datetime="{{ arrow.get(post.posted_at).format('YYYY-MM-DD HH:mm:ss ZZ') }}" title="{{ arrow.get(post.posted_at).format('YYYY-MM-DD HH:mm:ss ZZ') }}">{{ arrow.get(post.posted_at).humanize(locale=locale) }}</time> by
{{ render_username(post.author) }}
{% if post.edited_at -%} edited <time datetime="{{ arrow.get(post.posted_at).format('YYYY-MM-DD HH:mm:ss ZZ') }}" title="{{ arrow.get(post.posted_at).format('YYYY-MM-DD HH:mm:ss ZZ') }}">{{ arrow.get(post.edited_at).humanize(locale=locale) }}{% endif -%}</time></small>
</p>
{{ render_username(post.author, htmx_redirect_back_to=request.url) }}
{% if post.edited_at -%} edited <time datetime="{{ arrow.get(post.posted_at).format('YYYY-MM-DD HH:mm:ss ZZ') }}" title="{{ arrow.get(post.posted_at).format('YYYY-MM-DD HH:mm:ss ZZ') }}">{{ arrow.get(post.edited_at).humanize(locale=locale) }}</time>{% endif -%}</small>
</div>
{% if post.type == POST_TYPE_IMAGE -%}
<div class="post_image">
{% if post.image_id -%}

View file

@ -28,7 +28,7 @@
<div class="row">
<div class="col-auto comment_author">
<span class="visually-hidden">by</span>
{{ 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 -%}
<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small"> [OP]</span>
{% endif -%}

View file

@ -9,7 +9,7 @@
{# do nothing - blocked by keyword filter #}
{% else -%}
<div class="h-entry pb-0 post_teaser type_{{ post.type }}{{ ' reported' if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator() }}{{ ' blocked' if content_blocked }}{{ ' blur' if blur_content }}"
{% if content_blocked -%} title="{{ _('Filtered: ') }}{{ content_blocked }}"{% else %} title="Post: {{ post.title }}" aria-label="Post: {{ post.title }}"{% endif %} tabindex="0">
{% if content_blocked -%} title="{{ _('Filtered: ') }}{{ content_blocked }}"{% else %} title="Post: {{ post.title }}" aria-label="Post: {{ post.title }}"{% endif %} id="post_{{ post.id }}" tabindex="0">
<div class="row">
{% if post.type == POST_TYPE_ARTICLE %}
{% include "post/post_teaser/_article.html" -%}

View file

@ -11,7 +11,7 @@
{% else %}
{% set post_title = post.title.replace('`', "'") %}
<div class="item{{ ' reported' if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator() }}{{ ' blocked' if content_blocked }}{{ ' blur' if blur_content }}"
{% if content_blocked %} title="{{ _('Filtered: ') }}{{ content_blocked }}"{% endif %}>
{% if content_blocked %} title="{{ _('Filtered: ') }}{{ content_blocked }}"{% endif %} id="post_{{ post.id }}">
{% if post.image_id and not (post.url and (post.url.endswith('.mp4') or post.url.endswith('.webm'))) %}
<div class="masonry_thumb" title="{{ post_title }}">
{% if post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO %}

View file

@ -28,4 +28,4 @@
<span class="author small">{% if show_post_community -%}<a href="/c/{{ post.community.link() }}" aria-label="{{ _('Go to community %(name)s', name=post.community.name) }}">
{% if post.community.icon_id and not low_bandwidth %}<img class="community_icon_small rounded-circle" src="{{ post.community.icon_image('tiny') }}" alt="Community icon" />{% endif -%}
c/{{ post.community.name }}</a>{% endif -%}
by {{ render_username(post.author) }} <time datetime="{{ post.last_active }}" title="{{ post.last_active }}">{{ post.posted_at_localized(sort, locale) }}</time></span>
by {{ render_username(post.author, htmx_redirect_back_to=request.url + '#post_' + str(post.id)) }} <time datetime="{{ post.last_active }}" title="{{ post.last_active }}">{{ post.posted_at_localized(sort, locale) }}</time></span>

View file

@ -42,6 +42,10 @@
<button id="vomit" class="emojitoggle">🤮</button>
</div>
{{ render_form(form) }}
{% if return_to -%}
<p></p>
<a href="{{ return_to }}" class="go_back">{{ _('Back') }}</a>
{% endif -%}
<div class="row mt-5"><small class="field_hint">{{ _('This note appears next to their username. It\'s meant just for you and not displayed to anyone else.') }}</small></div>
</div>
</div>

View file

@ -53,6 +53,11 @@
<div class="col-auto text-center">
<a href="/u/{{ user.link() }}" class="btn btn-primary btn-sm">{{ _('View profile') }}</a>
</div>
{% if current_user.is_authenticated -%}
<div class="col-auto text-center">
<a href="{{ url_for('user.edit_user_note', actor=user.link(), return_to=return_to) }}" class="btn btn-secondary btn-sm">{{ _('Edit note') }}</a>
</div>
{% endif -%}
</div>
</div>
</div>

View file

@ -1346,6 +1346,7 @@ def user_read_posts_delete():
@login_required
def edit_user_note(actor):
actor = actor.strip()
return_to = request.args.get('return_to')
if '@' in actor:
user: User = User.query.filter_by(ap_id=actor, deleted=False).first()
else:
@ -1365,22 +1366,25 @@ def edit_user_note(actor):
cache.delete_memoized(User.get_note, user, current_user)
flash(_('Your changes have been saved.'), 'success')
goto = request.args.get('redirect') if 'redirect' in request.args else f'/u/{actor}'
return redirect(goto)
if return_to:
return redirect(return_to)
else:
return redirect(f'/u/{actor}')
elif request.method == 'GET':
form.note.data = user.get_note(current_user)
return render_template('user/edit_note.html', title=_('Edit note'), form=form, user=user,
return render_template('user/edit_note.html', title=_('Edit note'), form=form, user=user, return_to=return_to,
menu_topics=menu_topics(), site=g.site)
@bp.route('/user/<int:user_id>/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/<person>/<domain>')