From 4d63dddcde34ef242f0f4283adc39ff04737a9c6 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Tue, 26 Jan 2016 16:21:55 +0100 Subject: [PATCH] =?utf8?q?fix=20#3667:=20poprawa=20wy=C5=9Bwietlanania=20l?= =?utf8?q?osowych=20przyk=C5=82ad=C3=B3w=20w=20katalogach=20tag=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/catalogue/templates/catalogue/tag_box.html | 10 +++++----- src/catalogue/templatetags/catalogue_tags.py | 7 +++++++ src/catalogue/views.py | 6 ++++-- src/wolnelektury/static/scss/main/base.scss | 2 ++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/catalogue/templates/catalogue/tag_box.html b/src/catalogue/templates/catalogue/tag_box.html index e16e5534d..b6dc69713 100644 --- a/src/catalogue/templates/catalogue/tag_box.html +++ b/src/catalogue/templates/catalogue/tag_box.html @@ -2,11 +2,11 @@ {% load i18n %} {% load catalogue_tags %}
-

{% trans tag.category as c %}{{ c|capfirst }}: {{ tag }}

- {% if tag.description %} - {{ tag.description|safe|truncatewords_html:40 }} - {% else %} +

{% trans tag.category as c %}{{ c|capfirst }}: {{ tag }}

+ {% if tag.description %} + {{ tag.description|strip_tag:"a"|safe|truncatewords_html:40 }} + {% else %} {% trans "No description." %} - {% endif %} + {% endif %}
{% endspaceless %} diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index 117abba0c..941ab63c7 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -490,3 +490,10 @@ def choose_fragment(request, book_id=None, tag_ids=None, unless=False): fragment_count = fragments.count() fragment = fragments[randint(0, fragment_count - 1)] if fragment_count else None return fragment.pk if fragment is not None else None + + +@register.filter +def strip_tag(html, tag_name): + # docelowo może być warto zainstalować BeautifulSoup do takich rzeczy + import re + return re.sub(r"<.?%s\b[^>]*>" % tag_name, "", html) diff --git a/src/catalogue/views.py b/src/catalogue/views.py index e71895f0d..847831d69 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -712,8 +712,10 @@ def tag_catalogue(request, category): else: tags = list(get_top_level_related_tags((), categories=(category,))) - if len(tags) > 3: - best = random.sample(tags, 3) + tags = [tag for tag in tags if tag.description] + + if len(tags) > 4: + best = random.sample(tags, 4) else: best = tags diff --git a/src/wolnelektury/static/scss/main/base.scss b/src/wolnelektury/static/scss/main/base.scss index 2225c0f26..1a25dbdc9 100755 --- a/src/wolnelektury/static/scss/main/base.scss +++ b/src/wolnelektury/static/scss/main/base.scss @@ -156,7 +156,9 @@ ul.plain { @media screen and (min-width: 768px) { display: inline-block; + vertical-align: top; width: 48%; margin-right: 1%; + @include size(margin-bottom, 10px); } } -- 2.20.1