reply.jinja 2.88 KB
Newer Older
Skia's avatar
Skia committed
1 2 3 4
{% extends "core/base.jinja" %}
{% from 'forum/macros.jinja' import display_message %}

{% block title %}
Skia's avatar
Skia committed
5
{% if topic %}
Skia's avatar
Skia committed
6
{% trans %}Reply{% endtrans %}
Skia's avatar
Skia committed
7 8 9
{% else %}
{% trans %}New topic{% endtrans %}
{% endif %}
Skia's avatar
Skia committed
10 11 12
{% endblock %}

{% block content %}
Skia's avatar
Skia committed
13
{% if topic %}
Skia's avatar
Skia committed
14 15 16 17 18 19 20 21
<p>
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
{% for f in topic.forum.get_parent_list() %}
> <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
{% endfor %}
> <a href="{{ topic.forum.get_absolute_url() }}">{{ topic.forum }}</a>
> <a href="{{ topic.get_absolute_url() }}">{{ topic }}</a>
</p>
Skia's avatar
Skia committed
22 23 24 25 26 27 28 29
<div id="forum">
    <h3>{{ topic.title }}</h3>
    <h4>{% trans %}Reply{% endtrans %}</h4>
    {% else %}
    <h4>{% trans %}New topic{% endtrans %}</h4>
    {% endif %}
    <form action="" method="post" enctype="multipart/form-data">
        {% csrf_token %}
30 31
        <p>{{ form.title.errors }}<label for="{{ form.title.name }}">{{ form.title.label }}</label> {{ form.title }}</p>
        <p>{{ form.message.errors }}<label for="{{ form.message.name }}">{{ form.message.label }}</label> </p>
32 33
        <p><a href="{{ syntax_help_page.get_absolute_url() }}">{% trans %}Help on the syntax{% endtrans %}</a>
        <div class="markdown_editor">
34
        {{ form.message }}
35
        </div>
36
        </p>
Skia's avatar
Skia committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        <p><input type="button" value="{% trans %}Preview{% endtrans %}" onclick="javascript:make_preview();" /></p>
        <p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
    </form>
    <div id="preview_message" class="message" style="display: none;">
        <div class="msg_author">
            {% if user.avatar_pict %}
            <img src="{{ user.avatar_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" id="picture" />
            {% else %}
            <img src="{{ static('core/img/unknown.jpg') }}" alt="{% trans %}Profile{% endtrans %}" id="picture" />
            {% endif %}
            <br/>
            <strong><a href="{{ user.get_absolute_url() }}">{{ user.get_short_name() }}</a></strong>
        </div>
        <div class="msg_content">
            <hr>
52
            <div id="preview" class="ib"></div>
Skia's avatar
Skia committed
53 54
            <div class="forum_signature">{{ user.forum_signature|markdown }}</div>
        </div>
Skia's avatar
Skia committed
55
    </div>
Skia's avatar
Skia committed
56

Skia's avatar
Skia committed
57
    <hr>
Skia's avatar
Skia committed
58

Skia's avatar
Skia committed
59 60 61 62 63 64 65 66
    {% if topic %}
    {% for m in topic.messages.select_related('author__avatar_pict').order_by('-id')[:10] %}
        {{ display_message(m, user) }}
    {% endfor %}
    {% endif %}


</div>
Skia's avatar
Skia committed
67 68 69 70

{% endblock %}


Skia's avatar
Skia committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
{% block script %}
{{ super() }}
<script>
function make_preview() {
    $("#preview_message").hide(300);
    text = $("#id_message").val();
    console.log("Rendering text: " + text);
    $.ajax({
        url: "{{ url('api:api_markdown') }}",
        method: "POST",
        data: { text:  text, csrfmiddlewaretoken: "{{ csrf_token }}"}
    }).done(function (msg) {
        $("#preview").html(msg);
        $("#preview_message").show(300);
    });
}
</script>
{% endblock %}

Skia's avatar
Skia committed
90 91