Staticman: Nested comments with Reply to support.

Created on 9 Oct 2016  Â·  17Comments  Â·  Source: eduardoboucas/staticman

Please investigate how nested comments can be supported, so that commenters can reply to older comments.

I can think this can be achieved if each comment stores the id (timestamp) of its parent comment and itself.

feature request in development

Most helpful comment

I've added support for a new generated field of type uniqueId. When present, it will append a field with a unique id to the entry files:

_In the config:_

generatedFields:
  nameOfYourField: # you can call it whatever you want
    type: "uniqueId"

I've added this to the preview server. Submit your form to https://dev.staticman.net instead of https://api.staticman.net.

I believe this is all you need from the service itself to implement what you're after. You should be able to build the rest on your site, which should be something along the lines of:

  1. Add a field to allowedFields called something like parentId
  2. In your Liquid templates, cycle through comments that don't have a parentId field and render them (these are the main comments)
  3. For each of the above, cycle through the comments again and find any comments with a parentId that is equal to the id of the comment you were rendering (these are your replies)

As for the submit form, you need to build some sort of JavaScript routine that injects in the form a fields[parentId] field with the id of the comment you're replying to.

Does that make sense?

Let me know how you get on.

All 17 comments

I've added support for a new generated field of type uniqueId. When present, it will append a field with a unique id to the entry files:

_In the config:_

generatedFields:
  nameOfYourField: # you can call it whatever you want
    type: "uniqueId"

I've added this to the preview server. Submit your form to https://dev.staticman.net instead of https://api.staticman.net.

I believe this is all you need from the service itself to implement what you're after. You should be able to build the rest on your site, which should be something along the lines of:

  1. Add a field to allowedFields called something like parentId
  2. In your Liquid templates, cycle through comments that don't have a parentId field and render them (these are the main comments)
  3. For each of the above, cycle through the comments again and find any comments with a parentId that is equal to the id of the comment you were rendering (these are your replies)

As for the submit form, you need to build some sort of JavaScript routine that injects in the form a fields[parentId] field with the id of the comment you're replying to.

Does that make sense?

Let me know how you get on.

Been thinking about this and how best to achieve a useful reply system. I'd like to have an email notification system, so that you choose to be notified when someone replies to one of your comments.

The most obvious approach would be to use a database where we'd store subscriptions as a pair of comment id + email address. However, I'd really want Staticman to stay in a course of not storing any data whatsoever on its infrastructure.

I thought we could still use the site's repository to store this, by having a file that acts as the notifications db, where e-mail addresses would be encrypted (with the approach suggested by @zburgermeiszter on #20).

We could use the GitHub API to read and write to this file, effectively transforming it into a flat-file database.

Is this just a 💩 idea? Would love some thoughts.

Comment reply notifications are the one thing I've missed since going static. I like the flat-file database idea.

The uniqueId generated field looks very useful too, so thanks for that!. Will have to give that a go to implement comment replies on my sites.

You can use Mailchimp (Mandrill), or something else for sending email updates.
Usually these services are free up to few thusand emails per month.

Yeah, I found SparkPost, which offers 100,000 emails per month for free.

Seems good.

@mmistakes I'm changing this quite substantially to support comment replies and email notifications, so you might want to hold on implementing this.

For example, I'm removing the uniqueId transform and make it a field that is always added to entries.

Will share more details soon.

Thanks for the heads-up @eduardoboucas. I'll watch this space for future developments.

🎉

img_0777 1

I would recommend to have email address verifications, if you are serious about email notifications.
As, it is possible for me to fill in any valid and random email address while commenting. This would mean they would get email notifications. Also, you dont want to have your SparkPost API key blocked for spamming.

Also if you end up using the approach of using a public/private key pair as proposed by @zburgermeiszter in #20. You could have everyone get their own SparkPost API key and then send that in encrypted form to staticman API.

I would recommend to have email address verifications, if you are serious about email notifications.
As, it is possible for me to fill in any valid and random email address while commenting. This would mean they would get email notifications.

Receiving an email and clicking on a link to confirm that you're okay with receiving further emails seems like a very convoluted process for such a simple thing. I don't think I've ever seen something like this — can you find an example?

You could have everyone get their own SparkPost API key and then send that in encrypted form to staticman API.

I want to allow this possibility, at least in a future release, but I don't want to force it. Using SparkPost means configuring a domain, which some people might not have. I want to make it simple and accessible for everyone.

Plus, the 100k monthly limit offered by SparkPost should be enough for a while. If people want to make absolutely sure their emails will be sent, then they can supply their own API keys.

Or alternatively simply use OAuth only without allowing visitors to enter their name and email address.

It would be good to somehow handle the commenters as users for email notification purposes.
It would allow them to update their addresses in opposite to savind encrypted email address for each comment.

It is quite easy with the proposed OAuth login where the OAuth provider provides you with an ID.

It is related to this issue:
Do you plan to add RSS support for comments?
Some people prefer it instead of email, and it's possible to do a lot of magic with it.
For example you can set up an IFTTT event to send email when there's a new item on the list.

Closing in favour of #42.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joeczar picture joeczar  Â·  3Comments

mmistakes picture mmistakes  Â·  8Comments

onwingslikeeagles picture onwingslikeeagles  Â·  6Comments

jkbecker picture jkbecker  Â·  5Comments

PaulieScanlon picture PaulieScanlon  Â·  3Comments