Move stars into header for ratings

This commit is contained in:
Mouse Reeve 2021-04-20 11:06:14 -07:00
parent 07dbc4c6c0
commit 9e5ebf9807
4 changed files with 120 additions and 119 deletions

View file

@ -1,7 +1,7 @@
{% spaceless %} {% spaceless %}
{% load i18n %} {% load i18n %}
<p class="stars"> <span class="stars">
<span class="is-sr-only"> <span class="is-sr-only">
{% if rating %} {% if rating %}
{% blocktranslate trimmed with rating=rating|floatformat count counter=rating|length %} {% blocktranslate trimmed with rating=rating|floatformat count counter=rating|length %}
@ -23,5 +23,5 @@
aria-hidden="true" aria-hidden="true"
></span> ></span>
{% endfor %} {% endfor %}
</p> </span>
{% endspaceless %} {% endspaceless %}

View file

@ -6,23 +6,20 @@
{% with status_type=status.status_type %} {% with status_type=status.status_type %}
<div <div
class="block" class="block"
{% firstof "reviewBody" as body_prop %} {% if status_type == "Review" %}
{% firstof 'itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating"' as rating_type %}
itemprop="rating" itemprop="rating"
itemtype="https://schema.org/Rating" itemtype="https://schema.org/Rating"
{% endif %}
> >
<div class="columns"> <div class="columns">
{% if not hide_book %} {% if not hide_book %}
{% with book=status.book|default:status.mention_books.first %} {% with book=status.book|default:status.mention_books.first %}
<div class="column is-narrow"> <div class="column is-narrow is-hidden-mobile">
<div>
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book %}</a> <a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book %}</a>
{% include 'snippets/stars.html' with rating=book|rating:request.user %} {% include 'snippets/stars.html' with rating=book|rating:request.user %}
{% include 'snippets/shelve_button/shelve_button.html' with book=book %} {% include 'snippets/shelve_button/shelve_button.html' with book=book %}
</div> </div>
</div>
{% endwith %} {% endwith %}
{% endif %} {% endif %}
@ -40,7 +37,11 @@
<h4 class="subtitle is-6"> <h4 class="subtitle is-6">
<span <span
class="is-hidden" class="is-hidden"
{{ rating_type }} {% if status_type == "Review" %}
itemprop="reviewRating"
itemscope
itemtype="https://schema.org/Rating"
{% endif %}
> >
<meta itemprop="ratingValue" content="{{ status.rating|floatformat }}"> <meta itemprop="ratingValue" content="{{ status.rating|floatformat }}">
@ -87,7 +88,7 @@
{% endif %} {% endif %}
{% if status.content and status_type != 'GeneratedNote' and status_type != 'Announce' %} {% if status.content and status_type != 'GeneratedNote' and status_type != 'Announce' %}
{% with full=status.content|safe no_trim=status.content_warning itemprop=body_prop %} {% with full=status.content|safe no_trim=status.content_warning itemprop="reviewBody" %}
{% include 'snippets/trimmed_text.html' %} {% include 'snippets/trimmed_text.html' %}
{% endwith %} {% endwith %}
{% endif %} {% endif %}
@ -120,6 +121,7 @@
{% endif %} {% endif %}
</div> </div>
</article> </article>
</div>
</div> </div>
{% endwith %} {% endwith %}

View file

@ -3,29 +3,9 @@
{% load bookwyrm_tags %} {% load bookwyrm_tags %}
{% load i18n %} {% load i18n %}
{% if status_type == 'Rating' %}
<div
class="block"
{% firstof 'itemprop="reviewRating" itemscope itemtype="https://schema.org/Rating"' as rating_type %}
itemprop="rating"
itemtype="https://schema.org/Rating"
>
<div>
<span class="is-sr-only" {{ 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>
{% include 'snippets/stars.html' with rating=status.rating %}
</div>
</div>
{% endif %}
{% if not hide_book %} {% if not hide_book %}
{% with book=status.book|default:status.mention_books.first %} {% with book=status.book|default:status.mention_books.first %}
<div class="columns"> <div class="columns is-mobile">
<div class="column is-narrow"> <div class="column is-narrow">
<div> <div>
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book size="small" %}</a> <a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book size="small" %}</a>

View file

@ -40,10 +40,29 @@
{% endwith %} {% endwith %}
{% endif %} {% endif %}
{% if status.book %} {% if status.book %}
<a href="/book/{{ status.book.id }}">{{ status.book.title }}</a> {% if status.status_type == 'GeneratedNote' or status.status_type == 'Rating' %}
<a href="/book/{{ status.book.id }}">{{ status.book.title }}</a>{% if status.status_type == 'Rating' %}:
<span
itemprop="reviewRating"
itemscope
itemtype="https://schema.org/Rating"
>
<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>
{% include 'snippets/stars.html' with rating=status.rating %}
{% endif %}
{% else %}
{% include 'snippets/book_titleby.html' with book=status.book %}
{% endif %}
{% elif status.mention_books %} {% elif status.mention_books %}
<a href="/book/{{ status.mention_books.first.id }}">{{ status.mention_books.first.title }}</a> <a href="/book/{{ status.mention_books.first.id }}">{{ status.mention_books.first.title }}</a>
{% endif %} {% endif %}
{% if status.progress %} {% if status.progress %}