{% extends 'snippet/layout.html' %}
{% load forum_extras %}

{% block javascript %}
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({
            tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
        });
    </script>
    <script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script type="text/javascript" src="/static/js/widget/emmet.min.js"></script>
    <script type="text/javascript" src="/static/js/widget/jquery.textarea.min.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(function() {
            $('textarea.smart-code-support').tabby();
            emmet.require('textarea').setup({
                pretty_break: false, // enable formatted line breaks (when inserting // between opening and closing tag)
                use_tab: false       // expand abbreviations by Tab key
            });
        });
    </script>
{% endblock %}

{% block main %}
    <div class="topic-create container-box">
        <div class="ui-header">
            <span class="title">创建新主题</span>
        </div>

        <div class="ui-content">
            <form class="mt10" action="/t/create/{{ node_slug }}/" method="post">
                {{ errors|dump_errors }}
                <div class="input-prepend mt10">
                    <span class="add-on">#</span>
                    <input class="span11" id="prependedInput" type="text" placeholder="主题" name="title">
                </div>
                <textarea rows="3" class="content mt5 smart-code-support" placeholder="正文" name="content"></textarea>
                <input type="submit" id="checkall" class="btn btn-small" value="立即创建">
                {% csrf_token %}
            </form>
        </div>
    </div>
{% endblock %}

{% block sidebar %}
    <div class="usercard container-box">
        <div class="ui-header">
            <a href="/u/{{ user.username }}/">
                <img src="/static/avatar/m_{% if user.avatar %}{{ user.avatar }}{% else %}default.png{% endif %}?t={% gen_random %}" alt="" class="avatar" />
            </a>
            <div class="username">{{ user.username }}</div>
            <div class="website"><a href="{% if user.website %}{{ user.website }}{% endif %}">{% if user.website %}{{ user.website }}{% endif %}</a></div>
        </div>
        <div class="ui-content">
            <div class="status status-topic">
                <strong><a href="/u/{{ user.username }}/topics/">{{ counter.topics }}</a></strong> 主题
            </div>
            <div class="status status-reply">
                <strong><a href="/u/{{ user.username }}/replies/">{{ counter.replies }}</a></strong> 回复
            </div>
            <div class="status status-favorite">
                <strong><a href="/u/{{ user.username }}/favorites/">{{ counter.favorites }}</a></strong> 收藏
            </div>
            <div class="status status-reputation">
                <strong>{% if user.reputation %}{{ user.reputation }}{% else %}0{% endif %}</strong> 威望
            </div>
        </div>
    </div>
{% endblock %}
