Update subtitle behaviour:

- on Book
	- Remove problematic punctuation (locale and multiple punctuation if the title ends with `?`, `!` or similar).
	- Update view.
	- Use proper semantic to split combined title into `name`, `alternativeHeadline` and series-related microdata.
	- The author is not a subtitle, just data.
- Use parenthesis in the `get_title` filter instead of punctuation.
This commit is contained in:
Fabien Basmaison 2021-05-26 13:21:06 +02:00
parent e4c7eaf0b7
commit c894f5ef35
2 changed files with 24 additions and 17 deletions

View file

@ -8,28 +8,35 @@
<div class="block" itemscope itemtype="https://schema.org/Book"> <div class="block" itemscope itemtype="https://schema.org/Book">
<div class="columns is-mobile"> <div class="columns is-mobile">
<div class="column"> <div class="column">
<h1 class="title"> <h1 class="title" itemprop="name">
<span itemprop="name"> {{ book.title }}
{{ book.title }}{% if book.subtitle %}: </h1>
<small>{{ book.subtitle }}</small>
{% if book.subtitle or book.series %}
<p class="subtitle">
{% if book.subtitle %}
<meta
itemprop="alternativeHeadline"
content="{{ book.subtitle | escape }}"
>
{{ book.subtitle }}
{% endif %} {% endif %}
</span>
{% if book.series %} {% if book.series %}
<meta itemprop="isPartOf" content="{{ book.series }}"> <meta itemprop="isPartOf" content="{{ book.series | escape }}">
<meta itemprop="volumeNumber" content="{{ book.series_number }}"> <meta itemprop="volumeNumber" content="{{ book.series_number }}">
<small class="has-text-grey-dark">
({{ book.series }} ({{ book.series }}
{% if book.series_number %} #{{ book.series_number }}{% endif %}) {% if book.series_number %} #{{ book.series_number }}{% endif %})
</small> {% endif %}
<br> </p>
{% endif %} {% endif %}
</h1>
{% if book.authors %} {% if book.authors %}
<h2 class="subtitle"> <div>
{% trans "by" %} {% include 'snippets/authors.html' with book=book %} {% trans "by" %} {% include 'snippets/authors.html' with book=book %}
</h2> </div>
{% endif %} {% endif %}
</div> </div>

View file

@ -25,7 +25,7 @@ def get_title(book):
return "" return ""
title = book.title title = book.title
if len(title) < 6 and book.subtitle: if len(title) < 6 and book.subtitle:
title = "{:s}: {:s}".format(title, book.subtitle) title = "{:s} ({:s})".format(title, book.subtitle)
return title return title