mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-16 11:13:23 +00:00
50 lines
1.9 KiB
Django/Jinja
50 lines
1.9 KiB
Django/Jinja
{% from "core/macros.jinja" import user_profile_link %}
|
|
|
|
{% macro page_history(page) %}
|
|
<p>{% trans page_name=page.name %}You're seeing the history of page "{{ page_name }}"{% endtrans %}</p>
|
|
<ul>
|
|
{% for r in (page.revisions.all()|sort(attribute='date', reverse=True)) %}
|
|
{% if loop.index < 2 %}
|
|
<li><a href="{{ url('core:page', page_name=page.get_full_name()) }}">{% trans %}last{% endtrans %}</a> -
|
|
{{ user_profile_link(page.revisions.last().author) }} -
|
|
{{ page.revisions.last().date|localtime|date(DATETIME_FORMAT) }} {{ page.revisions.last().date|localtime|time(DATETIME_FORMAT) }}</a></li>
|
|
{% else %}
|
|
<li><a href="{{ url('core:page_rev', page_name=page.get_full_name(), rev=r['id']) }}">{{ r.revision }}</a> -
|
|
{{ user_profile_link(r.author) }} -
|
|
{{ r.date|localtime|date(DATETIME_FORMAT) }} {{ r.date|localtime|time(DATETIME_FORMAT) }}</a></li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
{% endmacro %}
|
|
|
|
{% macro page_edit_form(page, form, url, token) %}
|
|
<h2>{% trans %}Edit page{% endtrans %}</h2>
|
|
<form action="{{ url }}" method="post">
|
|
<input type="hidden" name="csrfmiddlewaretoken" value="{{ token }}">
|
|
{{ form.as_p() }}
|
|
{{ markdown_preview_button() }}
|
|
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
|
|
</form>
|
|
<div id="preview" class="page_content">
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro markdown_preview_script(token) %}
|
|
<script>
|
|
function make_preview() {
|
|
text = $("#id_content").val();
|
|
console.log("Rendering text: " + text);
|
|
$.ajax({
|
|
url: "{{ url('api:api_markdown') }}",
|
|
method: "POST",
|
|
data: { text: text, csrfmiddlewaretoken: "{{ token }}"}
|
|
}).done(function (msg) {
|
|
$("#preview").html(msg);
|
|
});
|
|
}
|
|
</script>
|
|
{% endmacro %}
|
|
|
|
{% macro markdown_preview_button() %}
|
|
<p><input type="button" value="{% trans %}Preview{% endtrans %}" onclick="javascript:make_preview();" /></p>
|
|
{% endmacro %} |