Minor vocabulary fixes and structured data improvements (#3036)

* Remove duplicate Review object under `rating` property

This was preventing validation, since `rating` is not a valid property
(`review` is, which is created from book.html already).

* Drop `bestRating` property in ratings, since it defaults to 5

See <https://schema.org/bestRating> ("If bestRating is omitted,
5 is assumed").

* Create Rating object (and its enclosing Review) in book/rating.html

* Use `position` property for Book objects in a series

`volumeNumber`, previously used, is only valid for objects of type
PublicationVolume (which series members are not).

* Give URL of book series when setting of `isPartOf`

* series.html: Add empty BookSeries object

---------

Co-authored-by: Adeodato Simó <dato@users.noreply.github.com>
This commit is contained in:
Adeodato Simó 2023-10-21 12:53:24 -03:00 committed by GitHub
parent 695c67a714
commit 698e74a496
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 31 deletions

View file

@ -44,16 +44,18 @@
{% endif %}
{% if book.series %}
<meta itemprop="isPartOf" content="{{ book.series | escape }}">
<meta itemprop="volumeNumber" content="{{ book.series_number }}">
<meta itemprop="position" content="{{ book.series_number }}">
<span itemprop="isPartOf" itemscope itemtype="https://schema.org/BookSeries">
{% if book.authors.exists %}
<a href="{% url 'book-series-by' book.authors.first.id %}?series_name={{ book.series | urlencode }}">
<a href="{% url 'book-series-by' book.authors.first.id %}?series_name={{ book.series | urlencode }}"
itemprop="url">
{% endif %}
{{ book.series }}{% if book.series_number %} #{{ book.series_number }}{% endif %}
<span itemprop="name">{{ book.series }}</span>
{% if book.series_number %} #{{ book.series_number }}{% endif %}
{% if book.authors.exists %}
</a>
{% endif %}
</span>
{% endif %}
</p>
{% endif %}
@ -186,8 +188,6 @@
itemtype="https://schema.org/AggregateRating"
>
<meta itemprop="ratingValue" content="{{ rating|floatformat }}">
{# @todo Is it possible to not hard-code the value? #}
<meta itemprop="bestRating" content="5">
<meta itemprop="reviewCount" content="{{ review_count }}">
<span>

View file

@ -5,13 +5,18 @@
{% include 'snippets/avatar.html' with user=user %}
</div>
<div class="media-content">
<div>
<a href="{{ user.local_path }}">{{ user.display_name }}</a>
<div class="media-content" itemprop="review" itemscope itemtype="https://schema.org/Review">
<div itemprop="author"
itemscope
itemtype="https://schema.org/Person"
>
<a href="{{ user.local_path }}" itemprop="url">
<span itemprop="name">{{ user.display_name }}</span>
</a>
</div>
<div class="is-flex">
<div class="is-flex" itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating">
<meta itemprop="ratingValue" content="{{ rating.rating|floatformat }}">
<p class="mr-1">{% trans "rated it" %}</p>
{% include 'snippets/stars.html' with rating=rating.rating %}
</div>
<div>

View file

@ -5,15 +5,15 @@
{% block title %}{{ series_name }}{% endblock %}
{% block content %}
<div class="block">
<h1 class="title">{{ series_name }}</h1>
<div class="block" itemscope itemtype="https://schema.org/BookSeries">
<h1 class="title" itemprop="name">{{ series_name }}</h1>
<div class="subtitle" dir="auto">
{% trans "Series by" %} <a
href="{{ author.local_path }}"
class="author {{ link_class }}"
itemprop="author"
itemprop="creator"
itemscope
itemtype="https://schema.org/Thing"
itemtype="https://schema.org/Person"
><span
itemprop="name"
>{{ author.name }}</span></a>
@ -22,6 +22,7 @@
<div class="columns is-multiline is-mobile">
{% for book in books %}
{% with book=book %}
{# @todo Set `hasPart` property in some meaningful way #}
<div class="column is-one-fifth-tablet is-half-mobile is-flex is-flex-direction-column">
<div class="is-flex-grow-1 mb-3">
<span class="subtitle">{% if book.series_number %}{% blocktrans with series_number=book.series_number %}Book {{ series_number }}{% endblocktrans %}{% else %}{% trans 'Unsorted Book' %}{% endif %}</span>

View file

@ -6,14 +6,6 @@
{% load humanize %}
{% with status_type=status.status_type %}
<div
class="block"
{% if status_type == "Review" %}
itemprop="rating"
itemtype="https://schema.org/Rating"
{% endif %}
>
<div class="columns is-gapless">
{% if not hide_book %}
{% with book=status.book|default:status.mention_books.first %}
@ -58,9 +50,6 @@
{% endif %}
>
<meta itemprop="ratingValue" content="{{ status.rating|floatformat }}">
{# @todo Is it possible to not hard-code the value? #}
<meta itemprop="bestRating" content="5">
</span>
{% include 'snippets/stars.html' with rating=status.rating %}
</h4>
@ -154,6 +143,5 @@
</div>
</article>
</div>
</div>
{% endwith %}

View file

@ -16,9 +16,6 @@
>
<span class="is-hidden" {{ rating_type }}>
<meta itemprop="ratingValue" content="{{ status.rating|floatformat }}">
{# @todo Is it possible to not hard-code the value? #}
<meta itemprop="bestRating" content="5">
</span>
</span>
</span>