Have been learning so much from your theme. Thank you for the hard work you have put into it - and for the excellent documentation.
Static man has added the possibility of a "subscription to comments" option via mailgun. eduardoboucas describes it here: https://github.com/eduardoboucas/staticman/issues/42#issuecomment-262938831
Basically it requires the staticman yml entries to be removed from the _config.yml file and placed in a dedicated staticman.yml.
How hard would it be to get this functionality to work with minimal-mistakes?
Thank you.
Great to hear that :smile:.
Adding support for comment reply notifications along with nested replies is on my radar, but I haven't figured out how I want to handle it yet. To use both of those there are some changes I'd need to manage as to not break support for those who don't upgrade to Staticman v2.
Essentially it comes down to moving all the Staticman configs out of _config.yml and into a staticman.yml file and changing the POST url in the comment form.
I've done both of these on my personal site and even wrote about all the changes. If you're interested that might be a good reference to start with until I can bake it into the theme officially.
You might want to take a look at @justinrummel's repo for inspiration since he's currently trying to use Staticman v2 features with Minimal Mistakes.
I'm really close now. Able to POST and display comments by integrating Staticman and Travis using v2. Now need to work on threaded replies.
My findings is patience is the key. And browser cache will give you false negatives.
Thank you @justinrummel and @mmistakes . Appreciate the suggestions. Will continue to investigate and work on this when the site is linked to a custom domain.
I've got it! Parent/child is now displaying correctly and using Staticman and Travis.
Next is Mailgun, but that feature is low priority.
Public Test URL: https://www.justinrummel.com/macworld-2010-pictures/
@justinrummel RE: working on pull request to add support for Staticman v2. Off the top of my head here's some thoughts/suggestions:
v1 Staticman implementationstaticman-v2comment.html and comments.html includes to reuse between v1 and v2... might be too much of a hassle since the way their for loops are constructed is widely different._includes/comment-providers/staticman.html with current form handling scripts or breakoff into main.min.js?If you do come up something or have a work in progress you want me to look at that's cool. Work off the develop branch as I checkout all new feature branches from there and it may have something not in master yet.
I was wondering about _includes/comment-providers/staticman.html. Using the GEM version I didn't pick up on that file till it was too late. Should be able to refactor and get something to develop after the weekend.
@justinrummel Sounds good. It might be possible with some clever {% if %} or {% unless %} conditionals in there to combine v1 and v2 support... but it might also turn into Liquid spaghetti.
See what you come up with. I'm cool with a comment-provider/staticman-v2.html if it makes things cleaner.
@mmistakes Did you find Mailgun to be slow in responses? I believe I have replicated the setup process, made a couple of test comments, but I'm not seeing anything on Mailgun indicating email notifications are working.
I use the public instance of Staticman. Never bothered setting up my own.
Greetings! As i recently started my own blog, i am very interested in the minimal mistakes theme (Hey, it's great!) and did not want to start unless i got the nested comments working. As i pulled some hair out i would like to protect others from lost hair, too. To make it easier in case someone also starts fresh, i have created a diff from a freshly forked minimal mistakes 4.4.1 including the changes i made to get statesman v2 with nested comments up and running. As the step by step guide is a bit lengthy, you can find it here: Minimal Mistakes: v4.4.1 with staticman v2 and nested comments.
It is far from perfect but got me up and running with my blog, staticman v2 and nested comments.
Regards,
Andreas
@andreasfaerber it seems that you have achieved the same level for comments as I have (example post w/ comments here). Just wish I had time to figure out mailgun to complete the setup.
Hello everyone,
I think I may have found the issue that caused mail notifications not to work by doing some staticman debugging with a local staticman instance. I have submitted a pull request to the staticman repository.
If my assumptions are correct and this is a fix then it should make all so far not working mail notifications working. My staticman test instance used a test mailgun account I have set up but that should also be working with the staticman account.
Let's see what Eduardo says after reviewing the pull request.
Regards,
Andreas
PS: That fix needs to make it's way to the official staticman site but I think that it'll be quite fast as the change is rather small.
@andreasfaerber this is excellent news. Waiting to hear if this solves the issue.
Yo! Eduardo merced the pull request and it worked for me right of the box with moderation: false. If you enabled moderation, then you need to add the web hook as per the staticman documentation, which then triggers the email upon merging the pull request via staticman. Without webhook and moderation enabled there will be no email as staticman is not notified of the merge.
Regards,
Andreas
@andreasfaerber the staticman webhook documentation specifies v1:
https://api.staticman.net/v1/webhook
Should I change it this way to get it to work:
https://api.staticman.net/v2/webhook
Sorry if this is too basic a question, but I've tried so many different combinations that my head is spinning.
@alec1 I believe we are still using v1. When trying to POST dummy data, v1 gives me an application error response while v2 is "Cannot POST"
justin@localhost ~> curl -X POST "https://api.staticman.net/v1/webhook" -d "test=true"
{"error":"No id found in the request"}
justin@localhost ~> curl -X POST "https://api.staticman.net/v2/webhook" -d "test=true"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /v2/webhook</pre>
</body>
</html>
Maybe some help when looking into my forked repo. I got it to work weeks before without any fixes to staticman. And with my own mailgun account. I did a lot trial and error testing, but finally I took the minimal-mistakes settings as basis and included the settings from made-mistakes.
Then I had to add an email.fromAddress which is only described in https://staticman.net/docs/api.
I've tested only one nesting level for possible replies to the comment. But so far it works.
Only one issue: When you have more than one parent comment and replying to one of them, don't merge the pull request and reply to another comment, the counting is mixed up. So when you merge all reply pull requests later, the will be attached to the wrong comment. This was the experience with my settup so far.
But thanks for the amazing work, @mmistakes, and all the folkes contributing.
@dev4223 For the reply stuff did you pull from my latest on the Made Mistakes repo? I haven't come across any order issues with replies, so just curious.
@mmistakes I've read your article https://mademistakes.com/articles/improving-jekyll-static-comments/ and gone through the files manually and then copy and pasted the described things to my forked minimal mistakes repo.
I remember I had 3 comments and then replied to the first one and then to the second one. Then I merged the pull requests and the order of the replies where mixed up. But maybe I have to do a test once more on this issue.
@dev4223 Let me know what you find. It should be fairly easy to spot if something is off by looking at the comment files produced in _data. If replying_to has the correct parent number then there shouldn't be a problem.
And since that field is only populated on a reply the order shouldn't matter since you can't really reply to a parent comment that hasn't been merged yet. Unless you're fudging the form data before submitting.
I'm seeing something similar on my jekyll-3.4.3 site as @dev4223 describes, replies grouped with the wrong main comment. This happens only when my web page is uploaded to github pages. In comments.html, it appears the assign statement extracts the main comments in reverse datecode order. (My comment files go by names like comment-1498195100613.yml). The inspect statement lists the newest comment first, not the oldest.
{% assign comments = site.data.comments[post_slug] | where_exp: "item", "item.replying_to == ''" %}
{{ comments | inspect }}
If I git-pull the comments from github pages down to my Mac and render my site, the interleaved comments and replies are correct.
site: http://spinningnumbers.org/a/charge.html
github: https://github.com/willymcallister/willymcallister.github.io/tree/master/_includes
@willymcallister That it works correctly building locally might be a sign that the gems are different. Perhaps a different version of Liquid than what GitHub is using with its pages gem is causing the difference?
The only site I have replies setup with is my personal which isn't built by GitHub Pages. Other than that looks like your comment code is slightly different from mine so that could be the issue too. Sorting out the loops and all the nuances of sort aren't all that straightforward. The YAML Front Matter inside o your comment files matters too (but at quick glance yours looks similar to mine).
My jekyll-staticman site when hosted at github had problems with the order of nested comments. To get nested comments to attach themselves to the proper main comment, I made these updates to my version of made-mistakes source files:
On the suggestion of GitHub support, I changed my Gemfile to use the github-pages gem instead of the jekyll gem.
#gem "jekyll", "3.4.0" << commented out this line
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
gem 'github-pages' << added this line
end
With this change, my local site and my github site both sorted nested comments incorrectly. The issue appears to be the way the "where_exp" produces its output object. At github-pages the where_exp result is in newest-to-oldest order, which messes up the association of comments and replies. To fix this I added two sort commands right after the where_exp statements.
In comments.html to sort the main comments:
{% assign comments = site.data.comments[post_slug] | where_exp: "item", "item.replying_to == ''" %}
{% assign comments_date = comments | sort: 'date' %} <<< Add this sort statement.
{% for comment in comments_date %} <<< Use the sorted main comments.
{% assign index = forloop.index %} ... etc.
And something similar in comment.html to sort the replies in oldest-to-newest order:
{% assign replies = site.data.comments[post_slug] | where_exp: 'item', 'item.replying_to == i' %}
{% assign replies_date = replies | sort: 'date' %}
{% for reply in replies_date %}
If the jekyll/liquid sort order at github-pages ever changes, these sort commands should continue to work, albeit in benign fashion.
Something happened recently, but the "message" section are no longer part of the files that are being saved to _data/comments/
Doing a POST to https://api.staticman.net/v2/entry/justinrummel/jr.com-mm/jr-branch/comments I get a 200 response. Below is the form field:
fields[message]: Test Comment to Axel
fields[name]: Me
fields[email]: [email protected]
options[origin]: http://localhost:4000/what-is-smime-email-and-why-should-i-be-using-it/
fields[replying_to]: 1
options[slug]: what-is-smime-email-and-why-should-i-be-using-it
options[reCaptcha][siteKey]: [removed on purpose]
options[reCaptcha][secret]: [removed on purpose]
fields[hidden]:
g-recaptcha-response: [removed on purpose]
However, the JSON response is as follows:
{"success":true,"fields":{"message":" ","name":"Me","email":"15eafca7e392482b2c2b6617afffdaaf","replying_to":"1","hidden":"","date":"2018-05-15T00:11:31.328Z","layout":"post"}}
I'm not sure what is happing to the fields[message] data in-between sending and Staticman returning the response.
Also setting the provider : "staticman_v2 doesn't seem to make a difference.
There is a known bug where strange fields show up in data files and other times some go missing.
It's a tough one to isolate which is why I don't think it's been fixed yet.
Here's the issue if you want to track it. https://github.com/eduardoboucas/staticman/issues/176
This issue has been automatically marked as stale because it has not had recent activity.
If this is a bug and you can still reproduce this error on the master branch, please reply with any additional information you have about it in order to keep the issue open.
If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.
This issue will automatically be closed in 7 days if no further activity occurs. Thank you for all your contributions.
Most helpful comment
Greetings! As i recently started my own blog, i am very interested in the minimal mistakes theme (Hey, it's great!) and did not want to start unless i got the nested comments working. As i pulled some hair out i would like to protect others from lost hair, too. To make it easier in case someone also starts fresh, i have created a diff from a freshly forked minimal mistakes 4.4.1 including the changes i made to get statesman v2 with nested comments up and running. As the step by step guide is a bit lengthy, you can find it here: Minimal Mistakes: v4.4.1 with staticman v2 and nested comments.
It is far from perfect but got me up and running with my blog, staticman v2 and nested comments.
Regards,
Andreas