From 54687b7b358bdbd957feda7bb01c96e8bd4f2db4 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 28 Feb 2021 13:45:49 -0800 Subject: [PATCH 01/44] Make users editors by default --- bookwyrm/models/user.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index f137236c0..21ef8dd2d 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -3,7 +3,7 @@ import re from urllib.parse import urlparse from django.apps import apps -from django.contrib.auth.models import AbstractUser +from django.contrib.auth.models import AbstractUser, Group from django.core.validators import MinValueValidator from django.db import models from django.utils import timezone @@ -208,6 +208,9 @@ class User(OrderedCollectionPageMixin, AbstractUser): # an id needs to be set before we can proceed with related models super().save(*args, **kwargs) + # make users editors by default + self.groups.add(Group.objects.get(name='editor')) + # create keys and shelves for new local users self.key_pair = KeyPair.objects.create( remote_id='%s/#main-key' % self.remote_id) From 0d8eb959ea6a68c7db88f729747a9e413525e8a8 Mon Sep 17 00:00:00 2001 From: Fabien Basmaison Date: Wed, 3 Mar 2021 15:48:04 +0100 Subject: [PATCH 02/44] [profile] Use unique IDs on statuses. --- bookwyrm/templates/user/user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index 5dd24caee..cefaab99f 100644 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -67,7 +67,7 @@ {% for activity in activities %} -
+
{% include 'snippets/status/status.html' with status=activity %}
{% endfor %} From a05b14c338aeab3471f0416d5d5ee793c26f7067 Mon Sep 17 00:00:00 2001 From: Fabien Basmaison Date: Wed, 3 Mar 2021 20:10:09 +0100 Subject: [PATCH 03/44] [profile] Various HTML fixes: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Wrap block level elements within block level elements, not inline. - Avoid empty blocks. - Change `
` in lists into allowed type of children. - Fix duplicated ID (some change that was not propagated across the template?). - Make the anchor optional in the navbar (interactive elements (`a`, `input`, `button`…) should not appear into other interactive elements). - Remove redundant `role` on main navigation. - Make the modal a modal with `role="dialog". - Use `button` instead of form-less `label`. --- bookwyrm/templates/components/dropdown.html | 2 +- bookwyrm/templates/components/modal.html | 11 ++++++--- bookwyrm/templates/layout.html | 22 +++++++++++------ .../templates/snippets/shelf_selector.html | 2 +- .../snippets/status/status_content.html | 8 ++++--- bookwyrm/templates/snippets/trimmed_text.html | 24 +++++++++++++------ bookwyrm/templates/snippets/username.html | 15 +++++++++++- 7 files changed, 61 insertions(+), 23 deletions(-) diff --git a/bookwyrm/templates/components/dropdown.html b/bookwyrm/templates/components/dropdown.html index 1e45fe51a..72582ddc3 100644 --- a/bookwyrm/templates/components/dropdown.html +++ b/bookwyrm/templates/components/dropdown.html @@ -5,7 +5,7 @@ {% block dropdown-trigger %}{% endblock %} diff --git a/bookwyrm/templates/components/modal.html b/bookwyrm/templates/components/modal.html index 554f9ccde..1110a8eea 100644 --- a/bookwyrm/templates/components/modal.html +++ b/bookwyrm/templates/components/modal.html @@ -1,8 +1,13 @@ - -{% endblock %} +{% endspaceless %}{% endblock %} diff --git a/locale/fr_FR/LC_MESSAGES/django.mo b/locale/fr_FR/LC_MESSAGES/django.mo index 2cddb7935337507fcce9245e070abe10274ca6fb..2620d2499b37f4a2772a7de337251835e38f686a 100644 GIT binary patch delta 7753 zcmZ|Ud3;V+9>?(;BtaxZ5J^NHWRZ}FSYj=qmLRrRVktrrGR;;=ijKOpL#rKYlqwZV zEzwdfN;}4`6r;7Yv|4S7u2jZarmgvWpL@Kf|IB^$m-jj6o_qFtleTA%c&t3?VPC3U zf6jT}@1b1)oNVLl!*wrXTqdF0n&D%NgnSzR#;J#i!Y;}-P7 zedvuJVpTkamGL}Q!;5Zh%eqQJ6>p#(yoWXL5A;KyCQd#W1IS0AFLp%TPe#UMrC|a- zgKBRJs=b|98~2#QF}5B-CLXYRTGR73_m99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Xs4x{66WPwXHbB4WAYF#ba5`jx0k z*;ULXIuNUgCjKrl5i#|sscB;jp)`|7Cn^w?{nKJ15)P8m)xlbMIqyF=(yZ(@|Hha` z32#&NJ28!@a;q8U5XrRcjzLA&Vs=+4s+RIxy;|90\n" "Language-Team: Mouse Reeve \n" @@ -613,37 +613,42 @@ msgstr "(Rechargez la page pour mettre à jour !" #: bookwyrm/templates/import_status.html:35 msgid "Failed to load" -msgstr "Le chargement a échoué" +msgstr "Items non importés" -#: bookwyrm/templates/import_status.html:59 +#: bookwyrm/templates/import_status.html:42 +#, python-format +msgid "Jump to the bottom of the list to select the %(failed_count)s items which failed to import." +msgstr "Sauter en bas de liste pour sélectionner les %(failed_count)s items n’ayant pu être importés." + +#: bookwyrm/templates/import_status.html:74 msgid "Select all" msgstr "Tout sélectionner" -#: bookwyrm/templates/import_status.html:62 +#: bookwyrm/templates/import_status.html:79 msgid "Retry items" -msgstr "Essayer d’importer les objets sélectionnés de nouveau" +msgstr "Essayer d’importer les items sélectionnés de nouveau" -#: bookwyrm/templates/import_status.html:84 +#: bookwyrm/templates/import_status.html:101 msgid "Successfully imported" msgstr "Importation réussie" -#: bookwyrm/templates/import_status.html:88 +#: bookwyrm/templates/import_status.html:105 #: bookwyrm/templates/lists/curate.html:14 msgid "Book" msgstr "Livre" -#: bookwyrm/templates/import_status.html:91 +#: bookwyrm/templates/import_status.html:108 #: bookwyrm/templates/snippets/create_status_form.html:10 #: bookwyrm/templates/snippets/shelf.html:10 msgid "Title" msgstr "Titre" -#: bookwyrm/templates/import_status.html:94 +#: bookwyrm/templates/import_status.html:111 #: bookwyrm/templates/snippets/shelf.html:11 msgid "Author" msgstr "Auteur ou autrice" -#: bookwyrm/templates/import_status.html:117 +#: bookwyrm/templates/import_status.html:134 msgid "Imported" msgstr "Importé" From b70e728ffb816574f68433b7ff5c1c1441217ac2 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 5 Mar 2021 06:58:22 -0800 Subject: [PATCH 27/44] Removes the word "cover" from cover alt text Fixes #694 --- bookwyrm/models/book.py | 2 +- bookwyrm/tests/models/test_book_model.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/models/book.py b/bookwyrm/models/book.py index f1f208303..6a1a18b1e 100644 --- a/bookwyrm/models/book.py +++ b/bookwyrm/models/book.py @@ -91,7 +91,7 @@ class Book(BookDataModel): @property def alt_text(self): ''' image alt test ''' - text = '%s cover' % self.title + text = '%s' % self.title if self.edition_info: text += ' (%s)' % self.edition_info return text diff --git a/bookwyrm/tests/models/test_book_model.py b/bookwyrm/tests/models/test_book_model.py index 98d6d446e..b4a099d05 100644 --- a/bookwyrm/tests/models/test_book_model.py +++ b/bookwyrm/tests/models/test_book_model.py @@ -81,7 +81,7 @@ class Book(TestCase): book.save() self.assertEqual(book.edition_info, 'worm, Glorbish language, 2020') self.assertEqual( - book.alt_text, 'Test Edition cover (worm, Glorbish language, 2020)') + book.alt_text, 'Test Edition (worm, Glorbish language, 2020)') def test_get_rank(self): From 91a14d3a1334848132a0474824da8b2ce054f185 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 5 Mar 2021 07:50:23 -0800 Subject: [PATCH 28/44] Updates alt text in status model tests --- bookwyrm/tests/models/test_status_model.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bookwyrm/tests/models/test_status_model.py b/bookwyrm/tests/models/test_status_model.py index c6911b6df..29be5c072 100644 --- a/bookwyrm/tests/models/test_status_model.py +++ b/bookwyrm/tests/models/test_status_model.py @@ -150,7 +150,7 @@ class Status(TestCase): self.assertEqual(activity['attachment'][0].url, 'https://%s%s' % \ (settings.DOMAIN, self.book.cover.url)) self.assertEqual( - activity['attachment'][0].name, 'Test Edition cover') + activity['attachment'][0].name, 'Test Edition') def test_comment_to_activity(self, _): ''' subclass of the base model version with a "pure" serializer ''' @@ -177,7 +177,7 @@ class Status(TestCase): self.assertEqual(activity['attachment'][0].url, 'https://%s%s' % \ (settings.DOMAIN, self.book.cover.url)) self.assertEqual( - activity['attachment'][0].name, 'Test Edition cover') + activity['attachment'][0].name, 'Test Edition') def test_quotation_to_activity(self, _): ''' subclass of the base model version with a "pure" serializer ''' @@ -207,7 +207,7 @@ class Status(TestCase): self.assertEqual(activity['attachment'][0].url, 'https://%s%s' % \ (settings.DOMAIN, self.book.cover.url)) self.assertEqual( - activity['attachment'][0].name, 'Test Edition cover') + activity['attachment'][0].name, 'Test Edition') def test_review_to_activity(self, _): ''' subclass of the base model version with a "pure" serializer ''' @@ -238,7 +238,7 @@ class Status(TestCase): self.assertEqual(activity['attachment'][0].url, 'https://%s%s' % \ (settings.DOMAIN, self.book.cover.url)) self.assertEqual( - activity['attachment'][0].name, 'Test Edition cover') + activity['attachment'][0].name, 'Test Edition') def test_favorite(self, _): ''' fav a status ''' From 99e5e3e414386bae121cd4da0cd2d2db350916e5 Mon Sep 17 00:00:00 2001 From: Fabien Basmaison Date: Fri, 5 Mar 2021 22:09:56 +0100 Subject: [PATCH 29/44] [import] Show skip link to all when there is more than 10 failed imports. --- bookwyrm/static/css/format.css | 5 +++++ bookwyrm/templates/import_status.html | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index 92e0d92c7..9badfaf0b 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -1,3 +1,8 @@ +html { + scroll-behavior: smooth; + scroll-padding-top: 20%; +} + /* --- --- */ .image { overflow: hidden; diff --git a/bookwyrm/templates/import_status.html b/bookwyrm/templates/import_status.html index 3ee9c4a58..f9ba36bf4 100644 --- a/bookwyrm/templates/import_status.html +++ b/bookwyrm/templates/import_status.html @@ -38,9 +38,13 @@ {% csrf_token %} {% with failed_count=failed_items|length %} - + {% if failed_count > 10 %} +

