From 984cafb28ef9c478226b056b2f313d383a8d7630 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 3 May 2020 16:22:33 -0700 Subject: [PATCH] Cleans up alt tag generation for covers --- fedireads/static/format.css | 13 ++++++++----- fedireads/templates/editions.html | 2 +- fedireads/templates/snippets/book_cover.html | 5 +++-- fedireads/templates/snippets/cover_alt.html | 3 ++- fedireads/templatetags/fr_display.py | 12 ++++++++++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/fedireads/static/format.css b/fedireads/static/format.css index 0a3d3f509..89459c2f3 100644 --- a/fedireads/static/format.css +++ b/fedireads/static/format.css @@ -170,13 +170,15 @@ body { div.pulldown-button { background-color: #eee; - border: 2px solid #247BA0; border-radius: 0.3em; color: #247BA0; width: max-content; margin: 0 auto; white-space: nowrap; } +.post div.pulldown-button { + border: 2px solid #247BA0; +} .pulldown-button form { display: inline; @@ -348,9 +350,12 @@ button, input[type="submit"] { } button.secondary { background-color: #EEE; - border: 2px solid #247BA0; color: #247BA0; } +.post button.secondary { + border: 2px solid #247BA0; +} + button.warning { background-color: #FF1654; } @@ -499,6 +504,7 @@ button .icon { .book-preview { overflow: hidden; z-index: 1; + text-align: center; } .book-preview.grid { float: left; @@ -597,9 +603,6 @@ dd { width: auto; margin: 0; } -.covers-shelf button, .covers-shelf .pulldown-button { - border: none; -} .close { float: right; diff --git a/fedireads/templates/editions.html b/fedireads/templates/editions.html index 98f647cf9..d916ac11e 100644 --- a/fedireads/templates/editions.html +++ b/fedireads/templates/editions.html @@ -7,7 +7,7 @@ {% for book in editions %}
  • - {% include 'snippets/book_cover.html' with book=book %} + {% include 'snippets/book_cover.html' with book=book %} {% include 'snippets/shelve_button.html' with book=book %}
  • diff --git a/fedireads/templates/snippets/book_cover.html b/fedireads/templates/snippets/book_cover.html index 3635532e7..4a76dde4b 100644 --- a/fedireads/templates/snippets/book_cover.html +++ b/fedireads/templates/snippets/book_cover.html @@ -1,11 +1,12 @@ +{% load fr_display %} {% if book.cover %} {% include 'snippets/cover_alt.html' with book=book %} {% else %}
    - {% include 'snippets/cover_alt.html' with book=book %} + No cover

    {{ book.title }}

    -

    {{ book.authors.first.name }}

    +

    ({{ book|edition_info }})

    {% endif %} diff --git a/fedireads/templates/snippets/cover_alt.html b/fedireads/templates/snippets/cover_alt.html index 055d65103..52bd52f2b 100644 --- a/fedireads/templates/snippets/cover_alt.html +++ b/fedireads/templates/snippets/cover_alt.html @@ -1 +1,2 @@ -'{{ book.title }}' Cover ({% if book.physical_format %}{{ book.physical_format }}{% if book.published_date %}, {% endif %}{% endif %}{% if book.published_date %}{{ book.published_date.year }}{% endif %}) +{% load fr_display %} +'{{ book.title }}' Cover ({{ book|edition_info }}) diff --git a/fedireads/templatetags/fr_display.py b/fedireads/templatetags/fr_display.py index 883edccd2..5f7d3a263 100644 --- a/fedireads/templatetags/fr_display.py +++ b/fedireads/templatetags/fr_display.py @@ -118,6 +118,18 @@ def get_boosted(boost): ).get() +@register.filter(name='edition_info') +def get_edition_info(book): + ''' paperback, French language, 1982 ''' + items = [ + book.physical_format, + book.languages[0] + ' language' if book.languages and \ + book.languages[0] != 'English' else None, + str(book.published_date.year) if book.published_date else None, + ] + return ', '.join(i for i in items if i) + + @register.simple_tag(takes_context=True) def shelve_button_identifier(context, book): ''' check what shelf a user has a book on, if any '''