From 428d87a3510687714cd5139f6726bfa511999c0f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 1 Oct 2021 10:08:56 -0700 Subject: [PATCH] Don't render empty html about books --- bookwyrm/templates/book/book_identifiers.html | 2 + bookwyrm/templates/book/publisher_info.html | 90 +++++++++---------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/bookwyrm/templates/book/book_identifiers.html b/bookwyrm/templates/book/book_identifiers.html index 6021d243..8c8313f3 100644 --- a/bookwyrm/templates/book/book_identifiers.html +++ b/bookwyrm/templates/book/book_identifiers.html @@ -1,6 +1,7 @@ {% spaceless %} {% load i18n %} +{% if book.isbn13 or book.oclc_number or book.asin %}
{% if book.isbn_13 %}
@@ -23,4 +24,5 @@
{% endif %}
+{% endif %} {% endspaceless %} diff --git a/bookwyrm/templates/book/publisher_info.html b/bookwyrm/templates/book/publisher_info.html index 42cb4098..da3d7d1d 100644 --- a/bookwyrm/templates/book/publisher_info.html +++ b/bookwyrm/templates/book/publisher_info.html @@ -3,31 +3,29 @@ {% load i18n %} {% load humanize %} +{% firstof book.physical_format_detail book.physical_format as format %} +{% firstof book.physical_format book.physical_format_detail as format_property %} +{% with pages=book.pages %} +{% if format or pages %}

- {% firstof book.physical_format_detail book.physical_format as format %} - {% firstof book.physical_format book.physical_format_detail as format_property %} - {% with pages=book.pages %} - {% if format %} - {% comment %} - @todo The bookFormat property is limited to a list of values whereas the book edition is free text. - @see https://schema.org/bookFormat - {% endcomment %} - - {% endif %} + {% if format_property %} + + {% endif %} - {% if pages %} - - {% endif %} + {% if pages %} + + {% endif %} - {% if format and not pages %} - {% blocktrans %}{{ format }}{% endblocktrans %} - {% elif format and pages %} - {% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %} - {% elif pages %} - {% blocktrans %}{{ pages }} pages{% endblocktrans %} - {% endif %} - {% endwith %} + {% if format and not pages %} + {% blocktrans %}{{ format }}{% endblocktrans %} + {% elif format and pages %} + {% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %} + {% elif pages %} + {% blocktrans %}{{ pages }} pages{% endblocktrans %} + {% endif %}

+{% endif %} +{% endwith %} {% if book.languages %} {% for language in book.languages %} @@ -41,32 +39,34 @@

{% endif %} +{% with date=book.published_date|naturalday publisher=book.publishers|join:', ' %} +{% if date or book.first_published_date or book.publishers %}

- {% with date=book.published_date|naturalday publisher=book.publishers|join:', ' %} - {% if date or book.first_published_date %} - - {% endif %} + {% if date or book.first_published_date %} + + {% endif %} - {% comment %} - @todo The publisher property needs to be an Organization or a Person. We’ll be using Thing which is the more generic ancestor. - @see https://schema.org/Publisher - {% endcomment %} - {% if book.publishers %} - {% for publisher in book.publishers %} - - {% endfor %} - {% endif %} + {% comment %} + @todo The publisher property needs to be an Organization or a Person. We’ll be using Thing which is the more generic ancestor. + @see https://schema.org/Publisher + {% endcomment %} + {% if book.publishers %} + {% for publisher in book.publishers %} + + {% endfor %} + {% endif %} - {% if date and publisher %} - {% blocktrans %}Published {{ date }} by {{ publisher }}.{% endblocktrans %} - {% elif date %} - {% blocktrans %}Published {{ date }}{% endblocktrans %} - {% elif publisher %} - {% blocktrans %}Published by {{ publisher }}.{% endblocktrans %} - {% endif %} - {% endwith %} + {% if date and publisher %} + {% blocktrans %}Published {{ date }} by {{ publisher }}.{% endblocktrans %} + {% elif date %} + {% blocktrans %}Published {{ date }}{% endblocktrans %} + {% elif publisher %} + {% blocktrans %}Published by {{ publisher }}.{% endblocktrans %} + {% endif %}

+{% endif %} +{% endwith %} {% endspaceless %}