diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py
index d3b01f7a..a63a788e 100644
--- a/bookwyrm/connectors/connector_manager.py
+++ b/bookwyrm/connectors/connector_manager.py
@@ -35,10 +35,10 @@ def search(query, min_confidence=0.1):
return results
-def local_search(query, min_confidence=0.1):
+def local_search(query, min_confidence=0.1, raw=False):
''' only look at local search results '''
connector = load_connector(models.Connector.objects.get(local=True))
- return connector.search(query, min_confidence=min_confidence)
+ return connector.search(query, min_confidence=min_confidence, raw=raw)
def first_search_result(query, min_confidence=0.1):
diff --git a/bookwyrm/connectors/self_connector.py b/bookwyrm/connectors/self_connector.py
index c5d58a59..f57fbc1c 100644
--- a/bookwyrm/connectors/self_connector.py
+++ b/bookwyrm/connectors/self_connector.py
@@ -11,7 +11,8 @@ from .abstract_connector import AbstractConnector, SearchResult
class Connector(AbstractConnector):
''' instantiate a connector '''
- def search(self, query, min_confidence=0.1):
+ # pylint: disable=arguments-differ
+ def search(self, query, min_confidence=0.1, raw=False):
''' search your local database '''
if not query:
return []
@@ -22,10 +23,14 @@ class Connector(AbstractConnector):
results = search_title_author(query, min_confidence)
search_results = []
for result in results:
- search_results.append(self.format_search_result(result))
+ if raw:
+ search_results.append(result)
+ else:
+ search_results.append(self.format_search_result(result))
if len(search_results) >= 10:
break
- search_results.sort(key=lambda r: r.confidence, reverse=True)
+ if not raw:
+ search_results.sort(key=lambda r: r.confidence, reverse=True)
return search_results
diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html
index 1a6c065e..fe8a7509 100644
--- a/bookwyrm/templates/layout.html
+++ b/bookwyrm/templates/layout.html
@@ -59,10 +59,10 @@
Feed
- {% endif %}
Lists
+ {% endif %}
diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html
index 38be3edf..04fd5e11 100644
--- a/bookwyrm/templates/lists/list.html
+++ b/bookwyrm/templates/lists/list.html
@@ -65,6 +65,23 @@
{% if not list.curation == 'closed' or request.user == list.user %}
{% if list.curation == 'open' or request.user == list.user %}Add{% else %}Suggest{% endif %} Books
+
{% for book in suggested_books %}
diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py
index c126102d..ff2a2f21 100644
--- a/bookwyrm/views/list.py
+++ b/bookwyrm/views/list.py
@@ -10,6 +10,7 @@ from django.views.decorators.http import require_POST
from bookwyrm import forms, models
from bookwyrm.activitypub import ActivitypubResponse
+from bookwyrm.connectors import connector_manager
from .helpers import is_api_request, object_visible_to_user, privacy_filter
@@ -52,16 +53,22 @@ class List(View):
if is_api_request(request):
return ActivitypubResponse(book_list.to_activity())
- suggestions = request.user.shelfbook_set.filter(
- ~Q(book__in=book_list.books.all())
- )
- suggestions = [s.book for s in suggestions[:5]]
- if len(suggestions) < 5:
- suggestions += [s.default_edition for s in \
- models.Work.objects.filter(
- ~Q(editions__in=book_list.books.all()),
- ).order_by('-updated_date')
- ][:5 - len(suggestions)]
+ query = request.GET.get('q')
+ if query:
+ # search for books
+ suggestions = connector_manager.local_search(query, raw=True)
+ else:
+ # just suggest whatever books are nearby
+ suggestions = request.user.shelfbook_set.filter(
+ ~Q(book__in=book_list.books.all())
+ )
+ suggestions = [s.book for s in suggestions[:5]]
+ if len(suggestions) < 5:
+ suggestions += [s.default_edition for s in \
+ models.Work.objects.filter(
+ ~Q(editions__in=book_list.books.all()),
+ ).order_by('-updated_date')
+ ][:5 - len(suggestions)]
data = {
@@ -69,6 +76,7 @@ class List(View):
'list': book_list,
'suggested_books': suggestions,
'list_form': forms.ListForm(instance=book_list),
+ 'query': query or ''
}
return TemplateResponse(request, 'lists/list.html', data)