diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index 6a1167b26..c640cd273 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -15,6 +15,11 @@ html { overflow: visible; } +.scroll-x { + overflow: hidden; + overflow-x: auto; +} + /* --- SHELVING --- */ .shelf-option:disabled > *::after { font-family: "icomoon"; diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index bc35d3b90..24131051a 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -1,6 +1,7 @@ {% extends 'feed/feed_layout.html' %} {% load i18n %} {% load bookwyrm_tags %} +{% load humanize %} {% block panel %}

@@ -48,6 +49,32 @@ {% 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" %}

+
+ {% 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 %} +

+ {% endif %} +
+
+ {% endfor %} +
+
+{% endif %}
{% include 'snippets/status/status.html' with status=activity %}
diff --git a/bookwyrm/templates/snippets/follow_button.html b/bookwyrm/templates/snippets/follow_button.html index 3df85a1a6..962d4d34a 100644 --- a/bookwyrm/templates/snippets/follow_button.html +++ b/bookwyrm/templates/snippets/follow_button.html @@ -4,16 +4,12 @@ {% include 'snippets/block_button.html' %} {% else %} -
+
+ {% if not minimal %}
{% include 'snippets/user_options.html' with user=user class="is-small" %}
+ {% endif %}
{% endif %} diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index e0de932d2..7d85675c4 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -1,7 +1,7 @@ """ non-interactive pages """ from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator -from django.db.models import Q +from django.db.models import Count, Q from django.http import HttpResponseNotFound from django.template.response import TemplateResponse from django.utils import timezone @@ -34,11 +34,30 @@ class Feed(View): paginated = Paginator(activities, PAGE_LENGTH) + suggested_users = ( + models.User.objects.filter( + ~Q(id__in=request.user.following.all()), + ~Q(id=request.user.id), + discoverable=True, + is_active=True, + bookwyrm_user=True, + ) + .annotate( + mutuals=Count( + "following", + filter=Q(following__in=request.user.following.all()), + ) + ) + .order_by("-mutuals", "-last_active_date") + .all()[:5] + ) + data = { **feed_page_data(request.user), **{ "user": request.user, "activities": paginated.page(page), + "suggested_users": suggested_users, "tab": tab, "goal_form": forms.GoalForm(), "path": "/%s" % tab,