{% load i18n %}
{% load catalogue_tags %}
<div class="white-box normal-text">
- <h2>{% trans tag.category as c %}{{ c|capfirst }}: {{ tag }}</h2>
- {% if tag.description %}
- {{ tag.description|safe|truncatewords_html:40 }}
- {% else %}
+ <h2>{% trans tag.category as c %}{{ c|capfirst }}: {{ tag }}</h2>
+ {% if tag.description %}
+ {{ tag.description|strip_tag:"a"|safe|truncatewords_html:40 }}
+ {% else %}
<em>{% trans "No description." %}</em>
- {% endif %}
+ {% endif %}
</div>
{% endspaceless %}
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)
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
@media screen and (min-width: 768px) {
display: inline-block;
+ vertical-align: top;
width: 48%;
margin-right: 1%;
+ @include size(margin-bottom, 10px);
}
}