-
Notifications
You must be signed in to change notification settings - Fork 2k
/
facet_list.html
60 lines (54 loc) · 2.39 KB
/
facet_list.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!--!
Construct a facet module populated with links to filtered results.
name
The field name identifying the facet field, eg. "tags"
title
The title of the facet, eg. "Tags", or "Tag Cloud"
label_function
Renders the human-readable label for each facet value.
If defined, this should be a callable that accepts a `facet_item`.
eg. lambda facet_item: facet_item.display_name.upper()
By default it displays the facet item's display name, which should
usually be good enough
if_empty
A string, which if defined, and the list of possible facet items is empty,
is displayed in lieu of an empty list.
count_label
A callable which accepts an integer, and returns a string. This controls
how a facet-item's count is displayed.
-->
<py:with vars="items=h.get_facet_items_dict(name)" xmlns:py="http://genshi.edgewall.org/">
<section class="module">
<h2 class="heading">${c.facet_titles.get(name)} <a href="${c.remove_field(name)}" class="action">Clear All</a></h2>
<nav py:if="items">
<ul class="unstyled nav nav-simple nav-facet">
<py:for each="item in items">
<py:choose test="">
<py:if test="item.active">
<li class="active">
<a href="${c.remove_field(name, item.name)}">
${label_function(item) if vars().has_key('label_function') else h.truncate(item.display_name, 22)}
${count_label(item['count']) if vars().has_key('count_label') else ('(%d)' % item['count'])}
</a>
</li>
</py:if>
<py:otherwise>
<py:if test="not item.active">
<li>
<a href="${c.drill_down_url(**{name: item.name})}">
${label_function(item) if vars().has_key('label_function') else h.truncate(item.display_name, 22)}
${count_label(item['count']) if vars().has_key('count_label') else ('(%d)' % item['count'])}
</a>
</li>
</py:if>
</py:otherwise>
</py:choose>
</py:for>
</ul>
</nav>
<p class="footer" py:if="items">
<a py:if="c.search_facets_limits.get(name)" href="${c.remove_field('_%s_limit' % name, replace=0)}" class="read-more">Show All ${c.facet_titles.get(name)}</a>
<a py:if="not c.search_facets_limits.get(name)" href="${c.remove_field('_%s_limit' % name)}" class="read-more">Show Only Popular ${c.facet_titles.get(name)}</a>
</p>
</section>
</py:with>