From b44562b3d70ca8bbc2247cfe9fb56ae05a965c2f Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 13 Apr 2024 00:53:56 -0400 Subject: [PATCH] show title deco for editions in comments --- catalog/book/models.py | 5 +++++ catalog/common/models.py | 4 ++++ catalog/templates/_item_comments.html | 4 +++- catalog/templates/_item_reviews.html | 4 +++- catalog/templates/edition.html | 2 +- common/static/scss/_common.scss | 5 +++++ journal/templates/action_open_post.html | 1 + journal/templates/collection.html | 3 ++- journal/templates/review.html | 3 ++- 9 files changed, 26 insertions(+), 5 deletions(-) diff --git a/catalog/book/models.py b/catalog/book/models.py index 04beca1f..f0df61f2 100644 --- a/catalog/book/models.py +++ b/catalog/book/models.py @@ -208,6 +208,11 @@ class Edition(Item): .exclude(merged_to_item__isnull=False) ) + @property + def title_deco(self): + a = [str(i) for i in [self.pub_house, self.pub_year] if i] + return f"({' '.join(a)})" if a else "" + def has_related_books(self): works = list(self.works.all()) if not works: diff --git a/catalog/common/models.py b/catalog/common/models.py index 80529672..a7712462 100644 --- a/catalog/common/models.py +++ b/catalog/common/models.py @@ -354,6 +354,10 @@ class Item(SoftDeleteMixin, PolymorphicModel): def sibling_items(self): return Item.objects.none() + @property + def title_deco(self) -> str: + return "" + @property def sibling_item_ids(self): return list(self.sibling_items.values_list("id", flat=True)) diff --git a/catalog/templates/_item_comments.html b/catalog/templates/_item_comments.html index 8dab0d1e..e5ca2235 100644 --- a/catalog/templates/_item_comments.html +++ b/catalog/templates/_item_comments.html @@ -66,7 +66,9 @@ {{ comment.mark.action_label }} - {% if comment.item != item %}{{ comment.item.title }}{% endif %} + {% if comment.item != item %} + {{ comment.item.title }}{{ comment.item.title_deco }} + {% endif %}
{{ comment.html|safe }}
{% if comment.latest_post %}
{% endif %} diff --git a/catalog/templates/_item_reviews.html b/catalog/templates/_item_reviews.html index 346222c9..1b34f081 100644 --- a/catalog/templates/_item_reviews.html +++ b/catalog/templates/_item_reviews.html @@ -28,7 +28,9 @@ {{ review.created_time|date }} 评论 - {% if review.item != item %}{{ review.item.title }}{% endif %} + {% if review.item != item %} + {{ review.item.title }}{{ comment.item.title_deco }} + {% endif %}
{{ review.title }} diff --git a/catalog/templates/edition.html b/catalog/templates/edition.html index cf80507c..44fc7657 100644 --- a/catalog/templates/edition.html +++ b/catalog/templates/edition.html @@ -118,7 +118,7 @@ {% for b in related_books %}
{{ b.title }} - ({{ b.pub_house | default:'' }} {{ b.pub_year | default:'' }}) + {{ b.title_deco }} {% comment %} {% for res in b.external_resources.all %} {{ res.site_name.label }} diff --git a/common/static/scss/_common.scss b/common/static/scss/_common.scss index 11c4748d..1c20441e 100644 --- a/common/static/scss/_common.scss +++ b/common/static/scss/_common.scss @@ -171,6 +171,11 @@ details { } } +small.title_deco { + color: var(--pico-muted-color); + opacity: 0.5; +} + form img { max-height: 20vh; } diff --git a/journal/templates/action_open_post.html b/journal/templates/action_open_post.html index 018a5729..43c823a4 100644 --- a/journal/templates/action_open_post.html +++ b/journal/templates/action_open_post.html @@ -2,6 +2,7 @@ {% if post.visibility == 1 %} diff --git a/journal/templates/collection.html b/journal/templates/collection.html index 624e3d16..fe114e46 100644 --- a/journal/templates/collection.html +++ b/journal/templates/collection.html @@ -142,7 +142,8 @@ + onclick="navigator.share({url:'{{ collection.shared_link|escapejs }}'});event.preventDefault();" + title="联邦宇宙分享链接"> 创建于 {{ collection.created_time|date }} diff --git a/journal/templates/review.html b/journal/templates/review.html index ced529e2..ab9fef1b 100644 --- a/journal/templates/review.html +++ b/journal/templates/review.html @@ -94,7 +94,8 @@ + onclick="navigator.share({url:'{{ review.shared_link |escapejs }}'});event.preventDefault();" + title="联邦宇宙分享链接"> {{ review.created_time|date }}