diff --git a/bookwyrm/templates/search_results.html b/bookwyrm/templates/search_results.html
new file mode 100644
index 000000000..573dc1ee3
--- /dev/null
+++ b/bookwyrm/templates/search_results.html
@@ -0,0 +1,45 @@
+{% extends 'layout.html' %}
+{% block content %}
+
+
+
Matching Books
+ {% for result_set in book_results %}
+ {% if result_set.results %}
+
+ {% if not result_set.connector.local %}
+
+ {% endif %}
+
+ {% for result in result_set.results %}
+
+
+
+ {% endfor %}
+
+ {% endif %}
+ {% endfor %}
+ {% if not results %}
+
No books found for "{{ query }}"
+ {% endif %}
+
+
+
Matching Users
+ {% if not user_results %}
+
No users found for "{{ query }}"
+ {% endif %}
+ {% for result in user_results %}
+
+ {% include 'snippets/avatar.html' with user=result %}
+ {% include 'snippets/username.html' with user=result show_full=True %}
+ {% include 'snippets/follow_button.html' with user=result %}
+
+ {% endfor %}
+
+
+{% endblock %}
diff --git a/bookwyrm/templates/user_results.html b/bookwyrm/templates/user_results.html
index 9ea169e28..accfdc460 100644
--- a/bookwyrm/templates/user_results.html
+++ b/bookwyrm/templates/user_results.html
@@ -6,6 +6,7 @@
No results found for "{{ query }}"
{% endif %}
{% for result in results %}
+ {{ result }}
{% include 'snippets/avatar.html' with user=result %}
{% include 'snippets/username.html' with user=result show_full=True %}
diff --git a/bookwyrm/views.py b/bookwyrm/views.py
index 2bc840c0c..0cc9df187 100644
--- a/bookwyrm/views.py
+++ b/bookwyrm/views.py
@@ -147,22 +147,25 @@ def get_activity_feed(user, filter_level, model=models.Status):
def search(request):
''' that search bar up top '''
query = request.GET.get('q')
- if re.match(r'\w+@\w+.\w+', query):
- # if something looks like a username, search with webfinger
- results = outgoing.handle_account_search(query)
- return TemplateResponse(
- request, 'user_results.html', {'results': results, 'query': query}
- )
-
- # or just send the question over to book search
if is_api_request(request):
- # only return local results via json so we don't cause a cascade
- results = books_manager.local_search(query)
- return JsonResponse([r.__dict__ for r in results], safe=False)
+ # only return local book results via json so we don't cause a cascade
+ book_results = books_manager.local_search(query)
+ return JsonResponse([r.__dict__ for r in book_results], safe=False)
- results = books_manager.search(query)
- return TemplateResponse(request, 'book_results.html', {'results': results})
+ user_results = []
+ # use webfinger looks like a mastodon style account@domain.com username
+ if re.match(r'\w+@\w+.\w+', query):
+ # if something looks like a username, search with webfinger
+ user_results = outgoing.handle_remote_webfinger(query)
+
+ book_results = books_manager.search(query)
+ data = {
+ 'book_results': book_results,
+ 'user_results': user_results,
+ 'query': query,
+ }
+ return TemplateResponse(request, 'search_results.html', data)
@login_required