{% extends "profile.html" %}
{% block title %}
<title>{{user.canonical_name}}</title>
{% endblock %}

{% block profile %}
<div class="row">
  <div class="col-md-4 profile">
    {% if profile.avatar %}
    <img
      src="{{profile.avatar}}"
      alt="{{user.username}}'s avatar"
      class="avatar"
    />
    {% endif %}

    {% if profile.location %}
    <p>{{profile.location}}</p>
    {% endif %}
    {% if profile.url %}
    <p>
      <a
        href="{{profile.url}}"
        target="_blank"
        rel="me noopener noreferrer nofollow"
      >{{profile.url}}</a>
    </p>
    {% endif %}
    {% if current_user and user.id == current_user.id %}
    <a
      class="btn btn-primary btn-block"
      href="{{url_for("projects.create_GET")}}"
    >Create a new project {{icon("caret-right")}}</a>
    <a
      class="btn btn-white btn-sm btn-block"
      href="{{get_origin("meta.sr.ht", external=True)}}/profile"
    >Edit your profile {{icon("caret-right")}}</a>
    {% endif %}
  </div>

  <div class="col-md-8">
    {% if profile.bio %}
    <blockquote>{{profile.bio | md}}</blockquote>
    {% endif %}

    {% if projects %}
    <div class="event-list">
      {% for project in projects %}
      <div class="event">
        <h4>
          {% if project.visibility.value != 'PUBLIC' %}
          <small class="text-muted pull-right">{{project.visibility.value.lower()}}</small>
          {% endif %}
          <a href="{{url_for("projects.summary_GET",
            owner=project.owner.canonical_name,
            project_name=project.name)}}">{{project.name}}</a>
        </h4>
        <p>{{project.description}}</p>
        {% if project.tags %}
        <div class="tags">
        {% for tag in project.tags %}
          <a href="{{url_for("public.project_index",
                search=((search or "").strip() + " #"+tag).lstrip())}}"
             class="tag" rel="nofollow">#{{tag}}</a>
        {% endfor %}
        </div>
        {% endif %}
      </div>
      {% endfor %}

      {% if total_results > 5 %}
      <div class="row">
        <div class="col-md-5 offset-md-7 text-right">
          <a
            class="btn btn-default"
            href="{{url_for(".projects_GET", owner=user.username)}}"
          >
            More projects {{icon('caret-right')}}
          </a>
        </div>
      </div>
      {% endif %}
    </div>
    {% else %}
    <div class="alert alert-info">
      This user does not have any projects.
    </div>
    {% endif %}
  </div>
</div>
{% endblock %}
