1 [[!template id=plugin name=comments author="[[Simon_McVittie|smcv]]"]]
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.
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]].
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]]
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.
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.
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".
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]]
33 >> The best reason to keep the pages internal seems to me to be that you
34 >> don't want the overhead of every comment spawning its own wiki page.
35 >> The worst problem with it though is that you have to assume the pages
36 >> are mdwn (or `default_pageext`) and not support other formats. --[[Joey]]
38 When using this plugin, you should also enable [[htmlscrubber]] and either [[htmltidy]]
39 or [[htmlbalance]]. Directives are filtered out by default, to avoid commenters slowing
40 down the wiki by causing time-consuming processing. As long as the recommended plugins
41 are enabled, comment authorship should hopefully be unforgeable by CGI users.
43 > I'm not sure that raw html should be a problem, as long as the
44 > htmlsanitizer and htmlbalanced plugins are enabled. I can see filtering
45 > out directives, as a special case. --[[Joey]]
47 >> Right, if I sanitize each post individually, with htmlscrubber and either htmltidy
48 >> or htmlbalance turned on, then there should be no way the user can forge a comment;
49 >> I was initially wary of allowing meta directives, but I think those are OK, as long
50 >> as the comment template puts the \[[!meta author]] at the *end*. Disallowing
51 >> directives is more a way to avoid commenters causing expensive processing than
52 >> anything else, at this point.
54 >> I've rebased the plugin on master, made it sanitize individual posts' content
55 >> and removed the option to disallow raw HTML. --[[smcv]]
57 >> There might be some use cases for other directives, such as img, in
60 >> I don't know if meta is "safe" (ie, guaranteed to be inexpensive and not
61 >> allow users to do annoying things) or if it will continue to be in the
62 >> future. Hard to predict really, all that can be said with certainty is
63 >> all directives will contine to be inexpensive and safe enough that it's
64 >> sensible to allow users to (ab)use them on open wikis.
67 When comments have been enabled generally, you still need to mark which pages
68 can have comments, by including the `\[[!comments]]` directive in them. By default,
69 this directive expands to a "post a comment" link plus an `\[[!inline]]` with
72 > I don't like this, because it's hard to explain to someone why they have
73 > to insert this into every post to their blog. Seems that the model used
74 > for discussion pages could work -- if comments are enabled, automatically
75 > add the comment posting form and comments to the end of each page.
78 >> I don't think I'd want comments on *every* page (particularly, not the
79 >> front page). Perhaps a pagespec in the setup file, where the default is "*"?
80 >> Then control freaks like me could use "link(tags/comments)" and tag pages
81 >> as allowing comments.
83 >>> Yes, I think a pagespec is the way to go. --[[Joey]]
85 >> The model used for discussion pages does require patching the existing
86 >> page template, which I was trying to avoid - I'm not convinced that having
87 >> every possible feature hard-coded there really scales (and obviously it's
88 >> rather annoying while this plugin is on a branch). --[[smcv]]
90 >>> Using the template would allow customising the html around the comments
91 >>> which seems like a good thing?
93 The plugin adds a new [[ikiwiki/PageSpec]] match type, `postcomment`, for use
94 with `anonok_pagespec` from the [[plugins/anonok]] plugin or `locked_pages` from
95 the [[plugins/lockedit]] plugin. Typical usage would be something like:
97 locked_pages => "!postcomment(*)"
99 to allow non-admin users to comment on pages, but not edit anything. You can also do
101 anonok_pages => "postcomment(*)"
103 to allow anonymous comments (the IP address will be used as the "author").
105 > This is still called postcomment, although I've renamed the rest of the plugin
106 > to comments as suggested on #ikiwiki --[[smcv]]
108 Optional parameters to the comments directive:
110 * `commit=no`: by default, comments are committed to version control. Use this to
112 * `allowdirectives=yes`: by default, IkiWiki directives are filtered out. Use this
113 to allow directives (avoid enabling any [[plugins/type/slow]] directives if you
115 * `closed=yes`: use this to prevent new comments while still displaying existing ones.
116 * `atom`, `rss`, `feeds`, `feedshow`, `timeformat`, `feedonly`: the same as for [[plugins/inline]]
118 This plugin aims to close the [[todo]] item "[[todo/supporting_comments_via_disussion_pages]]",
119 and is currently available from [[smcv]]'s git repository on git.pseudorandom.co.uk (it's the
120 `postcomment` branch). A demo wiki with the plugin enabled is running at
121 <http://www.pseudorandom.co.uk/2008/ikiwiki/demo/>.
126 * The access control via postcomment() is rather strange
127 * There is some common code cargo-culted from other plugins (notably inline and editpage) which
128 should probably be shared
129 * If the comments directive is removed from a page, comments can still be made on that page,
130 and will be committed but not displayed; to disable comments properly you have to set the
131 closed="yes" directive parameter (and refresh the wiki), *then* remove the directive if
134 > I haven't done a detailed code review, but I will say I'm pleased you
135 > avoided re-implementing inline! --[[Joey]]