diff --git a/comments/templates/comments/_add_comment_form.html b/comments/templates/comments/_add_comment_form.html index ae6dfc2c3d1313bc294a17b78eefef1bd4756cb9..721d7b0d66da204cd6a4fd757cceaf6362dff1da 100644 --- a/comments/templates/comments/_add_comment_form.html +++ b/comments/templates/comments/_add_comment_form.html @@ -3,7 +3,8 @@ {% load staticfiles %} {% block footer_script %} - <script type="text/javascript" src="{% static 'scipost/comment-preview.js' %}"></script> + <script src="{% static 'scipost/fetch-markup-preview.js' %}"></script> + <script src="{% static 'scipost/comment-preview.js' %}"></script> {% endblock %} <form enctype="multipart/form-data" {% if url %}action="{{ url }}" {% endif %}method="post"> @@ -12,10 +13,11 @@ <div class="col-md-9"> {{ form.comment_text|bootstrap:'12,12' }} - <p> - In your comment, you can use $\LaTeX$ \$...\$ for in-text equations or \ [ ... \ ] for on-line equations. - </p> - <p class="good_commenter">Be professional. Only serious and meaningful comments will be vetted through.</p> + <p class="good_commenter"> + You can use plain text, Markdown or reStructuredText; see our + <a href="{% url 'markup:help' %}" target="_blank">markup help</a> pages. + <br> + Be professional. Only serious and meaningful comments will be vetted through.</p> </div> <div class="col-md-3 radio-list"> <label>Specify categorization(s):</label> @@ -49,19 +51,25 @@ <h3 class="anonymous-no"><span class="text-danger">Your Comment will be <span class="text-underline">signed</span>.</span> Thank you very much!</h3> </div> {% endif %} - <input type="submit" name="submit" value="Submit your Comment for vetting" class="btn btn-primary" id="submit-id-submit"> - {% if form.anonymous %} - <p class="mt-2" id="goodCommenter"><i>By clicking on Submit, you agree with the <a target="_blank" href="{% url 'scipost:terms_and_conditions' %}">Terms and Conditions</a>.</i></p> - {% else %} - <p class="mt-2" id="goodCommenter"><i>By clicking on Submit, you agree with the <a target="_blank" href="{% url 'scipost:terms_and_conditions' %}">Terms and Conditions</a>, in particular that <span class="text-danger">your identity will be attached to the Comment</span>.</i></p> - {% endif %} + <div id="submitButton"> + <input type="submit" value="Submit your Comment for vetting" class="btn btn-primary"> + {% if form.anonymous %} + <p class="mt-2" id="goodCommenter"><i>By clicking on Submit, you agree with the <a target="_blank" href="{% url 'scipost:terms_and_conditions' %}">Terms and Conditions</a>.</i></p> + {% else %} + <p class="mt-2" id="goodCommenter"><i>By clicking on Submit, you agree with the <a target="_blank" href="{% url 'scipost:terms_and_conditions' %}">Terms and Conditions</a>, in particular that <span class="text-danger">your identity will be attached to the Comment</span>.</i></p> + {% endif %} + </div> </div> </div> </form> -<div class="row"> - <div class="col-md-9"> - <h3>Preview of your comment:</h3> - <p id="preview-comment_text"></p> +<button class="btn btn-warning" id="runPreviewButton">Run/refresh preview and check your Comment before submitting it:</button> +<div class="card m-2"> + <div class="card-header"> + Preview of your comment + </div> + <div class="card-content"> + <div id="preview-comment_text"></div> </div> </div> +<br> diff --git a/comments/templates/comments/_single_comment.html b/comments/templates/comments/_single_comment.html index 2a64b0cc4f745b78b1b7909c5e390bd1341784e1..01cf9a852d231fd47c62bd078f2489c7a3fb00c6 100644 --- a/comments/templates/comments/_single_comment.html +++ b/comments/templates/comments/_single_comment.html @@ -2,6 +2,7 @@ {% load filename %} {% load file_extentions %} {% load user_groups %} +{% load automarkup %} {% is_edcol_admin request.user as is_edcol_admin %} {% is_editorial_college request.user as is_editorial_college %} @@ -16,8 +17,9 @@ {% endif %} <p class="my-3 pb-2"> - {{ comment.comment_text|linebreaksbr }} + {{ comment.comment_text|automarkup:'plain' }} </p> + {% if comment.file_attachment %} <h3>Attachment:</h3> <p> diff --git a/helpdesk/templates/helpdesk/ticket_form.html b/helpdesk/templates/helpdesk/ticket_form.html index dfb4836d47be8b7c071323327c0c5cd7900aad9e..0ffd27430e8bc87a750fde668e154f611496c696 100644 --- a/helpdesk/templates/helpdesk/ticket_form.html +++ b/helpdesk/templates/helpdesk/ticket_form.html @@ -50,7 +50,7 @@ <h2 class="highlight"> Preview of your ticket </h2> - <p><em id="languageElement" class="text-muted mb-2"></em></p> + <p><em id="language-description" class="text-muted mb-2"></em></p> <div class="card"> <div class="card-header" id="preview-title"></div> <div class="card-content"> @@ -58,11 +58,12 @@ </div> </div> </div> + </div> </div> - </div> {% endblock content %} {% block footer_script %} + <script src="{% static 'scipost/fetch-markup-preview.js' %}"></script> <script src="{% static 'scipost/ticket-preview.js' %}"></script> {% endblock footer_script %} diff --git a/scipost/static/scipost/comment-preview.js b/scipost/static/scipost/comment-preview.js index 57c31bfc9f3240034da471f7b981e3eebbd30927..33890730090447c1059c97f4805511fe1d3c7f68 100644 --- a/scipost/static/scipost/comment-preview.js +++ b/scipost/static/scipost/comment-preview.js @@ -1,21 +1,27 @@ -$(function(){ - var comment_text_input = $("#id_comment_text"); +$(document).ready(function() { - comment_text_input.on('keyup', function(){ - var new_text = $(this).val() - $("#preview-comment_text").text(new_text) - if( typeof MathJax.Hub !== 'undefined' ) { - MathJax.Hub.Queue(["Typeset",MathJax.Hub]); - } - }).trigger('keyup'); + $('#submitButton').hide(); + + $("#id_comment_text").on('keyup', function(){ + $('#runPreviewButton').show(); + $('#preview-comment_text').css('background', '#feebce'); + $('#submitButton').hide(); + }); + + $('#runPreviewButton').on('click', function(){ + fetchMarkupPreview('comment_text'); + $('#runPreviewButton').hide(); + $('#preview-comment_text').css('background', '#ffffff'); + $('#submitButton').show(); + }).trigger('change'); $('input[name$="anonymous"]').on('change', function() { - $('.anonymous-alert').show() + $('.anonymous-alert').show() .children('h3').hide() - if ($(this).prop('checked')) { + if ($(this).prop('checked')) { $('.anonymous-yes').show(); - } else { + } else { $('.anonymous-no').show(); - } + } }).trigger('change'); }); diff --git a/scipost/static/scipost/fetch-markup-preview.js b/scipost/static/scipost/fetch-markup-preview.js new file mode 100644 index 0000000000000000000000000000000000000000..d253d548837782183f0850aa2f1b1a89e40dfff2 --- /dev/null +++ b/scipost/static/scipost/fetch-markup-preview.js @@ -0,0 +1,27 @@ +function fetchMarkupPreview(label) { + + $.ajax({ + type: "POST", + url: "/markup/process/", + data: { + csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(), + markup_text: $('#id_' + label).val(), + }, + dataType: 'json', + success: function(data) { + $('#language-' + label).text("Language (auto-detected): " + data.language); + if (data.errors) { + $('#preview-' + label).css('background', '#feebce'); + $('#submitButton').hide(); + $('#runPreviewButton').show(); + alert("An error has occurred while processing the text:\n\n" + data.errors); + } + $('#preview-' + label).html(data.processed); + let preview = document.getElementById('preview-' + label); + MathJax.Hub.Queue(["Typeset",MathJax.Hub, preview]); + }, + error: function(data) { + alert("An error has occurred while processing the text:\n\n." + data); + } + }); +} diff --git a/scipost/static/scipost/ticket-preview.js b/scipost/static/scipost/ticket-preview.js index 0dd9f07de86f3a61d0997ca0b7975fbb14427829..19c2acfd41c36b5d390cbed24fecfbc02464a2e8 100644 --- a/scipost/static/scipost/ticket-preview.js +++ b/scipost/static/scipost/ticket-preview.js @@ -16,31 +16,7 @@ $('#id_description').on('keyup', function(){ $('#runPreviewButton').on('click', function(){ $('#preview-title').text($('#id_title').val()); - $.ajax({ - type: "POST", - url: "/markup/process/", - data: { - csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(), - markup_text: $('#id_description').val(), - }, - dataType: 'json', - success: function(data) { - $('#languageElement').text("Language (auto-detected): " + data.language); - if (data.errors) { - $('#preview-title').css('background', '#eedbbe'); - $('#preview-description').css('background', '#feebce'); - $('#submitButton').hide(); - $('#runPreviewButton').show(); - alert("An error has occurred while processing the text:\n\n" + data.errors); - } - $('#preview-description').html(data.processed); - let preview = document.getElementById('preview-description'); - MathJax.Hub.Queue(["Typeset",MathJax.Hub, preview]); - }, - error: function(data) { - alert("An error has occurred while processing the text:\n\n." + data); - } - }); + fetchMarkupPreview('description'); $('#runPreviewButton').hide(); $('#preview-title').css('background', '#f1f1f1'); $('#preview-description').css('background', '#ffffff'); diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html index f0d453b1a3ae8f535af51949e2f6b2dabe2613c9..510d67e9b836affbb77398c406afffcd6d702aa6 100644 --- a/submissions/templates/submissions/submission_detail.html +++ b/submissions/templates/submissions/submission_detail.html @@ -100,7 +100,7 @@ {% if submission.author_comments %} <h3>Author comments upon resubmission</h3> <div class="blockquote"> - {{ submission.author_comments|linebreaks }} + {{ submission.author_comments|linebreaksbr }} </div> {% endif %}