From d9ae69bd0d97668c2361c149c5f37fafd5739dd4 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:26:05 +1300 Subject: [PATCH] popup user profile --- app/static/styles.css | 23 ++++++++++++++- app/static/styles.scss | 26 ++++++++++++++++- app/templates/base.html | 8 +++++- app/templates/post/_post_teaser.html | 2 +- app/templates/user/show_profile.html | 2 +- app/templates/user/user_preview.html | 42 ++++++++++++++++++++++++++++ app/user/routes.py | 8 ++++++ 7 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 app/templates/user/user_preview.html diff --git a/app/static/styles.css b/app/static/styles.css index 6d486083..9417b433 100644 --- a/app/static/styles.css +++ b/app/static/styles.css @@ -1350,7 +1350,7 @@ time { display: inline; } } -.comment .comment_author img { +.comment .comment_author .author_link img { width: 25px; height: 25px; border-radius: 50%; @@ -1959,6 +1959,27 @@ form h5 { padding-top: 0.12rem !important; } +.render_username { + position: relative; +} +.render_username .author_link { + display: inline-block; +} +.render_username .author_link:hover + .user_preview, .render_username .user_preview:hover { + display: inline-block !important; + position: absolute; + top: 17px; + left: 0; + background-color: white; + z-index: 20; +} +.render_username .user_preview .card { + width: 300px; +} +.render_username .user_preview .card .preview_avatar_image img { + max-width: 100%; +} + /* high contrast */ @media (prefers-contrast: more) { :root { diff --git a/app/static/styles.scss b/app/static/styles.scss index 90cc7304..04bc22b6 100644 --- a/app/static/styles.scss +++ b/app/static/styles.scss @@ -1010,7 +1010,7 @@ time { } } - .comment_author { + .comment_author .author_link { img { width: 25px; height: 25px; @@ -1675,6 +1675,30 @@ form { padding-top: .12rem !important; } +.render_username { + position: relative; + + .author_link { + display: inline-block; + } + + .author_link:hover + .user_preview, .user_preview:hover { + display: inline-block !important; + position: absolute; + top: 17px; + left: 0; + background-color: white; + z-index: 20; + } + + .user_preview .card { + width: 300px; + + .preview_avatar_image img { + max-width: 100%; + } + } +} /* high contrast */ @import "scss/high_contrast"; diff --git a/app/templates/base.html b/app/templates/base.html index d48d00e8..fb729fca 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -7,7 +7,7 @@ [deleted] {% endif -%} {% else -%} - + {% if user.avatar_id and not low_bandwidth and not collapsed -%} {% endif -%} @@ -33,6 +33,12 @@ [{{ user_note | truncate(12, True) }}] {% endif -%} {% endif -%} +
{% endif -%} {% endmacro -%} diff --git a/app/templates/post/_post_teaser.html b/app/templates/post/_post_teaser.html index 91541cf2..52f6b042 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 -%}
+ {% if content_blocked -%} title="{{ _('Filtered: ') }}{{ content_blocked }}"{% else %} title="Post: {{ post.title }}" aria-label="Post: {{ post.title }}"{% endif %} tabindex="0">
{% if post.type == POST_TYPE_ARTICLE %} {% include "post/post_teaser/_article.html" -%} diff --git a/app/templates/user/show_profile.html b/app/templates/user/show_profile.html index 5c536d8f..a3aad723 100644 --- a/app/templates/user/show_profile.html +++ b/app/templates/user/show_profile.html @@ -119,7 +119,7 @@ {% if current_user.is_authenticated and current_user.is_admin() and user.reputation %}{{ _('Reputation') }}: {{ user.reputation | round | int }}
{% endif %} {{ _('Posts') }}: {{ user.post_count }}
{{ _('Comments') }}: {{ user.post_reply_count }}
- {% if current_user.is_authenticated %}{{ _('User note') }}: {{ user.get_note(current_user) }}
{% endif %} + {% if current_user.is_authenticated %}{{ _('Note') }}: {{ user.get_note(current_user) }}
{% endif %}

{{ user.about_html|safe }} diff --git a/app/templates/user/user_preview.html b/app/templates/user/user_preview.html new file mode 100644 index 00000000..cdb7208a --- /dev/null +++ b/app/templates/user/user_preview.html @@ -0,0 +1,42 @@ +
+
+ +
+
+

{{ _('Instance') }}: {{ user.instance_domain() }} + {% if user.is_instance_admin() or (user.is_local() and user.is_admin()) %}({{ _('Admin') }}){% endif %}
+ {% if user.is_admin() or user.is_staff() %}{{ _('Role permissions') }}: {% if user.is_admin() %}{{ _('Admin') }}{% endif %} {% if user.is_staff() %}{{ _('Staff') }}{% endif %}
{% endif %} + {{ _('Joined') }}: {{ arrow.get(user.created).humanize(locale=locale) }}
+ {% if current_user.is_authenticated and current_user.is_admin() %}{{ _('Referer') }}: {{ user.referrer if user.referrer }}
{% endif %} + {% if current_user.is_authenticated and current_user.is_admin() %}{{ _('IP and country code') }}: {{ user.ip_address if user.ip_address }}{% if user.ip_address_country %} ({{ user.ip_address_country }}){% endif %}
{% endif %} + {% if current_user.is_authenticated and current_user.is_admin() and user.last_seen %}{{ _('Active') }}: {{ arrow.get(user.last_seen).humanize(locale=locale) }}
{% endif %} + {% if user.bot %} + {{ _('Bot Account') }}
+ {% endif %} + {{ _('Attitude') }}: {{ (user.attitude * 100) | round | int }}%
+ {% if current_user.is_authenticated and current_user.is_admin() and user.reputation %}{{ _('Reputation') }}: {{ user.reputation | round | int }}
{% endif %} + {{ _('Posts') }}: {{ user.post_count }}
+ {{ _('Comments') }}: {{ user.post_reply_count }}
+ {% if current_user.is_authenticated %}{{ _('Note') }}: {{ user.get_note(current_user) }}
{% endif %} +

+
+ {{ user.about_html|safe }} +
+
+
+ +
+
\ No newline at end of file diff --git a/app/user/routes.py b/app/user/routes.py index fe7235fc..bae7f1c4 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -1379,3 +1379,11 @@ def edit_user_note(actor): return render_template('user/edit_note.html', title=_('Edit note'), form=form, user=user, menu_topics=menu_topics(), site=g.site) + + +@bp.route('/user//preview') +def user_preview(user_id): + user = User.query.get_or_404(user_id) + if (user.deleted or user.banned) and current_user.is_anonymous: + abort(404) + return render_template('user/user_preview.html', user=user)