{% load base_filters %}
{% load base_tags %}
{% load perm_tags %}
{% load tagging_tags %}
{% load i18n %}

{% has_perm user pages.change_page page as can_edit %}
{% has_perm user pages.delete_page page as can_delete %}
{% tags_for_object page as tags %}
{% tags_hash_tags page as hash_tags %}
{% tags_strip_hash page as nonhash_tags %}


<div class="meta {% if not user.is_authenticated %}anon{% endif %}">
    <div class="meta-left">
    	
    	{% with page.category_set as page_cat %}
        {% if page_cat %}
        <div class="categories">
            <strong>{% trans "Category:" %} </strong><a href="{% url page.search %}?q=category:{{ page_cat }}">{{ page_cat.category }}</a>
        {% if page_cat.sub_category %}
            | <strong>{% trans "Sub Category:" %} </strong><a href="{% url page.search %}?q=sub_category:{{ page_cat.sub_category }}">{{ page_cat.sub_category }}</a>
        {% endif %}
        </div>
        {% endif %}
        {% endwith %}
        
        {% if nonhash_tags or hash_tags %}
                    <div class="tags">
                      {% if nonhash_tags or can_edit %}<strong>Tags: </strong>{% endif %}
                      {% for tag in nonhash_tags %}
                        <a href="{% url page.search %}?q=tag:{{ tag }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
                      {% endfor %}
           
                      {% if hash_tags and can_edit %}
                      {% for tag in hash_tags %}
                        {% if forloop.first and nonhash_tags %}| {% endif %}<a href="{% url page.search %}?q=tag:{{ tag }}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
                      {% endfor %}
                    {% endif %}
                    </div>
                    {% endif %}
        
        {% if user.is_authenticated %}
            {% if user.profile.is_superuser or user.id == page.creator_id or user.id == page.owner_id %}
                {% meta_creator_owner page %}
            {% endif %}
        {% endif %}
        
    </div>
    <div class="meta-right">
        {% if page.status %}
        <a class="print-link" href="{% url page.print_view page.slug %}">{% trans "Print" %}</a>
        {% endif %}
    </div>
</div>

{% if request.user.is_authenticated %}
    {% has_perm request.user pages.change_page page as can_edit_page %}
    {% has_perm request.user pages.delete_page page as can_delete_page %}
{% endif %}

{% if can_edit_page %}
<div class="editor-bar">
    <div class="perm-status">
    <ul>
        <li>{{ page.obj_perms }}</li>
        <li>{{ page.obj_status }}</li>
    </ul>
    </div>
    <div class="edit-links">
    <ul>
        <li><a class="eventlog-link" href="{% url event_log.search %}?application=pages&object_id={{ page.pk }}">{% trans "Eventlogs" %}</a></li>
        <li><a class="versions-link" href="{% url versions page.content_type_id page.pk %}">{% trans "Versions" %}</a></li>
        <li><a class="edit-link" href="{% url page.edit page.pk %}">{% trans "Edit" %}</a></li>
        <li><a class="options-link" href="#">{% trans "Options" %} <small>&#9650;</small></a>
        <div class="options-list">
            <ul>
            {% if page.status and can_delete_page %}
                <li><a class="delete" href="{% url page.delete page.pk %}">{% trans "Delete" %}</a></li>
            {% endif %}
                <li><a href="{% url page.edit.meta page.pk %}">{% trans "Edit Meta" %}</a></li>
                <li><a href="{% url category.update page.opt_app_label page.opt_module_name page.pk %}">{% trans "Edit Categories" %}</a></li>
            </ul>
        </div>
        </li>
    </ul>
    </div>
</div> 
{% endif %}

