Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested comments with Reply to support. #35

Closed
vg opened this issue Oct 9, 2016 · 17 comments
Closed

Nested comments with Reply to support. #35

vg opened this issue Oct 9, 2016 · 17 comments

Comments

@vg
Copy link

@vg vg commented Oct 9, 2016

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.

@eduardoboucas
Copy link
Owner

@eduardoboucas eduardoboucas commented Oct 9, 2016

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.

@eduardoboucas
Copy link
Owner

@eduardoboucas eduardoboucas commented Oct 12, 2016

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.

@mmistakes
Copy link

@mmistakes mmistakes commented Oct 12, 2016

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.

@zburgermeiszter
Copy link
Contributor

@zburgermeiszter zburgermeiszter commented Oct 13, 2016

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

@eduardoboucas
Copy link
Owner

@eduardoboucas eduardoboucas commented Oct 13, 2016

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

@zburgermeiszter
Copy link
Contributor

@zburgermeiszter zburgermeiszter commented Oct 13, 2016

Seems good.

@eduardoboucas
Copy link
Owner

@eduardoboucas eduardoboucas commented Oct 14, 2016

@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.

@mmistakes
Copy link

@mmistakes mmistakes commented Oct 14, 2016

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

@eduardoboucas
Copy link
Owner

@eduardoboucas eduardoboucas commented Oct 15, 2016

🎉

img_0777 1

@vg
Copy link
Author

@vg vg commented Oct 15, 2016

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.

@vg
Copy link
Author

@vg vg commented Oct 15, 2016

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.

@eduardoboucas
Copy link
Owner

@eduardoboucas eduardoboucas commented Oct 15, 2016

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.

@zburgermeiszter
Copy link
Contributor

@zburgermeiszter zburgermeiszter commented Oct 16, 2016

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

@zburgermeiszter
Copy link
Contributor

@zburgermeiszter zburgermeiszter commented Oct 24, 2016

@zburgermeiszter
Copy link
Contributor

@zburgermeiszter zburgermeiszter commented Oct 25, 2016

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.

@zburgermeiszter
Copy link
Contributor

@zburgermeiszter zburgermeiszter commented Oct 25, 2016

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.

@eduardoboucas
Copy link
Owner

@eduardoboucas eduardoboucas commented Nov 25, 2016

Closing in favour of #42.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.