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

Static comment injector #160

Closed
bbalet opened this Issue Dec 31, 2013 · 9 comments

Comments

Projects
None yet
4 participants
@bbalet

bbalet commented Dec 31, 2013

While many goes to disqus to add comments to their blogs, I prefer having a static comment generator for my static websites written with Jekyll. The pros:

  • Comments are included into the actual HTML content so they can improve it and have an impact on SEO.
  • I don't know if disqus will last long or if one day they will decide to inject unsolicited content via their comments widget.

The cons: many, but I don't care.

On this website [0] dedicated to golang, I implemented this approach with Jekyll. Here an example of a post with comments [1]. The workflow is as follow :

  • The visitor fills the comment form and struggle to understand what the hell is written into the recaptcha image.
  • After many unsuccessful tries the visitor either give up or manage to submit the comment by asking me to indulge myself in acts reproved by moral.
  • My Jekyll content includes a PHP script that prepares a file containing the comment and it sends me an e-mail notification with the comment file attached.
  • The comment filename starts by a UNIX timestamp (for sorting purposes). It contains a YAML field indicating to which post it is related to.
  • If I approve the comment, I copy it into a _comment folder and it will be merged to the content next time my website is generated.

What do you think about this enhancement request?

[0] http://decouvrir-golang.net/
[1] http://decouvrir-golang.net/golang/package/compress/gzip/compresser-les-reponses-http-golang.html

@dsthode

This comment has been minimized.

dsthode commented Dec 31, 2013

I've been thinking about that since I knew about Hugo when I saw it in HN last week. I have a site that doesn't fit Disqus comments for the same reasons, SEO and durability of their platform, so I started browsing the code to see how could a comments processor be included.

I thought of the following workflow, that somehow resembles your proposal:

  • The blog owner may enable the commenting facility with a global configuration item (say something like "comments: true")
  • The user is presented with a form and a captcha in the post page only if comments are enabled
  • The comment submission goes to Hugo where a process receives the data and finds the associated post comments file (something like "[post original file].comments") and appends it in YAML, TOML or JSON format, with one field "approved: false" if comments require approval (also globally configurable).
  • As the comments file is modified, the watcher process regenerates the page combining the post source file with the post comments file, attaching all the comments that have been approved.

I think that having the option to comment in Hugo is very beneficial, as it frees you to depend on any external platform, and the fact that at least two people have been thinking about that gives a light on the need of this feature.

@spf13

This comment has been minimized.

Contributor

spf13 commented Dec 31, 2013

As I think about it there are really 3 common dynamic functions that websites offer:

  1. Commenting (or general user input)
  2. Search
  3. Editing

Hugo already implements a relative high performance web server thanks to the great http serving functionality provided by the core go libraries.

I think we could easily provide each of these functionalities.

Contrasting the three:
Commenting (public write)
Search (read only)
Edit (private write)

I think the idea of adding a comment server is a good one, but I'm hopefully we can take a simpler approach than the one you describe with Jekyll. In some ways it's the most complicated one since it involves public writing.

Steps required for comments

  1. Provide an endpoint to take user input
  2. Validate the input
  3. Add it to the content repository (not necessarily git)
  4. Include this new content in a format that doesn't conflict with the authors associated content

I also think that this should be able to work independently of the server functionality. For instance I may want to serve pages statically, but have a single endpoint that is dynamic collecting input for comments, but me manually rebuild the site to include these content.

This also creates multimaster issues where writing can happen simultaneously in two places. The key here is to have additive user input where a conflict isn't possible.

@spf13

This comment has been minimized.

Contributor

spf13 commented Dec 31, 2013

I like this approach..

The blog owner may enable the commenting facility with a global configuration item (say something like "comments: true")

I agree

The user is presented with a form and a captcha in the post page only if comments are enabled

Should not be automatically added, but the responsibility of the template. We can provide a template that ships with Hugo that can be included in the single.html file as desired.

The comment submission goes to Hugo where a process receives the data and finds the associated post comments file (something like ".comments") and appends it in YAML, TOML or JSON format, with one field "approved: false" if comments require approval (also globally configurable).

This makes sense to me. Append only file for easy conflict resolution.

As the comments file is modified, the watcher process regenerates the page combining the post source file with the post comments file, attaching all the comments that have been approved.

Somewhat makes sense, but how often is someone going to ssh into the server to approve a comment. Probably better here is email that a comment happened with a random hash associated with it. Then provide an endpoint with that unique and obscure url that permits the author to approve or reject. Something like spf13.com/_/comment/5550c4148e91f5b1cdc4a552b6ece42caa4fc5e8

Overall I think this would be a great feature addition.

@dsthode

This comment has been minimized.

dsthode commented Dec 31, 2013

Should not be automatically added, but the responsibility of the template. We can provide a template that ships with Hugo that can be included in the single.html file as desired.

Yes, agree, I forgot to say that a new file should be added to the templates with the comment form that would be included to the generated page if comments are enabled.

Somewhat makes sense, but how often is someone going to ssh into the server to approve a comment. Probably better here is email that a comment happened with a random hash associated with it. Then provide an endpoint with that unique and obscure url that permits the author to approve or reject. Something like spf13.com/_/comment/5550c4148e91f5b1cdc4a552b6ece42caa4fc5e8

Ok, the email option is right, I was thinking on the blogger that starts the server with the watch feature on. But one thing I don't really like are the obscure URL to manage approval or rejection, at least not without some authorization procedure.

Somehow in the future a light admin view could be added, that gives the option to edit online and review and approve comments? Might be something separated from Hugo too.

@spf13

This comment has been minimized.

Contributor

spf13 commented Jan 1, 2014

I think let's start with the obscure urls (1 time use) which should be pretty secure. Can add admin down the road later.

@spf13

This comment has been minimized.

Contributor

spf13 commented Jan 15, 2014

Has anyone started on this? Should I create a fork for people to contribute to?

@dsthode

This comment has been minimized.

dsthode commented Jan 15, 2014

I'm sorry but I'm currently rather busy with some side projects, and I think I can't dedicate some time to it at least in a month.

@spf13

This comment has been minimized.

Contributor

spf13 commented Apr 8, 2014

I've started this as a stand alone project.

See more at http://github.com/spf13/kaiju

I would welcome any help on kaiju.

@michaelsync

This comment has been minimized.

michaelsync commented Oct 26, 2015

As this issue is a closed issue, I post my reply in hugo discussion forum http://discuss.gohugo.io/t/static-comment-for-hugo/1944

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment