diff --git a/bookwyrm/templates/search/book.html b/bookwyrm/templates/search/book.html
new file mode 100644
index 00000000..5d66ef90
--- /dev/null
+++ b/bookwyrm/templates/search/book.html
@@ -0,0 +1,9 @@
+{% extends 'search/layout.html' %}
+
+{% block panel %}
+
+{% for result in results %}
+hi
+{% endfor %}
+
+{% endblock %}
diff --git a/bookwyrm/templates/search/layout.html b/bookwyrm/templates/search/layout.html
new file mode 100644
index 00000000..005cda9d
--- /dev/null
+++ b/bookwyrm/templates/search/layout.html
@@ -0,0 +1,59 @@
+{% extends 'layout.html' %}
+{% load i18n %}
+
+{% block title %}{% trans "Search" %}{% endblock %}
+
+{% block content %}
+
+
+ {% blocktrans %}Search{% endblocktrans %}
+
+
+
+
+
+
+
+
+
+
+
+ {% block panel %}
+ {% endblock %}
+
+
+{% endblock %}
diff --git a/bookwyrm/templates/search/list.html b/bookwyrm/templates/search/list.html
new file mode 100644
index 00000000..5d66ef90
--- /dev/null
+++ b/bookwyrm/templates/search/list.html
@@ -0,0 +1,9 @@
+{% extends 'search/layout.html' %}
+
+{% block panel %}
+
+{% for result in results %}
+hi
+{% endfor %}
+
+{% endblock %}
diff --git a/bookwyrm/templates/search/user.html b/bookwyrm/templates/search/user.html
new file mode 100644
index 00000000..5d66ef90
--- /dev/null
+++ b/bookwyrm/templates/search/user.html
@@ -0,0 +1,9 @@
+{% extends 'search/layout.html' %}
+
+{% block panel %}
+
+{% for result in results %}
+hi
+{% endfor %}
+
+{% endblock %}
diff --git a/bookwyrm/templates/search_results.html b/bookwyrm/templates/search_results.html
deleted file mode 100644
index fdb77f72..00000000
--- a/bookwyrm/templates/search_results.html
+++ /dev/null
@@ -1,133 +0,0 @@
-{% 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 local_results.results %}
- {% blocktrans %}No books found for "{{ query }}"{% endblocktrans %}
- {% if not user.is_authenticated %}
-
- {% trans "Log in to import or add books." %}
-
- {% endif %}
- {% else %}
-
- {% for result in local_results.results %}
-
- {% include 'snippets/search_result_text.html' with result=result %}
-
- {% endfor %}
-
- {% endif %}
-
-
- {% if request.user.is_authenticated %}
- {% if book_results|slice:":1" and local_results.results %}
-
-
- {% trans "Didn't find what you were looking for?" %}
-
- {% trans "Show results from other catalogues" as button_text %}
- {% include 'snippets/toggle/open_button.html' with text=button_text small=True controls_text="more-results" %}
-
- {% if local_results.results %}
- {% trans "Hide results from other catalogues" as button_text %}
- {% include 'snippets/toggle/close_button.html' with text=button_text small=True controls_text="more-results" %}
- {% endif %}
-
- {% endif %}
-
-
- {% for result_set in book_results|slice:"1:" %}
- {% if result_set.results %}
-
- {% if not result_set.connector.local %}
-
- {% endif %}
-
-
-
-
- {% trans "Close" as button_text %}
- {% include 'snippets/toggle/toggle_button.html' with label=button_text class="delete" nonbutton=True controls_text="more-results-panel" controls_uid=result_set.connector.identifier pressed=forloop.first %}
-
-
-
- {% for result in result_set.results %}
-
- {% include 'snippets/search_result_text.html' with result=result remote_result=True %}
-
- {% endfor %}
-
-
-
-
- {% endif %}
- {% endfor %}
-
-
-
- {% endif %}
-
-
- {% if request.user.is_authenticated %}
-
- {% trans "Matching Users" %}
- {% if not user_results %}
- {% blocktrans %}No users found for "{{ query }}"{% endblocktrans %}
- {% endif %}
-
-
- {% endif %}
-
- {% trans "Lists" %}
- {% if not list_results %}
- {% blocktrans %}No lists found for "{{ query }}"{% endblocktrans %}
- {% endif %}
- {% for result in list_results %}
-
- {% endfor %}
-
-
-
-{% endwith %}
-{% endblock %}
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py
index 99e51ff3..a06e0bd4 100644
--- a/bookwyrm/urls.py
+++ b/bookwyrm/urls.py
@@ -163,7 +163,8 @@ urlpatterns = [
name="direct-messages-user",
),
# search
- re_path(r"^search/?$", views.Search.as_view()),
+ re_path(r"^search/?$", views.Search.as_view(), name="search"),
+ re_path(r"^search/(?Puser|list|book)/?$", views.Search.as_view(), name="search"),
# imports
re_path(r"^import/?$", views.Import.as_view()),
re_path(r"^import/(\d+)/?$", views.ImportStatus.as_view()),
diff --git a/bookwyrm/views/search.py b/bookwyrm/views/search.py
index df80603c..aaca7377 100644
--- a/bookwyrm/views/search.py
+++ b/bookwyrm/views/search.py
@@ -30,15 +30,22 @@ class Search(View):
)
return JsonResponse([r.json() for r in book_results], safe=False)
- data = {"query": query, "type": search_type}
- # make a guess about what type of query this is for
- if search_type == "user" or (not search_type and "@" in query):
- results = user_search(query, request.user)
- elif search_type == "list":
- results = list_search(query, request.user)
- else:
- results = book_search(query, min_confidence)
- return TemplateResponse(request, "search_results.html", {**data, **results})
+ data = {"query": query or "", "type": search_type}
+ results = {}
+ if query:
+ # make a guess about what type of query this is for
+ if search_type == "user" or (not search_type and "@" in query):
+ results = user_search(query, request.user)
+ elif search_type == "list":
+ results = list_search(query, request.user)
+ else:
+ results = book_search(query, min_confidence)
+
+ return TemplateResponse(
+ request,
+ "search/{:s}.html".format(search_type or "book"),
+ {**data, **results}
+ )
def book_search(query, min_confidence):
@@ -46,7 +53,7 @@ def book_search(query, min_confidence):
return {
"query": query or "",
- "book_results": connector_manager.search(query, min_confidence=min_confidence),
+ "results": connector_manager.search(query, min_confidence=min_confidence),
}
@@ -63,7 +70,7 @@ def user_search(query, viewer):
return {
"query": query,
- "user_results": (
+ "results": (
models.User.viewer_aware_objects(viewer)
.annotate(
similarity=Greatest(
@@ -83,7 +90,7 @@ def list_search(query, viewer):
"""any relevent lists?"""
return {
"query": query,
- "list_results": (
+ "results": (
privacy_filter(
viewer,
models.List.objects,