{% macro other(user) -%}
{% if current_user.is_authenticated and current_user.id != user.id %}
<div class="list-group-item">
  <span class="text-right" style="display:block">
    {% if user.id | user_is_followed %}
    <button class="btn btn-sm btn-default user-following active" data-id="{{ user.id}}">取消关注</button>
    {% else %}
    <button class="btn btn-sm btn-default user-following" data-id="{{ user.id}}">关注他</button>
    {% endif %}
    <button class="btn btn-sm btn-default" id="{{ user.id}}" title="私信" data-toggle="modal" data-target="#send-message"><i class="fa fa-comments" style="font-size:16px;"></i></button>
  </span>
</div>
{% endif %}
{%- endmacro %}

{% macro mine(user) -%}
{% if g.user.is_authenticated and current_user.id == user.id and not user.is_confirmed %}
<div class="alert alert-info" style="padding:6px;font-size:12px;margin-top:10px;">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
  {{ _("You haven't confirm your account,Please confirmed") }}
  <span id="email-confirm" class="btn btn-info btn-sm" style="padding:2px 5px;">{{ _('Activate  Account')}}</span>
</div>
{% endif %}
{%- endmacro %}

{% macro online(user) -%}
{% set setting = user.setting %}
{%- set _a = (setting.online_status == 1 and user.username | is_online) %}
{%- set _b = (setting.online_status == 2 and current_user.is_authenticated and user.username | is_online) %}
{%- if _a or _b %}
<span class="online">{{ _('ONLINE') }} </span>
{%- else %}
<span class="online">{{ _('OUTLINE') }}</span>
{% endif -%}
{%- endmacro %}

<div class="list-group">
  <div class="media list-group-item">
    <div class="media-left">
      <img class="media-object img-circle" src="{{ url_for('avatar',text=user.username) }}" alt="avatar" style="width:64px;height:64px"/>
    </div>
    <div class="media-body">
      <h4 class="media-heading">
        {{ user.username}}
        {{ online(user) }}
      </h4>
      <small style="color:#999">
        <span>第{{ user.id }}号会员</span>/
        <span>{{user.register_time | timesince }}</span>
        <br/>
        <span>{{ user.topics.count() }}篇主题</span> |
        <span>{{ user.replies.count() }}条回复</span>
      </small>
    </div>
    <blockquote style="font-size:14px;">
      <p>{{ user.info.word }}</p>
      <footer>Someone famous in <cite title="Source Title">{{ user.info.school }}</cite></footer>
    </blockquote>
    <table  style="font-size:12px;width:100%" align="center">
      <tr>
        <td align="center" style="border-right:1px solid #AACCEE;"><p>1</p>积分</td>
        <td align="center" style="border-right:1px solid #AACCEE;"><p>{{ user.followers.count()}}</p>粉丝</td>
        <td align="center"><p>{{ user.following_users.count() }}</p>关注</td>
      </tr>
    </table>
  </div>
  {{ other(user) }}
  {{ mine(user) }}
</div>
