forked from mirrors/bookwyrm
Adds separate view and load links for book search results
This commit is contained in:
parent
d482c66ad4
commit
fba44206ac
4 changed files with 9 additions and 5 deletions
|
@ -25,7 +25,7 @@ class Book(ActivityObject):
|
|||
publishedDate: str = ""
|
||||
|
||||
openlibraryKey: str = None
|
||||
inventiareId: str = None
|
||||
inventaireId: str = None
|
||||
librarythingKey: str = None
|
||||
goodreadsKey: str = None
|
||||
|
||||
|
@ -70,7 +70,7 @@ class Author(ActivityObject):
|
|||
aliases: List[str] = field(default_factory=lambda: [])
|
||||
bio: str = ""
|
||||
openlibraryKey: str = None
|
||||
inventiareId: str = None
|
||||
inventaireId: str = None
|
||||
librarythingKey: str = None
|
||||
goodreadsKey: str = None
|
||||
wikipediaLink: str = ""
|
||||
|
|
|
@ -263,6 +263,7 @@ class SearchResult:
|
|||
title: str
|
||||
key: str
|
||||
connector: object
|
||||
view_link: str = None
|
||||
author: str = None
|
||||
year: str = None
|
||||
cover: str = None
|
||||
|
@ -284,7 +285,7 @@ class Mapping:
|
|||
""" associate a local database field with a field in an external dataset """
|
||||
|
||||
def __init__(self, local_field, remote_field=None, formatter=None):
|
||||
noop = lambda x: x
|
||||
noop = lambda x, *_: x
|
||||
|
||||
self.local_field = local_field
|
||||
self.remote_field = remote_field or local_field
|
||||
|
|
|
@ -11,9 +11,11 @@ class Connector(AbstractConnector):
|
|||
def __init__(self, identifier):
|
||||
super().__init__(identifier)
|
||||
|
||||
get_remote_id = lambda a, *args: self.base_url + a
|
||||
self.book_mappings = [
|
||||
Mapping("title", remote_field="wdt:P1476", formatter=get_claim),
|
||||
Mapping("id", remote_field="id"),
|
||||
Mapping("id", remote_field="key", formatter=get_remote_id),
|
||||
Mapping("inventaireId", remote_field="id"),
|
||||
Mapping("cover", remote_field="image", formatter=self.get_cover_url),
|
||||
Mapping("isbn13", remote_field="wdt:P212", formatter=get_claim),
|
||||
Mapping("isbn10", remote_field="wdt:P957", formatter=get_claim),
|
||||
|
@ -35,6 +37,7 @@ class Connector(AbstractConnector):
|
|||
return SearchResult(
|
||||
title=search_result.get("label"),
|
||||
key="{:s}{:s}".format(self.books_url, search_result.get("uri")),
|
||||
view_link="{:s}{:s}".format(self.base_url, search_result.get("uri")),
|
||||
cover=cover,
|
||||
connector=self,
|
||||
)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div class="column">
|
||||
<p>
|
||||
<strong>
|
||||
<a href="{{ result.key }}"{% if remote_result %} rel=”noopener” target="_blank"{% endif %}>{{ result.title }}</a>
|
||||
<a href="{{ result.view_link|default:result.key }}"{% if remote_result %} rel=”noopener” target="_blank"{% endif %}>{{ result.title }}</a>
|
||||
</strong>
|
||||
{% if result.author %}
|
||||
{% blocktrans with author=result.author %}by {{ author }}{% endblocktrans %}{% endif %}{% if result.year %} ({{ result.year }})
|
||||
|
|
Loading…
Reference in a new issue