When adding custom sorting support, Article.__cmp__() was removed but
Article are still compared for equality by the command-line interface.
This commit adds Article.__eq__() to fix that.
Allow custom sorting when displaying several articles
A new form variable is accepted, "sort", to allow custom sorting when
several articles are rendered (default view, atom feed or list view).
The sort variable uses a very simple sort specification format:
[+-]?<field>?
Where "-" means reverse order, while "+" is regular, ascending, order.
Field specifies what article field will be used when sorting; title,
author, created, updated and uuid are accepted.
Both values are optional, and when one is omitted, a default will be used
according to the type of view being rendered.
Note: since "+" is used to encode " " in URLs, " " is accepted as an alias
for "+" to make easier to write URLs with sort specification manually.
A special string token (##POST_URL##) is recognized in post bodies and
replaced with the path to the post (URL-wise) in the rendered HTML. This
makes easier to have local resorces and makes links or use them as image
sources in posts.
This patch adds a post preview feature to see how a post is rendered without
adding it to the articles DB, using the URI /preview/post/ARTICLE_PATH (where
ARTICLE_PATH is the relative path to the article from the data path).
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).