+ + {% blocktrans %}Jump to the bottom of the list to select the {{ failed_count }} items which failed to import.{% endblocktrans %} + +

+ {% endif %} {% endwith %}
@@ -64,7 +68,7 @@
-

From 703ff60271fe4ad36bf2210949e0b375998df084 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Mon, 1 Mar 2021 21:09:21 +0100 Subject: [PATCH 30/44] isbn search --- bookwyrm/connectors/abstract_connector.py | 33 ++++++++++++ bookwyrm/connectors/bookwyrm_connector.py | 8 +++ bookwyrm/connectors/connector_manager.py | 33 ++++++++++-- bookwyrm/connectors/openlibrary.py | 16 ++++++ bookwyrm/connectors/self_connector.py | 42 +++++++++++++++ bookwyrm/management/commands/initdb.py | 3 ++ .../0047_connector_isbn_search_url.py | 18 +++++++ bookwyrm/models/connector.py | 1 + bookwyrm/templates/isbn_search_results.html | 33 ++++++++++++ .../connectors/test_abstract_connector.py | 4 ++ .../test_abstract_minimal_connector.py | 6 +++ .../connectors/test_openlibrary_connector.py | 29 ++++++++++ bookwyrm/tests/data/ol_isbn_search.json | 45 ++++++++++++++++ bookwyrm/tests/views/test_isbn.py | 54 +++++++++++++++++++ bookwyrm/tests/views/test_search.py | 4 ++ bookwyrm/urls.py | 3 ++ bookwyrm/views/__init__.py | 1 + bookwyrm/views/isbn.py | 29 ++++++++++ 18 files changed, 358 insertions(+), 4 deletions(-) create mode 100644 bookwyrm/migrations/0047_connector_isbn_search_url.py create mode 100644 bookwyrm/templates/isbn_search_results.html create mode 100644 bookwyrm/tests/data/ol_isbn_search.json create mode 100644 bookwyrm/tests/views/test_isbn.py create mode 100644 bookwyrm/views/isbn.py diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index 68ff2a483..e6372438e 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -26,6 +26,7 @@ class AbstractMinimalConnector(ABC): 'books_url', 'covers_url', 'search_url', + 'isbn_search_url', 'max_query_count', 'name', 'identifier', @@ -61,6 +62,30 @@ class AbstractMinimalConnector(ABC): results.append(self.format_search_result(doc)) return results + def isbn_search(self, query): + ''' isbn search ''' + params = {} + resp = requests.get( + '%s%s' % (self.isbn_search_url, query), + params=params, + headers={ + 'Accept': 'application/json; charset=utf-8', + 'User-Agent': settings.USER_AGENT, + }, + ) + if not resp.ok: + resp.raise_for_status() + try: + data = resp.json() + except ValueError as e: + logger.exception(e) + raise ConnectorException('Unable to parse json response', e) + results = [] + + for doc in self.parse_isbn_search_data(data): + results.append(self.format_isbn_search_result(doc)) + return results + @abstractmethod def get_or_create_book(self, remote_id): ''' pull up a book record by whatever means possible ''' @@ -73,6 +98,14 @@ class AbstractMinimalConnector(ABC): def format_search_result(self, search_result): ''' create a SearchResult obj from json ''' + @abstractmethod + def parse_isbn_search_data(self, data): + ''' turn the result json from a search into a list ''' + + @abstractmethod + def format_isbn_search_result(self, search_result): + ''' create a SearchResult obj from json ''' + class AbstractConnector(AbstractMinimalConnector): ''' generic book data connector ''' diff --git a/bookwyrm/connectors/bookwyrm_connector.py b/bookwyrm/connectors/bookwyrm_connector.py index 00e6c62f1..96b72f267 100644 --- a/bookwyrm/connectors/bookwyrm_connector.py +++ b/bookwyrm/connectors/bookwyrm_connector.py @@ -19,3 +19,11 @@ class Connector(AbstractMinimalConnector): def format_search_result(self, search_result): search_result['connector'] = self return SearchResult(**search_result) + + def parse_isbn_search_data(self, data): + return data + + def format_isbn_search_result(self, search_result): + search_result['connector'] = self + return SearchResult(**search_result) + diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index a63a788eb..053e1f9ef 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -1,5 +1,6 @@ ''' interface with whatever connectors the app has ''' import importlib +import re from urllib.parse import urlparse from requests import HTTPError @@ -15,13 +16,31 @@ class ConnectorException(HTTPError): def search(query, min_confidence=0.1): ''' find books based on arbitary keywords ''' results = [] + + # Have we got a ISBN ? + isbn = re.sub('[\W_]', '', query) + maybe_isbn = len(isbn) in [10, 13] # ISBN10 or ISBN13 + dedup_slug = lambda r: '%s/%s/%s' % (r.title, r.author, r.year) result_index = set() for connector in get_connectors(): - try: - result_set = connector.search(query, min_confidence=min_confidence) - except (HTTPError, ConnectorException): - continue + result_set = None + if maybe_isbn: + # Search on ISBN + if not connector.isbn_search_url or connector.isbn_search_url == '': + result_set = [] + else: + try: + result_set = connector.isbn_search(isbn) + except (HTTPError, ConnectorException): + pass + + # if no isbn search or results, we fallback to generic search + if result_set == None or result_set == []: + try: + result_set = connector.search(query, min_confidence=min_confidence) + except (HTTPError, ConnectorException): + continue result_set = [r for r in result_set \ if dedup_slug(r) not in result_index] @@ -41,6 +60,12 @@ def local_search(query, min_confidence=0.1, raw=False): return connector.search(query, min_confidence=min_confidence, raw=raw) +def isbn_local_search(query, raw=False): + ''' only look at local search results ''' + connector = load_connector(models.Connector.objects.get(local=True)) + return connector.isbn_search(query, raw=raw) + + def first_search_result(query, min_confidence=0.1): ''' search until you find a result that fits ''' for connector in get_connectors(): diff --git a/bookwyrm/connectors/openlibrary.py b/bookwyrm/connectors/openlibrary.py index a767a45ac..8d227eef1 100644 --- a/bookwyrm/connectors/openlibrary.py +++ b/bookwyrm/connectors/openlibrary.py @@ -129,6 +129,22 @@ class Connector(AbstractConnector): ) + def parse_isbn_search_data(self, data): + return list(data.values()) + + def format_isbn_search_result(self, search_result): + # build the remote id from the openlibrary key + key = self.books_url + search_result['key'] + authors = search_result.get('authors') or [{'name': 'Unknown'}] + author_names = [ author.get('name') for author in authors] + return SearchResult( + title=search_result.get('title'), + key=key, + author=', '.join(author_names), + connector=self, + year=search_result.get('publish_date'), + ) + def load_edition_data(self, olkey): ''' query openlibrary for editions of a work ''' url = '%s/works/%s/editions' % (self.books_url, olkey) diff --git a/bookwyrm/connectors/self_connector.py b/bookwyrm/connectors/self_connector.py index f57fbc1cc..b3a4d6f9f 100644 --- a/bookwyrm/connectors/self_connector.py +++ b/bookwyrm/connectors/self_connector.py @@ -33,6 +33,31 @@ class Connector(AbstractConnector): search_results.sort(key=lambda r: r.confidence, reverse=True) return search_results + def isbn_search(self, query, raw=False): + ''' search your local database ''' + if not query: + return [] + + filters = [{f: query} for f in ['isbn_10', 'isbn_13']] + results = models.Edition.objects.filter( + reduce(operator.or_, (Q(**f) for f in filters)) + ).distinct() + + # when there are multiple editions of the same work, pick the default. + # it would be odd for this to happen. + results = results.filter(parent_work__default_edition__id=F('id')) \ + or results + + search_results = [] + for result in results: + if raw: + search_results.append(result) + else: + search_results.append(self.format_search_result(result)) + if len(search_results) >= 10: + break + return search_results + def format_search_result(self, search_result): return SearchResult( @@ -47,6 +72,19 @@ class Connector(AbstractConnector): ) + def format_isbn_search_result(self, search_result): + return SearchResult( + title=search_result.title, + key=search_result.remote_id, + author=search_result.author_text, + year=search_result.published_date.year if \ + search_result.published_date else None, + connector=self, + confidence=search_result.rank if \ + hasattr(search_result, 'rank') else 1, + ) + + def is_work_data(self, data): pass @@ -59,6 +97,10 @@ class Connector(AbstractConnector): def get_authors_from_data(self, data): return None + def parse_isbn_search_data(self, data): + ''' it's already in the right format, don't even worry about it ''' + return data + def parse_search_data(self, data): ''' it's already in the right format, don't even worry about it ''' return data diff --git a/bookwyrm/management/commands/initdb.py b/bookwyrm/management/commands/initdb.py index 9fd117871..5759abfcc 100644 --- a/bookwyrm/management/commands/initdb.py +++ b/bookwyrm/management/commands/initdb.py @@ -66,6 +66,7 @@ def init_connectors(): books_url='https://%s/book' % DOMAIN, covers_url='https://%s/images/covers' % DOMAIN, search_url='https://%s/search?q=' % DOMAIN, + isbn_search_url='https://%s/isbn/' % DOMAIN, priority=1, ) @@ -77,6 +78,7 @@ def init_connectors(): books_url='https://bookwyrm.social/book', covers_url='https://bookwyrm.social/images/covers', search_url='https://bookwyrm.social/search?q=', + isbn_search_url='https://bookwyrm.social/isbn/', priority=2, ) @@ -88,6 +90,7 @@ def init_connectors(): books_url='https://openlibrary.org', covers_url='https://covers.openlibrary.org', search_url='https://openlibrary.org/search?q=', + isbn_search_url='https://openlibrary.org/api/books?jscmd=data&format=json&bibkeys=ISBN:', priority=3, ) diff --git a/bookwyrm/migrations/0047_connector_isbn_search_url.py b/bookwyrm/migrations/0047_connector_isbn_search_url.py new file mode 100644 index 000000000..617a89d9d --- /dev/null +++ b/bookwyrm/migrations/0047_connector_isbn_search_url.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2021-02-28 16:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0046_sitesettings_privacy_policy'), + ] + + operations = [ + migrations.AddField( + model_name='connector', + name='isbn_search_url', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/bookwyrm/models/connector.py b/bookwyrm/models/connector.py index 6f64cdf3e..c1fbf58bc 100644 --- a/bookwyrm/models/connector.py +++ b/bookwyrm/models/connector.py @@ -22,6 +22,7 @@ class Connector(BookWyrmModel): books_url = models.CharField(max_length=255) covers_url = models.CharField(max_length=255) search_url = models.CharField(max_length=255, null=True, blank=True) + isbn_search_url = models.CharField(max_length=255, null=True, blank=True) politeness_delay = models.IntegerField(null=True, blank=True) #seconds max_query_count = models.IntegerField(null=True, blank=True) diff --git a/bookwyrm/templates/isbn_search_results.html b/bookwyrm/templates/isbn_search_results.html new file mode 100644 index 000000000..a3861a68a --- /dev/null +++ b/bookwyrm/templates/isbn_search_results.html @@ -0,0 +1,33 @@ +{% extends 'layout.html' %} +{% load i18n %} + +{% block title %}{% trans "Search Results" %}{% endblock %} + +{% block content %} +{% with book_results|first as local_results %} +
+

