Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

post_comments.html 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. {{ if .Site.Data.blog.staticmanComments.enable }}
  2. <section class="mt-4">
  3. <h3>{{ i18n "comments" }}</h3>
  4. {{ $postSlug := .File.BaseFileName }}
  5. {{ $.Scratch.Add "entryId" $postSlug }}
  6. {{ $comments := index $.Site.Data.comments ($.Scratch.Get "entryId") }}
  7. {{ $.Scratch.Set "hasComments" 0 }}
  8. {{ range $comments }}
  9. {{ $.Scratch.Add "hasComments" 1 }}
  10. {{ if not .reply_to }}
  11. {{ $.Scratch.Set "parentId" ._id }}
  12. {{ $.Scratch.Set "parentName" .name }}
  13. {{ $.Scratch.Set "hasReplies" 0 }}
  14. <div id="commentid-{{ ._id }}" class="post-comment">
  15. <div class="post-comment-header">
  16. <img class="post-comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=70&pg&d=identicon">
  17. <p class="post-comment-info">
  18. <span class="post-comment-name">{{ .name }}</span>
  19. <br>
  20. <a href="#commentid-{{ ._id }}" title="{{ i18n "permalinkComment" }}">
  21. <time class="post-time">{{ dateFormat "02.01.2006, 15:04" .date }}</time>
  22. </a>
  23. </p>
  24. </div>
  25. {{ .message | markdownify }}
  26. <div class="clearfix">
  27. <div class="post-comment-reply-button float-right mt-1">
  28. <a id="{{ ._id }}" class="btn btn-info btn-sm" href="#staticman-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')">{{ i18n "replyTo" }} {{ .name }}</a>
  29. </div>
  30. </div>
  31. </div>
  32. {{ range $comments }}
  33. {{ if eq .reply_to ( $.Scratch.Get "parentId" ) }}
  34. {{ $.Scratch.Add "hasReplies" 1 }}
  35. <div id="commentid-{{ ._id }}" class="post-comment ml-5">
  36. <div class="post-comment-header">
  37. <img class="post-comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=70&pg&d=identicon">
  38. <p class="post-comment-info">
  39. <span class="post-comment-name">{{ .name }} </span>
  40. <br>
  41. <i><span class="tf-ion-forward"></span> <span>{{ ( $.Scratch.Get "parentName" ) }}</span></i>
  42. <br>
  43. <a href="#commentid-{{ ._id }}" title="{{ i18n "permalinkComment" }}">
  44. <time class="post-time">{{ dateFormat "02.01.2006, 15:04" .date }}</time>
  45. </a>
  46. </p>
  47. </div>
  48. {{ .message | markdownify }}
  49. {{ if gt ($.Scratch.Get "hasReplies") 0 }}
  50. <div class="clearfix">
  51. <div class="post-comment-reply-button float-right mt-1">
  52. <a id="{{ ._id }}" class="btn btn-info btn-sm" href="#staticman-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')">{{ i18n "replyToThread" }}</a>
  53. </div>
  54. </div>
  55. {{ end }}
  56. </div>
  57. {{ end }}
  58. {{ end }}
  59. {{ end }}
  60. {{ end }}
  61. {{ if eq ($.Scratch.Get "hasComments") 0 }}
  62. <p>{{ i18n "noComments" }}</p>
  63. {{ end }}
  64. </section>
  65. <div class="clearfix"></div>
  66. <section id="staticman-form">
  67. <h3>{{ i18n "tellSomething" }}</h3>
  68. <script>var submitted=false;</script>
  69. <iframe name="hidden_iframe" id="hidden_iframe" onload='if(submitted){swal("{{ i18n "thanksForComment" }}!", "{{ i18n "commentSent" }} 😊", "success");}'></iframe>
  70. <form class="form-control-meghna" method="POST" action="{{ .Site.Data.blog.staticmanComments.api }}" target="hidden_iframe" onsubmit="submitted=true;">
  71. <input type="hidden" name="options[slug]" value="{{ .File.BaseFileName }}">
  72. <input type="hidden" name="options[origin]" value="{{ $.Permalink }}#comments">
  73. <input type="hidden" name="fields[reply_to]" value="">
  74. <div class="form-group">
  75. <label for="nick" class="font-weight-bold">{{ i18n "nickname" }}</label>
  76. <input class="form-control" id="nick" name="fields[name]" type="text" required="required"/>
  77. </div>
  78. <div class="form-group">
  79. <label for="mail" class="font-weight-bold">Email</label>
  80. <input type="email" class="form-control" id="mail" name="fields[email]" type="text" required="required"/>
  81. <small id="mailHelp" class="form-text text-muted">{{ if .Site.Data.blog.staticmanComments.notifications }} {{ i18n "emailUseGravatarNotifications" | markdownify }} {{else}} {{ i18n "emailUseGravatar" | markdownify }} {{end}}</small>
  82. </div>
  83. <input name="e-mail" type="text" id="e-mail" autocomplete="off">
  84. <div class="form-group">
  85. <label for="message" class="font-weight-bold">{{ i18n "comment" }}</label>
  86. <textarea id="message" name="fields[message]" minlength="5" rows="3" data-min-rows="3" class="form-control" required="required" placeholder="{{ i18n "commentPlaceholder" }}"></textarea>
  87. </div>
  88. {{ if .Site.Data.blog.staticmanComments.notifications }}
  89. <input type="hidden" name="options[parent]" value="{{ .File.BaseFileName }}">
  90. <div class="form-group">
  91. <div class="custom-control custom-checkbox">
  92. <input id="form-submit" name="options[subscribe]" type="checkbox" class="custom-control-input" value="email">
  93. <label class="custom-control-label" for="form-submit">{{ i18n "commentNotify" }}</label>
  94. </div>
  95. </div>
  96. {{ end }}
  97. <div class="clearfix">
  98. <input type="submit" class="btn btn-info" value="{{ i18n "addComment" }}">
  99. </div>
  100. </form>
  101. </section>
  102. {{ end }}