{% set modified = False -%}

{%- if articles %}
    {# if we have nothing else, set the copyright date to what we use on the index #}
    {% set copy_date = articles[0].date.strftime('%Y') %}
{% else %}
    {% set copy_date = INDEX_COPY_DATE %}
{% endif -%}

{% if article %}
    {% if article.date %}
        {% set copy_date = article.date.strftime('%Y') %}
    {% endif %}
    {% if article.copy_date %}
        {% set copy_date = article.copy_date %}
    {% endif %}
    {% if article.modified %}
        {% set modified = article.modified.strftime('%B %d, %Y').replace(' 0',' ') %}
    {% endif %}
{% endif -%}

{% if page %}
    {% if page.date %}
        {% set copy_date = page.date.strftime('%Y') %}
    {% endif %}
    {% if page.copy_date %}
        {% set copy_date = page.copy_date %}
    {% endif %}
    {% if page.modified %}
        {% set modified = page.modified.strftime('%B %d, %Y').replace(' 0',' ') %}
    {% endif %}
{% endif -%}

{% if ADAM %}
    {% if copy_date == '' %}
        {% set copy_date = ADAM_COPY_DATE %}
    {% endif %}
    {% set modified = ADAM_UPDATED %}
{% endif -%}

{% if page_name == 'index' %}
    {% if INDEX_COPY_DATE %}
        {% set copy_date = INDEX_COPY_DATE %}
    {% endif %}
{% endif %}

<footer>
    <div class="container">
        <hr>
        <div class="row">
            <div class="col-sm-10 col-xs-8">
                &copy; {{ copy_date }} {{ AUTHOR }}
                {% if modified %}
                    {# 'bull' looks better than middot' in the Cabin font #}
                    {# &middot; #}
                    &bull;
                    Last Updated {{ modified }}
                {% endif %}
                {% if ADAM_VERSION %}
                    &bull;
                    <a href="{{ ADAM_LINK }}">{{ ADAM_VERSION }}</a>
                {% endif %}
                {%- if CC_LICENSE or CC_LICENSE_DERIVATIVES or CC_LICENSE_COMMERCIAL %}
                    &bull;
                    {% from 'includes/cc-license.html' import cc_license_mark %}
                    <p><small>{{ cc_license_mark(cc_name=CC_LICENSE,derivatives=CC_LICENSE_DERIVATIVES,commercial=CC_LICENSE_COMMERCIAL,attr_markup=CC_ATTR_MARKUP,attr_props={'title':SITENAME,'name':article.author if article else AUTHOR,'url':SITEURL}) }}</small></p>
                {% endif %}
                {% if FEED_ALL_ATOM %}
                    &bull;
                    <a href="{{ SITEURL }}/{{ FEED_ALL_ATOM }}" type="application/atom+xml" rel="alternate" title="{{ SITENAME }} ATOM Feed"><i class="fa fa-rss-square" aria-hidden="true"></i> Atom Feed</a> (all posts)
                {% endif %}
            </div>
            <div class="col-sm-2 col-xs-4"><p class="pull-right"><span class="fa fa-arrow-up"></span> <a href="#">Back to top</a></p></div>
        </div>
    </div>
</footer>
