~ubuntu-branches/ubuntu/utopic/python-django-threadedcomments/utopic

« back to all changes in this revision

Viewing changes to README.rst

  • Committer: Package Import Robot
  • Author(s): Bernhard Reiter, Bernhard Reiter, Jakub Wilk
  • Date: 2013-08-09 19:12:14 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130809191214-p8482p4e1ctekffq
Tags: 0.9.0-1
[ Bernhard Reiter ]
* New upstream release
* debian/compat: Bump to 9.
* debian/control, debian/copyright: Update upstream links. (Closes: #713930)
* debian/control: 
  - Remove python-textile, python-markdown, python-docutils from
    Build-Depends: and Suggests:
  - Bump debhelper Build-Depends to >= 9.
  - Bump Standards-Version to 3.9.4.
  - Add Suggests: python-django-south
* debian/copyright: s/BSD-new/BSD-3-clause/
* debian/docs, debian/doc-base: Update/remove to correspond with
  upstream sources.
* debian/patches/series, debian/patches/add_markup_deps_to_install,
  debian/patches/gravatar_default_url, debian/patches/django14:
  Remove patches, as obsolete.
* debian/rules: Add a SECRET_KEY for tests during building. (Closes: #711369)
* debian/NEWS.Debian: Add.

[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
django-threadedcomments
 
2
=======================
 
3
 
 
4
*threadedcomments* is a Django application which allows for the simple creation of a threaded commenting system.
 
5
Commenters can reply both to the original item, and reply to other comments as well.
 
6
 
 
7
The application is (as of 0.9) built on top of django.contrib.comments,
 
8
which allows it to be easily extended by other modules.
 
9
 
 
10
 
 
11
Installation
 
12
============
 
13
 
 
14
Install the package via pip::
 
15
 
 
16
    pip install django-threadedcomments
 
17
 
 
18
It's preferred to install the module in a virtual environment.
 
19
 
 
20
Configuration
 
21
-------------
 
22
 
 
23
Add the following to ``settings.py``::
 
24
 
 
25
    INSTALLED_APPS += (
 
26
        'threadedcomments',
 
27
        'django.contrib.comments',
 
28
    )
 
29
 
 
30
    COMMENTS_APP = 'threadedcomments'
 
31
 
 
32
By placing the ``threadedcomments`` app above the ``django.contrib.comments`` application,
 
33
the placeholder ``comments/list.html`` template will already be replaced by a threaded view.
 
34
 
 
35
Make sure django.contrib.comments_ is configured in ``urls.py``::
 
36
 
 
37
    urlpatterns += patterns('',
 
38
        url(r'^articles/comments/', include('django.contrib.comments.urls')),
 
39
    )
 
40
 
 
41
Provide a template that displays the comments for the ``object`` (e.g. article or blog entry)::
 
42
 
 
43
    {% load threadedcomments_tags %}
 
44
 
 
45
    ...
 
46
 
 
47
    <h2>Comments for {{ object.title }}:</h2>
 
48
 
 
49
    {% render_comment_list for object %}
 
50
    {% render_comment_form for object %}
 
51
 
 
52
 
 
53
Template design
 
54
---------------
 
55
 
 
56
Naturally, it's desirable to write your own version of ``comments/list.html`` in your project,
 
57
or use one of the ``comments/app/list.html`` or ``comments/app/model/list.html`` overrides.
 
58
 
 
59
Make sure to override ``comments/base.html`` as well, so the other views of django.contrib.comments_
 
60
are displayed using your web site design. The other templates of django.contrib.comments_ are
 
61
very plain as well on purpose (for example ``comments/posted.html``),
 
62
since these pages depend on the custom design of the web site.
 
63
 
 
64
See the provided ``example`` app for a basic configuration,
 
65
including a JavaScript-based reply form that moves to the comment the visitor replies to.
 
66
 
 
67
 
 
68
Template tags
 
69
=============
 
70
 
 
71
The ``threadedcomments_tags`` library is a drop-in replacement for the ``comments`` library
 
72
that is required for the plain comments. The tags are forwards compatible;
 
73
they support the same syntax as django.contrib.comments_ provides,
 
74
and they add a few extra parameters.
 
75
 
 
76
Fething comment counts::
 
77
 
 
78
    {% get_comment_count for [object] as [varname] %}
 
79
    {% get_comment_count for [object] as [varname] root_only %}
 
80
 
 
81
    {% get_comment_count for [app].[model] [id] as [varname] %}
 
82
    {% get_comment_count for [app].[model] [id] as [varname] root_only %}
 
83
 
 
84
Fetching the comments list::
 
85
 
 
86
    {% get_comment_list for [object] as [varname] %}
 
87
    {% get_comment_list for [object] as [varname] flat %}
 
88
    {% get_comment_list for [object] as [varname] root_only %}
 
89
 
 
90
Rendering the comments list::
 
91
 
 
92
    {% render_comment_list for [object] %}
 
93
    {% render_comment_list for [object] root_only %}
 
94
 
 
95
    {% render_comment_list for [app].[model] [id] %}
 
96
    {% render_comment_list for [app].[model] [id] root_only %}
 
97
 
 
98
Fetching the comment form::
 
99
 
 
100
    {% get_comment_form for [object] as [varname] %}
 
101
    {% get_comment_form for [object] as [varname] with [parent_id] %}
 
102
    {% get_comment_form for [app].[model] [id] as [varname] %}
 
103
    {% get_comment_form for [app].[model] [id] as [varname] with [parent_id] %}
 
104
 
 
105
Rendering the comment form::
 
106
 
 
107
    {% render_comment_form for [object] %}
 
108
    {% render_comment_form for [object] with [parent_id] %}
 
109
    {% render_comment_form for [app].[model] [id] %}
 
110
    {% render_comment_form for [app].[model] [id] with [parent_id] %}
 
111
 
 
112
Rendering the whole tree::
 
113
 
 
114
    {% for comment in comment_list|fill_tree|annotate_tree %}
 
115
        {% ifchanged comment.parent_id %}{% else %}</li>{% endifchanged %}
 
116
        {% if not comment.open and not comment.close %}</li>{% endif %}
 
117
        {% if comment.open %}<ul>{% endif %}
 
118
 
 
119
        <li id="c{{ comment.id }}">
 
120
            ...
 
121
        {% for close in comment.close %}</li></ul>{% endfor %}
 
122
    {% endfor %}
 
123
 
 
124
The ``fill_tree`` filter is required for pagination, it ensures that the parents of the first comment are included as well.
 
125
 
 
126
The ``annotate_tree`` filter adds the ``open`` and ``close`` properties to the comment.
 
127
 
 
128
 
 
129
Extending the module
 
130
====================
 
131
 
 
132
The application is built on top of the standard django.contrib.comments_ framework,
 
133
which supports various signals, and template overrides to customize the comments.
 
134
 
 
135
To customize django-threadedcomments, override the proper templates, or include the apps that provide the missing features.
 
136
Front-end editing support for example, is left out on purpose. It belongs to the domain of moderation, and policies
 
137
to know "who can do what". That deserves to be in a separate application, it shouldn't be in this application as it focuses on threading.
 
138
The same applies to social media logins, comment subscriptions, spam protection and Ajax posting.
 
139
 
 
140
Note that the standard framework also supports moderation, flagging, and RSS feeds too. More documentation can be found at:
 
141
 
 
142
* `Django's comments framework <https://docs.djangoproject.com/en/dev/ref/contrib/comments/>`_
 
143
* `Customizing the comments framework <http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/>`_
 
144
* `Example of using the in-built comments app <http://docs.djangoproject.com/en/dev/ref/contrib/comments/example/>`_
 
145
 
 
146
Some of the modules worth looking at are:
 
147
 
 
148
* django-comments-spamfighter_
 
149
* django-myrecaptcha_
 
150
* django-fluent-comments_
 
151
 
 
152
These modules can enhance the comments system even further.
 
153
 
 
154
 
 
155
.. _django.contrib.comments: https://docs.djangoproject.com/en/dev/ref/contrib/comments/
 
156
.. _django-fluent-comments: https://github.com/edoburu/django-fluent-comments/
 
157
.. _django-myrecaptcha: https://bitbucket.org/pelletier/django-myrecaptcha/
 
158
.. _django-comments-spamfighter: https://github.com/bartTC/django-comments-spamfighter/