-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
FulltextSuggestionSnippet.html
26 lines (24 loc) · 1.2 KB
/
FulltextSuggestionSnippet.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
$def with (q, doc=None)
$ ia = doc.get('fields', {}).get('identifier', [''])[0]
$ ia_base_url = "https://archive.org"
$ availability = doc.get('availability', {})
$ snippet = doc.get('highlight', {}).get('text', [''])[0]
$ page_nums = doc.get('fields', {}).get('page_num', [])
$if len(page_nums) == 1 and isinstance(page_nums[0], list):
$ page_nums = page_nums[0]
$ page = ', '.join(str(num) for num in page_nums)
$if snippet:
<div class="fsi-snippet">
$if snippet:
<div class="fsi-snippet__main">
<div class="fsi-snippet__quotation-mark">$_('❝')</div>
<a class="fsi-snippet__link" href="$ia_base_url/details/$ia" data-ol-link-track="SearchInsideSuggestion|QuoteClick">
…$:(snippet.replace("<", "«").replace(">", "»").replace("{{{", "<mark class='highlight'><strong>").replace("}}}", "</strong></mark>"))…
</a>
<div class="fsi-snippet__quotation-mark">$_('❞')</div>
$if page:
<span class="fsi-snippet__page-num" href="$ia_base_url/details/$ia">
<a data-ol-link-track="SearchInsideSuggestion|QuoteClick">$_('Page: %(page)s', page=page)</a>
</span>
</div>
</div>