$def with (param, facet_counts=None, async_load=True, path=None, query={})
$code:
start_facet_count = 5
facet_inc = 10
def add_facet_url(k, v):
if k != 'has_fulltext':
return changequery(query=dict(query), page=None, _path=path, **{k:param.get(k, []) + [v]})
else:
return changequery(query=dict(query), page=None, _path=path, **{k:v})
def add_track(key: str) -> str:
"""
KeyError will be raised if key is not in the following dict.
"""
facets = {
"has_fulltext": "Ebook",
"author_key": "Author",
"subject_facet": "Subjects",
"person_facet": "People",
"place_facet": "Places",
"time_facet": "Times",
"first_publish_year": "FirstPublished",
"publisher_facet": "Publisher",
"language": "Language",
}
return "SearchFacet|" + facets[key]
$def facet(header, label, counts):
$def facet_entry(display, count, facet_url, hide_entry=False):
$ facet_classes = 'facetEntry'
$if hide_entry:
$ facet_classes += ' ui-helper-hidden'
$if async_load:
$_('Loading...')
$else:
$ link_title = _('Filter results for %(facet)s', facet=display)
$if header == 'has_fulltext':
$ link_title = _('Filter results for ebook availability')
$if display == 'yes':
$ display = _('yes')
$else:
$ display = _('no')
$display $commify(count)
$_("Zoom In")
$:_('Focus your results using these
filters')
$for header, label in get_facet_map():
$if header=='has_fulltext' and 'has_fulltext' in param:
$continue
$if header=='public_scan_b':
$continue
$ counts = [i for i in facet_counts[header] if i[0] not in param.get(header, [])] if not async_load else [(None, None, None)]
$if not counts and not async_load:
$continue
$:facet(header, label, counts)