{%- extends "!footer.html" %}

{% if page_source_suffix %}
{% set suffix = page_source_suffix %}
{% else %}
{% set suffix = source_suffix %}
{% endif %}

{% if meta is defined and meta is not none %}
{% set check_meta = True %}
{% else %}
{% set check_meta = False %}
{% endif %}

{% if check_meta and 'github_url' in meta %}
{% set display_github = True %}
{% endif %}

{% set display_vcs_links = display_vcs_links if display_vcs_links is defined else True %}

{% block extrafooter %}
    <p class="float-right">
        {% if hasdoc(pagename) and display_vcs_links %}
            {% if display_github %}
                {% if check_meta and 'github_url' in meta %}
                  <!-- User defined GitHub URL -->
                  <a href="{{ meta['github_url'] }}" class="fa fa-github">
                      {{ _('Edit on GitHub') }}{{ reldelim2 }}
                  </a>
                {% else %}
                  <a href="https://{{ github_host|default('github.com') }}/{{ github_user }}/{{ github_repo }}/{{ theme_vcs_pageview_mode|default('blob') }}/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ suffix }}" class="fa fa-github">
                      {{ _('Edit on GitHub') }}{{ reldelim2 }}
                  </a>
                {% endif %}
            {% elif show_source and source_url_prefix %}
                <a href="{{ source_url_prefix }}{{ pagename }}{{ suffix }}">
                    {{ _('Page Source') }}{{ reldelim2 }}
                </a>
            {% elif show_source and has_source and sourcename %}
                <a href="{{ pathto('_sources/' + sourcename, true)|e }}" rel="nofollow">
                    {{ _('Page Source') }}{{ reldelim2 }}
                </a>
            {% endif %}
        {% endif %}
        <a href="#">Back to Top</a>
    </p>
{% endblock %}
