$def with (q_param, search_response, get_doc, param, page, rows)

$_("Search Books")

$:macros.SearchNavigation()
$:render_template("search/searchbox", q=q_param) $if ctx.user and (ctx.user.is_admin() or ctx.user.is_super_librarian() or ctx.user.is_librarian()):
$ sticky = set(['sort', 'author_facet', 'language', 'first_publish_year', 'publisher_facet', 'subject_facet', 'person_facet', 'place_facet', 'time_facet', 'public_scan_b']) $for k, values in param.items(): $if k not in sticky: $continue $for v in values if isinstance(values, list) else [values]:
$if search_response.facet_counts: $:render_template('search/work_search_selected_facets', param, search_response, q_param)
$if param and not search_response.docs: $if ctx.path == '/search': $ path_id = 'books' $else: $ path_id = ctx.path.split('/') $ query = query_param('q') $# Temporarily (2020-03-26) disable automatically showing full-text $# results because of performance issues due to increased load. See $# this commit to revert.
$:_('No %(path_id)s directly matched your search', path_id=path_id)

$:macros.LoadingIndicator(_("Checking Search Inside matches"))
$elif param and not search_response.error and len(search_response.docs):
$ungettext('%(count)s hit', '%(count)s hits', search_response.num_found, count=commify(search_response.num_found)) $if search_response.num_found > 1: $:render_template("search/sort_options.html", search_response.sort)
    $ works = [get_doc(d) for d in search_response.docs] $ add_availability([(w.get('editions') or [None])[0] or w for w in works]) $ username = ctx.user and ctx.user.key.split('/')[-1] $if username: $ works = add_read_statuses(username, works) $ show_librarian_extras = ctx.user and (ctx.user.is_admin() or ctx.user.is_librarian()) $# Subject key list will only be included in each doc if the patron has a sfw cookie $ subject_keys = [d.get('subject', []) for d in search_response.docs] $for work, subjects in zip(works, subject_keys): $ content_warning = len([s for s in subjects if s.startswith("content_warning:")]) != 0 $:macros.SearchResultsWork(work, show_librarian_extras=show_librarian_extras, include_dropper=True, blur=content_warning)
$:macros.Pager(page, search_response.num_found, rows)
$if search_response.error:

$_("BARF! Search engine ERROR!")

$search_response.error.decode('utf-8', 'ignore')
$elif param and len(search_response.docs): $:render_template('search/work_search_facets', param, facet_counts=search_response.facet_counts)
$if param and not search_response.error and len(search_response.docs): $if ctx.user and ctx.user.is_admin():

$_('Searching solr took %(count)s seconds', count="%.2f" % search_response.time)