forked from mirrors/bookwyrm
Don't render empty html about books
This commit is contained in:
parent
0928fd03a6
commit
428d87a351
2 changed files with 47 additions and 45 deletions
|
@ -1,6 +1,7 @@
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% if book.isbn13 or book.oclc_number or book.asin %}
|
||||||
<dl>
|
<dl>
|
||||||
{% if book.isbn_13 %}
|
{% if book.isbn_13 %}
|
||||||
<div class="is-flex">
|
<div class="is-flex">
|
||||||
|
@ -23,4 +24,5 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
|
{% endif %}
|
||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
|
|
|
@ -3,31 +3,29 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load humanize %}
|
{% 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 %}
|
||||||
<p>
|
<p>
|
||||||
{% firstof book.physical_format_detail book.physical_format as format %}
|
{% if format_property %}
|
||||||
{% firstof book.physical_format book.physical_format_detail as format_property %}
|
<meta itemprop="bookFormat" content="{{ format_property }}">
|
||||||
{% with pages=book.pages %}
|
{% endif %}
|
||||||
{% 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 %}
|
|
||||||
<meta itemprop="bookFormat" content="{{ format_property }}">
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if pages %}
|
{% if pages %}
|
||||||
<meta itemprop="numberOfPages" content="{{ pages }}">
|
<meta itemprop="numberOfPages" content="{{ pages }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if format and not pages %}
|
{% if format and not pages %}
|
||||||
{% blocktrans %}{{ format }}{% endblocktrans %}
|
{% blocktrans %}{{ format }}{% endblocktrans %}
|
||||||
{% elif format and pages %}
|
{% elif format and pages %}
|
||||||
{% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %}
|
{% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %}
|
||||||
{% elif pages %}
|
{% elif pages %}
|
||||||
{% blocktrans %}{{ pages }} pages{% endblocktrans %}
|
{% blocktrans %}{{ pages }} pages{% endblocktrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
{% if book.languages %}
|
{% if book.languages %}
|
||||||
{% for language in book.languages %}
|
{% for language in book.languages %}
|
||||||
|
@ -41,32 +39,34 @@
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% with date=book.published_date|naturalday publisher=book.publishers|join:', ' %}
|
||||||
|
{% if date or book.first_published_date or book.publishers %}
|
||||||
<p>
|
<p>
|
||||||
{% with date=book.published_date|naturalday publisher=book.publishers|join:', ' %}
|
{% if date or book.first_published_date %}
|
||||||
{% if date or book.first_published_date %}
|
<meta
|
||||||
<meta
|
itemprop="datePublished"
|
||||||
itemprop="datePublished"
|
content="{{ book.first_published_date|default:book.published_date|date:'Y-m-d' }}"
|
||||||
content="{{ book.first_published_date|default:book.published_date|date:'Y-m-d' }}"
|
>
|
||||||
>
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% comment %}
|
{% comment %}
|
||||||
@todo The publisher property needs to be an Organization or a Person. We’ll be using Thing which is the more generic ancestor.
|
@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
|
@see https://schema.org/Publisher
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
{% if book.publishers %}
|
{% if book.publishers %}
|
||||||
{% for publisher in book.publishers %}
|
{% for publisher in book.publishers %}
|
||||||
<meta itemprop="publisher" content="{{ publisher }}">
|
<meta itemprop="publisher" content="{{ publisher }}">
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if date and publisher %}
|
{% if date and publisher %}
|
||||||
{% blocktrans %}Published {{ date }} by {{ publisher }}.{% endblocktrans %}
|
{% blocktrans %}Published {{ date }} by {{ publisher }}.{% endblocktrans %}
|
||||||
{% elif date %}
|
{% elif date %}
|
||||||
{% blocktrans %}Published {{ date }}{% endblocktrans %}
|
{% blocktrans %}Published {{ date }}{% endblocktrans %}
|
||||||
{% elif publisher %}
|
{% elif publisher %}
|
||||||
{% blocktrans %}Published by {{ publisher }}.{% endblocktrans %}
|
{% blocktrans %}Published by {{ publisher }}.{% endblocktrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
|
|
Loading…
Reference in a new issue