reply.jinja 2.33 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 22 23
<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>
<h3>{{ topic.title }}</h3>
<h4>{% trans %}Reply{% endtrans %}</h4>
Skia's avatar
Skia committed
24 25 26
{% else %}
<h4>{% trans %}New topic{% endtrans %}</h4>
{% endif %}
Skia's avatar
Skia committed
27 28 29
<form action="" method="post" enctype="multipart/form-data">
    {% csrf_token %}
    {{ form.as_p() }}
Skia's avatar
Skia committed
30
    <p><input type="button" value="{% trans %}Preview{% endtrans %}" onclick="javascript:make_preview();" /></p>
Skia's avatar
Skia committed
31 32
    <p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form>
Skia's avatar
Skia committed
33 34 35 36 37 38 39 40 41 42 43
<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">
Skia's avatar
Skia committed
44 45 46
        <hr>
        <div id="preview" class="ib w_big"></div>
        <div class="forum_signature">{{ user.forum_signature|markdown }}</div>
Skia's avatar
Skia committed
47 48
    </div>
</div>
Skia's avatar
Skia committed
49 50 51

<hr>

Skia's avatar
Skia committed
52
{% if topic %}
Skia's avatar
Skia committed
53
{% for m in topic.messages.select_related('author__avatar_pict').order_by('-id')[:10] %}
Skia's avatar
Skia committed
54 55
    {{ display_message(m, user) }}
{% endfor %}
Skia's avatar
Skia committed
56
{% endif %}
Skia's avatar
Skia committed
57 58 59 60

{% endblock %}


Skia's avatar
Skia committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
{% 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
80 81