improve notification display

This commit is contained in:
Your Name 2024-04-20 22:02:42 -04:00 committed by Henri Dickson
parent bcd9a63c39
commit 50cd724e88
6 changed files with 77 additions and 7 deletions

View file

@ -122,6 +122,16 @@ details {
}
}
.post {
span.invisible {
display: none;
}
span.ellipsis:after {
content: "";
}
}
.action {
width: max-content;
float: right;

View file

@ -1,7 +1,7 @@
{% load i18n %}
<section class="replies" hx-target="this" hx-swap="outerHTML">
{% for post in replies %}
<div>
<div class="post">
<span class="action">
{% include "action_reply_post.html" %}
{% include "action_like_post.html" %}
@ -33,6 +33,13 @@
{% else %}
{{ post.safe_content_local }}
{% endif %}
{% for attachment in post.attachments.all %}
<a href="{{ attachment.full_url.relative }}" class="download">
<div>
<i class="fa-solid fa-download"></i> {{ attachment.file_display_name }}
</div>
</a>
{% endfor %}
<div id="replies_{{ post.pk }}"></div>
</div>
{% empty %}

View file

@ -2085,14 +2085,14 @@ msgstr "提到了你"
msgid ""
"\n"
"replied to your collection <a href=\"%(piece_url)s\">%(piece_title)s</a>\n"
msgstr "\n评论了你的收藏单 <a href=\"%(piece_url)s\">%(piece_title)s</a>\n"
msgstr "\n回应了你的收藏单 <a href=\"%(piece_url)s\">%(piece_title)s</a>\n"
#: social/templates/event/mentioned_comment.html:3
#, python-format
msgid ""
"\n"
"replied to your comment on <a href=\"%(item_url)s\">%(item_title)s</a>\n"
msgstr "\n回了你对 <a href=\"%(item_url)s\">%(item_title)s</a> 的短评\n"
msgstr "\n回了你对 <a href=\"%(item_url)s\">%(item_title)s</a> 的短评\n"
#: social/templates/event/mentioned_review.html:2
#, python-format
@ -2101,7 +2101,7 @@ msgid ""
"replied to your review <a href=\"%(piece_url)s\">%(piece_title)s</a> on <a "
"href=\"%(item_url)s\">%(item_title)s</a>\n"
msgstr ""
"\n回了你对 <a href=\"%(item_url)s\">%(item_title)s</a> 的评论 <a "
"\n回了你对 <a href=\"%(item_url)s\">%(item_title)s</a> 的评论 <a "
"href=\"%(piece_url)s\">%(piece_title)s</a>\n"
#: social/templates/event/mentioned_shelfmember.html:3
@ -2109,7 +2109,7 @@ msgstr ""
msgid ""
"\n"
"replied to your mark on <a href=\"%(item_url)s\">%(item_title)s</a>\n"
msgstr "\n回了你对 <a href=\"%(item_url)s\">%(item_title)s</a> 的标记\n"
msgstr "\n回了你对 <a href=\"%(item_url)s\">%(item_title)s</a> 的标记\n"
#: social/templates/events.html:44
msgid "nothing more."

View file

@ -1,4 +1,4 @@
<div>
<div class="post">
<span class="action">
{% include "action_reply_post.html" %}
{% include "action_like_post.html" %}
@ -13,5 +13,12 @@
{% else %}
{{ post.safe_content_local }}
{% endif %}
{% for attachment in post.attachments.all %}
<a href="{{ attachment.full_url.relative }}" class="download">
<div>
<i class="fa-solid fa-download"></i> {{ attachment.file_display_name }}
</div>
</a>
{% endfor %}
<div id="replies_{{ post.pk }}"></div>
</div>

View file

@ -2,6 +2,6 @@
{% load bleach_tags %}
{% trans 'mentioned you' %}
<blockquote class="tldr" _="on click toggle .tldr on me">
{{ event.post.content|bleach:"a,p,span,br,div,img"|default:"<br>" }}
{{ event.post.content|bleach:"a,p,span,br,div,img"|default:"" }}
</blockquote>
{% include "event/_post.html" with post=event.reply %}

View file

@ -1330,6 +1330,52 @@ class PostAttachment(models.Model):
# managed = False
db_table = "activities_postattachment"
def is_image(self):
return self.mimetype in [
"image/apng",
"image/avif",
"image/gif",
"image/jpeg",
"image/png",
"image/webp",
]
def is_video(self):
return self.mimetype in [
"video/mp4",
"video/ogg",
"video/webm",
]
def thumbnail_url(self) -> RelativeAbsoluteUrl:
if self.thumbnail:
return RelativeAbsoluteUrl(self.thumbnail.url)
elif self.file:
return RelativeAbsoluteUrl(self.file.url)
else:
return ProxyAbsoluteUrl(
f"/proxy/post_attachment/{self.pk}/",
remote_url=self.remote_url,
)
def full_url(self):
if self.file:
return RelativeAbsoluteUrl(self.file.url)
if self.is_image():
return ProxyAbsoluteUrl(
f"/proxy/post_attachment/{self.pk}/",
remote_url=self.remote_url,
)
return RelativeAbsoluteUrl(self.remote_url)
@property
def file_display_name(self):
if self.remote_url:
return self.remote_url.rsplit("/", 1)[-1]
if self.file:
return self.file.name.rsplit("/", 1)[-1]
return f"attachment ({self.mimetype})"
class EmojiQuerySet(models.QuerySet):
def usable(self, domain: Domain | None = None):