{% extends "base.html" %}

{% block content %}
<section class="col1 row w4 h4 well">
&nbsp;
</section>
<section class="col1 row1 w4 h1">
    <h2>Find people you know</h2>
    <p>Sharing your content allows your friends to see everything you posted as <strong>{{ active_persona.username }}</strong>.</p>
</section>

<section class="col1 row3 w4 h2">
<form method="POST" action="{{url_for('find_people')}}">
    <div class="control-group {% if form.email.errors %}error{% endif %}">
        <div class="input-prepend input-append controls">
            <span class="add-on"><i class="fa fa-envelope"></i></span>
            {{form.email(placeholder="Email")}}
            <button class="btn" type="submit">Find</button>
        </div>
        {% if error %}
        <p class="errors">{{ error }}</p>
        {% endif %}
        {% if form.email.errors %}
        <ul class="errors">{% for error in form.email.errors %}<li>{{ error }}</li>{% endfor %}</ul>
        {% endif %}
    </div>

    {{ form.csrf_token }}
</form>
</section>

{% if found %}
<section class="col6 row1 w5 h2">
    <table class="table table-hover">
        <thead>
            <tr><th colspan="2">Found {{found|length}} Personas</th></tr>
        </thead>
        <tbody>
            {% for p in found %}
            <tr>
                <td><a href="{{ url_for('persona', id=p.id) }}" class="btn btn-link">
                    <i class="fa fa-circle"></i>
                    {{p.username}} <{{p.id|truncate(6, True, end="")}}>
                </a></td>
                <td>
                    <form action="{{ url_for('add_contact', persona_id=p.id)}}" method="POST">
                        <button class="btn btn-small" type="submit" {% if p.outgoing %}disabled=disabled{% endif %}>{% if p.outgoing %}Already sharing{% else %}Share my profile{% endif %}</button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</section>
{% endif %}
{% endblock %}
