{% load spirit_tags i18n %}

<div class="profile__img">
  {% if p_user.st.avatar %}
    <img
      class="profile__img__avatar"
      alt=""
      src="{{ p_user.st.avatar.url }}"/>
  {% else %}
    <div
      class="profile__img__avatar no-pic"
      style="background-color:{% get_avatar_color p_user.pk %};"
    >{{ p_user.st.nickname.0.upper }}</div>
  {% endif %}
  <div class="profile__img__username">{{ p_user.st.nickname }}</div>
</div>

<div class="profile__info">
  {% spaceless %}
    <ul>
      <li>
        <div class="profile__info__title">{% trans "Joined at" %}</div>
        <div class="profile__info__date">{{ p_user.date_joined|shortnaturaltime }}</div>
      </li>
      <li>
        <div class="profile__info__title">{% trans "Seen" %}</div>
        <div class="profile__info__date">{{ p_user.st.last_seen|shortnaturaltime }}</div>
      </li>
      {% if user.st.is_administrator %}
        <li>
          <div class="profile__info__title">{% trans "Last IP" %}</div>
          <div class="profile__info__date">{{ p_user.st.last_ip }}</div>
        </li>
      {% endif %}
    </ul>
  {% endspaceless %}
</div>

{% if user.username == p_user.username %}
  <div class="profile__profile_preferences">
    <a
      class="button"
      href="{% url "spirit:user:update" %}"
    ><i class="fa fa-cog"></i> {% trans "Preferences" %}</a>
  </div>
  {% else %}
  <div class="profile__private_message">
    <a
      class="button"
      href="{% url "spirit:topic:private:publish" user_id=p_user.pk %}"
    ><i class="fa fa-envelope"></i> {% trans "Private Message" %}</a>
  </div>
{% endif %}

{% if user.st.is_administrator %}
  <div class="profile__profile_preferences">
    <a
      class="button"
      href="{% url "spirit:admin:user:edit" user_id=p_user.pk %}"
    ><i class="fa fa-cog"></i> {% trans "Edit user" %}</a>
  </div>
{% endif %}

{% spaceless %}
  <ul class="nav__tabs">
    <li><a
      class="nav__tabs__link{% if active_tab == 0 %} is-selected{% endif %}"
      href="{% url "spirit:user:detail" pk=p_user.pk slug=p_user.st.slug %}"
    >{% trans "Comments" %}</a></li>
    <li><a
      class="nav__tabs__link{% if active_tab == 1 %} is-selected{% endif %}"
      href="{% url "spirit:user:topics" pk=p_user.pk slug=p_user.st.slug %}"
    >{% trans "Topics" %}</a></li>
    <li><a
      class="nav__tabs__link{% if active_tab == 2 %} is-selected{% endif %}"
      href="{% url "spirit:user:likes" pk=p_user.pk slug=p_user.st.slug %}"
    >{% trans "Likes" %}</a>
    </li>
  </ul>
{% endspaceless %}
