From 978760475f5140f61f8f3dd7c3a7a0b454fa412c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 20 Apr 2021 09:54:02 -0700 Subject: [PATCH 1/7] More compact display of statuses --- .../snippets/status/book_preview.html | 14 -- .../snippets/status/content_status.html | 126 ++++++++++++++++ .../snippets/status/generated_status.html | 43 ++++++ .../templates/snippets/status/layout.html | 86 +++++++++++ .../snippets/status/status_body.html | 89 +----------- .../snippets/status/status_content.html | 137 ------------------ 6 files changed, 261 insertions(+), 234 deletions(-) delete mode 100644 bookwyrm/templates/snippets/status/book_preview.html create mode 100644 bookwyrm/templates/snippets/status/content_status.html create mode 100644 bookwyrm/templates/snippets/status/generated_status.html create mode 100644 bookwyrm/templates/snippets/status/layout.html delete mode 100644 bookwyrm/templates/snippets/status/status_content.html diff --git a/bookwyrm/templates/snippets/status/book_preview.html b/bookwyrm/templates/snippets/status/book_preview.html deleted file mode 100644 index 920b9f538..000000000 --- a/bookwyrm/templates/snippets/status/book_preview.html +++ /dev/null @@ -1,14 +0,0 @@ -{% load bookwyrm_tags %} -
-
-
- {% include 'snippets/book_cover.html' with book=book %} - {% include 'snippets/stars.html' with rating=book|rating:request.user %} - {% include 'snippets/shelve_button/shelve_button.html' with book=book %} -
-
-
-

{% include 'snippets/book_titleby.html' with book=book %}

- {% include 'snippets/trimmed_text.html' with full=book|book_description %} -
-
diff --git a/bookwyrm/templates/snippets/status/content_status.html b/bookwyrm/templates/snippets/status/content_status.html new file mode 100644 index 000000000..05662098c --- /dev/null +++ b/bookwyrm/templates/snippets/status/content_status.html @@ -0,0 +1,126 @@ +{% spaceless %} + +{% load bookwyrm_tags %} +{% load i18n %} + +{% with status_type=status.status_type %} +
+ +
+ {% if not hide_book %} + {% with book=status.book|default:status.mention_books.first %} +
+
+ {% include 'snippets/book_cover.html' with book=book %} + {% include 'snippets/stars.html' with rating=book|rating:request.user %} + {% include 'snippets/shelve_button/shelve_button.html' with book=book %} +
+
+ {% endwith %} + {% endif %} + +
+ {% if status_type == 'Review' %} +
+

+ {{ status.name|escape }} +

+ +

+ + {% include 'snippets/stars.html' with rating=status.rating %} +

+
+ {% endif %} + + {% if status.content_warning %} +
+

{{ status.content_warning }}

