This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathstaticman.html
60 lines (56 loc) · 2.59 KB
/
staticman.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<h2>Say something</h2>
{{ with .Site.Params.staticman }}
<form class="post-new-comment" method="POST" action="https://dev.staticman.net/v3/entry/github/{{ .username }}/{{ .repo }}/{{ .branch }}/data/comments">
{{ end }}
<input type="hidden" name="options[redirect]" value="{{ .Site.BaseURL }}{{ .RelPermalink }}">
<input type="hidden" name="options[entryId]" value="{{ .UniqueID }}">
<input required name="fields[name]" type="text" placeholder="Your name (Required)">
<input name="fields[website]" type="text" placeholder="Your website">
<input required name="fields[email]" type="email" placeholder="Your email address (Required for Gravatar)">
<textarea required name="fields[body]" placeholder="Your message. Feel free to use Markdown (Google 'Markdown Cheat Sheet')." rows="10"></textarea>
{{ if .Site.Params.staticman.recaptcha.recaptcha }}
<input type="hidden" name="options[reCaptcha][siteKey]" value="{{ .Site.Params.staticman.recaptcha.sitekey }}">
<input type="hidden" name="options[reCaptcha][secret]" value="{{ .Site.Params.staticman.recaptcha.encryptedkey }}">
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response">
{{ end }}
<input type="submit" value="Submit">
</form>
{{ if .Site.Params.staticman.recaptcha.recaptcha }}
<script>
grecaptcha.ready(function() {
grecaptcha.execute('{{ .Site.Params.staticman.recaptcha.sitekey }}', {action: 'homepage'})
.then(function(token) {
//console.log(token);
document.getElementByID('g-recaptcha-response').value=token;
});
});
</script>
{{ end }}
<h2>Comments</h2>
{{ $comments := readDir "data/comments" }}
{{ $.Scratch.Add "hasComments" 0 }}
{{ $entryId := .UniqueID }}
{{ range $comments }}
{{ if eq .Name $entryId }}
{{ $.Scratch.Add "hasComments" 1 }}
{{ range $index, $comments := (index $.Site.Data.comments $entryId ) }}
<article id="{{ .uniqueID }}" class="post-comment">
<img class="post-comment-avatar" src="https://www.gravatar.com/avatar/{{ .email }}?s=100">
<h3 class="post-comment-author">
<a rel="external nofollow" href="{{ .website }}">{{ .name }}</a>
</h3>
<div class="post-comment-timestamp">
<a href="#{{ .uniqueID }}" title="Permalink to this comment">
<time datetime="{{ .date }}">{{ dateFormat "02/01/2006" .date }}</time>
</a>
</div>
<div class="post-comment-content">
{{ .body | markdownify }}
</div>
</article>
{{ end }}
{{ end }}
{{ end }}
{{ if eq ($.Scratch.Get "hasComments") 0 }}
<p>Nothing yet.</p>
{{ end }}