From 0044dc65875a628c998af147664c5ea5bc6cd497 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 22 May 2021 11:20:39 -0700 Subject: [PATCH] Show suggested users when the feed is empty --- bookwyrm/suggested_users.py | 2 ++ bookwyrm/templates/feed/feed.html | 16 ++++++---- bookwyrm/templates/feed/suggested_users.html | 29 ++++--------------- bookwyrm/templates/get_started/users.html | 2 +- .../templates/snippets/suggested_users.html | 25 ++++++++++++++++ 5 files changed, 43 insertions(+), 31 deletions(-) create mode 100644 bookwyrm/templates/snippets/suggested_users.html diff --git a/bookwyrm/suggested_users.py b/bookwyrm/suggested_users.py index a6d09ecd2..7b20461a6 100644 --- a/bookwyrm/suggested_users.py +++ b/bookwyrm/suggested_users.py @@ -66,6 +66,8 @@ class SuggestedUsers(RedisStore): def rerank_user_suggestions(self, user): """update the ranks of the follows suggested to a user""" + if not user.local: + raise ValueError('Attempting to create suggestions for remote user: ', user.id) self.populate_store(self.store_id(user)) def get_suggestions(self, user): diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index 21e71ae18..78b03436e 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -44,18 +44,22 @@ {# activity feed #} {% if not activities %} -

{% trans "There aren't any activities right now! Try following a user to get started" %}

+
+

{% trans "There aren't any activities right now! Try following a user to get started" %}

+ + {% if suggested_users %} + {# suggested users for when things are very lonely #} + {% include 'feed/suggested_users.html' with suggested_users=suggested_users %} +
+{% endif %} + {% endif %} {% for activity in activities %} {% if not activities.number > 1 and forloop.counter0 == 2 and suggested_users %} {# suggested users on the first page, two statuses down #} -
-

{% trans "Who to follow" %}

- {% include 'feed/suggested_users.html' with suggested_users=suggested_users %} - View directory -
+{% include 'feed/suggested_users.html' with suggested_users=suggested_users %} {% endif %}
{% include 'snippets/status/status.html' with status=activity %} diff --git a/bookwyrm/templates/feed/suggested_users.html b/bookwyrm/templates/feed/suggested_users.html index eb146f7eb..c095faa55 100644 --- a/bookwyrm/templates/feed/suggested_users.html +++ b/bookwyrm/templates/feed/suggested_users.html @@ -1,25 +1,6 @@ {% load i18n %} -{% load utilities %} -{% load humanize %} -
- {% for user in suggested_users %} -
-
- - {% include 'snippets/avatar.html' with user=user large=True %} - {{ user.display_name|truncatechars:10 }} - @{{ user|username|truncatechars:8 }} - - {% include 'snippets/follow_button.html' with user=user minimal=True %} - {% if user.mutuals %} -

- {% blocktrans with mutuals=user.mutuals|intcomma count counter=user.mutuals %}{{ mutuals }} follower you follow{% plural %}{{ mutuals }} followers you follow{% endblocktrans %} -

- {% elif user.shared_books %} -

{% blocktrans with shared_books=user.shared_books|intcomma count counter=user.shared_books %}{{ shared_books }} book on your shelves{% plural %}{{ shared_books }} books on your shelves{% endblocktrans %}

- {% endif %} -
-
- {% endfor %} -
- +
+

{% trans "Who to follow" %}

+ {% include 'snippets/suggested_users.html' with suggested_users=suggested_users %} + View directory +
diff --git a/bookwyrm/templates/get_started/users.html b/bookwyrm/templates/get_started/users.html index 259f06d34..753691fbd 100644 --- a/bookwyrm/templates/get_started/users.html +++ b/bookwyrm/templates/get_started/users.html @@ -22,7 +22,7 @@
- {% include 'feed/suggested_users.html' with suggested_users=suggested_users %} + {% include 'snippets/suggested_users.html' with suggested_users=suggested_users %} {% endblock %} diff --git a/bookwyrm/templates/snippets/suggested_users.html b/bookwyrm/templates/snippets/suggested_users.html new file mode 100644 index 000000000..eb146f7eb --- /dev/null +++ b/bookwyrm/templates/snippets/suggested_users.html @@ -0,0 +1,25 @@ +{% load i18n %} +{% load utilities %} +{% load humanize %} +
+ {% for user in suggested_users %} +
+
+ + {% include 'snippets/avatar.html' with user=user large=True %} + {{ user.display_name|truncatechars:10 }} + @{{ user|username|truncatechars:8 }} + + {% include 'snippets/follow_button.html' with user=user minimal=True %} + {% if user.mutuals %} +

+ {% blocktrans with mutuals=user.mutuals|intcomma count counter=user.mutuals %}{{ mutuals }} follower you follow{% plural %}{{ mutuals }} followers you follow{% endblocktrans %} +

+ {% elif user.shared_books %} +

{% blocktrans with shared_books=user.shared_books|intcomma count counter=user.shared_books %}{{ shared_books }} book on your shelves{% plural %}{{ shared_books }} books on your shelves{% endblocktrans %}

+ {% endif %} +
+
+ {% endfor %} +
+