user page UI: ellipsize user-visible handles

fixes #994
pull/1141/head
Ryan Barrett 2024-06-19 11:05:10 -07:00
rodzic b20bbf0564
commit 349f4ba544
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
4 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -671,9 +671,10 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
return f"""\
<span class="logo" title="{self.__class__.__name__}">{self.LOGO_HTML}</span>
<a class="h-card u-author" href="{url}" title="{self.name()}">
<a class="h-card u-author" href="{url}" title="{self.name()} {maybe_handle}">
{img}
{util.ellipsize(self.name(), chars=40)} {maybe_handle}
{util.ellipsize(self.name(), chars=40)}
{util.ellipsize(maybe_handle, chars=40)}
</a>"""
def profile_picture(self):

Wyświetl plik

@ -44,11 +44,12 @@
{% if proto and not isinstance(user, proto) and proto.LABEL not in ('ui', 'web')
and user.is_enabled(proto) %}
{% set url = proto.bridged_web_url_for(user) %}
{% set handle = user.handle_as(proto) %}
&middot;
<nobr title="{{ proto.__name__ }} (bridged)">
<nobr title="{{ proto.__name__ }} (bridged): {{ handle }}">
{% if url %} <a href="{{ url }}"> {% endif %}
<span class="logo">{{ proto.LOGO_HTML|safe }}</span>
{{ user.handle_as(proto) }}
{{ util.ellipsize(handle, chars=40) }}
{% if url %} </a> {% endif %}
</nobr>
{% endif %}

Wyświetl plik

@ -31,7 +31,7 @@ class CommonTest(TestCase):
# current user's homepage gets converted to BF user page
self.assert_multiline_equals("""\
<span class="logo" title="Web">🌐</span>
<a class="h-card u-author" href="/web/user.com" title="user.com">
<a class="h-card u-author" href="/web/user.com" title="user.com ">
user.com
</a>""", common.pretty_link('https://user.com/', user=Web(id='user.com')),
ignore_blanks=True)

Wyświetl plik

@ -173,17 +173,17 @@ class UserTest(TestCase):
def test_user_link(self):
self.assert_multiline_equals("""\
<span class="logo" title="Web">🌐</span>
<a class="h-card u-author" href="/web/y.z" title="y.z">
<a class="h-card u-author" href="/web/y.z" title="y.z ">
y.z
</a>""", self.user.user_link(), ignore_blanks=True)
self.user.obj = Object(id='a', as2=ACTOR)
self.assert_multiline_equals("""\
<span class="logo" title="Web">🌐</span>
<a class="h-card u-author" href="/web/y.z" title="Mrs. ☕ Foo">
<a class="h-card u-author" href="/web/y.z" title="Mrs. ☕ Foo ">
<img src="https://user.com/me.jpg" class="profile">
Mrs. Foo
</a>""", self.user.user_link())
</a>""", self.user.user_link(), ignore_blanks=True)
def test_is_web_url(self):
for url in 'y.z', '//y.z', 'http://y.z', 'https://y.z':
@ -626,7 +626,7 @@ class ObjectTest(TestCase):
obj = Object(id='x', source_protocol='ui', users=[self.user.key])
got = obj.actor_link(user=self.user)
self.assertIn('href="web:fake:user" title="Alice">', got)
self.assertIn('href="web:fake:user" title="Alice ">', got)
self.assertIn('Alice', got)
def test_actor_link_object_in_datastore(self):