-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59936ee
commit aadb35e
Showing
7 changed files
with
130 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$def with(query, results, page=1) | ||
|
||
$if results and results.get('hits'): | ||
$ loans = ctx.user.get_loans() if ctx.user else [] | ||
$ waiting_loans = ctx.user.get_waitinglist() if ctx.user else [] | ||
$ user = {'loans': loans, 'waitlists': waiting_loans} | ||
|
||
$ hits = results['hits'].get('hits', []) | ||
$ num_found = results['hits'].get('total', 0) | ||
<div id="searchResults"> | ||
<ul id="siteSearch"> | ||
$for doc in hits: | ||
$if doc.get('edition'): | ||
$ toc = macros.TocSnippet(query, doc=doc) | ||
$:macros.SearchResultsWork(doc['edition'], availability=doc['availability'], user=user, extra=toc) | ||
</ul> | ||
$:macros.Pager(page, num_found) | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
$def with (q, doc=None) | ||
|
||
$ toc = doc['_source']['toc'] | ||
<section class="fulltext-excerpts" aria-label="search results from: $doc['edition']['title']"> | ||
<pre> | ||
$for sec in toc: | ||
$sec.split(':', 1)[1] | ||
</pre> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
$def with (q, results, search_time, page=1, results_per_page=20) | ||
|
||
$var title: Search Open Library for $q | ||
|
||
<div id="contentHead"> | ||
<h1>$_("Search Tables of Contents")</h1> | ||
</div> | ||
|
||
<div id="contentBody"> | ||
|
||
<form class="siteSearch searchInsideForm" action="/search/toc"> | ||
<input type="text" class="larger" name="q" value="$q"/> | ||
<input type="submit" class="generic-button" value="$_('Search')"> | ||
</form> | ||
$ num_found = 0 | ||
$if q: | ||
$if results and 'error' not in results and results['hits']: | ||
$ hits = results['hits'].get('hits', []) | ||
$ num_found = results['hits'].get('total', 0) | ||
|
||
$if 'error' in results: | ||
<div class="searchResultsError">$results['error']</div> | ||
|
||
$if not num_found: | ||
<p class="sansserif red collapse">No hits for: <strong>$q</strong></span></p> | ||
|
||
$else: | ||
<p class="search-results-stats">About $commify(num_found) result$("s" if num_found != 1 else "") ($("%.2f" % search_time) seconds)</p> | ||
|
||
$:macros.TocResults(q, results, page=page) | ||
</div> | ||
|