|
пре 11 година | |
---|---|---|
.. | ||
Readme.md | пре 11 година | |
__init__.py | пре 11 година | |
pelican_comment_system.py | пре 11 година |
The pelican comment system allows you to add static comments to your articles. It also supports replies to comments.
The comments are stored in Markdown files. Each comment in it own file.
See it in action here: blog.scheirle.de
Thanks to jesrui the author of Static comments. I reused some code from it.
Activate the plugin by adding it you your pelicanconf.py
PLUGIN_PATH = '/path/to/pelican-plugins'
PLUGINS = ['pelican_comment_system']
PELICAN_COMMENT_SYSTEM = True
And modify your article.html
theme (see below).
Name | Type | Default | Description |
---|---|---|---|
PELICAN_COMMENT_SYSTEM |
boolean |
False |
Activates or deactivates the comment system |
PELICAN_COMMENT_SYSTEM_DIR |
string |
comments |
Folder where the comments are stored |
Every comment file has to be stored in a sub folder of PELICAN_COMMENT_SYSTEM_DIR
.
Sub folders are named after the slug
of the articles.
So the comments to your foo-bar
article are stored in comments/foo-bar/
The filenames of the comment files are up to you. But the filename is the Identifier of the comment (without extension).
.
└── comments
└── foo-bar
│ ├── 1.md
│ └── 0.md
└── some-other-slug
├── random-Name.md
├── 1.md
└── 0.md
Tag | Required | Description |
---|---|---|
date |
yes | Date when the comment was posted |
replyto |
no | Identifier of the parent comment. Identifier = Filename (without extension) |
locale_date |
forbidden | Will be overwritten with a locale representation of the date |
Every other (custom) tag gets parsed as well and will be available through the theme.
date: 2014-3-21 15:02
author: Author of the comment
website: http://authors.website.com
replyto: 7
anothermetatag: some random tag
Content of the comment.
In the article.html
theme file are now two more variables available.
Variables | Description |
---|---|
article.metadata.comments_count |
Amount of total comments for this article (including replies to comments) |
article.metadata.comments |
Array containing the top level comments for this article (no replies to comments) |
Variables | Description |
---|---|
id |
Identifier of this comment |
content |
Content of this comment |
metadata |
All metadata as in the comment file (or described above) |
replies |
Array containing the top level replies for this comment |
(only the comment section)
{% if article.metadata.comments %}
{% for comment in article.metadata.comments recursive %}
{% set metadata = comment.metadata %}
{% if loop.depth0 == 0 %}
{% set marginLeft = 0 %}
{% else %}
{% set marginLeft = 50 %}
{% endif %}
<article id="comment-{{comment.id}}" style="border: 1px solid #DDDDDD; padding: 5px 0px 0px 5px; margin: 0px -1px 5px {{marginLeft}}px;">
<a href="{{ SITEURL }}/{{ article.url }}#comment-{{comment.id}}" rel="bookmark" title="Permalink to this comment">Permalink</a>
<h4>{{ metadata['author'] }}</h4>
<p>Posted on <abbr class="published" title="{{ metadata['date'].isoformat() }}">{{ metadata['locale_date'] }}</abbr></p>
{{ comment.content }}
{% if comment.replies %}
{{ loop(comment.replies) }}
{% endif %}
</article>
{% endfor %}
{% else %}
<p>There are no comments yet.<p>
{% endif %}