{% set gpm = admin.gpm() %}
{% set installed = gpm.isThemeInstalled(admin.route) %}

<div class="grav-update theme" data-gpm-theme="{{ admin.route }}">
    {% if installed and gpm.isThemeUpdatable(admin.route) %}
    {% set remote = gpm.getRepositoryTheme(admin.route) %}
        <p>
            <i class="fa fa-bullhorn"></i>
            <strong>v{{ remote.available }}</strong> {{ "PLUGIN_ADMIN.OF_THIS_THEME_IS_NOW_AVAILABLE"|tu }}!
            <button class="button button-small secondary" data-download="{{ remote.zipball_url }}">{{ "PLUGIN_ADMIN.UPDATE_THEME"|tu }}</button>
        </p>
    {% endif %}
</div>

<h1>
    {{ theme.name|e }}
    {% if admin.isTeamGrav(theme) %}
        <small><span class="info-reverse"><i class="fa fa-check-circle" title="Grav Official Theme"></i></span></small>
    {% endif %}
    {% if theme.symlink %}
    <small class="hint--bottom"  data-hint="{{ "PLUGIN_ADMIN.THEME_SYMBOLICALLY_LINKED"|tu }}">
        <i class="fa fa-fw fa-link"></i>
    </small>
    {% endif %}
    <small>{{ theme.version ? 'v' ~ theme.version|e }}</small>
</h1>
<div class="gpm-item-info">
    <i class="gpm-item-icon fa fa-fw fa-{{  theme.icon }}"></i>
    <table>
        {% if theme.version %}
        <tr>
            <td>{{ "PLUGIN_ADMIN.VERSION"|tu }}:</td>
            <td>{{ theme.version }}</td>
        </tr>
        {% endif %}
        {% if theme.author %}
            <tr>
                <td>{{ "PLUGIN_ADMIN.AUTHOR"|tu }}:</td>
                <td>
                    {% if theme.author.url %}
                        <a href="{{ theme.author.url }}" target="_blank">{{ theme.author.name }}</a>
                    {% else %}
                        {{ theme.author.name }}
                    {% endif %}
                    {% if theme.author.email %}
                         - <a href="mailto:{{ theme.author.email }}">{{ theme.author.email }}</a>
                    {% endif %}
                </td>
            </tr>
        {% endif %}
        {% if theme.homepage %}
        <tr>
            <td>{{ "PLUGIN_ADMIN.HOMEPAGE"|tu }}:</td>
            <td><a href="{{ theme.homepage }}" target="_blank">{{ theme.homepage }}</a></td>
        </tr>
        {% endif %}
        {% if theme.demo %}
        <tr>
            <td>{{ "PLUGIN_ADMIN.DEMO"|tu }}:</td>
            <td><a href="{{ theme.demo }}" target="_blank">{{ theme.demo }}</a></td>
        </tr>
        {% endif %}
        {% if theme.bugs %}
            <tr>
                <td>{{ "PLUGIN_ADMIN.BUG_TRACKER"|tu }}:</td>
                <td><a href="{{ theme.bugs }}" target="_blank">{{ theme.bugs }}</a></td>
            </tr>
        {% endif %}
        {% if theme.keywords %}
            <tr>
                <td>{{ "PLUGIN_ADMIN.KEYWORDS"|tu }}:</td>
                <td>{{ theme.keywords }}</td>
            </tr>
        {% endif %}
        {% if theme.license %}
            <tr>
                <td>{{ "PLUGIN_ADMIN.LICENSE"|tu }}:</td>
                <td>{{ theme.license }}</td>
            </tr>
        {% endif %}
        {% if theme.description %}
            <tr>
                <td>{{ "PLUGIN_ADMIN.DESCRIPTION"|tu }}:</td>
                <td>{{ theme.description_html }}</td>
            </tr>
        {% endif %}

        {% if theme.readme or theme.homepage %}
            {% set readme_link = theme.readme ?: theme.homepage ~ '/blob/develop/README.md' %}
            <tr>
                <td>{{ "PLUGIN_ADMIN.README"|tu }}:</td>
                <td><a href="{{ readme_link }}" target="_blank">{{ readme_link }}</a></td>
            </tr>
        {% endif %}
    </table>
</div>

{% if (installed) %}
    {% set data = admin.data('themes/' ~ admin.route) %}
    {% include 'partials/blueprints.html.twig' with { data: data, blueprints: data.blueprints } %}

    {% if (config.get('system.pages.theme') != admin.route) %}
    <div class="button-bar danger">
        <span class="danger-zone"></span>
        <a class="button" href="{{ base_url_relative }}/themes/{{ theme.slug }}/task{{ config.system.param_sep }}uninstall"><i class="fa fa-fw fa-warning"></i>{{ "PLUGIN_ADMIN.REMOVE_THEME"|tu }}</a>
    </div>
    {% endif %}
{% else %}
    <div class="button-bar success">
        <a class="button" href="{{ base_url_relative }}/themes/{{ theme.slug }}/task{{ config.system.param_sep }}install"><i class="fa fa-fw fa-plus"></i>{{ "PLUGIN_ADMIN.INSTALL_THEME"|tu }}</a>
    </div>
{% endif %}




