This repository was archived by the owner on May 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.tag
58 lines (46 loc) · 1.45 KB
/
results.tag
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
53
54
55
56
57
58
<results>
<p if={opts.hits.length > 0}>
<a class="btn btn-secondary-outline btn-sm" if={opts.prev_url} href={opts.prev_url}>«</a>
{opts.total} hits
<span class="count_by_index" if={opts.collections}>
(<span each={col, n in opts.counts}><b>{parent.collectionTitle(col)}</b>
{n}<span class="comma">, </span></span>)
</span>
(page {opts.page}/{opts.page_count})
<a class="btn btn-secondary-outline btn-sm" if={opts.next_url} href={opts.next_url}>»</a>
</p>
<ul id="results" if={opts.hits.length > 0}>
<li each={opts.hits} class="results-item">
<a href={parent.viewUrl(this)} target="_blank">
<h3>{fields.title}</h3>
<ul class="results-highlight">
<li each={hi in highlight.text}>
<raw-span content={hi}></raw-span>
</li>
</ul>
</a>
</li>
</ul>
<p if={opts.hits.length == 0}>
-- no results --
</p>
<script>
collectionTitle(name) {
var col = opts.collections.find(function(c) {
return c.name == name
})
if(col) return col.title
return name
}
function pdfViewer(url) {
return 'http://pdfjs.hoover.grep.ro/web/viewer.html?file=' +
encodeURIComponent(url)
}
viewUrl(item) {
var url = item.fields.url[0]
var mime_type = (item.fields.mime_type || [])[0]
if(mime_type == 'application/pdf') return pdfViewer(url)
return url
}
</script>
</results>