staticman-comments.html 5.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {% if site.staticman.repository and site.staticman.branch %}
  2. <div class="staticman-comments">
  3. <div class="page__comments">
  4. <!-- Start static comments -->
  5. <div class="js-comments">
  6. {% if site.data.comments[page.slug] %}
  7. <h3 class="page__comments-title">{{ site.data.ui-text[site.locale].comments_title | default: "Comments" }}</h3>
  8. {% assign comments = site.data.comments[page.slug] | sort %}
  9. {% for comment in comments %}
  10. {% assign email = comment[1].email %}
  11. {% assign name = comment[1].name %}
  12. {% assign url = comment[1].url %}
  13. {% assign date = comment[1].date %}
  14. {% assign message = comment[1].message %}
  15. {% include staticman-comment.html index=forloop.index email=email name=name url=url date=date message=message %}
  16. {% endfor %}
  17. {% endif %}
  18. </div>
  19. <!-- End static comments -->
  20. <!-- Start new comment form -->
  21. <div class="page__comments-form">
  22. <h3 class="page__comments-title">{{ site.data.ui-text[site.locale].comments_label | default: "Leave a Comment" }}</h3>
  23. <p class="small">{{ site.data.ui-text[site.locale].comment_form_info | default: "Your email address will not be published. Required fields are marked" }} <span class="required">*</span></p>
  24. <form id="new_comment" class="page__comments-form js-form form" method="post">
  25. <div class="form-group">
  26. <label for="comment-form-message">{{ site.data.ui-text[site.locale].comment_form_comment_label | default: "Comment" }} <small class="required">*</small></label><br>
  27. <textarea type="text" rows="12" cols="36" id="comment-form-message" name="fields[message]" tabindex="1"></textarea>
  28. <div class="small form-text"><a href="https://daringfireball.net/projects/markdown/">{{ site.data.ui-text[site.locale].comment_form_md_info | default: "Markdown is supported." }}</a></div>
  29. </div>
  30. <div class="form-group">
  31. <label for="comment-form-name">{{ site.data.ui-text[site.locale].comment_form_name_label | default: "Name" }} <small class="required">*</small></label>
  32. <input type="text" id="comment-form-name" name="fields[name]" tabindex="2" />
  33. </div>
  34. <div class="form-group">
  35. <label for="comment-form-email">{{ site.data.ui-text[site.locale].comment_form_email_label | default: "Email address" }} <small class="required">*</small></label>
  36. <input type="email" id="comment-form-email" name="fields[email]" tabindex="3" />
  37. </div>
  38. <div class="form-group">
  39. <label for="comment-form-url">{{ site.data.ui-text[site.locale].comment_form_website_label | default: "Website (optional)" }}</label>
  40. <input type="url" id="comment-form-url" name="fields[url]" tabindex="4"/>
  41. </div>
  42. <div class="form-group d-none" style="display: none;">
  43. <input type="hidden" name="options[origin]" value="{{ page.url | absolute_url }}">
  44. <input type="hidden" name="options[slug]" value="{{ page.slug }}">
  45. <label for="comment-form-location">Not used. Leave blank if you are a human.</label>
  46. <input type="text" id="comment-form-location" name="fields[hidden]" autocomplete="off"/>
  47. {% if site.staticman.reCaptcha.siteKey %}<input type="hidden" name="options[reCaptcha][siteKey]" value="{{ site.staticman.reCaptcha.siteKey }}">{% endif %}
  48. {% if site.staticman.reCaptcha.secret %}<input type="hidden" name="options[reCaptcha][secret]" value="{{ site.staticman.reCaptcha.secret }}">{% endif %}
  49. </div>
  50. <!-- Start comment form alert messaging -->
  51. <p class="d-none js-notice alert">
  52. <strong class="js-notice-text-success d-none">{{ site.data.ui-text[site.locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}</strong>
  53. <strong class="js-notice-text-failure d-none">{{ site.data.ui-text[site.locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}</strong>
  54. </p>
  55. <!-- End comment form alert messaging -->
  56. {% if site.staticman.reCaptcha.siteKey %}
  57. <div class="form-group">
  58. <div class="g-recaptcha" data-sitekey="{{ site.staticman.reCaptcha.siteKey }}"></div>
  59. </div>
  60. {% endif %}
  61. <div class="form-group">
  62. <button type="submit" id="comment-form-submit" tabindex="5" class="btn btn-primary btn-lg">{{ site.data.ui-text[site.locale].comment_btn_submit | default: "Submit Comment" }}</button>
  63. <button type="submit" id="comment-form-submitted" tabindex="5" class="btn btn-primary btn-lg d-none" disabled>{{ site.data.ui-text[site.locale].comment_btn_submitted | default: "Submitted" }}</button>
  64. </div>
  65. </form>
  66. </div>
  67. <!-- End new comment form -->
  68. <!-- Load reCaptcha if site key is set -->
  69. {% if site.staticman.reCaptcha.siteKey %}
  70. <script async src="https://www.google.com/recaptcha/api.js"></script>
  71. {% endif %}
  72. </div>
  73. <!-- Load script to handle comment form submission -->
  74. <!-- doing something a bit funky here because I want to be careful not to include JQuery twice! -->
  75. <script>
  76. if (typeof jQuery == 'undefined') {
  77. document.write('<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></scr' + 'ipt>');
  78. }
  79. </script>
  80. <script src="{{ "/assets/js/staticman.js" | relative_url }}"></script>
  81. </div>
  82. {% endif %}