From b86123575745cb5b1ee72018c08e34a187ec25a1 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jun 2021 15:07:45 +0200 Subject: [PATCH 1/1] Nicer collection boxes. --- .../templates/catalogue/collection_box.html | 17 +++---- src/catalogue/views.py | 8 ++- .../static/scss/main/catalogue.scss | 18 +++++++ .../templates/base/superbase.html | 4 +- src/wolnelektury/templates/main_page.html | 50 ++++++++++++------- src/wolnelektury/views.py | 7 +-- 6 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/catalogue/templates/catalogue/collection_box.html b/src/catalogue/templates/catalogue/collection_box.html index c32122f32..214db8be9 100644 --- a/src/catalogue/templates/catalogue/collection_box.html +++ b/src/catalogue/templates/catalogue/collection_box.html @@ -2,18 +2,17 @@ {% load i18n %}

{% trans "Collection" %}: {{ collection }}

+

{% if collection.description %} {{ collection.description|safe|truncatewords_html:40 }} {% endif %} - {% for book in collection.get_books|slice:":5" %} - {{ book.mini_box }} - {% endfor %} - {% with collection.get_books.count|add:-5 as more %} - {% if more > 0 %} - - {% blocktrans count c=more %}and one more{% plural %}and {{ c }} more{% endblocktrans %} +

+
+ {% for book in collection.get_books|slice:":5" %} + + {{ book.pretty_title }} - {% endif %} - {% endwith %} + {% endfor %} +
{% endspaceless %} diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 904cdc531..38c616520 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -66,7 +66,10 @@ def daisy_list(request): def collection(request, slug): coll = get_object_or_404(Collection, slug=slug) - return render(request, 'catalogue/collection.html', {'collection': coll}) + return render(request, 'catalogue/collection.html', { + 'collection': coll, + 'active_menu_item': 'collections', + }) def differentiate_tags(request, tags, ambiguous_slugs): @@ -455,13 +458,14 @@ def collections(request): objects = Collection.objects.filter(listed=True) if len(objects) > 3: - best = random.sample(list(objects), 3) + best = random.sample(list(objects), 4) else: best = objects return render(request, 'catalogue/collections.html', { 'objects': objects, 'best': best, + 'active_menu_item': 'collections' }) diff --git a/src/wolnelektury/static/scss/main/catalogue.scss b/src/wolnelektury/static/scss/main/catalogue.scss index ba30e8271..8148930b2 100644 --- a/src/wolnelektury/static/scss/main/catalogue.scss +++ b/src/wolnelektury/static/scss/main/catalogue.scss @@ -27,3 +27,21 @@ @include size(padding, 26px); } } + + +.collection-box { + display: inline-block; + vertical-align: top; + + @media screen and (min-width:500px) { + width: 465px; + } + + p { + height: 75px; + overflow: hidden; + } + .covers { + line-height: 0; + } +} diff --git a/src/wolnelektury/templates/base/superbase.html b/src/wolnelektury/templates/base/superbase.html index e1ec73419..e1483b683 100644 --- a/src/wolnelektury/templates/base/superbase.html +++ b/src/wolnelektury/templates/base/superbase.html @@ -120,8 +120,8 @@ {% trans "Audiobooks" %} - - {% trans "All works" %} + + {% trans "Collections" %}
  • {% trans "Newsletter" %} diff --git a/src/wolnelektury/templates/main_page.html b/src/wolnelektury/templates/main_page.html index 1bec4c2e7..f47e1d227 100644 --- a/src/wolnelektury/templates/main_page.html +++ b/src/wolnelektury/templates/main_page.html @@ -31,8 +31,39 @@ +
    +

    + + {% trans "Recent publications" %} + → + +

    + {% for book in last_published %} + {{ book.mini_box }} + {% endfor %} +
    + + {% if collections %} +
    +

    + + {% trans "Collections" %} + → + +

    + {% for collection in collections %} + {{ collection.box }} + {% endfor %} +
    + {% endif %} +
    -

    {% trans "Motifs and themes" %}

    +

    + + {% trans "Motifs and themes" %} + → + +

    {% trans "Theme" %}: {{ theme }}

    {% trans "Explore works with the same theme" %}

    @@ -45,23 +76,6 @@ {% endcache %} {% endif %}
    - {% trans "See motifs catalog" %} -
    - - {% if collection %} -
    -

    {% trans "Collections" %}

    - {{ collection.box }} - {% trans "See collections catalog" %} -
    - {% endif %} - -
    -

    {% trans "Recent publications" %}

    - {% for book in last_published %} - {{ book.mini_box }} - {% endfor %} - {% trans "More recent publications" %}
    diff --git a/src/wolnelektury/views.py b/src/wolnelektury/views.py index 48063d29b..2cc0fd799 100644 --- a/src/wolnelektury/views.py +++ b/src/wolnelektury/views.py @@ -46,11 +46,8 @@ def main_page(request): break break - # Choose a collection for main. - try: - ctx['collection'] = Collection.objects.filter(listed=True).order_by('?')[:1][0] - except IndexError: - pass + # Choose collections for main. + ctx['collections'] = Collection.objects.filter(listed=True).order_by('?')[:4] best = [] best_places = 5 -- 2.20.1