{% extends 'emma/base.html' %}

{% block section_main %}
    {% if messages %}
        {% for msg in messages %}
            <div class="row">
                <div class="four columns">
                    <div class="alert-box success">
                        {{ msg }}
                        <a href class="close">×</a>
                    </div>
                </div>
            </div>
        {% endfor %}
    {% endif %}
    <div class="row">
    <section class="four columns">
        <div class="panel">
            <h2>Tasks</h2>
            <a href="{{ get_url('build') }}" class="nice large radius blue button">Build</a>
            <br/><br/>
            <a href="{{ get_url('clean') }}" class="nice large radius white button">Clean and Build</a>
            <br/><br/>
            <a href="{{ get_url('reload_settings') }}" class="nice large radius green button">Reload Settings</a>
            <br/><br/>
            <a href="{{ get_url('disable') }}" class="nice large radius red button">Disable Emma</a>
            <br/><br/>
        </div>
    </section>
    <section class="four columns">
        <div class="panel">
            <h2>Log</h2>
            {% if stats %}
                <div><span class="black radius label">Last Build:</span>
                    {{ stats['time_run']|naturaltime }}
                </div>
                <div>
                    <span class="green radius label">{{ stats['counts']['new_posts'] }}</span> New/Modified Posts
                </div>
                <hr/>
                <h4>File Activity</h4>
                <div>
                    <span class="green radius label">{{ len(stats['files']['new']) }} new</span>
                </div>
                <div>
                    <span class="blue radius label">{{ len(stats['files']['overwritten']) }} modified</span>
                </div>
                <div>
                    <span class="red radius label">{{ len(stats['files']['deleted']) }} deleted</span>
                </div>
                </div>
            {% else %}
                <div>
                    No log information available.
                </div>
            {% endif %}
    </section>
    <section class="four columns">
        <div class="panel">
            <h2>Site Stats</h2>
            {% if stats %}
                <hr/>
                <div>
                    <span class="black radius label">
                        {{ stats['counts']['new_posts'] + stats['counts']['cached_posts'] }}</span> Posts
                </div>
                <div>
                    <span class="black radius label">{{ stats['counts']['rollups'] }}</span> Rollup Pages
                </div>
                <div>
                    <span class="black radius label">{{ stats['counts']['template_pages'] }}</span> Template Pages
                </div>
                <div>
                    <span class="black radius label">{{ stats['counts']['tag_pages'] }}</span> Tags
                </div>
            {% else %}
                <div>
                    No site stats available.
                </div>
            {% endif %}
        </div>
    </section>
    <div class="row">
        <section class="twelve columns">
            <div class="panel">
                <h2>Configuration Details</h2>

                <div>SETTINGS_FILE: <span class="white radius label">{{ settings.SETTINGS_FILE }}</span></div>
                <div>SETTINGS_FILE_LOAD_TIME: <span class="white radius label">
                    {{ settings.SETTINGS_FILE_LOAD_TIME|naturaltime }}</span>
                </div>
                <div>SITE_URL: <span class="white radius label">{{ settings.SITE_URL }}</span></div>
                <div>POST_DIR: <span class="white radius label">{{ settings.POST_DIR }}</span></div>
                <div>TEMPLATE_DIR: <span class="white radius label">{{ settings.TEMPLATE_DIR }}</span></div>
                <div>OUTPUT_DIR: <span class="white radius label">{{ settings.OUTPUT_DIR }}</span></div>
            </div>
        </section>
    </div>
{% endblock %}
