{% extends "home_base.html" %}

{% load seahub_tags i18n %}


{% block sub_title %}{% trans "Personal Wiki" %} - {% endblock %}

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

{% block right_panel %}
<div class="wiki-top ovhd">
    <ul class="wiki-nav fleft">
        <li class="item"><a href="{% url 'personal_wiki' %}" class="link">{% trans "Home" %}</a></li>
        <li class="item cur-item"><a href="{% url 'personal_wiki_pages' %}" class="link">{% trans "Pages" %}</a></li>
        <li class="item"><a href="{% url 'repo_history' repo_id %}" class="link" id="wiki-history">{% trans "Wiki History" %}</a></li>
    </ul>
    <button id="page-create" class="btn-white">{% trans "New Page" %}</button>
</div>

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

<form id="page-create-form" action="{% url 'personal_wiki_page_new' %}" method="post" class="hide">{% csrf_token %}
    <h3 id="dialogTitle">{% trans "New Page"%}</h3>
    <label for="page-name">{% 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" value="{% trans "Submit" %}" class="submit" />
</form>
{% endblock %}

{% block extra_script %}{{block.super}}
<script type="text/javascript">
$('#page-create').on('click', function() {
    $('#page-create-form').modal({appendTo: '#main'});
    $('#simplemodal-container').css({'height':'auto'});
})
$('#page-create-form').on('submit', function() {
    var page_name = $.trim($('[name="page_name"]', $(this)).val());
    if (!page_name) {
        return false;
    }
});
var $wikiHistory = $('#wiki-history');
$wikiHistory.attr('href', $wikiHistory.attr('href') + '?referer=' + encodeURIComponent(location.href));
</script>
{% endblock %}
