Merge pull request #995 from bookwyrm-social/show-subtitles

Show subtitles when titles are very short
This commit is contained in:
Mouse Reeve 2021-04-24 06:58:00 -07:00 committed by GitHub
commit deb1257114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 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

@ -168,6 +168,17 @@ def get_next_shelf(current_shelf):
return "to-read"
@register.filter(name="title")
def get_title(book):
""" display the subtitle if the title is short """
if not book:
return ""
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):
""" for notifications """