staticman-comments.html 5.4 KB

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