This patch adds support for online commenting. A new template
``com_form.html`` to customize the commenting form is added. Online
commenting is only available if ``enable_comments`` is True, and you need
to let the web server write to the ``comments_path`` directory.
Note that this patch exposes the race in the CommentDB.save() method
(described in the previous commit), but since this event is unlikely
enough, we don't care at the moment and can be fixed later if needed.
This patch implements the basics for comments support. Two new classes are
added: Comment and CommentDB.
Comments are stored in almost the same format as articles, but a comment DB is
present for each article. All comments are stored in the ``comments_path``
directory (which usually won't be the same as the ``data_path`` because,
when online comment posting is implemented, it will need to be writeable by
the web server). Each article should have a subdirectory in that path (with
the article's uuid as directory name), where a ``db`` file is expected, with
this format::
comment number, creation time (epoch)
Comments are numbered incrementally and this number is considered both the
ID and the filename where the comment contents are stored under the
article's comments directory. An empty line in the comments DB represents
a deleted comment.
Comment files have a similar format to Article files, a header is expected
in the form of key, values:
Author: Leandro Lucarella Link: http://www.example.com/
Headers end with an empty line, where the body begin, in RestructuredText
format. The link can be any URL (for example, mailto:pomelo@example.com).
A new attribute ``comments`` is added to Article class, with a list of
comments for that article (loaded via the CommentDB class).
Note that a race is possible if more than one process add a comment at the
same time, because of how the CommentDB.save() method is implemented (the
same happens with ArticleDB.save(), but it's more likely that 2 comments
are added at the same, for example when online commenting is implemented).