diff --git a/assets/js/app/post.js b/assets/js/app/post.js index c3f2524..abdf14b 100644 --- a/assets/js/app/post.js +++ b/assets/js/app/post.js @@ -1,3 +1,5 @@ +const Routing = require('./routing') + const Post = function(w) { this.window = w; } @@ -48,7 +50,7 @@ Post.prototype.commentsEvents = function() { previewRender.innerHTML = '

Chargement en cours…

'; } - var content = document.querySelector('#comment_content').value; + var content = document.querySelector('#user_comment_content').value; var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function(data) { @@ -59,7 +61,7 @@ Post.prototype.commentsEvents = function() { } }; - httpRequest.open('POST', Routing.generate('api_comment_preview')); + httpRequest.open('POST', Routing.generate('api_blog_comment_preview')); httpRequest.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' diff --git a/public/js/fos_js_routes.json b/public/js/fos_js_routes.json index 1003fe6..f2bc483 100644 --- a/public/js/fos_js_routes.json +++ b/public/js/fos_js_routes.json @@ -1 +1 @@ -{"base_url":"","routes":{"blog_tech_form_without_javascript":{"tokens":[["text","\/nojs"]],"defaults":[],"requirements":[],"hosttokens":[["text","local.deblan"]],"methods":[],"schemes":[]}},"prefix":"","host":"localhost","port":"","scheme":"http","locale":[]} \ No newline at end of file +{"base_url":"","routes":{"api_blog_comment_preview":{"tokens":[["text","\/api\/blog\/comment\/preview"]],"defaults":[],"requirements":[],"hosttokens":[],"methods":[],"schemes":[]},"blog_tech_form_without_javascript":{"tokens":[["text","\/nojs"]],"defaults":[],"requirements":[],"hosttokens":[["text","local.deblan"]],"methods":[],"schemes":[]}},"prefix":"","host":"localhost","port":"","scheme":"http","locale":[]} \ No newline at end of file diff --git a/src/Controller/Blog/Api/CommentController.php b/src/Controller/Blog/Api/CommentController.php new file mode 100644 index 0000000..a247d59 --- /dev/null +++ b/src/Controller/Blog/Api/CommentController.php @@ -0,0 +1,23 @@ +json([ + 'render' => $parser->transformMarkdown($request->request->get('content')), + ]); + } +}