{% extends "layout.html" %}
{% set title = "OD-Database - Submit website" %}
{% set current_page = "submit" %}

{% block body %}
    <div class="container">
        <div class="card">
            <div class="card-header">
                <ul class="nav nav-tabs card-header-tabs" id="myTab" role="tablist">
                    <li class="nav-item">
                        <a class="nav-link active" id="normal-tab" data-toggle="tab" href="#normal" role="tab"
                           aria-controls="normal" aria-selected="true">Single website</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" id="bulk-tab" data-toggle="tab" href="#bulk" role="tab" aria-controls="bulk"
                           aria-selected="false">Bulk</a>
                    </li>
                </ul>
            </div>
            <div class="card-body">

                <div class="tab-content" id="myTabContent">
                    <div class="tab-pane fade show active" id="normal" role="tabpanel" aria-labelledby="normal-tab">
                        {# Single website #}
                        <form action="/enqueue" method="POST">
                            <div class="form-group">
                                <input class="form-control" name="url" id="url" placeholder="URL">
                            </div>
                            {% if show_captcha %}
                                <div class="form-row">
                                    {{ captcha.get_code()|safe }}
                                </div>
                            {% endif %}
                            <input class="btn btn-primary" type="submit" value="Submit" title="Submit open directory">
                        </form>

                    </div>
                    <div class="tab-pane fade" id="bulk" role="tabpanel" aria-labelledby="bulk-tab">
                        {# Bulk #}
                        <form action="/enqueue_bulk" method="POST">
                            <div class="form-group">
                                <textarea class="form-control" name="urls" id="urls" rows="10"
                                          placeholder="One URL per line, max. 10"></textarea>
                            </div>
                            {% if show_captcha %}
                                <div class="form-row">
                                    {{ captcha.get_code()|safe }}
                                </div>
                            {% endif %}

                            <input class="btn btn-primary" type="submit" value="Submit"
                                   title="Submit open directories">
                        </form>
                    </div>
                </div>


                <hr>

                <p class="text-muted">By submitting this form you agree that your IP address and User Agent will be
                    saved (for debugging purposes only).
                </p>
            </div>
        </div>


        <div class="card">
            <div class="card-header">Queued websites</div>
            <div class="card-body">

                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>Url</th>
                        <th>Priority</th>
                        <th>Task type</th>
                    </tr>
                    </thead>

                    <tbody>
                    {% for task in queue %}
                        <tr>
                            <td title="{{ task.url }}">{{ task.url | truncate(70) }}</td>
                            <td>{{ task.priority }}</td>
                            <td>{{ task.callback_type if task.callback_type else "NORMAL" }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>

                </table>

            </div>
        </div>
    </div>
{% endblock body %}
