<div class="popup-card"> <img class="rounded img-fluid avatar-s popup-avatar" src="{{ url_for('main.get_avatar', filename=user.avatar_m) }}"> <div class="popup-profile"> <h6>{{ user.name }}</h6> <p class="text-muted">{{ user.username }} {% if current_user.is_authenticated %} {% if current_user != user and current_user.is_followed_by(user) %} {% if user.is_followed_by(current_user) %} <span class="badge badge-light">互相关注</span> {% else %} <span class="badge badge-light">关注你</span> {% endif %} {% endif %} {% endif %} </p> </div> <p class="card-text"> <a href="{{ url_for('user.index', username=user.username) }}"> <strong>{{ user.photos|length }}</strong> 照片 </a> <a href="{{ url_for('user.show_followers', username=user.username) }}"> <strong id="followers-count-{{ user.id }}" data-href="{{ url_for('ajax.followers_count', user_id=user.id) }}"> {{ user.followers.count() - 1 }} </strong> 关注者 </a> </p> <a href="{{ url_for('user.index', username=user.username) }}" class="btn btn-light btn-sm">主页</a> {% if current_user.is_authenticated %} {% if user != current_user %} <button data-id="{{ user.id }}" data-href="{{ url_for('ajax.unfollow', username=user.username) }}" class="{% if not current_user.is_following(user) %}hide{% endif %} btn btn-dark btn-sm unfollow-btn"> 取消关注 </button> <button data-id="{{ user.id }}" data-href="{{ url_for('ajax.follow', username=user.username) }}" class="{% if current_user.is_following(user) %}hide{% endif %} btn btn-primary btn-sm follow-btn"> 关注 </button> {% endif %} {% else %} <form class="inline" method="post" action="{{ url_for('user.follow', username=user.username) }}"> <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> <button type="submit" class="btn btn-primary btn-sm">关注</button> </form> {% endif %} </div>