diff --git a/common/static/scss/_common.scss b/common/static/scss/_common.scss index 1c20441e..6b84b60d 100644 --- a/common/static/scss/_common.scss +++ b/common/static/scss/_common.scss @@ -122,6 +122,16 @@ details { } } +.post { + span.invisible { + display: none; + } + + span.ellipsis:after { + content: "…"; + } +} + .action { width: max-content; float: right; diff --git a/journal/templates/replies.html b/journal/templates/replies.html index c4266af7..247b2859 100644 --- a/journal/templates/replies.html +++ b/journal/templates/replies.html @@ -1,7 +1,7 @@ {% load i18n %}
{% for post in replies %} -
+
{% 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 %} + +
+ {{ attachment.file_display_name }} +
+
+ {% endfor %}
{% empty %} diff --git a/locale/zh_Hans/LC_MESSAGES/django.po b/locale/zh_Hans/LC_MESSAGES/django.po index 5f7c0d3a..5311d261 100644 --- a/locale/zh_Hans/LC_MESSAGES/django.po +++ b/locale/zh_Hans/LC_MESSAGES/django.po @@ -2085,14 +2085,14 @@ msgstr "提到了你" msgid "" "\n" "replied to your collection %(piece_title)s\n" -msgstr "\n评论了你的收藏单 %(piece_title)s\n" +msgstr "\n回应了你的收藏单 %(piece_title)s\n" #: social/templates/event/mentioned_comment.html:3 #, python-format msgid "" "\n" "replied to your comment on %(item_title)s\n" -msgstr "\n回复了你对 %(item_title)s 的短评\n" +msgstr "\n回应了你对 %(item_title)s 的短评\n" #: social/templates/event/mentioned_review.html:2 #, python-format @@ -2101,7 +2101,7 @@ msgid "" "replied to your review %(piece_title)s on %(item_title)s\n" msgstr "" -"\n回复了你对 %(item_title)s 的评论 %(item_title)s 的评论 %(piece_title)s\n" #: social/templates/event/mentioned_shelfmember.html:3 @@ -2109,7 +2109,7 @@ msgstr "" msgid "" "\n" "replied to your mark on %(item_title)s\n" -msgstr "\n回复了你对 %(item_title)s 的标记\n" +msgstr "\n回应了你对 %(item_title)s 的标记\n" #: social/templates/events.html:44 msgid "nothing more." diff --git a/social/templates/event/_post.html b/social/templates/event/_post.html index 0166e028..065d5b3d 100644 --- a/social/templates/event/_post.html +++ b/social/templates/event/_post.html @@ -1,4 +1,4 @@ -
+
{% 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 %} + +
+ {{ attachment.file_display_name }} +
+
+ {% endfor %}
diff --git a/social/templates/event/mentioned.html b/social/templates/event/mentioned.html index 5c781a65..d7a83ece 100644 --- a/social/templates/event/mentioned.html +++ b/social/templates/event/mentioned.html @@ -2,6 +2,6 @@ {% load bleach_tags %} {% trans 'mentioned you' %}
- {{ event.post.content|bleach:"a,p,span,br,div,img"|default:"
" }} + {{ event.post.content|bleach:"a,p,span,br,div,img"|default:"" }}
{% include "event/_post.html" with post=event.reply %} diff --git a/takahe/models.py b/takahe/models.py index c766e597..6155d77e 100644 --- a/takahe/models.py +++ b/takahe/models.py @@ -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):