-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
SearchResultsWork.html
86 lines (81 loc) · 4.05 KB
/
SearchResultsWork.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
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
$def with (doc, decorations=None, cta=True, availability=None, extra=None)
$ availability = availability or doc.get('availability') or {}
$ ocaid = availability.get('identifier')
$ is_work = doc.get('type', {}).get('key') == '/type/work'
$ book_url = doc.url() if is_work else doc.key
$ cover_ids = [cover for cover in doc.get('covers', []) if cover != -1]
<li class="searchResultItem" itemscope itemtype="https://schema.org/Book">
<span class="bookcover">
$if availability:
$if availability.get('openlibrary_edition'):
$ cover = get_coverstore_url() + "/b/olid/%s-M.jpg" % availability.get('openlibrary_edition')
$elif ocaid:
$ cover = "//archive.org/download/%s/page/cover_w60_h60.jpg" % ocaid
$elif doc.get('cover_i') or cover_ids:
$ cover = get_coverstore_url() + "/b/id/%s-M.jpg" % (doc.cover_i or cover_ids[0])
$elif doc.get('cover_edition_key'):
$ cover = get_coverstore_url() + "/b/olid/%s-M.jpg" % doc.cover_edition_key
$elif doc.get('ocaid'):
$ cover = "//archive.org/download/%s/page/cover_w60_h60.jpg" % doc.get('ocaid')
$else:
$ cover = "/images/icons/avatar_book-sm.png"
<a href="$(book_url)?edition=$(ocaid)"><img itemprop="image" src="$cover" alt="Cover of: $doc.title$(': ' + doc.subtitle if doc.get('subtitle', None) else '')" title="Cover of: $doc.title$(': ' + doc.subtitle if doc.get('subtitle', None) else '')"/></a>
</span>
<div class="details">
<div class="resultTitle">
<h3 itemprop="name" class="booktitle">
<a itemprop="url" href="$(book_url)?edition=$(ocaid)"
class="results">$doc.title$(': ' + doc.subtitle if doc.get('subtitle', None) else '')</a>
$if doc.get('publish_date'):
($(doc['publish_date']))
</h3>
</div>
<span itemprop="author" itemscope itemtype="https://schema.org/Organization" class="bookauthor">$_('by')
$if not doc.authors:
<em>$_('Unknown author')</em>
$else:
$for a in doc.authors:
$if not (hasattr(a, 'name') and a.name) and not (hasattr(a, 'author') and hasattr(a.author, 'name') and a.author.name):
<em>$_('Unknown author')</em>$(',' if not loop.last else '')
$continue
<a itemprop="url" href="$(a.get('url') or a.get('key') or a.author.get('url') or a.author.key)" class="results">$(a.name or a.author.name)</a>$(',' if not loop.last else '')
</span>
<span class="resultPublisher">
$if doc.get('first_publish_year'):
<span class="publishedYear">
$_('First published in %(year)s', year=doc.first_publish_year)
</span>
$if doc.get('edition_count'):
<a href="$(book_url)?edition=$(ocaid)#editions-list">$ungettext('1 edition', '%(count)d editions', doc.edition_count, count=doc.edition_count)</a>
$if doc.get('languages'):
<span class="languages">
$_('in') <a class="hoverlink" title="$(', '.join(doc.languages))">$(len(doc.languages)) $_('languages')</a>
</span>
$if doc.get('ia'):
— $_('%s previewable', len(doc.get('ia')))
$if len(doc.get('ia')) > 1:
<span class="preview-covers">
$for x, i in enumerate(doc.get('ia')[1:10]):
<a href="$(book_url)?edition=$(i)">
<img width="30" height="45" loading="lazy" src="//archive.org/download/$(i)/page/cover_w60_h60.jpg" alt="Cover of edition $i">
</a>
</span>
</span>
$if extra:
<div class="serp-extras">
$:extra
</div>
</div>
<div class="searchResultItemCTA">
$if decorations:
$# should show reading log status widget if there is one in decorations, or read, or return, or leave waitlist
<div class="decorations">
$:decorations
</div>
<div class="searchResultItemCTA-lending">
$if cta:
$ doc['availability'] = doc.get('availability', {})
$:macros.LoanStatus(doc, work_key=doc.key)
</div>
</div>
</li>