Adds "suggested follows" panel

This commit is contained in:
Mouse Reeve
2021-03-26 10:32:42 -07:00
parent c00558bda6
commit b0e1095fe6
4 changed files with 53 additions and 7 deletions

View File

@ -1,6 +1,7 @@
{% extends 'feed/feed_layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
{% load humanize %}
{% block panel %}
<h1 class="title">
@ -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 #}
<section class="block">
<h2 class="title is-5">{% trans "Who to follow" %}</h2>
<div class="columns is-mobile is-gapless scroll-x">
{% for user in suggested_users %}
<div class="column is-flex">
<div class="box has-text-centered is-shadowless has-background-white-bis">
<a href="{{ user.local_path }}" class="has-text-black">
{% include 'snippets/avatar.html' with user=user large=True %}
<span title="{{ user.display_name }}" class="is-block is-6 has-text-weight-bold">{{ user.display_name|truncatechars:10 }}</span>
<span title="@{{ user|username }}" class="is-block pb-3">@{{ user|username|truncatechars:8 }}</span>
</a>
{% include 'snippets/follow_button.html' with user=user minimal=True %}
{% if user.mutuals %}
<p class="help">
{% blocktrans with mutuals=user.mutuals|intcomma count counter=user.mutuals %}{{ mutuals }} follower you follow{% plural %}{{ mutuals }} followers you follow{% endblocktrans %}
</p>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
<div class="block">
{% include 'snippets/status/status.html' with status=activity %}
</div>

View File

@ -4,16 +4,12 @@
{% include 'snippets/block_button.html' %}
{% else %}
<div class="field has-addons">
<div class="field{% if not minimal %} has-addons{% else %} mb-0{% endif %}">
<div class="control">
<form action="{% url 'follow' %}" method="POST" class="interaction follow-{{ user.id }} {% if request.user in user.followers.all or request.user in user.follower_requests.all %}hidden{%endif %}" data-id="follow-{{ user.id }}">
{% csrf_token %}
<input type="hidden" name="user" value="{{ user.username }}">
{% if user.manually_approves_followers %}
<button class="button is-small is-link" type="submit">{% trans "Send follow request" %}</button>
{% else %}
<button class="button is-small is-link" type="submit">{% trans "Follow" %}</button>
{% endif %}
<button class="button is-small{% if not minimal %} is-link{% endif %}" type="submit">{% trans "Follow" %}</button>
</form>
<form action="{% url 'unfollow' %}" method="POST" class="interaction follow-{{ user.id }} {% if not request.user in user.followers.all and not request.user in user.follower_requests.all %}hidden{%endif %}" data-id="follow-{{ user.id }}">
{% csrf_token %}
@ -25,8 +21,10 @@
{% endif %}
</form>
</div>
{% if not minimal %}
<div class="control">
{% include 'snippets/user_options.html' with user=user class="is-small" %}
</div>
{% endif %}
</div>
{% endif %}