From 5ed73b3f1618164b189b8faceb7ee6a2d67d293f Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Wed, 4 Oct 2017 14:14:25 -0400 Subject: [PATCH] Add support for Staticman v2 endpoint and reCAPTCHA on `/docs` Ref: #803 --- _config.yml | 27 +++-- docs/_config.yml | 26 +++-- .../comments-providers/staticman_v2.html | 42 +++++++ docs/_includes/comments.html | 72 ++++++++++++ staticfile.yml | 104 ++++++++++++++++++ 5 files changed, 248 insertions(+), 23 deletions(-) create mode 100644 docs/_includes/comments-providers/staticman_v2.html create mode 100644 staticfile.yml diff --git a/_config.yml b/_config.yml index b1a87438..6d9ff63b 100644 --- a/_config.yml +++ b/_config.yml @@ -20,7 +20,7 @@ teaser : # path of fallback teaser image, e.g. "/assets/images # breadcrumbs : false # true, false (default) words_per_minute : 200 comments: - provider : # false (default), "disqus", "discourse", "facebook", "google-plus", "staticman", "custom" + provider : # false (default), "disqus", "discourse", "facebook", "google-plus", "staticman", "staticman_v2" "custom" disqus: shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname- discourse: @@ -31,21 +31,24 @@ comments: num_posts : # 5 (default) colorscheme : # "light" (default), "dark" staticman: - allowedFields : ['name', 'email', 'url', 'message'] - branch : "master" - commitMessage : "New comment." - filename : comment-{@timestamp} - format : "yml" - moderation : true - path : "docs/_data/comments/{options.slug}" # "/_data/comments/{options.slug}" (default) - requiredFields : ['name', 'email', 'message'] + allowedFields : # ['name', 'email', 'url', 'message'] + branch : # "master" + commitMessage : # "New comment." + filename : # comment-{@timestamp} + format : # "yml" + moderation : # true + path : # "/_data/comments/{options.slug}" (default) + requiredFields : # ['name', 'email', 'message'] transforms: - email : "md5" + email : # "md5" generatedFields: date: - type : "date" + type : # "date" options: - format : "iso8601" # "iso8601" (default), "timestamp-seconds", "timestamp-milliseconds" + format : # "iso8601" (default), "timestamp-seconds", "timestamp-milliseconds" +reCaptcha: + siteKey : + secret : atom_feed: path : # blank (default) uses feed.xml diff --git a/docs/_config.yml b/docs/_config.yml index 247b7744..544c4adb 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -20,7 +20,7 @@ teaser : # path of fallback teaser image, e.g. "/assets/images # breadcrumbs : false # true, false (default) words_per_minute : 200 comments: - provider : "staticman" # false (default), "disqus", "discourse", "facebook", "google-plus", "staticman", "custom" + provider : "staticman_v2" # false (default), "disqus", "discourse", "facebook", "google-plus", "staticman", "staticman_v2" "custom" disqus: shortname : discourse: @@ -31,21 +31,25 @@ comments: num_posts : # 5 (default) colorscheme : # "light" (default), "dark" staticman: - allowedFields : ['name', 'email', 'url', 'message'] + allowedFields : # ['name', 'email', 'url', 'message'] branch : "master" - commitMessage : "New comment" - filename : comment-{@timestamp} - format : "yml" - moderation : true - path : "_data/comments/{options.slug}" - requiredFields : ['name', 'email', 'message'] + commitMessage : # "New comment" + filename : # comment-{@timestamp} + format : # "yml" + moderation : # true + path : # "_data/comments/{options.slug}" + requiredFields : # ['name', 'email', 'message'] transforms: - email : "md5" + email : # "md5" generatedFields: date: - type : "date" + type : # "date" options: - format : "iso8601" # "iso8601" (default), "timestamp-seconds", "timestamp-milliseconds" + format : # "iso8601" (default), "timestamp-seconds", "timestamp-milliseconds" +reCaptcha: + siteKey : "6LdRBykTAAAAAFB46MnIu6ixuxwu9W1ihFF8G60Q" + secret : "PznnZGu3P6eTHRPLORniSq+J61YEf+A9zmColXDM5icqF49gbunH51B8+h+i2IvewpuxtA9TFoK68TuhUp/X3YKmmqhXasegHYabY50fqF9nJh9npWNhvITdkQHeaOqnFXUIwxfiEeUt49Yoa2waRR7a5LdRAP3SVM8hz0KIBT4=" + atom_feed: path : # blank (default) uses feed.xml diff --git a/docs/_includes/comments-providers/staticman_v2.html b/docs/_includes/comments-providers/staticman_v2.html new file mode 100644 index 00000000..471fa867 --- /dev/null +++ b/docs/_includes/comments-providers/staticman_v2.html @@ -0,0 +1,42 @@ +{% if site.repository and site.staticman.branch %} + +{% endif %} \ No newline at end of file diff --git a/docs/_includes/comments.html b/docs/_includes/comments.html index 332374ee..a2bd2dbf 100644 --- a/docs/_includes/comments.html +++ b/docs/_includes/comments.html @@ -91,6 +91,78 @@ {% endif %} + {% when "staticman_v2" %} +
+ {% if site.repository and site.staticman.branch %} + +
+ {% if site.data.comments[page.slug] %} +

{{ site.data.ui-text[site.locale].comments_title | default: "Comments" }}

+ {% assign comments = site.data.comments[page.slug] | sort %} + + {% for comment in comments %} + {% assign email = comment[1].email %} + {% assign name = comment[1].name %} + {% assign url = comment[1].url %} + {% assign date = comment[1].date %} + {% assign message = comment[1].message %} + {% include comment.html index=forloop.index email=email name=name url=url date=date message=message %} + {% endfor %} + {% endif %} +
+ + + +
+

{{ site.data.ui-text[site.locale].comments_label | default: "Leave a Comment" }}

+

{{ site.data.ui-text[site.locale].comment_form_info | default: "Your email address will not be published. Required fields are marked" }} *

+
+
+ + {{ site.data.ui-text[site.locale].loading_label | default: "Loading..." }} +
+ +
+ + + +
+
+ + +
+
+ + +
+
+ + +
+ + + + +
+
+
+
+ +
+
+
+ + {% if site.reCaptcha.siteKey %}{% endif %} + {% endif %} +
{% when "custom" %}
{% endcase %} diff --git a/staticfile.yml b/staticfile.yml new file mode 100644 index 00000000..3c90df2a --- /dev/null +++ b/staticfile.yml @@ -0,0 +1,104 @@ +# Name of the property. You can have multiple properties with completely +# different config blocks for different sections of your site. +# For example, you can have one property to handle comment submission and +# another one to handle posts. +# To encrypt strings use the following endpoint: +# https://api.staticman.net/v2/encrypt/{TEXT TO BE ENCRYPTED} + +comments: + # (*) REQUIRED + # + # Names of the fields the form is allowed to submit. If a field that is + # not here is part of the request, an error will be thrown. + allowedFields: ["name", "email", "url", "message"] + + # (*) REQUIRED WHEN USING NOTIFICATIONS + # + # When allowedOrigins is defined, only requests sent from one of the domains + # listed will be accepted. The origin is sent as part as the `options` object + # (e.g.