{% extends 'base.html' %}

{% block title %}
{{ article.title|striptags }} {%if article.subtitle %} - {{ article.subtitle }} {% endif %} · {{ super() }}
{% endblock title %}

{% block head_description %}
{% if article.summary %}
{{ article.summary|striptags }}
{% endif %}
{% endblock head_description %}

{% block meta_tags_in_head %}
{% if article.tags or article.category or article.keywords %}
<meta name="keywords" content="{{ [article.tags|join(', '), article.category, article.keywords]|join(', ') }}" />
{% endif %}
{% endblock meta_tags_in_head %}

{% block content %}
<article>
<div class="row-fluid">
    <header class="page-header span10 offset2">
    <h1><a href="{{ SITEURL }}/{{ article.url }}"> {{ article.title }} {%if article.subtitle %} <small> {{ article.subtitle }} </small> {% endif %} </a></h1>
    </header>
</div>

<div class="row-fluid">
    {% if article.toc %}
    <div class="span2 table-of-content">
        <nav>
        <h4>Contents</h4>
        {{ article.toc }}
        </nav>
    </div>
    <div class="span8 article-content">
       {% else %}
        <div class="span8 offset2 article-content">
            {% endif %}

            {% import '_includes/translations.html' as translations with context %}
            {{ translations.translations_for(article) }}
            {{ article.content }}
            {% from '_includes/share_links.html' import share_links with context %}
            {{ share_links(article) }}
            {% from '_includes/comments.html' import comments with context %}
            {{ comments(article) }}
            <hr/>
            {% include '_includes/related_posts.html' with context %}
            {% if article.prev_article or article.next_article %}
            <aside>
            <nav>
            <ul class="articles-timeline">
                {% if article.prev_article %}
                    {% set ptitle = article.prev_article.title|striptags %}
                    {% set pv_title = ptitle %}
                    {%if article.prev_article.subtitle %}
                        {% set pv_title = ptitle + ' ' +  '<small>' + article.prev_article.subtitle + '</small>' %}
                        {% set ptitle = ptitle + ' - ' + article.prev_article.subtitle %}
                    {% endif %}
                <li class="previous-article">« <a href="{{ SITEURL }}/{{ article.prev_article.url }}" title="Previous: {{ ptitle }}">{{ pv_title }}</a></li>
                {% endif %}
                {% if article.next_article %}
                    {% set ntitle = article.next_article.title|striptags %}
                    {% set nv_title = ntitle %}
                    {%if article.next_article.subtitle %}
                        {% set nv_title = ntitle + ' ' +  '<small>' + article.next_article.subtitle + '</small>' %}
                        {% set ntitle = ntitle + ' - ' + article.next_article.subtitle %}
                    {% endif %}
                <li class="next-article"><a href="{{ SITEURL }}/{{ article.next_article.url }}" title="Next: {{ ntitle }}">{{ nv_title }}</a> »</li>
                {% endif %}
            </ul>
            </nav>
            </aside>
            {% endif %}
        </div>
        <section>
        <div class="span2" style="float:right;font-size:0.9em;">
            {% if article.date %}
            <h4>Published</h4>
            {% set day = article.date.strftime('%d')|int %}
            <time pubdate="pubdate" datetime="{{ article.date.isoformat() }}">{{ article.date.strftime('%b') }} {{ day }} {{- article.date.strftime(', %Y') }}</time>
            {% endif %}
            {% include '_includes/last_updated.html' %}
            {% if article.category|trim|count > 0 %}
            <h4>Category</h4>
            <a class="category-link" href="{{ SITEURL }}/categories.html#{{ category.slug }}-ref">{{ article.category }}</a>
            {% endif %}
            {% if article.tags and article.tags[0]|trim|count > 0 %}
            <h4>Tags</h4>
            <ul class="list-of-tags tags-in-article">
                {% for tag in article.tags|sort %}
                <li><a href="{{ SITEURL }}/tags.html#{{ tag.slug }}-ref">{{ tag }}
                    {% for aTag, tagged_articles in tags if aTag == tag %}
                    <span>{{ tagged_articles|count }}</span>
                    {% endfor %}</a></li>
                {% endfor %}
            </ul>
            {% endif %}
            {% include '_includes/social_links.html' %}
            {% include '_includes/mailchimp.html' %}
        </div>
        </section>
</div>
</article>
{% endblock content %}

{% block script %}
    {{ super() }}
    {% from '_includes/comments.html' import comments_script with context %}
    {{ comments_script(article) }}
{% endblock script %}