{% extends 'group/group_base.html' %}

{% load seahub_tags avatar_tags group_avatar_tags i18n %}
{% load url from future %}

{% block cur_wiki %}tab-cur{% endblock %}

{% block right_panel %}
<div class="wiki-top ovhd">
    <ul class="wiki-nav fleft">
        <li class="item"><a href="{% url 'group_wiki' group.id %}" class="link">{% trans "Home" %}</a></li>
        <li class="item cur-item"><a href="{% url 'group_wiki_pages' group.id %}" class="link">{% trans "Pages" %}</a></li>
        {% if group.view_perm != "pub" %}
        <li class="item"><a href="{% url 'repo_history' repo_id %}" target="_blank" class="link">{% trans "Wiki History" %}</a></li>
        {% endif %}
    </ul>
    {% if repo_perm == 'rw' %}
    <button id="page-create" class="op-btn">{% trans "New Page" %}</button>
    {% endif %}
</div>

<ul id="wiki-pages">
    {% for page_slug, page in pages.items %}
    <li><a href="{% url 'group_wiki' group.id page_slug %}">{{ page }}</a></li>
    {% endfor %}
</ul>

<form id="page-create-form" action="{% url 'group_wiki_page_new' group.id %}" method="post" class="hide">{% csrf_token %}
    <h3>{% trans "New Page"%}</h3>
    <label>{% trans "Name"%}</label><br/>
    <input id="page-name" type="text" name="page_name" value="" maxlength="{{max_file_name}}" class="input" /><br />
    <p class="error hide"></p>
    <input type="submit" id="page-create-submit" value="{% trans "Submit"%}" class="submit" />
</form>
{% endblock %}

{% block extra_script %}{{block.super}}
<script type="text/javascript">
$('#page-create').click(function() {
    $('#page-create-form').modal({appendTo: '#main', autoResize: true});
})
</script>
{% endblock %}
