Self hosted commenting system for blogs or other things.
- Self hosted.
- Backed by LevelDB.
- Support for multiple "namespaces".
- Realtime.
- No client side dependencies (except the one script ofc).
Tala is a self hosted comments platform for your static blog or whatever.
It's written in Node and it uses LevelDB as it's database.
There's also a WebSocket component that'll make comments appear in real time for everyone currently on the page.
There's is currently no executable or anything. So the easiest way for now is probably to clone the repo using git (or just downloding a tarball):
$ git clone git@github.com:simme/node-tala.git tala
$ cd tala
$ npm install
$ npm start
By default the server will listen on port 3000
You configure Tala by adding a config.json
file to the same directory as
tala.js
. In the future there'll be a possibility to change the path to the
configuration file.
The config may include the following keys:
- port, what port to run the HTTP server on.
- db, path to where the database will be stored.
- cors, array of domains that may use the server. Used to allow AJAX requests from the browser.
- spam, an object containing
apiKey
andblog
.apiKey
is your Akismet api key. More on spam below.
Tala currently uses Akismet to provide spam protection. This requires you to set up an account at akismet.com. There are free accounts available for those who have less then 80 000 comments per month.
You may choose to omit the spam
key from your config in which case no spam
protection will be done at all.
To add Tala to your blog you need to include the client code. This is best
done by adding this code to the bottom of your <body>
.
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "http://localhost:3000/js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else
window.onload = downloadJSAtOnload;
</script>
Remember to change the element.src
line to point to your Tala server.
What this will do is to wait for the document ready event before loading the comments. For more about this particular techinque you can read this blog post by Patrick Sexton.
You can of course just use a regular script tag and a src
-attribute if you
want to. But that will cause the loading of Tala to delay the loading of your
page. Since your comments probably are below the fold it's probably not super
smart to make your visitors wait!
Then you'll need to tell Tala where to put your comments. This is done by
adding an element, probably a div
with the class comments-wrapper
. You'll
also need to give this element the attribute data-id
. This is used to
separate comments for different articles. The value can be anything but it's
probably smartest to go with the slug of the article or something similar.
<div class="comments-wrapper" data-id="myBlog:/an/article/url"></div>
Read on for details on how to configure the client.
Tala uses a global (sorry) object to read your preferences. So what you do
is you add another <script>
tag to your page:
<script>
window.talaConfig = {
// settings go here
};
</script>
These options are mostly used for localization. The available optionas are:
- host, if your Tala server is on any other domain then your blog you need to enter the host here. Make sure you include your blog's domain in the cors option for the server.
- nameField, the label for the name field in the form.
- nameFieldPlaceholder, the placeholder for the name field in the form.
- emailField, the label for the email field.
- emailFieldPlaceholder, the placeholder for the email field.
- submitButton, the text on the comment submit button.
- commentPostError, text output on posting error.
- loadError, text output on comment loading error.
More options and configurability will come with age!
This project is very new and not well tested yet. It should, at least in theory, work in IE8+ and all the good browsers.
As for security not much has been done. It's currently possible to post to the server using any HTTP client available. Which can be done to fill up your server or whatever. There's spam protection from Akismet which should alleviate the problem a bit, but not completely.
There is also rudimentary XSS protection.
If you have any ideas on how to improve this specific part of Tala I'm all ears.
With this said, I'm labeling it 1.0 because I want to. Also, I'm leaving no guarantees or anything! :)
- Where does the name come from?
Tala means "to talk" in Swedish.
- Can I use one Tala server for many blogs?
YES you can. All you need to to is to namespace your data-id
attributes so
that Tala can keep your comments separated.
- May I contribute?
Hellz yeah! Just open a pull request for any fix/feature you want and we'll talk about it! ;)
This project is licensed under the MIT license.