{% blocktrans %}Search Results for "{{ query }}"{% endblocktrans %}

+
+ +
+
+

{% trans "Matching Books" %}

+
+ {% if not results %} +

{% blocktrans %}No books found for "{{ query }}"{% endblocktrans %}

+ {% else %} + + {% endif %} +
+ +
+
+
+{% endwith %} +{% endblock %} diff --git a/bookwyrm/tests/connectors/test_abstract_connector.py b/bookwyrm/tests/connectors/test_abstract_connector.py index 6e912858b..1b3821040 100644 --- a/bookwyrm/tests/connectors/test_abstract_connector.py +++ b/bookwyrm/tests/connectors/test_abstract_connector.py @@ -42,6 +42,10 @@ class AbstractConnector(TestCase): return search_result def parse_search_data(self, data): return data + def format_isbn_search_result(self, search_result): + return search_result + def parse_isbn_search_data(self, data): + return data def is_work_data(self, data): return data['type'] == 'work' def get_edition_from_work_data(self, data): diff --git a/bookwyrm/tests/connectors/test_abstract_minimal_connector.py b/bookwyrm/tests/connectors/test_abstract_minimal_connector.py index 0c6d25350..9b939067b 100644 --- a/bookwyrm/tests/connectors/test_abstract_minimal_connector.py +++ b/bookwyrm/tests/connectors/test_abstract_minimal_connector.py @@ -18,6 +18,7 @@ class AbstractConnector(TestCase): books_url='https://example.com/books', covers_url='https://example.com/covers', search_url='https://example.com/search?q=', + isbn_search_url='https://example.com/isbn', ) class TestConnector(abstract_connector.AbstractMinimalConnector): @@ -28,6 +29,10 @@ class AbstractConnector(TestCase): pass def parse_search_data(self, data): return data + def format_isbn_search_result(self, search_result): + return search_result + def parse_isbn_search_data(self, data): + return data self.test_connector = TestConnector('example.com') @@ -39,6 +44,7 @@ class AbstractConnector(TestCase): self.assertEqual(connector.books_url, 'https://example.com/books') self.assertEqual(connector.covers_url, 'https://example.com/covers') self.assertEqual(connector.search_url, 'https://example.com/search?q=') + self.assertEqual(connector.isbn_search_url, 'https://example.com/isbn') self.assertIsNone(connector.name) self.assertEqual(connector.identifier, 'example.com') self.assertIsNone(connector.max_query_count) diff --git a/bookwyrm/tests/connectors/test_openlibrary_connector.py b/bookwyrm/tests/connectors/test_openlibrary_connector.py index 576e353bf..a174300a9 100644 --- a/bookwyrm/tests/connectors/test_openlibrary_connector.py +++ b/bookwyrm/tests/connectors/test_openlibrary_connector.py @@ -27,6 +27,7 @@ class Openlibrary(TestCase): books_url='https://openlibrary.org', covers_url='https://covers.openlibrary.org', search_url='https://openlibrary.org/search?q=', + isbn_search_url='https://openlibrary.org/isbn', ) self.connector = Connector('openlibrary.org') @@ -149,6 +150,34 @@ class Openlibrary(TestCase): self.assertEqual(result.connector, self.connector) + def test_parse_isbn_search_result(self): + ''' extract the results from the search json response ''' + datafile = pathlib.Path(__file__).parent.joinpath( + '../data/ol_isbn_search.json') + search_data = json.loads(datafile.read_bytes()) + result = self.connector.parse_isbn_search_data(search_data) + self.assertIsInstance(result, list) + self.assertEqual(len(result), 1) + + + def test_format_isbn_search_result(self): + ''' translate json from openlibrary into SearchResult ''' + datafile = pathlib.Path(__file__).parent.joinpath( + '../data/ol_isbn_search.json') + search_data = json.loads(datafile.read_bytes()) + results = self.connector.parse_isbn_search_data(search_data) + self.assertIsInstance(results, list) + + result = self.connector.format_isbn_search_result(results[0]) + self.assertIsInstance(result, SearchResult) + self.assertEqual(result.title, 'Les ombres errantes') + self.assertEqual( + result.key, 'https://openlibrary.org/books/OL16262504M') + self.assertEqual(result.author, 'Pascal Quignard') + self.assertEqual(result.year, '2002') + self.assertEqual(result.connector, self.connector) + + @responses.activate def test_load_edition_data(self): ''' format url from key and make request ''' diff --git a/bookwyrm/tests/data/ol_isbn_search.json b/bookwyrm/tests/data/ol_isbn_search.json new file mode 100644 index 000000000..8516ff069 --- /dev/null +++ b/bookwyrm/tests/data/ol_isbn_search.json @@ -0,0 +1,45 @@ +{ + "ISBN:9782070427796": { + "url": "https://openlibrary.org/books/OL16262504M/Les_ombres_errantes", + "key": "/books/OL16262504M", + "title": "Les ombres errantes", + "authors": [ + { + "url": "https://openlibrary.org/authors/OL269675A/Pascal_Quignard", + "name": "Pascal Quignard" + } + ], + "by_statement": "Pascal Quignard.", + "identifiers": { + "goodreads": [ + "1835483" + ], + "librarything": [ + "983474" + ], + "isbn_10": [ + "207042779X" + ], + "openlibrary": [ + "OL16262504M" + ] + }, + "classifications": { + "dewey_decimal_class": [ + "848/.91403" + ] + }, + "publishers": [ + { + "name": "Gallimard" + } + ], + "publish_places": [ + { + "name": "Paris" + } + ], + "publish_date": "2002", + "notes": "Hardback published Grasset, 2002." + } +} diff --git a/bookwyrm/tests/views/test_isbn.py b/bookwyrm/tests/views/test_isbn.py new file mode 100644 index 000000000..1966702b4 --- /dev/null +++ b/bookwyrm/tests/views/test_isbn.py @@ -0,0 +1,54 @@ +''' test for app action functionality ''' +import json +from unittest.mock import patch + +from django.http import JsonResponse +from django.template.response import TemplateResponse +from django.test import TestCase +from django.test.client import RequestFactory + +from bookwyrm import models, views +from bookwyrm.connectors import abstract_connector +from bookwyrm.settings import DOMAIN + + +class IsbnViews(TestCase): + ''' tag views''' + def setUp(self): + ''' we need basic test data and mocks ''' + self.factory = RequestFactory() + self.local_user = models.User.objects.create_user( + 'mouse@local.com', 'mouse@mouse.com', 'mouseword', + local=True, localname='mouse', + remote_id='https://example.com/users/mouse', + ) + self.work = models.Work.objects.create(title='Test Work') + self.book = models.Edition.objects.create( + title='Test Book', + isbn_13='1234567890123', + remote_id='https://example.com/book/1', + parent_work=self.work + ) + models.Connector.objects.create( + identifier='self', + connector_file='self_connector', + local=True + ) + models.SiteSettings.objects.create() + + + def test_isbn_json_response(self): + ''' searches local data only and returns book data in json format ''' + view = views.Isbn.as_view() + request = self.factory.get('') + with patch('bookwyrm.views.isbn.is_api_request') as is_api: + is_api.return_value = True + response = view(request, isbn='1234567890123') + self.assertIsInstance(response, JsonResponse) + + data = json.loads(response.content) + self.assertEqual(len(data), 1) + self.assertEqual(data[0]['title'], 'Test Book') + self.assertEqual( + data[0]['key'], 'https://%s/book/%d' % (DOMAIN, self.book.id)) + diff --git a/bookwyrm/tests/views/test_search.py b/bookwyrm/tests/views/test_search.py index 655b4563a..5d7109e71 100644 --- a/bookwyrm/tests/views/test_search.py +++ b/bookwyrm/tests/views/test_search.py @@ -64,6 +64,10 @@ class ShelfViews(TestCase): pass def parse_search_data(self, data): pass + def format_isbn_search_result(self, search_result): + return search_result + def parse_isbn_search_data(self, data): + return data models.Connector.objects.create( identifier='example.com', connector_file='openlibrary', diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index a741088a2..1c3da3016 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -135,6 +135,9 @@ urlpatterns = [ re_path(r'^resolve-book/?$', views.resolve_book), re_path(r'^switch-edition/?$', views.switch_edition), + # isbn + re_path(r'^isbn/(?P\d+)(.json)?/?$', views.Isbn.as_view()), + # author re_path(r'^author/(?P\d+)(.json)?/?$', views.Author.as_view()), re_path(r'^author/(?P\d+)/edit/?$', views.EditAuthor.as_view()), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 2c7cdc461..dd601b28b 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -31,3 +31,4 @@ from .site import Site from .status import CreateStatus, DeleteStatus from .updates import Updates from .user import User, EditUser, Followers, Following +from .isbn import Isbn diff --git a/bookwyrm/views/isbn.py b/bookwyrm/views/isbn.py new file mode 100644 index 000000000..e5539ba3a --- /dev/null +++ b/bookwyrm/views/isbn.py @@ -0,0 +1,29 @@ +''' isbn search view ''' +from django.http import HttpResponseNotFound +from django.http import JsonResponse +from django.shortcuts import get_object_or_404, redirect +from django.template.response import TemplateResponse +from django.utils.decorators import method_decorator +from django.views import View +from django.views.decorators.http import require_POST + +from bookwyrm import forms, models +from bookwyrm.connectors import connector_manager +from .helpers import is_api_request + +# pylint: disable= no-self-use +class Isbn(View): + ''' search a book by isbn ''' + def get(self, request, isbn): + ''' info about a book ''' + book_results = connector_manager.isbn_local_search(isbn) + + if is_api_request(request): + return JsonResponse([r.json() for r in book_results], safe=False) + + data = { + 'title': 'ISBN Search Results', + 'results': book_results, + 'query': isbn, + } + return TemplateResponse(request, 'isbn_search_results.html', data) From a52fee4ccfdd400ad07b2c291e8fb53462e8d486 Mon Sep 17 00:00:00 2001 From: Fabien Basmaison Date: Sat, 6 Mar 2021 21:18:39 +0100 Subject: [PATCH 31/44] Remove (potentially useful) unused CSS. --- bookwyrm/static/css/format.css | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index 9badfaf0b..435d8eb9e 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -161,35 +161,3 @@ html { content: "\e905"; right: 0; } - -/** - * Accessibility (a11y) - ============================================================================ */ - -/** - * Skip links - * - * @see https://webaim.org/styles/main.css - ---------------------------------------------------------------------------- */ -.skip-link { - position: absolute; - opacity: 0; - z-index: 100; - padding: 6px; - border: 1px solid white; - color: white; - background: #BF1722; - transition: opacity 1s ease-out; -} - -.skip-link:focus { - opacity: 1; - outline-color: transparent; - transition: opacity .1s ease-in; -} - -@media (prefers-reduced-motion: reduce) { - .skip-link { - transition-duration: 0.001ms !important; - } -} From 9ed18a2b1d20f5c052d1331e30265fbf1f8e5a4e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 6 Mar 2021 13:11:44 -0800 Subject: [PATCH 32/44] Fixes display name showing up on user page --- bookwyrm/templates/user/user.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index cefaab99f..52a915610 100644 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -1,7 +1,7 @@ {% extends 'user/user_layout.html' %} {% load i18n %} -{% block title %}{{ user.name }}{% endblock %} +{% block title %}{{ user.display_name }}{% endblock %} {% block header %}
From 09c5275ec41efb0a7467081e24b98668de7a299c Mon Sep 17 00:00:00 2001 From: erion Date: Sun, 7 Mar 2021 13:18:10 +0100 Subject: [PATCH 33/44] Fix typo. --- bookwyrm/templates/feed/status.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/feed/status.html b/bookwyrm/templates/feed/status.html index fc92f8556..9f90f355d 100644 --- a/bookwyrm/templates/feed/status.html +++ b/bookwyrm/templates/feed/status.html @@ -4,7 +4,7 @@ {% block panel %}
- + {% trans "Back" %}
From cb8ec01ccfff8ca71296226aea19f4050a5a12b8 Mon Sep 17 00:00:00 2001 From: erion Date: Sun, 7 Mar 2021 13:55:50 +0100 Subject: [PATCH 34/44] Indicate which page is the current. --- bookwyrm/templates/feed/feed.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index 1eae24d4e..4eb363e4a 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -6,13 +6,13 @@

{% blocktrans %}{{ tab_title }} Timeline{% endblocktrans %}

From ae8d39995d514f62b2a83e1e401f3244dcb7938b Mon Sep 17 00:00:00 2001 From: erion Date: Sun, 7 Mar 2021 14:39:18 +0100 Subject: [PATCH 35/44] Hide avatar image to screen readers on the status pages, since there is a link present for a user already. --- bookwyrm/templates/snippets/avatar.html | 2 +- bookwyrm/templates/snippets/status/status_header.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/snippets/avatar.html b/bookwyrm/templates/snippets/avatar.html index ca49075cf..6d27cd856 100644 --- a/bookwyrm/templates/snippets/avatar.html +++ b/bookwyrm/templates/snippets/avatar.html @@ -1,3 +1,3 @@ {% load bookwyrm_tags %} -{{ user.alt_text }} +{{ user.alt_text }} diff --git a/bookwyrm/templates/snippets/status/status_header.html b/bookwyrm/templates/snippets/status/status_header.html index 2b9418200..a9a8d72c5 100644 --- a/bookwyrm/templates/snippets/status/status_header.html +++ b/bookwyrm/templates/snippets/status/status_header.html @@ -1,6 +1,6 @@ {% load bookwyrm_tags %} {% load i18n %} -{% include 'snippets/avatar.html' with user=status.user %} +{% include 'snippets/avatar.html' with user=status.user ariaHide="true" %} {% include 'snippets/username.html' with user=status.user %} {% if status.status_type == 'GeneratedNote' %} From 9082eefd8fd7073342af5116ac2432b82cb6a28d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 07:08:19 -0800 Subject: [PATCH 36/44] Sets specific proportions for book page columns --- bookwyrm/templates/book.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index d80daca24..ec6c504aa 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -35,7 +35,7 @@
-
+
{% include 'snippets/book_cover.html' with book=book size=large %} {% include 'snippets/rate_action.html' with user=request.user book=book %} {% include 'snippets/shelve_button/shelve_button.html' %} @@ -93,7 +93,7 @@
-
+

{% include 'snippets/stars.html' with rating=rating %} @@ -201,7 +201,7 @@

-
+
{% if book.subjects %}

{% trans "Subjects" %}

From 9c94be8804b3bc7bcdb5c5bfbcb9bba83ffb4972 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 07:35:38 -0800 Subject: [PATCH 37/44] Fixes typo in subject places block --- bookwyrm/templates/book.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index ec6c504aa..c4cede2ed 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -217,7 +217,7 @@

{% trans "Places" %}

    - {% for place in book.subject_placess %} + {% for place in book.subject_places %}
  • {{ place }}
  • {% endfor %}
From e5bdb4b9d1a9ef38ad49227362df28d1d9945099 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 07:35:50 -0800 Subject: [PATCH 38/44] Make empty cover value null --- bookwyrm/activitypub/book.py | 2 +- bookwyrm/tests/actions/__init__.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 bookwyrm/tests/actions/__init__.py diff --git a/bookwyrm/activitypub/book.py b/bookwyrm/activitypub/book.py index 87c40c90a..8c32be967 100644 --- a/bookwyrm/activitypub/book.py +++ b/bookwyrm/activitypub/book.py @@ -26,7 +26,7 @@ class Book(ActivityObject): librarythingKey: str = '' goodreadsKey: str = '' - cover: Image = field(default_factory=lambda: {}) + cover: Image = None type: str = 'Book' diff --git a/bookwyrm/tests/actions/__init__.py b/bookwyrm/tests/actions/__init__.py deleted file mode 100644 index b6e690fd5..000000000 --- a/bookwyrm/tests/actions/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import * From b895059f03f25a866cffde77d600c8a5cb8f3034 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 07:42:02 -0800 Subject: [PATCH 39/44] Uses same alt text generation for books with no cover --- bookwyrm/templates/snippets/book_cover.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bookwyrm/templates/snippets/book_cover.html b/bookwyrm/templates/snippets/book_cover.html index 6d15b37f8..921378537 100644 --- a/bookwyrm/templates/snippets/book_cover.html +++ b/bookwyrm/templates/snippets/book_cover.html @@ -6,8 +6,7 @@
No cover
-

{{ book.title }}

-

({{ book.edition_info }})

+

{{ book.alt_text }}

{% endif %} From dfecdca6f93bb4f52c4a7ac9f807041fab816495 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 07:56:33 -0800 Subject: [PATCH 40/44] Fixes display of ratings --- bookwyrm/templates/book.html | 4 ++-- bookwyrm/templates/layout.html | 2 +- bookwyrm/templates/snippets/username.html | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index c4cede2ed..06578e894 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -254,8 +254,8 @@
{% include 'snippets/username.html' with user=rating.user %}
-
-
{% trans "rated it" %}
+
+

{% trans "rated it" %}

{% include 'snippets/stars.html' with rating=rating.rating %}
diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index ee42b4f6e..8a708f633 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -79,7 +79,7 @@ aria-controls="navbar-dropdown" > {% include 'snippets/avatar.html' with user=request.user %} - {% include 'snippets/username.html' with user=request.user anchor=false %} + {% include 'snippets/username.html' with user=request.user anchor=false %}
-{% include 'snippets/delete_readthrough_modal.html' with controls_text="delete-readthrough" controls_uid=readthrough.id %} +{% include 'snippets/delete_readthrough_modal.html' with controls_text="delete-readthrough" controls_uid=readthrough.id no_body=True %} From 5ddb3b810e800648d8607026d97bdad611cb4d65 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 08:37:39 -0800 Subject: [PATCH 42/44] Don't show books lists when item isn't approved --- bookwyrm/views/books.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py index 4d6afba96..cf246446c 100644 --- a/bookwyrm/views/books.py +++ b/bookwyrm/views/books.py @@ -89,7 +89,7 @@ class Book(View): 'rating': reviews.aggregate(Avg('rating'))['rating__avg'], 'tags': models.UserTag.objects.filter(book=book), 'lists': privacy_filter( - request.user, book.list_set.all() + request.user, book.list_set.filter(listitem__approved=True) ), 'user_tags': user_tags, 'user_shelves': user_shelves, From a70264c12c71b1a08ee86d53da71480cc769c7a1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 08:42:30 -0800 Subject: [PATCH 43/44] Fixes showing link to user lists --- bookwyrm/templates/snippets/status/status_header.html | 2 ++ bookwyrm/templates/user/user_layout.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/snippets/status/status_header.html b/bookwyrm/templates/snippets/status/status_header.html index a9a8d72c5..cecdddf61 100644 --- a/bookwyrm/templates/snippets/status/status_header.html +++ b/bookwyrm/templates/snippets/status/status_header.html @@ -1,7 +1,9 @@ {% load bookwyrm_tags %} {% load i18n %} + {% include 'snippets/avatar.html' with user=status.user ariaHide="true" %} {% include 'snippets/username.html' with user=status.user %} + {% if status.status_type == 'GeneratedNote' %} {{ status.content | safe }} diff --git a/bookwyrm/templates/user/user_layout.html b/bookwyrm/templates/user/user_layout.html index d76291608..75dc61dc3 100644 --- a/bookwyrm/templates/user/user_layout.html +++ b/bookwyrm/templates/user/user_layout.html @@ -56,7 +56,7 @@ {% trans "Reading Goal" %} {% endif %} - {% if is_self or user.lists.exists %} + {% if is_self or user.list_set.exists %} {% url 'user-lists' user|username as url %} {% trans "Lists" %} From ec92aff7930c4f4d2749d939c7c3704ce20fc7fe Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 7 Mar 2021 08:50:07 -0800 Subject: [PATCH 44/44] Clearer notification preview for generated notes --- bookwyrm/templates/notifications.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/notifications.html b/bookwyrm/templates/notifications.html index 007e6b053..d27196ba9 100644 --- a/bookwyrm/templates/notifications.html +++ b/bookwyrm/templates/notifications.html @@ -114,7 +114,9 @@