Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

post_comments.html 5.3KB

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