remove django-markdown and handle preview manually

This commit is contained in:
Élie Bouttier 2014-09-06 00:39:50 -07:00
parent 4995c19560
commit 7e3173c7c0
32 changed files with 335 additions and 16478 deletions

View file

@ -0,0 +1,25 @@
var csrftoken = $.cookie('csrftoken');
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
$('a[href="#preview"]').on("show.bs.tab", function (e) {
$('#preview-content').html('Loading preview...');
var comment = $('#markdown-content').val();
$.post(markdown_preview_url, {'data': comment})
.done(function(data, textStatus) {
$('#preview-content').html(data);
})
.fail(function () {
$('#preview-content').html('Sorry, an error occured.');
});
})