reply.jinja 2.49 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
<div id="forum">
    <h3>{{ topic.title }}</h3>
    <h4>{% trans %}Reply{% endtrans %}</h4>
25 26
{% else %}
<div id="forum">
Skia's avatar
Skia committed
27
    <h4>{% trans %}New topic{% endtrans %}</h4>
28
{% endif %}
Skia's avatar
Skia committed
29 30
    <form action="" method="post" enctype="multipart/form-data">
        {% csrf_token %}
Skia's avatar
Skia committed
31
        {{ form.as_p() }}
Skia's avatar
Skia committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
        <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>
47
            <div id="preview" class="ib"></div>
Skia's avatar
Skia committed
48 49
            <div class="forum_signature">{{ user.forum_signature|markdown }}</div>
        </div>
Skia's avatar
Skia committed
50
    </div>
Skia's avatar
Skia committed
51

Skia's avatar
Skia committed
52
    <hr>
Skia's avatar
Skia committed
53

Skia's avatar
Skia committed
54 55 56 57 58 59 60 61
    {% 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
62 63 64 65

{% endblock %}


Skia's avatar
Skia committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
{% 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
85 86