{% extends "base.html" %}

{% block content %}
<div class="ui text container">
    <form class="ui form" action="" method="post" novalidate>
        {{ form.hidden_tag() }}
        <p>
            {{ form.channelId.label }}<br>
            {{ form.channelId(size=32) }}<br>
            {% for error in form.channelId.errors %}
            <span style="color: red;">[{{ error }}]</span>
            {% endfor %}
        </p>
        <p>{{ form.submit() }}</p>
    </form>

    {% if channels %}
    <h3 class="ui dividing header">Users</h3>
            <div class="ui relaxed divided list">

                    {% for res in channels %}
                    <div class="item">
                        {% if restricted or current_user.is_authenticated %}
                        <div class="right floated content">
                            {% if not current_user.is_following_yt(res.channelId) %}
                                <p>
                                    <form action="{{ url_for('ytfollow', channelId=res.channelId) }}" method="post">
                                        {{ btform.hidden_tag() }}
                                        {{ btform.submit(value='Follow') }}
                                    </form>
                                </p>
                            {% else %}
                                <p>
                                    <form action="{{ url_for('ytunfollow', channelId=res.channelId) }}" method="post">
                                        {{ btform.hidden_tag() }}
                                        {{ btform.submit(value='Unfollow') }}
                                    </form>
                                </p>
                            {% endif %}
                        </div>
                        {% endif %}
                        <img alt="Avatar" class="ui avatar image" src="{{ res.thumbnail }}">
                        <div class="content">
                            <a class = "header" href="{{ url_for('channel', id=res.channelId)}}">{{res.username}}</a>
                            <div class="description"><div class="ui label">
                                <i class="user icon"></i> {{res.subCount}}
                            </div></div>
                        </div>
                    </div>
                    {% endfor %}
                </div>
            {% endif %}


            <div class="ui middle aligned divided list">
                {% if videos %}
                <h3 class="ui dividing header">Videos</h3>
                    <div class="ui centered cards">
                        {% for video in videos %}
                            {% include '_video_item.html' %}
                        {% endfor %}
                    </div>
                {% endif %}
            </div>
</div>

{% endblock %}