Skip to content

Commit 68915ec

Browse files
committed
update
1 parent 208cbc2 commit 68915ec

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

_includes/comment_form.html

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<form class="js-form form" method="post" action="https://api.staticman.net/v3/entry/github/dannyzhan/dannyzhan.github.io/master/comments" autocomplete="off">
22
<input type="hidden" name="options[origin]" value="{{ page.url | absolute_url }}">
33
<input type="hidden" name="options[parent]" value="{{ page.url | absolute_url }}">
4-
<input type="hidden" id="comment-replying-to" name="fields[replying_to]" value="">
54
<input type="hidden" name="options[page_guid]" value="{{ page.guid }}">
65
<input type="hidden" name="options[reCaptcha][siteKey]" value="{{ site.reCaptcha.siteKey }}">
76
<input type="hidden" name="options[reCaptcha][secret]" value="{{ site.reCaptcha.secret }}">
87

8+
<input type="hidden" id="comment-replying-to" name="fields[replying_to]" value="">
9+
<input type="hidden" name="fields[client_ip]" id="comment-client-ip">
10+
911
<h2>
1012
添加点评
1113
</h2>
@@ -56,17 +58,17 @@ <h2>
5658

5759
<!-- Start comment form alert messaging -->
5860
<fieldset class="hidden js-notice">
59-
<article>
60-
<div>
61-
<h3 class="modal-title js-modal-title"></h3>
62-
</div>
63-
<div class="mdl-card__supporting-text js-modal-text">
64-
<strong class="js-notice-text"></strong>
65-
</div>
66-
<div class="mdl-card__actions mdl-card--border">
67-
<div class="button js-close-modal" style="display:inline-block">关闭</div>
68-
</div>
69-
</article>
61+
<article>
62+
<div>
63+
<h3 class="modal-title js-modal-title"></h3>
64+
</div>
65+
<div class="mdl-card__supporting-text js-modal-text">
66+
<strong class="js-notice-text"></strong>
67+
</div>
68+
<div class="mdl-card__actions mdl-card--border">
69+
<div class="button js-close-modal" style="display:inline-block">关闭</div>
70+
</div>
71+
</article>
7072
<br />
7173
</fieldset>
7274

assets/themes/sext-v/js/staticman.js

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
$('#comment-form-email').val(user_email);
1212
}
1313

14+
window.onload = function () {
15+
var script = document.createElement("script");
16+
script.type = "text/javascript";
17+
script.src = "https://api.ipify.org?format=jsonp&callback=getIP";
18+
document.getElementsByTagName("head")[0].appendChild(script);
19+
};
20+
function getIP(response) {
21+
$('#comment-client-ip').val(response.ip);
22+
}
23+
1424
$('.js-form').submit(function () {
1525
var form = this;
1626

staticman.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
comments:
2-
allowedFields: ["name", "email", "url", "message", "replying_to"]
2+
allowedFields: ["name", "email", "client_ip", "message", "replying_to"]
33
allowedOrigins: ["9932.js.org"]
44
requiredFields: ["name", "message"]
55
branch: "master"

0 commit comments

Comments
 (0)