]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/comments.mdwn
rename plugins/contrib/postcomment.mdwn to plugins/contrib/comments.mdwn
[ikiwiki.git] / doc / plugins / contrib / comments.mdwn
1 [[!template id=plugin name=postcomment 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". --[[smcv]]
27
28 Directives and raw HTML are filtered out by default, and comment authorship should
29 hopefully be unforgeable by CGI users.
30
31 > I'm not sure that raw html should be a problem, as long as the
32 > htmlsanitizer and htmlbalanced plugins are enabled. I can see filtering
33 > out directives, as a special case. --[[Joey]]
34
35 >> Right, if I sanitize each post individually, with htmlscrubber and either htmltidy
36 >> or htmlbalance turned on, then there should be no way the user can forge a comment;
37 >> I was initially wary of allowing meta directives, but I think those are OK, as long
38 >> as the comment template puts the \[[!meta author]] at the *end*. Disallowing
39 >> directives is more a way to avoid commenters causing expensive processing than
40 >> anything else, at this point. --[[smcv]]
41
42 When comments have been enabled generally, you still need to mark which pages
43 can have comments, by including the `\[[!postcomment]]` directive in them. By default,
44 this directive expands to a "post a comment" link plus an `\[[!inline]]` with
45 the comments.
46
47 > I don't like this, because it's hard to explain to someone why they have
48 > to insert this into every post to their blog. Seems that the model used
49 > for discussion pages could work -- if comments are enabled, automatically
50 > add the comment posting form and comments to the end of each page.
51 > --[[Joey]]
52
53 >> I don't think I'd want comments on *every* page (particularly, not the
54 >> front page). Perhaps a pagespec in the setup file, where the default is "*"?
55 >> Then control freaks like me could use "link(tags/comments)" and tag pages
56 >> as allowing comments.
57 >>
58 >> The model used for discussion pages does require patching the existing
59 >> page template, which I was trying to avoid - I'm not convinced that having
60 >> every possible feature hard-coded there really scales (and obviously it's
61 >> rather annoying while this plugin is on a branch). --[[smcv]]
62
63 The plugin adds a new [[ikiwiki/PageSpec]] match type, `postcomment`, for use
64 with `anonok_pagespec` from the [[plugins/anonok]] plugin or `locked_pages` from
65 the [[plugins/lockedit]] plugin. Typical usage would be something like:
66
67     locked_pages => "!postcomment(*)"
68
69 to allow non-admin users to comment on pages, but not edit anything. You can also do
70
71     anonok_pages => "postcomment(*)"
72
73 to allow anonymous comments (the IP address will be used as the "author").
74
75 Optional parameters to the postcomment directive:
76
77 * `commit=no`: by default, comments are committed to version control. Use this to
78   disable commits.
79 * `allowhtml=yes`: by default, raw HTML is filtered out. Use this to allow HTML
80   (you should enable [[plugins/htmlscrubber]] and either [[plugins/htmltidy]] or
81   [[plugins/contrib/htmlbalance]] if you do this).
82 * `allowdirectives=yes`: by default, IkiWiki directives are filtered out. Use this
83   to allow directives (avoid enabling any [[plugins/type/slow]] directives if you
84   do this).
85 * `closed=yes`: use this to prevent new comments while still displaying existing ones.
86 * `atom`, `rss`, `feeds`, `feedshow`, `timeformat`, `feedonly`: the same as for [[plugins/inline]]
87
88 This plugin aims to close the [[todo]] item "[[todo/supporting_comments_via_disussion_pages]]",
89 and is currently available from [[smcv]]'s git repository on git.pseudorandom.co.uk.
90
91 Known issues:
92
93 * Needs code review
94 * The access control via postcomment() is rather strange
95 * There is some common code cargo-culted from other plugins (notably inline and editpage) which
96   should probably be shared
97 * If the postcomment directive is removed from a page, comments can still be made on that page,
98   and will be committed but not displayed; to disable comments properly you have to set the
99   closed="yes" directive parameter (and refresh the wiki), *then* remove the directive if
100   desired
101
102 > I haven't done a detailed code review, but I will say I'm pleased you
103 > avoided re-implementing inline! --[[Joey]]