diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index afa9cf2b..25af1e08 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -8,6 +8,4 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - uses: psf/black@stable - with: - args: ". --check -l 80 -S" + - uses: psf/black@21.4b2 diff --git a/bookwyrm/templates/directory/directory.html b/bookwyrm/templates/directory/directory.html index 2fa8a5ae..f97a8481 100644 --- a/bookwyrm/templates/directory/directory.html +++ b/bookwyrm/templates/directory/directory.html @@ -1,7 +1,5 @@ {% extends 'layout.html' %} {% load i18n %} -{% load bookwyrm_tags %} -{% load humanize %} {% block title %}{% trans "Directory" %}{% endblock %} @@ -41,59 +39,7 @@
{% for user in users %}
-
-
- - -
- {% if user.summary %} - {{ user.summary | to_markdown | safe | truncatechars_html:40 }} - {% else %} {% endif %} -
-
- -
+ {% include 'directory/user_card.html' %}
{% endfor %}
diff --git a/bookwyrm/templates/directory/user_card.html b/bookwyrm/templates/directory/user_card.html new file mode 100644 index 00000000..8e7538c8 --- /dev/null +++ b/bookwyrm/templates/directory/user_card.html @@ -0,0 +1,57 @@ +{% load i18n %} +{% load bookwyrm_tags %} +{% load humanize %} + +
+
+ + +
+ {% if user.summary %} + {{ user.summary | to_markdown | safe | truncatechars_html:40 }} + {% else %} {% endif %} +
+
+ +
diff --git a/bookwyrm/templates/search/book.html b/bookwyrm/templates/search/book.html new file mode 100644 index 00000000..84c2fafe --- /dev/null +++ b/bookwyrm/templates/search/book.html @@ -0,0 +1,78 @@ +{% extends 'search/layout.html' %} +{% load i18n %} + +{% block panel %} + +{% if results %} +{% with results|first as local_results %} + +{% endwith %} + +
+{% for result_set in results|slice:"1:" %} + {% if result_set.results %} +
+ {% if not result_set.connector.local %} +
+ +
+ {% trans "Show" as button_text %} + {% include 'snippets/toggle/open_button.html' with text=button_text small=True controls_text="more-results-panel" controls_uid=result_set.connector.identifier class="is-small" icon="arrow-down" pressed=forloop.first %} +
+
+ {% 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 %} + {% if not remote %} + + {% trans "Load results from other catalogues" %} + + {% else %} + + {% trans "Manually add book" %} + + {% endif %} + {% else %} + + {% trans "Log in to import or add books." %} + + {% endif %} +

+ +{% endblock %} diff --git a/bookwyrm/templates/search/layout.html b/bookwyrm/templates/search/layout.html new file mode 100644 index 00000000..239586ef --- /dev/null +++ b/bookwyrm/templates/search/layout.html @@ -0,0 +1,70 @@ +{% extends 'layout.html' %} +{% load i18n %} + +{% block title %}{% trans "Search" %}{% endblock %} + +{% block content %} +
+

+ {% blocktrans %}Search{% endblocktrans %} +

+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +{% if query %} + + +
+ {% if not results %} +

+ {% blocktrans %}No results found for "{{ query }}"{% endblocktrans %} +

+ {% endif %} + {% block panel %} + {% endblock %} + +
+ {% include 'snippets/pagination.html' with page=results path=request.path %} +
+
+{% endif %} + +{% endblock %} diff --git a/bookwyrm/templates/search/list.html b/bookwyrm/templates/search/list.html new file mode 100644 index 00000000..d7e48f51 --- /dev/null +++ b/bookwyrm/templates/search/list.html @@ -0,0 +1,7 @@ +{% extends 'search/layout.html' %} + +{% block panel %} + +{% include 'lists/list_items.html' with lists=results %} + +{% endblock %} diff --git a/bookwyrm/templates/search/user.html b/bookwyrm/templates/search/user.html new file mode 100644 index 00000000..c6adc613 --- /dev/null +++ b/bookwyrm/templates/search/user.html @@ -0,0 +1,14 @@ +{% extends 'search/layout.html' %} +{% load bookwyrm_tags %} + +{% block panel %} + +
+{% for user in results %} +
+ {% include 'directory/user_card.html' %} +
+{% 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 %} -
- -
- {% trans "Show" as button_text %} - {% include 'snippets/toggle/open_button.html' with text=button_text small=True controls_text="more-results-panel" controls_uid=result_set.connector.identifier class="is-small" icon="arrow-down" pressed=forloop.first %} -
-
- {% 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/templates/snippets/pagination.html b/bookwyrm/templates/snippets/pagination.html index 3b33ca62..db2396ae 100644 --- a/bookwyrm/templates/snippets/pagination.html +++ b/bookwyrm/templates/snippets/pagination.html @@ -1,5 +1,5 @@ {% load i18n %} -