-
Notifications
You must be signed in to change notification settings - Fork 2k
/
facets.html
52 lines (46 loc) · 2.25 KB
/
facets.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
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip=""
>
<py:def function="facet_sidebar(code, limit=5, label=lambda n: n, title=h.facet_title, if_empty=None, count_label=lambda c: ' (%d)'%c)">
<div py:if="if_empty is not None or len(h.facet_items(c, code, limit=limit))" class="facet-box">
<h2>${title(code)}</h2>
<ul class="facet-options">
<li py:for="name, count in h.facet_items(c, code, limit=limit)"
py:if="not (code, name) in c.fields">
<a href="${c.drill_down_url(**{code: name})}">
<span py:if="'format' in code.lower()">${h.icon(h.format_icon(name))}</span>
${label(name)}</a>${count_label(count)}
</li>
</ul>
<p py:if="not len(h.facet_items(c, code, limit=limit))">${if_empty}</p>
</div>
</py:def>
<py:def function="facet_list_items(code, limit=5, label=lambda n: n, if_empty=None)">
<!-- Creates a possibly empty list of <li> elements containing links to further search results
This is different from the above function in that it requires the caller to wrap
up the resulting <li> elements in whatever dom element they need. But it does allow for
filters to displayed in a hierarchy.
If if_empty is not None and there are no facets to filter on, then a single <li> element
is generated, with the text specified by if_empty
-->
<li py:if="if_empty and len(h.facet_items(c, code, limit=limit)) == 0">${if_empty}</li>
<li py:for="name, count in h.facet_items(c, code, limit=limit)"
py:if="not (code, name) in c.fields">
<a href="${c.drill_down_url(**{code: name})}">${label(name)}</a> (${count})
</li>
</py:def>
<py:def function="field_list()">
<div class="filter-list" py:if="c.fields">
<div class="filter-entry" py:for="(field, value) in c.fields">
<span class="name">${h.facet_title(field)}</span>
<span class="value">${value}</span>
<a href="${c.remove_field(field, value)}">
${h.icon('unfilter')}
</a>
</div>
</div>
</py:def>
</html>