{% extends 'admin/master.html' %}

<!-- container -->
{% block body %}

    <div class="row">
        <div class="col-md-12">
            {%if config.get('ADMIN_HEADER') %}
                {{config.get('ADMIN_HEADER')|safe}}
            {% endif %}
        </div>
    </div>


    <div class="row">
        <div class="col-md-12">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-cog"></span> Actions</h3>
                </div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-md-12">
                            {% for endpoint, icon, text in config.get('ADMIN_ICONS', [])%}
                            <a href="{{ url_for(endpoint) }}" class="btn btn-lg" role="button"><span class="glyphicon {{icon}} glyphsize"></span> <br/>{{_gettext(text)|safe}}</a>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <div class="row">
        <div class="col-md-12">

            <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><span class="glyphicon glyphicon-th-list"></span> Latest content</h3>
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover table-condensed">
                                <thead>
                                    <tr>
                                        <th>Title</th>
                                        <th>Category</th>
                                        <th>Authors</th>
                                        <th>Date</th>
                                        <th>Type</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% for content in contents %}
                                    <tr>
                                        <td>{{ content['title'] }}</td>
                                        <td>{{ content['category'] }}</td>
                                        <td>{{ ','.join(content['authors']) }}</td>
                                        <td>{{ content['date'] }}</td>
                                        <td>{{ content['content_type'] }}</td>
                                        <td>
                                                <i class={% if content['published'] %} "fa fa-check-circle glyphicon glyphicon-ok-circle icon-ok-circle" {% else %} "fa fa-minus-circle glyphicon glyphicon-minus-sign icon-minus-sign" {% endif %}></i>
                                                {% set edit_url = url_for('quokka.core.content.admin.{content_type}view.edit_view'.format(**content), id=content['_id']) %}
                                                <a class="btn btn-success btn-xs" href="{{ edit_url }}">
                                                <i class="fa fa-pencil glyphicon glyphicon-pencil"></i> {{_gettext('Edit')}}</a>
                                                <a class="btn btn-primary btn-xs" target="_blank" href="/{{url_for_content(content)}}">
                                                <i class="fa fa-eye glyphicon glyphicon-eye-open"></i> {{_gettext('View') if content['published'] else _gettext('Preview')}}</a>
                                        </td>
                                    <tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="panel-footer">
                        <div class="pull-left">{{config.get('ADMIN_FOOTER', {'left': 'Powered by: Quokka CMS 🐹'}).get('left')|safe}}</div>
                        <div class="pull-right">{{config.get('ADMIN_FOOTER', {'right': '<a href="http://www.quokkaproject.org" target="_blank">quokkaproject.org</a>'}).get('right')|safe}}</div>
                        <div class="clearfix"></div>
                    </div>

            </div>

        </div>

    </div>

{% endblock %}
<!-- / container -->
