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 { .action {
width: max-content; width: max-content;
float: right; float: right;

View file

@ -1,7 +1,7 @@
{% load i18n %} {% load i18n %}
<section class="replies" hx-target="this" hx-swap="outerHTML"> <section class="replies" hx-target="this" hx-swap="outerHTML">
{% for post in replies %} {% for post in replies %}
<div> <div class="post">
<span class="action"> <span class="action">
{% include "action_reply_post.html" %} {% include "action_reply_post.html" %}
{% include "action_like_post.html" %} {% include "action_like_post.html" %}
@ -33,6 +33,13 @@
{% else %} {% else %}
{{ post.safe_content_local }} {{ post.safe_content_local }}
{% endif %} {% 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 id="replies_{{ post.pk }}"></div>
</div> </div>
{% empty %} {% empty %}

View file

@ -2085,14 +2085,14 @@ msgstr "提到了你"
msgid "" msgid ""
"\n" "\n"
"replied to your collection <a href=\"%(piece_url)s\">%(piece_title)s</a>\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 #: social/templates/event/mentioned_comment.html:3
#, python-format #, python-format
msgid "" msgid ""
"\n" "\n"
"replied to your comment on <a href=\"%(item_url)s\">%(item_title)s</a>\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 #: social/templates/event/mentioned_review.html:2
#, python-format #, python-format
@ -2101,7 +2101,7 @@ msgid ""
"replied to your review <a href=\"%(piece_url)s\">%(piece_title)s</a> on <a " "replied to your review <a href=\"%(piece_url)s\">%(piece_title)s</a> on <a "
"href=\"%(item_url)s\">%(item_title)s</a>\n" "href=\"%(item_url)s\">%(item_title)s</a>\n"
msgstr "" 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" "href=\"%(piece_url)s\">%(piece_title)s</a>\n"
#: social/templates/event/mentioned_shelfmember.html:3 #: social/templates/event/mentioned_shelfmember.html:3
@ -2109,7 +2109,7 @@ msgstr ""
msgid "" msgid ""
"\n" "\n"
"replied to your mark on <a href=\"%(item_url)s\">%(item_title)s</a>\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 #: social/templates/events.html:44
msgid "nothing more." msgid "nothing more."

View file

@ -1,4 +1,4 @@
<div> <div class="post">
<span class="action"> <span class="action">
{% include "action_reply_post.html" %} {% include "action_reply_post.html" %}
{% include "action_like_post.html" %} {% include "action_like_post.html" %}
@ -13,5 +13,12 @@
{% else %} {% else %}
{{ post.safe_content_local }} {{ post.safe_content_local }}
{% endif %} {% 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 id="replies_{{ post.pk }}"></div>
</div> </div>

View file

@ -2,6 +2,6 @@
{% load bleach_tags %} {% load bleach_tags %}
{% trans 'mentioned you' %} {% trans 'mentioned you' %}
<blockquote class="tldr" _="on click toggle .tldr on me"> <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> </blockquote>
{% include "event/_post.html" with post=event.reply %} {% include "event/_post.html" with post=event.reply %}

View file

@ -1330,6 +1330,52 @@ class PostAttachment(models.Model):
# managed = False # managed = False
db_table = "activities_postattachment" 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): class EmojiQuerySet(models.QuerySet):
def usable(self, domain: Domain | None = None): def usable(self, domain: Domain | None = None):