Show subtitles when titles are very short

This commit is contained in:
Mouse Reeve 2021-04-23 14:58:48 -07:00
parent cbdf573261
commit 9ba0aec6d9
3 changed files with 13 additions and 4 deletions

View file

@ -1,7 +1,8 @@
{% load i18n %}
{% load bookwyrm_tags %}
{% if book.authors %}
{% blocktrans with path=book.local_path title=book.title %}<a href="{{ path }}">{{ title }}</a> by {% endblocktrans %}{% include 'snippets/authors.html' with book=book %}
{% blocktrans with path=book.local_path title=book|title %}<a href="{{ path }}">{{ title }}</a> by {% endblocktrans %}{% include 'snippets/authors.html' with book=book %}
{% else %}
<a href="{{ book.local_path }}">{{ book.title }}</a>
<a href="{{ book.local_path }}">{{ book|title }}</a>
{% endif %}

View file

@ -43,7 +43,7 @@
{% if status.book %}
{% 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' %}:
<a href="/book/{{ status.book.id }}">{{ status.book|title }}</a>{% if status.status_type == 'Rating' %}:
<span
itemprop="reviewRating"
itemscope
@ -62,7 +62,7 @@
{% include 'snippets/book_titleby.html' with book=status.book %}
{% endif %}
{% 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 %}
{% if status.progress %}

View file

@ -167,6 +167,14 @@ def get_next_shelf(current_shelf):
return "read"
return "to-read"
@register.filter(name="title")
def get_title(book):
""" display the subtitle if the title is short """
title = book.title
if len(title) < 6 and book.subtitle:
title = "{:s}: {:s}".format(title, book.subtitle)
return title
@register.simple_tag(takes_context=False)
def related_status(notification):