+ + {% trans "Show more" as button_text %} + + {% with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %} + {% include 'snippets/toggle/open_button.html' %} + {% endwith %} +
+ {% endif %} + + +
+
+ +{% endwith %} +{% endspaceless %} diff --git a/bookwyrm/templates/snippets/status/generated_status.html b/bookwyrm/templates/snippets/status/generated_status.html new file mode 100644 index 000000000..f4186cd10 --- /dev/null +++ b/bookwyrm/templates/snippets/status/generated_status.html @@ -0,0 +1,43 @@ +{% spaceless %} + +{% load bookwyrm_tags %} +{% load i18n %} + +{% if status_type == 'Rating' %} +
+
+ + + + {# @todo Is it possible to not hard-code the value? #} + + + + {% include 'snippets/stars.html' with rating=status.rating %} +
+
+{% endif %} + +{% if not hide_book %} +{% with book=status.book|default:status.mention_books.first %} +
+ +
+

{% include 'snippets/book_titleby.html' with book=book %}

+

{{ book|book_description|default:""|truncatewords_html:20 }}

+ {% include 'snippets/shelve_button/shelve_button.html' with book=book %} +
+
+{% endwith %} +{% endif %} + +{% endspaceless %} diff --git a/bookwyrm/templates/snippets/status/layout.html b/bookwyrm/templates/snippets/status/layout.html new file mode 100644 index 000000000..5b6c0c78d --- /dev/null +++ b/bookwyrm/templates/snippets/status/layout.html @@ -0,0 +1,86 @@ +{% extends 'components/card.html' %} +{% load i18n %} + +{% load bookwyrm_tags %} +{% load humanize %} + +{% block card-header %} +

+ {% include 'snippets/status/status_header.html' with status=status %} +

+{% endblock %} + +{% block card-content %}{% endblock %} + +{% block card-footer %} + + + + + +{% if not moderation_mode %} + +{% endif %} +{% endblock %} + + +{% block card-bonus %} +{% if request.user.is_authenticated and not moderation_mode %} +{% with status.id|uuid as uuid %} + +{% endwith %} +{% endif %} +{% endblock %} diff --git a/bookwyrm/templates/snippets/status/status_body.html b/bookwyrm/templates/snippets/status/status_body.html index ffa71d5e1..58d3fbf4e 100644 --- a/bookwyrm/templates/snippets/status/status_body.html +++ b/bookwyrm/templates/snippets/status/status_body.html @@ -1,90 +1,13 @@ -{% extends 'components/card.html' %} -{% load i18n %} - -{% load bookwyrm_tags %} -{% load humanize %} - -{% block card-header %} -

- {% include 'snippets/status/status_header.html' with status=status %} -

-{% endblock %} - +{% extends 'snippets/status/layout.html' %} {% block card-content %} - {% include 'snippets/status/status_content.html' with status=status %} -{% endblock %} +{% with status_type=status.status_type %} - -{% block card-footer %} - - - - - -{% if not moderation_mode %} - +{% if status_type == 'GeneratedNote' or status_type == 'Rating' %} + {% include 'snippets/status/generated_status.html' with status=status %} +{% else %} + {% include 'snippets/status/content_status.html' with status=status %} {% endif %} -{% endblock %} - -{% block card-bonus %} -{% if request.user.is_authenticated and not moderation_mode %} -{% with status.id|uuid as uuid %} - {% endwith %} -{% endif %} {% endblock %} diff --git a/bookwyrm/templates/snippets/status/status_content.html b/bookwyrm/templates/snippets/status/status_content.html deleted file mode 100644 index 402c4aabd..000000000 --- a/bookwyrm/templates/snippets/status/status_content.html +++ /dev/null @@ -1,137 +0,0 @@ -{% spaceless %} - -{% load bookwyrm_tags %} -{% load i18n %} - -{% with status_type=status.status_type %} -
- {% if status_type == 'Review' or status_type == 'Rating' %} -
- {% if status.name %} -

- {{ status.name|escape }} -

- {% endif %} - - - - - {% if status_type == 'Rating' %} - {# @todo Is it possible to not hard-code the value? #} - - {% endif %} - - - {% include 'snippets/stars.html' with rating=status.rating %} -
- {% endif %} - - {% if status.content_warning %} -
-

{{ status.content_warning }}

- - {% trans "Show more" as button_text %} - - {% with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %} - {% include 'snippets/toggle/open_button.html' %} - {% endwith %} -
- {% endif %} - - -
- -{% if not hide_book %} - {% if status.book or status.mention_books.count %} -
- {% if status.book %} - {% with book=status.book %} - {% include 'snippets/status/book_preview.html' %} - {% endwith %} - {% elif status.mention_books.count %} - {% with book=status.mention_books.first %} - {% include 'snippets/status/book_preview.html' %} - {% endwith %} - {% endif %} -
- {% endif %} -{% endif %} -{% endwith %} -{% endspaceless %} From 07dbc4c6c042d9ce5b96106dd2f366d8c295d7a0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 20 Apr 2021 09:56:01 -0700 Subject: [PATCH 2/7] Much longer "full" version of trimmed text --- bookwyrm/templates/snippets/trimmed_text.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/snippets/trimmed_text.html b/bookwyrm/templates/snippets/trimmed_text.html index e1728b8f6..31c72eca3 100644 --- a/bookwyrm/templates/snippets/trimmed_text.html +++ b/bookwyrm/templates/snippets/trimmed_text.html @@ -5,7 +5,7 @@ {% with 0|uuid as uuid %} {% if full %} {% with full|to_markdown|safe as full %} - {% with full|to_markdown|safe|truncatewords_html:60 as trimmed %} + {% with full|to_markdown|safe|truncatewords_html:150 as trimmed %} {% if not no_trim and trimmed != full %}
From 9e5ebf9807b58b1eb4cd160e8071933fa0b7ea1b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 20 Apr 2021 11:06:14 -0700 Subject: [PATCH 3/7] Move stars into header for ratings --- bookwyrm/templates/snippets/stars.html | 4 +- .../snippets/status/content_status.html | 190 +++++++++--------- .../snippets/status/generated_status.html | 22 +- .../snippets/status/status_header.html | 23 ++- 4 files changed, 120 insertions(+), 119 deletions(-) diff --git a/bookwyrm/templates/snippets/stars.html b/bookwyrm/templates/snippets/stars.html index 2b40a9e3c..ac049f254 100644 --- a/bookwyrm/templates/snippets/stars.html +++ b/bookwyrm/templates/snippets/stars.html @@ -1,7 +1,7 @@ {% spaceless %} {% load i18n %} -

+ {% if rating %} {% blocktranslate trimmed with rating=rating|floatformat count counter=rating|length %} @@ -23,5 +23,5 @@ aria-hidden="true" > {% endfor %} -

+ {% endspaceless %} diff --git a/bookwyrm/templates/snippets/status/content_status.html b/bookwyrm/templates/snippets/status/content_status.html index 05662098c..44c52c836 100644 --- a/bookwyrm/templates/snippets/status/content_status.html +++ b/bookwyrm/templates/snippets/status/content_status.html @@ -6,120 +6,122 @@ {% with status_type=status.status_type %}
- {% if not hide_book %} - {% with book=status.book|default:status.mention_books.first %} -
-
+ {% if not hide_book %} + {% with book=status.book|default:status.mention_books.first %} +
{% include 'snippets/book_cover.html' with book=book %} {% include 'snippets/stars.html' with rating=book|rating:request.user %} {% include 'snippets/shelve_button/shelve_button.html' with book=book %}
-
- {% endwith %} - {% endif %} + {% endwith %} + {% endif %} -
- {% if status_type == 'Review' %} -
-

- {{ status.name|escape }} -

- -

-

-
- {% endif %} +

+

+ {% endif %} - {% if status.quote %} -
-
{{ status.quote | safe }}
+ {% if status.content_warning %} +
+

{{ status.content_warning }}

-

— {% include 'snippets/book_titleby.html' with book=status.book %}

+ {% trans "Show more" as button_text %} + + {% with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %} + {% include 'snippets/toggle/open_button.html' %} + {% endwith %}
{% endif %} - {% if status.content and status_type != 'GeneratedNote' and status_type != 'Announce' %} - {% with full=status.content|safe no_trim=status.content_warning itemprop=body_prop %} - {% include 'snippets/trimmed_text.html' %} - {% endwith %} - {% endif %} +
+ {% endif %} + + {% if status.content and status_type != 'GeneratedNote' and status_type != 'Announce' %} + {% with full=status.content|safe no_trim=status.content_warning itemprop="reviewBody" %} + {% include 'snippets/trimmed_text.html' %} + {% endwith %} + {% endif %} + + {% if status.attachments.exists %} +
+
+ {% for attachment in status.attachments.all %} +
+
+ + {{ attachment.caption }} + +
+
+ {% endfor %} +
+
+ {% endif %} +
+ +
{% endwith %} diff --git a/bookwyrm/templates/snippets/status/generated_status.html b/bookwyrm/templates/snippets/status/generated_status.html index f4186cd10..f3bbae44b 100644 --- a/bookwyrm/templates/snippets/status/generated_status.html +++ b/bookwyrm/templates/snippets/status/generated_status.html @@ -3,29 +3,9 @@ {% load bookwyrm_tags %} {% load i18n %} -{% if status_type == 'Rating' %} -
-
- - - - {# @todo Is it possible to not hard-code the value? #} - - - - {% include 'snippets/stars.html' with rating=status.rating %} -
-
-{% endif %} - {% if not hide_book %} {% with book=status.book|default:status.mention_books.first %} -
+
{% include 'snippets/book_cover.html' with book=book size="small" %} diff --git a/bookwyrm/templates/snippets/status/status_header.html b/bookwyrm/templates/snippets/status/status_header.html index 6493bd548..0fa74ddd1 100644 --- a/bookwyrm/templates/snippets/status/status_header.html +++ b/bookwyrm/templates/snippets/status/status_header.html @@ -40,10 +40,29 @@ {% endwith %} {% endif %} + {% if status.book %} -{{ status.book.title }} + {% if status.status_type == 'GeneratedNote' or status.status_type == 'Rating' %} + {{ status.book.title }}{% if status.status_type == 'Rating' %}: + + + + {% include 'snippets/stars.html' with rating=status.rating %} + {% endif %} + {% else %} + {% include 'snippets/book_titleby.html' with book=status.book %} + {% endif %} {% elif status.mention_books %} -{{ status.mention_books.first.title }} + {{ status.mention_books.first.title }} {% endif %} {% if status.progress %} From cbccb0725213a4a87b3d01e27088469abd5111b2 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 20 Apr 2021 11:18:59 -0700 Subject: [PATCH 4/7] Fixes display of replies --- bookwyrm/templates/snippets/status/content_status.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bookwyrm/templates/snippets/status/content_status.html b/bookwyrm/templates/snippets/status/content_status.html index 44c52c836..5021ee067 100644 --- a/bookwyrm/templates/snippets/status/content_status.html +++ b/bookwyrm/templates/snippets/status/content_status.html @@ -15,11 +15,13 @@
{% if not hide_book %} {% with book=status.book|default:status.mention_books.first %} + {% if book %}
{% include 'snippets/book_cover.html' with book=book %} {% include 'snippets/stars.html' with rating=book|rating:request.user %} {% include 'snippets/shelve_button/shelve_button.html' with book=book %}
+ {% endif %} {% endwith %} {% endif %} From 5fc1e3f2feae807ae84594d6b3e8b193f6fa01e7 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 20 Apr 2021 13:50:05 -0700 Subject: [PATCH 5/7] Fixes merge regression for localized timestamps --- bookwyrm/templates/snippets/status/layout.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bookwyrm/templates/snippets/status/layout.html b/bookwyrm/templates/snippets/status/layout.html index 5b6c0c78d..00e15857e 100644 --- a/bookwyrm/templates/snippets/status/layout.html +++ b/bookwyrm/templates/snippets/status/layout.html @@ -1,6 +1,5 @@ {% extends 'components/card.html' %} {% load i18n %} - {% load bookwyrm_tags %} {% load humanize %} @@ -61,7 +60,7 @@
{% if not moderation_mode %}