{%- extends 'posts.html' %}
{%- block disqus_header %}
{%- if is_post(current_path) and config.DISQUS %}
<script type="text/javascript">
    var disqus_shortname = "{{ config.DISQUS }}";
    var disqus_url = "{{ request.url }}";
    {%- if config.DISQUS_DEVELOPER %}
    var disqus_developer = 1;
    {%- endif %}
</script> 
{%- endif %}
{%- endblock %}

{%- block disqus_post %}
{%- if is_post(current_path) and config.DISQUS %}
<div id="disqus_thread"></div>
<script type="text/javascript">
    (function() {
        var dsq = document.createElement('script');
        dsq.type = 'text/javascript';
        dsq.async = true;
        dsq.src = 'http://{{ config.DISQUS }}.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
</script>
<noscript>
    Please enable JavaScript to view the
    <a href="http://disqus.com/?ref_noscript={{ config.DISQUS }}">
        comments powered by Disqus.
    </a>
</noscript>
<a href="http://disqus.com" class="dsq-brlink">
    blog comments powered by <span class="logo-disqus">Disqus</span>
</a>
{%- endif %}
{%- endblock %}

{%- block disqus_footer %}
{%- if config.DISQUS %}
<script type="text/javascript">
    //<![CDATA[
    (function() {
        var links = document.getElementsByTagName('a');
        var query = '?';
        for(var i = 0; i < links.length; i++) {
            if(links[i].href.indexOf('#disqus_thread') >= 0) {
                query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
            }
        }
        document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/{{ config.DISQUS }}/get_num_replies.js' + query + '"></' + 'script>');
    })();
    //]]>
</script>
{%- endif %}
{%- endblock %}

{%- block pagination %}
{%- if pagination %}
<div class="pagination">
    {%- if pagination.current != 1 %}
    <a href="{{ url_for('views.home', page=1) }}">&lt;&lt;</a>
    {%- else %}
    &lt;&lt;
    {%- endif %} |
    {%- if pagination.current > 1 %}
    <a href="{{ url_for('views.home', page=pagination.current-1) }}">&lt;</a>
    {%- else %}
    &lt;
    {%- endif %} |
    {%- for i in range(1, pagination.num_pages + 1) %}
    {%- if pagination.current != i %}
    <a href="{{ url_for('views.home', page=i) }}">
        {{ i }}
    </a> |
    {%- else %}
    {{ i }} |
    {%- endif %}
    {%- endfor %}
    {%- if pagination.current < pagination.num_pages %}
    <a href="{{ url_for('views.home', page=pagination.current+1) }}">&gt;</a>
    {%- else %}
    &gt;
    {%- endif %} |
    {%- if pagination.current != pagination.num_pages %}
    <a href="{{ url_for('views.home', page=pagination.num_pages) }}">&gt;&gt;</a>
    {%- else %}
    &gt;&gt;
    {%- endif %}
</div>
{%- endif %}
{%- endblock %}
