{% import 'base/link.html' as link %}

{% macro nav_list(type,name) -%}
<ul class="nav nav-pills nav-stacked" >
    <li role="presentation" {% if type =='topic' %}class="active"{% endif %}>
        <a href="{{ url_for('mine.topiclist',username=name)}}">{{ _("topics of %(n)s",n = name) }}</a>
    </li>
    <li role="presentation" {% if type =='reply' %}class="active"{% endif %}>
        <a href="{{ url_for('mine.replylist',username=name)}}">{{ _("replies of %(n)s",n = name) }}</a>
    </li>
    <li role="presentation" {% if type =='collect' %}class="active"{% endif %}>
        <a href="{{ url_for('mine.collectlist',username=name)}}">{{ _("collects of %(n)s",n = name) }}</a>
    </li>
    <li role="presentation" {% if type =='follower' %}class="active"{% endif %}>
        <a href="{{ url_for('mine.followerlist',username=name)}}">{{ _("followers of %(n)s",n = name) }}</a>
    </li>
    <li role="presentation" {% if type =='follower' %}class="active"{% endif %}>
        <a href="{{ url_for('mine.followinglist',username=name)}}">{{ _("following of %(n)s",n = name) }}</a>
    </li>
</ul>
{%- endmacro %}

{% macro other(user) -%}
{% if g.user.is_authenticated and g.user.username != user.username %}
<div class="list-group-item">
    <span class="text-right" style="display:block">
        {% if user in g.user.following_users %}
        <button class="btn btn-sm btn-default userfollow active" id="{{ user.id}}">取消关注</button>
        {% else %}
        <button class="btn btn-sm btn-default userfollow" 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="icon-comments-alt" style="font-size:16px;"></i></button>
    </span>
</div>
{% endif %}
{%- endmacro %}

{% macro mine(user) -%}
{% if g.user.is_authenticated and g.user.username == user.username 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 user_title(user) -%}
{% set setting = user.setting %}
{% set info = user.info %}
<div class="list-group">
    <div class="media list-group-item">
        <div class="media-left">
            {{ link.user_avatar(user)}}
        </div>
        <div class="media-body">
            <h4 class="media-heading">
                {{ user.username}}
                {%- set _a = (setting.online_status == 1 and user.username | is_online) %}
                {%- set _b = (setting.online_status == 2 and g.user.is_authenticated and user.username | is_online) %}
                {%- if _a or _b %}
                <span class="online">{{ _('ONLINE') }} </span>
                {%- else %}
                <span class="online">{{ _('OUTLINE') }}</span>
                {% endif -%}
            </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>{{ info.word }}</p>
            <footer>Someone famous in <cite title="Source Title">{{ 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>
{%- endmacro %}
