{% extends 'manage/general/master.twig' %}
{% from 'macros.twig' import container_title %}

{% block manage_content %}
    <div class="container manage-settings">
        {{ container_title('<i class="fab fa-twitter fa-fw"></i> Twitter Connection') }}

        <div class="manage__description">
            Manages the Twitter connection for announcing news posts on the Twitter account.
        </div>

        {% if twitter_has_oauth2 %}
            {% if twitter_has_access %}
                <div style="padding: 2px 5px">
                    A Twitter user has been authenticated.
                    Current access token expires <time datetime="{{ twitter_expires|date('c') }}" title="{{ twitter_expires|date('r') }}">{{ twitter_expires|time_diff }}</time>.
                </div>
                <div class="manage__emote__actions">
                    {% if twitter_has_refresh %}
                        <a class="input__button" href="?m=refresh&amp;csrf={{ csrf_token() }}">Refresh Access</a>
                    {% endif %}
                    <a class="input__button" href="?m=revoke&amp;csrf={{ csrf_token() }}">Revoke Access</a>
                </div>
            {% else %}
                <div style="padding: 2px 5px">
                    No Twitter user has been authorised yet.
                    Before beginning authorization, make sure you're logged into Twitter with the desired user.
                </div>
                <div class="manage__emote__actions">
                    <a class="input__button" href="?m=authorise&amp;csrf={{ csrf_token() }}">Begin Authorisation</a>
                </div>
            {% endif %}
        {% else %}
            <div style="padding: 2px 5px">
                Twitter OAuth2 credentials have not been registered.
                Add them through <a href="{{ url('manage-general-settings') }}" class="link">Settings</a> as <a href="{{ url('manage-general-setting', {'name': 'twitter.oauth2.clientId', 'type': 'string'}) }}" class="link"><code>twitter.oauth2.clientId</code></a> and  <a href="{{ url('manage-general-setting', {'name': 'twitter.oauth2.clientSecret', 'type': 'string'}) }}" class="link"><code>twitter.oauth2.clientSecret</code></a>.
            </div>
        {% endif %}
    </div>
{% endblock %}
