From fdcaf16e2f588a0fbf6e765a8b40b9e5bf1998e1 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Wed, 10 Aug 2016 16:08:13 -0400 Subject: [PATCH] Add includes for static-based comments powered by Staticman - Configure Staticman with sane defaults - Build comment form to capture new comments and ajax data to Staticman - Build comments view that iterates over `_data/comments/post-slug/*.yml` files --- _config.yml | 11 +++- _includes/comment.html | 22 ++++++++ _includes/comments-providers/scripts.html | 2 + _includes/comments-providers/staticman.html | 52 +++++++++++++++++++ _includes/comments.html | 57 +++++++++++++++++++++ 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 _includes/comment.html create mode 100644 _includes/comments-providers/staticman.html diff --git a/_config.yml b/_config.yml index 242574ae..7f2915d1 100644 --- a/_config.yml +++ b/_config.yml @@ -18,7 +18,7 @@ teaser : # filename of teaser fallback teaser image placed in # breadcrumbs : false # true, false (default) words_per_minute : 200 comments: - provider : # false (default), "disqus", "discourse", "facebook", "google-plus", custom" + provider : "staticman" # false (default), "disqus", "discourse", "facebook", "google-plus", "staticman", "custom" disqus: shortname : # https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname- discourse: @@ -28,6 +28,15 @@ comments: appid : num_posts : # 5 (default) colorscheme : # "light" (default), "dark" +staticman: + allowedFields : ['name', 'email', 'url', 'message'] + branch : # "master", "gh-pages" + format : "yml" + moderation : true + path : "_data/comments/{options.slug}" + requiredFields : ['name', 'email', 'message'] + transforms: + email : "md5" atom_feed: path : # blank (default) uses feed.xml diff --git a/_includes/comment.html b/_includes/comment.html new file mode 100644 index 00000000..17e874a6 --- /dev/null +++ b/_includes/comment.html @@ -0,0 +1,22 @@ +
+
+ +
+
+

+ {% if (include.url) and (include.url != '@url') %} + {{ include.name }} + {% else %} + {{ include.name }} + {% endif %} +

+

+ {% if include.date %} + {% if include.index %}{% endif %} + + {% if include.index %}{% endif %} + {% endif %} +

+ {{ include.message | markdownify }} +
+
\ No newline at end of file diff --git a/_includes/comments-providers/scripts.html b/_includes/comments-providers/scripts.html index 0da90c5d..ed192f7e 100644 --- a/_includes/comments-providers/scripts.html +++ b/_includes/comments-providers/scripts.html @@ -9,6 +9,8 @@ {% include /comments-providers/facebook.html %} {% when "google-plus" %} {% include /comments-providers/google-plus.html %} +{% when "staticman" %} + {% include /comments-providers/staticman.html %} {% when "custom" %} {% include /comments-providers/custom.html %} {% endcase %} diff --git a/_includes/comments-providers/staticman.html b/_includes/comments-providers/staticman.html new file mode 100644 index 00000000..9f478888 --- /dev/null +++ b/_includes/comments-providers/staticman.html @@ -0,0 +1,52 @@ +{% if site.repository and site.staticman.branch %} + + + + + +{% endif %} \ No newline at end of file diff --git a/_includes/comments.html b/_includes/comments.html index a01af60f..e7685fce 100644 --- a/_includes/comments.html +++ b/_includes/comments.html @@ -9,6 +9,63 @@
{% when "google-plus" %}
Loading Google+ Comments ...
+ {% when "staticman" %} +
+ {% if site.repository and site.staticman.branch %} + +
+
+ + Loading... +
+ +
+ + +
+
+ + +
Your email address will remain private and won't be shared with anyone.
+
+
+ + +
+
+ + +
Markdown is supported.
+
+ +
+ +
+
+ + + +
+ {% 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 %} +
+ + {% endif %} +
{% when "custom" %}
{% endcase %}