|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- {{ if .Site.Data.blog.staticmanComments.enable }}
- <section class="mt-4">
- <h3>{{ i18n "comments" }}</h3>
-
- {{ $postSlug := .File.BaseFileName }}
- {{ $.Scratch.Add "entryId" $postSlug }}
-
- {{ $.Scratch.Set "hasComments" 0 }}
- {{ if .Site.Data.comments }}
- {{ $comments := index $.Site.Data.comments ($.Scratch.Get "entryId") }}
- {{ range $comments }}
- {{ $.Scratch.Add "hasComments" 1 }}
- {{ if not .reply_to }}
- {{ $.Scratch.Set "parentId" ._id }}
- {{ $.Scratch.Set "parentName" .name }}
- {{ $.Scratch.Set "hasReplies" 0 }}
- <div id="commentid-{{ ._id }}" class="post-comment">
- <div class="post-comment-header">
- <img class="post-comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=70&pg&d=identicon">
- <p class="post-comment-info">
- <span class="post-comment-name">{{ .name }}</span>
- <br>
- <a href="#commentid-{{ ._id }}" title="{{ i18n "permalinkComment" }}">
- <time class="post-time">{{ dateFormat "02.01.2006, 15:04" .date }}</time>
- </a>
- </p>
- </div>
- {{ .message | markdownify }}
- <div class="clearfix">
- <div class="post-comment-reply-button float-right mt-1">
- <a id="{{ ._id }}" class="btn btn-info btn-sm" href="#staticman-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')">{{ i18n "replyTo" }} {{ .name }}</a>
- </div>
- </div>
- </div>
- {{ range $comments }}
- {{ if eq .reply_to ( $.Scratch.Get "parentId" ) }}
- {{ $.Scratch.Add "hasReplies" 1 }}
- <div id="commentid-{{ ._id }}" class="post-comment ml-5">
- <div class="post-comment-header">
- <img class="post-comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=70&pg&d=identicon">
- <p class="post-comment-info">
- <span class="post-comment-name">{{ .name }} </span>
- <br>
- <i><span class="tf-ion-forward"></span> <span>{{ ( $.Scratch.Get "parentName" ) }}</span></i>
- <br>
- <a href="#commentid-{{ ._id }}" title="{{ i18n "permalinkComment" }}">
- <time class="post-time">{{ dateFormat "02.01.2006, 15:04" .date }}</time>
- </a>
- </p>
- </div>
- {{ .message | markdownify }}
- {{ if gt ($.Scratch.Get "hasReplies") 0 }}
- <div class="clearfix">
- <div class="post-comment-reply-button float-right mt-1">
- <a id="{{ ._id }}" class="btn btn-info btn-sm" href="#staticman-form" onclick="changeValue('fields[reply_to]', '{{ ._id }}')">{{ i18n "replyToThread" }}</a>
- </div>
- </div>
- {{ end }}
- </div>
- {{ end }}
- {{ end }}
- {{ end }}
- {{ end }}
- {{ end }}
- {{ if eq ($.Scratch.Get "hasComments") 0 }}
- <p>{{ i18n "noComments" }}</p>
- {{ end }}
- </section>
- <div class="clearfix"></div>
- <section id="staticman-form">
- <h3>{{ i18n "tellSomething" }}</h3>
- <script>var submitted=false;</script>
- <iframe name="hidden_iframe" id="hidden_iframe" onload='if(submitted){swal("{{ i18n "thanksForComment" }}!", "{{ i18n "commentSent" }} 😊", "success");}'></iframe>
- <form class="form-control-meghna" method="POST" action="{{ .Site.Data.blog.staticmanComments.api }}" target="hidden_iframe" onsubmit="submitted=true;">
- <input type="hidden" name="options[slug]" value="{{ .File.BaseFileName }}">
- <input type="hidden" name="options[origin]" value="{{ $.Permalink }}#comments">
- <input type="hidden" name="fields[reply_to]" value="">
- <div class="form-group">
- <label for="nick" class="font-weight-bold">{{ i18n "nickname" }}</label>
- <input class="form-control" id="nick" name="fields[name]" type="text" required="required"/>
- </div>
-
- <div class="form-group">
- <label for="mail" class="font-weight-bold">Email</label>
- <input type="email" class="form-control" id="mail" name="fields[email]" type="text" required="required"/>
- <small id="mailHelp" class="form-text text-muted">{{ if .Site.Data.blog.staticmanComments.notifications }} {{ i18n "emailUseGravatarNotifications" | markdownify }} {{else}} {{ i18n "emailUseGravatar" | markdownify }} {{end}}</small>
- </div>
-
- <input name="e-mail" type="text" id="e-mail" autocomplete="off">
-
- <div class="form-group">
- <label for="message" class="font-weight-bold">{{ i18n "comment" }}</label>
- <textarea id="message" name="fields[message]" minlength="5" rows="3" data-min-rows="3" class="form-control" required="required" placeholder="{{ i18n "commentPlaceholder" }}"></textarea>
- </div>
- {{ if .Site.Data.blog.staticmanComments.notifications }}
- <input type="hidden" name="options[parent]" value="{{ .File.BaseFileName }}">
- <div class="form-group">
- <div class="custom-control custom-checkbox">
- <input id="form-submit" name="options[subscribe]" type="checkbox" class="custom-control-input" value="email">
- <label class="custom-control-label" for="form-submit">{{ i18n "commentNotify" }}</label>
- </div>
- </div>
- {{ end }}
- <div class="clearfix">
- <input type="submit" class="btn btn-info" value="{{ i18n "addComment" }}">
- </div>
- </form>
- </section>
- {{ end }}
|