]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/comments.mdwn
d56de44661d090ba16165c0b2aa2aba1d5ec34a1
[ikiwiki.git] / doc / plugins / contrib / comments.mdwn
1 [[!template id=plugin name=comments author="[[Simon_McVittie|smcv]]"]]
2 [[!tag type/useful]]
3
4 This plugin adds "blog-style" comments. The intention is that on a non-wiki site
5 (like a blog) you can lock all pages for admin-only access, then allow otherwise
6 unprivileged (or perhaps even anonymous) users to comment on posts.
7
8 Comments are saved as internal pages, so they can never be edited through the CGI,
9 only by direct committers. Currently, comments are always in [[ikiwiki/markdown]].
10
11 > So, why do it this way, instead of using regular wiki pages in a
12 > namespace, such as `$page/comments/*`? Then you could use [[plugins/lockedit]] to
13 > limit editing of comments in more powerful ways. --[[Joey]]
14
15 >> Er... I suppose so. I'd assumed that these pages ought to only exist as inlines
16 >> rather than as individual pages (same reasoning as aggregated posts), though.
17 >>
18 >> lockedit is actually somewhat insufficient, since `check_canedit()`
19 >> doesn't distinguish between creation and editing; I'd have to continue to use
20 >> some sort of odd hack to allow creation but not editing.
21 >>
22 >> I also can't think of any circumstance where you'd want a user other than
23 >> admins (~= git committers) and possibly the commenter (who we can't check for
24 >> at the moment anyway, I don't think?) to be able to edit comments - I think
25 >> user expectations for something that looks like ordinary blog comments are
26 >> likely to include "others can't put words into my mouth".
27 >>
28 >> My other objection to using a namespace is that I'm not particularly happy about
29 >> plugins consuming arbitrary pieces of the wiki namespace - /discussion is bad
30 >> enough already. Indeed, this very page would accidentally get matched by rules
31 >> aiming to control comment-posting... :-) --[[smcv]]
32
33 When using this plugin, you should also enable [[htmlscrubber]] and either [[htmltidy]]
34 or [[htmlbalance]]. Directives are filtered out by default, to avoid commenters slowing
35 down the wiki by causing time-consuming processing. As long as the recommended plugins
36 are enabled, comment authorship should hopefully be unforgeable by CGI users.
37
38 > I'm not sure that raw html should be a problem, as long as the
39 > htmlsanitizer and htmlbalanced plugins are enabled. I can see filtering
40 > out directives, as a special case. --[[Joey]]
41
42 >> Right, if I sanitize each post individually, with htmlscrubber and either htmltidy
43 >> or htmlbalance turned on, then there should be no way the user can forge a comment;
44 >> I was initially wary of allowing meta directives, but I think those are OK, as long
45 >> as the comment template puts the \[[!meta author]] at the *end*. Disallowing
46 >> directives is more a way to avoid commenters causing expensive processing than
47 >> anything else, at this point.
48 >>
49 >> I've rebased the plugin on master, made it sanitize individual posts' content
50 >> and removed the option to disallow raw HTML. --[[smcv]]
51
52 When comments have been enabled generally, you still need to mark which pages
53 can have comments, by including the `\[[!comments]]` directive in them. By default,
54 this directive expands to a "post a comment" link plus an `\[[!inline]]` with
55 the comments.
56
57 > I don't like this, because it's hard to explain to someone why they have
58 > to insert this into every post to their blog. Seems that the model used
59 > for discussion pages could work -- if comments are enabled, automatically
60 > add the comment posting form and comments to the end of each page.
61 > --[[Joey]]
62
63 >> I don't think I'd want comments on *every* page (particularly, not the
64 >> front page). Perhaps a pagespec in the setup file, where the default is "*"?
65 >> Then control freaks like me could use "link(tags/comments)" and tag pages
66 >> as allowing comments.
67 >>
68 >> The model used for discussion pages does require patching the existing
69 >> page template, which I was trying to avoid - I'm not convinced that having
70 >> every possible feature hard-coded there really scales (and obviously it's
71 >> rather annoying while this plugin is on a branch). --[[smcv]]
72
73 The plugin adds a new [[ikiwiki/PageSpec]] match type, `postcomment`, for use
74 with `anonok_pagespec` from the [[plugins/anonok]] plugin or `locked_pages` from
75 the [[plugins/lockedit]] plugin. Typical usage would be something like:
76
77     locked_pages => "!postcomment(*)"
78
79 to allow non-admin users to comment on pages, but not edit anything. You can also do
80
81     anonok_pages => "postcomment(*)"
82
83 to allow anonymous comments (the IP address will be used as the "author").
84
85 > This is still called postcomment, although I've renamed the rest of the plugin
86 > to comments as suggested on #ikiwiki --[[smcv]]
87
88 Optional parameters to the comments directive:
89
90 * `commit=no`: by default, comments are committed to version control. Use this to
91   disable commits.
92 * `allowdirectives=yes`: by default, IkiWiki directives are filtered out. Use this
93   to allow directives (avoid enabling any [[plugins/type/slow]] directives if you
94   do this).
95 * `closed=yes`: use this to prevent new comments while still displaying existing ones.
96 * `atom`, `rss`, `feeds`, `feedshow`, `timeformat`, `feedonly`: the same as for [[plugins/inline]]
97
98 This plugin aims to close the [[todo]] item "[[todo/supporting_comments_via_disussion_pages]]",
99 and is currently available from [[smcv]]'s git repository on git.pseudorandom.co.uk (it's the
100 `postcomment` branch). A demo wiki with the plugin enabled is running at
101 <http://www.pseudorandom.co.uk/2008/ikiwiki/demo/>.
102
103 Known issues:
104
105 * Needs code review
106 * The access control via postcomment() is rather strange
107 * There is some common code cargo-culted from other plugins (notably inline and editpage) which
108   should probably be shared
109 * If the comments directive is removed from a page, comments can still be made on that page,
110   and will be committed but not displayed; to disable comments properly you have to set the
111   closed="yes" directive parameter (and refresh the wiki), *then* remove the directive if
112   desired
113
114 > I haven't done a detailed code review, but I will say I'm pleased you
115 > avoided re-implementing inline! --[[Joey]]