mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Merge pull request 'Add user note edit button to the user preview hover' (#421) from h3ndrik/pyfedi:user-preview-redirect2 into main
Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/421
This commit is contained in:
commit
da29475224
11 changed files with 38 additions and 21 deletions
|
@ -612,7 +612,7 @@ div.navbar {
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
max-width: 350px;
|
max-width: 380px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ div.navbar {
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
max-width: 350px;
|
max-width: 380px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
||||||
|
|
|
@ -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">
|
<span class="render_username">
|
||||||
{% if user.deleted -%}
|
{% if user.deleted -%}
|
||||||
{% if current_user.is_authenticated and current_user.is_admin() -%}
|
{% if current_user.is_authenticated and current_user.is_admin() -%}
|
||||||
|
@ -13,6 +13,16 @@
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{{ user.display_name() }}{% if add_domain and not user.is_local() %}<span class="text-muted">@{{ user.ap_domain }}</span>{% endif %}
|
{{ user.display_name() }}{% if add_domain and not user.is_local() %}<span class="text-muted">@{{ user.ap_domain }}</span>{% endif %}
|
||||||
</a>
|
</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() -%}
|
{% if user.created_recently() -%}
|
||||||
<span class="fe fe-new-account" title="New account"> </span>
|
<span class="fe fe-new-account" title="New account"> </span>
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
@ -33,12 +43,6 @@
|
||||||
<span class="user_note" title="{{ _('User note: %(note)s', note=user_note) }}">[{{ user_note | truncate(12, True) }}]</span>
|
<span class="user_note" title="{{ _('User note: %(note)s', note=user_note) }}">[{{ user_note | truncate(12, True) }}]</span>
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
<div 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"
|
|
||||||
></div>
|
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
</span>
|
</span>
|
||||||
{% endmacro -%}
|
{% endmacro -%}
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
<p><a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="Go to image">{{ post.url|shorten_url }}
|
<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>
|
<span class="fe fe-external"></span></a></p>
|
||||||
{% endif -%}
|
{% 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>
|
<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
|
{% 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) }}
|
{{ 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) }}{% endif -%}</time></small>
|
{% 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>
|
||||||
</p>
|
</div>
|
||||||
{% if post.type == POST_TYPE_IMAGE -%}
|
{% if post.type == POST_TYPE_IMAGE -%}
|
||||||
<div class="post_image">
|
<div class="post_image">
|
||||||
{% if post.image_id -%}
|
{% if post.image_id -%}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-auto comment_author">
|
<div class="col-auto comment_author">
|
||||||
<span class="visually-hidden">by</span>
|
<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 -%}
|
{% if post_reply.author.id == post_reply.post.author.id -%}
|
||||||
<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small"> [OP]</span>
|
<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small"> [OP]</span>
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
{# do nothing - blocked by keyword filter #}
|
{# do nothing - blocked by keyword filter #}
|
||||||
{% else -%}
|
{% 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 }}"
|
<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">
|
<div class="row">
|
||||||
{% if post.type == POST_TYPE_ARTICLE %}
|
{% if post.type == POST_TYPE_ARTICLE %}
|
||||||
{% include "post/post_teaser/_article.html" -%}
|
{% include "post/post_teaser/_article.html" -%}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set post_title = post.title.replace('`', "'") %}
|
{% 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 }}"
|
<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'))) %}
|
{% 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 }}">
|
<div class="masonry_thumb" title="{{ post_title }}">
|
||||||
{% if post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO %}
|
{% if post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO %}
|
||||||
|
|
|
@ -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) }}">
|
<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 -%}
|
{% 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 -%}
|
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>
|
||||||
|
|
|
@ -42,6 +42,10 @@
|
||||||
<button id="vomit" class="emojitoggle">🤮</button>
|
<button id="vomit" class="emojitoggle">🤮</button>
|
||||||
</div>
|
</div>
|
||||||
{{ render_form(form) }}
|
{{ 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 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>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -52,6 +52,11 @@
|
||||||
<div class="col-auto text-center">
|
<div class="col-auto text-center">
|
||||||
<a href="/u/{{ user.link() }}" class="btn btn-primary btn-sm">{{ _('View profile') }}</a>
|
<a href="/u/{{ user.link() }}" class="btn btn-primary btn-sm">{{ _('View profile') }}</a>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1346,6 +1346,7 @@ def user_read_posts_delete():
|
||||||
@login_required
|
@login_required
|
||||||
def edit_user_note(actor):
|
def edit_user_note(actor):
|
||||||
actor = actor.strip()
|
actor = actor.strip()
|
||||||
|
return_to = request.args.get('return_to')
|
||||||
if '@' in actor:
|
if '@' in actor:
|
||||||
user: User = User.query.filter_by(ap_id=actor, deleted=False).first()
|
user: User = User.query.filter_by(ap_id=actor, deleted=False).first()
|
||||||
else:
|
else:
|
||||||
|
@ -1365,22 +1366,25 @@ def edit_user_note(actor):
|
||||||
cache.delete_memoized(User.get_note, user, current_user)
|
cache.delete_memoized(User.get_note, user, current_user)
|
||||||
|
|
||||||
flash(_('Your changes have been saved.'), 'success')
|
flash(_('Your changes have been saved.'), 'success')
|
||||||
goto = request.args.get('redirect') if 'redirect' in request.args else f'/u/{actor}'
|
if return_to:
|
||||||
return redirect(goto)
|
return redirect(return_to)
|
||||||
|
else:
|
||||||
|
return redirect(f'/u/{actor}')
|
||||||
|
|
||||||
elif request.method == 'GET':
|
elif request.method == 'GET':
|
||||||
form.note.data = user.get_note(current_user)
|
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)
|
menu_topics=menu_topics(), site=g.site)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/user/<int:user_id>/preview')
|
@bp.route('/user/<int:user_id>/preview')
|
||||||
def user_preview(user_id):
|
def user_preview(user_id):
|
||||||
user = User.query.get_or_404(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:
|
if (user.deleted or user.banned) and current_user.is_anonymous:
|
||||||
abort(404)
|
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>')
|
@bp.route('/user/lookup/<person>/<domain>')
|
||||||
|
|
Loading…
Add table
Reference in a new issue