schnack.js is a (yet to be written) simple node app for disqus-like drop-in commenting on static. websites
This is not a new idea, so there are a few projects that are doing almost the same thing:
- CoralProject Talk - Node + MongoDB + Redis
- Discourse - Ruby on Rails + PostgreSQL + Redis
- Commento - Go + Node
Mostly because I think that all of the above projects are too complicated or written in a language I don't understand well enough to be able to maintain/hack the software.
Node + SQLite.
The app runs as a node server that provides a JS file to be dropped into any website.
<script src="//comments.yoursite.com/embed.js"
data-slug="post-slug"
data-target=".comment-section">
</script>
Users who want to submit a comment need to authenticate using Twitter or Facebook authentication API.
Comments are stored in a SQLite database. For a normal sized blog this should last a couple of decades.
- Ideally there's an admin web app that allows approving/blocking of users and approving/rejecting of comments.
- Each new comment triggers a push notification, within reasonable limits.
- If a user is approved, all of her comments are automatically approved. If a user is blocked, all of his comments are automatically rejected. Otherwise each comment needs to be approved/rejected manually.
Theoretically any website could include the embed.js
script. So the first thing the script will do is to load the existing comments from the Node app, which will only permit certain, configurable domains using CORS.
embed.js
- the script for rendering the comments on your websiteindex.js
- the node server serving the comments, handling new comment requests and rendering the admin backendcomments.db
- a sqlite database storing your comments + user tableconfig.json
- the file where you store API keys for twitter/facebook and the allowed domains
GET /embed.js
- return the script to render the comments and the comment entry formGET /comments/:slug.json
- delivers comments for a given slug as JSONGET /authenticate/(twitter/facebook/...)
- authenticate on third-party website (opens in a popup window or something)POST /comment/:slug
- submits a new comment for a given slug, form-encodedGET /admin
- the admin backend