{% extends "WallabagCoreBundle::layout.html.twig" %}

{% block title %}{{ entry.title|raw }} ({{ entry.domainName|removeWww }}){% endblock %}

{% block body_class %}entry{% endblock %}

{% block menu %}
    <div class="progress">
        <div class="determinate"></div>
    </div>
    <nav class="hide-on-large-only">
        <div class="nav-wrapper cyan darken-1">
            <ul>
                <li>
                    <a class="waves-effect" href="{{ path('homepage') }}">
                        <i class="mdi-action-exit-to-app"></i>
                    </a>
                </li>
            </ul>
            <ul class="right">
                <li>
                    <a class="waves-effect" title="{{ 'entry.view.left_menu.set_as_read'|trans }}" href="{{ path('archive_entry', { 'id': entry.id }) }}" id="markAsRead">
                        <i class="{% if entry.isArchived == 0 %}mdi-action-done{% else %}mdi-content-redo{% endif %} small"></i>
                    </a>
                </li>
                <li>
                    <a class="waves-effect" title="{{ 'entry.view.left_menu.set_as_favorite'|trans }}" href="{{ path('star_entry', { 'id': entry.id }) }}" id="setFav">
                        <i class="{% if entry.isStarred == 0 %}mdi-action-favorite-outline{% else %}mdi-action-favorite{% endif %} small"></i>
                    </a>
                </li>
                <li>
                    <a href="#" data-activates="slide-out" class="button-collapse right">
                        <i class="mdi-navigation-menu"></i>
                    </a>
                </li>
            </ul>
        </div>
    </nav>
    <ul id="slide-out" class="collapsible side-nav fixed reader-mode" data-collapsible="accordion">
        <li class="bold border-bottom hide-on-med-and-down">
            <a class="waves-effect collapsible-header" href="{{ path('homepage') }}">
                <i class="mdi-action-exit-to-app small"></i>
                <span>{{ 'entry.view.left_menu.back_to_homepage'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

        <li class="bold border-bottom hide-on-med-and-down">
            <a class="waves-effect collapsible-header" href="{{ entry.url|e }}">
                <i class="mdi-content-link small"></i>
                <span>{{ 'entry.view.left_menu.view_original_article'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

        <li class="bold hide-on-med-and-down">
            <a class="waves-effect collapsible-header" title="{{ 'entry.view.left_menu.re_fetch_content'|trans }}" href="{{ path('reload_entry', { 'id': entry.id }) }}" id="reload">
                <i class="mdi-action-autorenew small"></i>
                <span>{{ 'entry.view.left_menu.re_fetch_content'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

        <li class="bold hide-on-med-and-down">
            <a class="waves-effect collapsible-header" title="{{ 'entry.view.left_menu.set_as_read'|trans }}" href="{{ path('archive_entry', { 'id': entry.id }) }}" id="markAsRead">
                <i class="{% if entry.isArchived == 0 %}mdi-action-done{% else %}mdi-content-redo{% endif %} small"></i>
                <span>{% if entry.isArchived == 0 %}{{ 'entry.view.left_menu.set_as_read'|trans }}{% else %}{{ 'entry.view.left_menu.set_as_unread'|trans }}{% endif %}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

        <li class="bold hide-on-med-and-down">
            <a class="waves-effect collapsible-header" title="{{ 'entry.view.left_menu.set_as_favorite'|trans }}" href="{{ path('star_entry', { 'id': entry.id }) }}" id="setFav">
                <i class="{% if entry.isStarred == 0 %}mdi-action-favorite-outline{% else %}mdi-action-favorite{% endif %} small"></i>
                <span>{{ 'entry.view.left_menu.set_as_favorite'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>
        <li class="bold border-bottom hide-on-med-and-down">
            <a class="waves-effect collapsible-header" title="{{ 'entry.view.left_menu.delete'|trans }}" href="{{ path('delete_entry', { 'id': entry.id }) }}">
                <i class="mdi-action-delete small"></i>
                <span>{{ 'entry.view.left_menu.delete'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

        <li class="bold border-bottom hide-on-med-and-down">
            <a class="waves-effect collapsible-header" id="nav-btn-add-tag">
                <i class="mdi-action-label-outline small"></i>
                <span>{{ 'entry.view.left_menu.add_a_tag'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

        <li class="bold">
            <a class="waves-effect collapsible-header">
                <i class="mdi-social-share small"></i>
                <span>{{ 'entry.view.left_menu.share_content'|trans }}</span>
            </a>
            <div class="collapsible-body">
                <ul>
                    {% if craue_setting('share_twitter') %}
                        <li>
                            <a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="twitter">
                                <span>twitter</span>
                            </a>
                        </li>
                    {% endif %}
                    {% if craue_setting('share_shaarli') %}
                        <li>
                            <a href="{{ craue_setting('shaarli_url') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="shaarli">
                                <span>shaarli</span>
                            </a>
                        </li>
                    {% endif %}
                    {% if craue_setting('share_diaspora') %}
                        <li>
                            <a href="{{ craue_setting('diaspora_url') }}/bookmarklet?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}&notes=&v=1&noui=1&jump=doclose" target="_blank" class="tool diaspora icon-image icon-image--diaspora" title="diaspora}">
                                <span>diaspora*</span>
                            </a>
                        </li>
                    {% endif %}
                    {% if craue_setting('carrot') %}
                        <li>
                            <a href="https://secure.carrot.org/GiveAndGetBack.do?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" class="tool carrot icon-image icon-image--carrot" target="_blank" title="carrot">
                                <span>Carrot</span>
                            </a>
                        </li>
                    {% endif %}
                    {% if craue_setting('share_mail') %}
                        <li>
                            <a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{{ 'entry.view.left_menu.share_email_label'|trans }}">
                                <span>{{ 'entry.view.left_menu.share_email_label'|trans }}</span>
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </li>

        {% if craue_setting('show_printlink') %}
        <li class="bold border-bottom hide-on-med-and-down">
            <a class="waves-effect collapsible-header" title="{{ 'entry.view.left_menu.print'|trans }}" href="javascript: window.print();">
                <i class="mdi-action-print small"></i>
                <span>{{ 'entry.view.left_menu.print'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>
        {% endif %}


        <li class="bold">
            <a class="waves-effect collapsible-header">
                <i class="mdi-file-file-download small"></i>
                <span>{{ 'entry.view.left_menu.download'|trans }}</span>
            </a>
            <div class="collapsible-body">
                <ul>
                    {% if craue_setting('export_epub') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'epub' }) }}" title="Generate ePub file">EPUB</a></li>{% endif %}
                    {% if craue_setting('export_mobi') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'mobi' }) }}" title="Generate Mobi file">MOBI</a></li>{% endif %}
                    {% if craue_setting('export_pdf') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'pdf' }) }}" title="Generate PDF file">PDF</a></li>{% endif %}
                    {% if craue_setting('export_csv') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'csv' }) }}" title="Generate CSV file">CSV</a></li>{% endif %}
                    {% if craue_setting('export_json') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'json' }) }}" title="Generate JSON file">JSON</a></li>{% endif %}
                    {% if craue_setting('export_txt') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'txt' }) }}" title="Generate TXT file">TXT</a></li>{% endif %}
                    {% if craue_setting('export_xml') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'xml' }) }}" title="Generate XML file">XML</a></li>{% endif %}
                </ul>
            </div>
        </li>

        <li class="bold hide-on-large-only">
            <a class="waves-effect collapsible-header" title="{{ 'entry.view.left_menu.delete'|trans }}" href="{{ path('delete_entry', { 'id': entry.id }) }}">
                <i class="mdi-action-delete small"></i>
                <span>{{ 'entry.view.left_menu.delete'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

        <li class="bold">
            <a class="waves-effect collapsible-header" href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&amp;body={{ entry.url|url_encode }}" title="{{ 'entry.view.left_menu.problem.description'|trans }}">
                <i class="mdi-alert-error small"></i>
                <span>{{ 'entry.view.left_menu.problem.label'|trans }}</span>
            </a>
            <div class="collapsible-body"></div>
        </li>

    </ul>

{% endblock %}

{% block content %}
    <div id="article">
        <header class="mbm">
            <h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{{ 'entry.view.edit_title'|trans }}">✎</a></h1>
        </header>
        <aside>
            <a href="{{ entry.url|e }}" target="_blank" title="{{ 'entry.view.original_article'|trans }} : {{ entry.title|e }}" class="tool link mdi-content-link"> <span>{{ entry.domainName|removeWww }}</span></a>
            <span class="tool link mdi-communication-comment"> {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }}</span>
            <div id="list">
                {% for tag in entry.tags %}
                    <div class="chip">
                    {{ tag.label }} <a href="{{ path('remove_tag', { 'entry': entry.id, 'tag': tag.id }) }}"><i class="mdi-action-delete"></i></a>
                    </div>
                {% endfor %}
            </div>

            <div class="input-field nav-panel-add-tag" style="display: none">
                {{ render(controller( "WallabagCoreBundle:Tag:addTagForm", { 'id': entry.id } )) }}
            </div>

            {% if entry.previewPicture is not null %}
                <div><img class="preview" src="{{ entry.previewPicture }}" alt="{{ entry.title|raw }}" /></div>
            {% endif %}

        </aside>
        <article>
            {{ entry.content | raw }}
        </article>
    </div>

<script type="text/javascript">

var app = new annotator.App();
app.include(annotator.ui.main, {
    element: document.querySelector('article')
});
app.include(annotator.storage.http, {
    prefix: '',
    urls: {
        create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}',
        update: '{{ path('annotations_put_annotation', { 'annotation': 'idAnnotation' }) }}',
        destroy: '{{ path('annotations_delete_annotation', { 'annotation': 'idAnnotation' }) }}',
        search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}'
    }
});
app
.start()
.then(function () {
     app.annotations.load({entry: {{ entry.id }}});
});
</script>

{% endblock %}

{% block footer %}
{% endblock %}
