{% extends "base.html" %}

{% block page-title %}/ {% if snipt.title %}{{ snipt.title }}{% else %}Untitled{% endif %} / {{ user.username }} - {{ block.super }}{% endblock %}
{% block html-class %}detail{% endblock %}
{% block body-class %}{% if request.path == '/api/' or request.path == '/blogging/' %}snipt-page{% else %}detail{% endif %}{% endblock %}

{% block js %}
        {{ block.super }}
        window.detail = true;
{% endblock %}

{% block breadcrumb %}
    <li><a href="/{{ user.username }}/">{{ user.username }}</a></li>
    <li><span class="prompt">/</span> <a href="{{ snipt.get_absolute_url }}">{{ snipt.title }}</a></li>
{% endblock %}

{% block aside %}
    {% if request.path == '/api/' or request.path == '/blogging/' %}
        {{ block.super }}
    {% endif %}
{% endblock %}
{% block aside-inner %}
    {% if request.path == '/api/' %}
        {% if request.user.is_authenticated %}
            <aside class="api-info api-creds">
                <div class="api-inner">
                    <h5>Your API credentials:</h5>
                    <ul>
                        <li>Username: <strong>{{ request.user.username }}</strong></li>
                        <li>User ID: <strong>{{ request.user.id }}</strong></li>
                        <li>API Key: <br /><input type="text" value="{{ request.user.api_key.key }}" /></li>
                    </ul>
                </div>
            </aside>
        {% endif %}
        <aside class="api-info immediate-help">
            <div class="api-inner">
                <h5>Need immediate help?</h5>
                <p>Ping &ldquo;nicksergeant&rdquo; in <strong>#snipt</strong> on irc.freenode.net.</p>
            </div>
        </aside>
    {% endif %}
{% endblock %}

{% block content %}
    {% if not request.user.profile.is_pro %}
        <div class="sifter group">
            <a class="sifter-logo" href="https://sifterapp.com/from/snipt" title="Sifter: Simple issue tracking for big projects and small teams.">
                <img src="{{ STATIC_URL }}images/sifter-black-white.png" alt="Sifter: Simple issue tracking for big projects and small teams." />
            </a>
            <div class="right">
                <h3>Building things is hard.</h3>
                <p>
                    Issue tracking shouldn't be. <a href="https://sifterapp.com/from/snipt" title="Sifter: Simple issue tracking for big projects and small teams.">Sifter</a> makes it simple.
                </p>
            </div>
        </div>
    {% endif %}
    <section class="snipts" id="snipts">
        {% if not request.user.profile.is_pro %}
            {% include 'go-pro.html' %}
        {% endif %}
        {% with 'true' as detail %}
            {% include "snipts/snipt-list.html" %}
        {% endwith %}
        <div id="disqus_thread">
            {% if snipt.public %}
                <script type="text/javascript">
                    var disqus_shortname = 'snipt-net';
                    {% if debug %}
                        var disqus_developer = 1;
                    {% endif %}
                    var disqus_url = '{{ snipt.get_full_absolute_url }}';
                    var disqus_title = '{{ snipt.title }}';
                    var disqus_identifier = {{ snipt.id }};

                    (function() {
                        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                        dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
                        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
                    })();
                </script>
            {% else %}
                <p class="alert alert-info">
                    <strong>Disqus comments have been disabled on private snipts.</strong><br /><br />
                    See <a href="https://github.com/nicksergeant/snipt/issues/53">https://github.com/nicksergeant/snipt/issues/53</a> if you would like more information on this decision.
                </p>
            {% endif %}
        </div>
    </section>
{% endblock %}
