]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/comments/discussion.mdwn
0e5c5e669a7e1059df8f123af512ec87893e8872
[ikiwiki.git] / doc / plugins / comments / discussion.mdwn
1 ## Syndication autodiscovery for comment feeds
2
3 A standard `\[[!inline]]` directive adds links to the autogenerated syndication feeds using link tags in the header:
4
5     <link rel="alternate" type="application/rss+xml" title="$title" href="$page.atom" />
6     <link rel="alternate" type="application/atom+xml" title="$title" href="$page.atom" />
7
8 These links aren't added to my pages that include comments even though comments generate syndication feeds.  How can I configure the comments plugin to add these links to the header?  (These links are required for user-agent autodiscovery of syndication feeds.) --[[anderbubble]]
9
10 ## Moderating comments from the CLI
11
12 How do you do this, without using the UI in the Preferences?
13
14 Please put this info on the page. Many thanks --[[Kai Hendry]]
15
16 ## Why internal pages? (unresolved)
17
18 Comments are saved as internal pages, so they can never be edited through the CGI,
19 only by direct committers.
20
21 > So, why do it this way, instead of using regular wiki pages in a
22 > namespace, such as `$page/comments/*`? Then you could use [[plugins/lockedit]] to
23 > limit editing of comments in more powerful ways. --[[Joey]]
24
25 >> Er... I suppose so. I'd assumed that these pages ought to only exist as inlines
26 >> rather than as individual pages (same reasoning as aggregated posts), though.
27 >>
28 >> lockedit is actually somewhat insufficient, since `check_canedit()`
29 >> doesn't distinguish between creation and editing; I'd have to continue to use
30 >> some sort of odd hack to allow creation but not editing.
31 >>
32 >> I also can't think of any circumstance where you'd want a user other than
33 >> admins (~= git committers) and possibly the commenter (who we can't check for
34 >> at the moment anyway, I don't think?) to be able to edit comments - I think
35 >> user expectations for something that looks like ordinary blog comments are
36 >> likely to include "others can't put words into my mouth".
37 >>
38 >> My other objection to using a namespace is that I'm not particularly happy about
39 >> plugins consuming arbitrary pieces of the wiki namespace - /discussion is bad
40 >> enough already. Indeed, this very page would accidentally get matched by rules
41 >> aiming to control comment-posting... :-) --[[smcv]]
42
43 >>> Thinking about it, perhaps one way to address this would be to have the suffix
44 >>> (e.g. whether commenting on Sandbox creates sandbox/comment1 or sandbox/c1 or
45 >>> what) be configurable by the wiki admin, in the same way that recentchanges has
46 >>> recentchangespage => 'recentchanges'? I'd like to see fewer hard-coded page
47 >>> names in general, really - it seems odd to me that shortcuts and smileys
48 >>> hard-code the name of the page to look at. Perhaps I could add
49 >>> discussionpage => 'discussion' too? --[[smcv]]
50
51 >>> (I've now implemented this in my branch. --[[smcv]])
52
53 >> The best reason to keep the pages internal seems to me to be that you
54 >> don't want the overhead of every comment spawning its own wiki page. --[[Joey]]
55
56 ## Formats (resolved)
57
58 The plugin now allows multiple comment formats while still using internal
59 pages; each comment is saved as a page containing one `\[[!comment]]` directive,
60 which has a superset of the functionality of [[ikiwiki/directives/format]].
61
62 ## Access control (unresolved?)
63
64 By the way, I think that who can post comments should be controllable by
65 the existing plugins opendiscussion, anonok, signinedit, and lockedit. Allowing
66 posting comments w/o any login, while a nice capability, can lead to
67 spam problems. So, use `check_canedit` as at least a first-level check?
68 --[[Joey]]
69
70 > This plugin already uses `check_canedit`, but that function doesn't have a concept
71 > of different actions. The hack I use is that when a user comments on, say, sandbox,
72 > I call `check_canedit` for the pseudo-page "sandbox[postcomment]". The
73 > special `postcomment(glob)` [[ikiwiki/pagespec]] returns true if the page ends with
74 > "[postcomment]" and the part before (e.g. sandbox) matches the glob. So, you can
75 > have postcomment(blog/*) or something. (Perhaps instead of taking a glob, postcomment
76 > should take a pagespec, so you can have postcomment(link(tags/commentable))?)
77 >
78 > This is why `anonok_pagespec => 'postcomment(*)'` and `locked_pages => '!postcomment(*)'`
79 > are necessary to allow anonymous and logged-in editing (respectively).
80 >
81 >> I changed that to move the flag out of the page name, and into a variable that the `match_postcomment`
82 >> function checks for. Other ugliness still applies. :-) --[[Joey]] 
83 >
84 > This is ugly - one alternative would be to add `check_permission()` that takes a
85 > page and a verb (create, edit, rename, remove and maybe comment are the ones I
86 > can think of so far), use that, and port the plugins you mentioned to use that
87 > API too. This plugin could either call `check_can("$page/comment1", 'create')` or
88 > call `check_can($page, 'comment')`.
89
90 > One odd effect of the code structure I've used is that we check for the ability to
91 > create the page before we actually know what page name we're going to use - when
92 > posting the comment I just increment a number until I reach an unused one - so
93 > either the code needs restructuring, or the permission check for 'create' would
94 > always be for 'comment1' and never 'comment123'. --[[smcv]]
95
96 >> Now resolved, in fact --[[smcv]]
97
98 > Another possibility is to just check for permission to edit (e.g.) `sandbox/comment1`.
99 > However, this makes the "comments can only be created, not edited" feature completely
100 > reliant on the fact that internal pages can't be edited. Perhaps there should be a
101 > `editable_pages` pagespec, defaulting to `'*'`? --[[smcv]]
102
103 ## comments directive vs global setting (resolved?)
104
105 When comments have been enabled generally, you still need to mark which pages
106 can have comments, by including the `\[[!comments]]` directive in them. By default,
107 this directive expands to a "post a comment" link plus an `\[[!inline]]` with
108 the comments. [This requirement has now been removed --[[smcv]]]
109
110 > I don't like this, because it's hard to explain to someone why they have
111 > to insert this into every post to their blog. Seems that the model used
112 > for discussion pages could work -- if comments are enabled, automatically
113 > add the comment posting form and comments to the end of each page.
114 > --[[Joey]]
115
116 >> I don't think I'd want comments on *every* page (particularly, not the
117 >> front page). Perhaps a pagespec in the setup file, where the default is "*"?
118 >> Then control freaks like me could use "link(tags/comments)" and tag pages
119 >> as allowing comments.
120 >>
121 >>> Yes, I think a pagespec is the way to go. --[[Joey]]
122
123 >>>> Implemented --[[smcv]]
124
125 >> 
126 >> The model used for discussion pages does require patching the existing
127 >> page template, which I was trying to avoid - I'm not convinced that having
128 >> every possible feature hard-coded there really scales (and obviously it's
129 >> rather annoying while this plugin is on a branch). --[[smcv]]
130
131 >>> Using the template would allow customising the html around the comments
132 >>> which seems like a good thing? --[[Joey]]
133
134 >>>> The \[[!comments]] directive is already template-friendly - it expands to
135 >>>> the contents of the template `comments_embed.tmpl`, possibly with the
136 >>>> result of an \[[!inline]] appended. I should change `comments_embed.tmpl`
137 >>>> so it uses a template variable `INLINE` for the inline result rather than
138 >>>> having the perl code concatenate it, which would allow a bit more
139 >>>> customization (whether the "post" link was before or after the inline).
140 >>>> Even if you want comments in page.tmpl, keeping the separate comments_embed.tmpl
141 >>>> and having a `COMMENTS` variable in page.tmpl might be the way forward,
142 >>>> since the smaller each templates is, the easier it will be for users
143 >>>> to maintain a patched set of templates. (I think so, anyway, based on what happens
144 >>>> with dpkg prompts in Debian packages with monolithic vs split
145 >>>> conffiles.) --[[smcv]]
146
147 >>>>> I've switched my branch to use page.tmpl instead; see what you think? --[[smcv]]
148
149 ## Raw HTML (resolved?)
150
151 Raw HTML was not initially allowed by default (this was configurable).
152
153 > I'm not sure that raw html should be a problem, as long as the
154 > htmlsanitizer and htmlbalanced plugins are enabled. I can see filtering
155 > out directives, as a special case. --[[Joey]]
156
157 >> Right, if I sanitize each post individually, with htmlscrubber and either htmltidy
158 >> or htmlbalance turned on, then there should be no way the user can forge a comment;
159 >> I was initially wary of allowing meta directives, but I think those are OK, as long
160 >> as the comment template puts the \[[!meta author]] at the *end*. Disallowing
161 >> directives is more a way to avoid commenters causing expensive processing than
162 >> anything else, at this point.
163 >>
164 >> I've rebased the plugin on master, made it sanitize individual posts' content
165 >> and removed the option to disallow raw HTML. Sanitizing individual posts before
166 >> they've been htmlized required me to preserve whitespace in the htmlbalance
167 >> plugin, so I did that. Alternatively, we could htmlize immediately and always
168 >> save out raw HTML? --[[smcv]]
169
170 >>> There might be some use cases for other directives, such as img, in
171 >>> comments.
172 >>> 
173 >>> I don't know if meta is "safe" (ie, guaranteed to be inexpensive and not
174 >>> allow users to do annoying things) or if it will continue to be in the
175 >>> future. Hard to predict really, all that can be said with certainty is
176 >>> all directives will contine to be inexpensive and safe enough that it's
177 >>> sensible to allow users to (ab)use them on open wikis.
178 >>> --[[Joey]]
179
180 ----
181
182 I have a test ikiwiki setup somewhere to investigate adopting the comments
183 plugin. It is setup with no auth enabled and I got hammered with a spam attack
184 over the last weekend (predictably).  What surprised me was the scale of the
185 attack: ikiwiki eventually triggered OOM and brought the box down. When I got
186 it back up, I checked out a copy of the underlying git repository, and it
187 measured 280M in size after being packed. Of that, about 300K was data prior
188 to the spam attack, so the rest was entirely spam text, compressed via git's
189 efficient delta compression.
190
191 I had two thoughts about possible improvements to the comments plugin in the
192 wake of this:
193
194  * comment pagination - there is a hard-to-define upper limit on the number
195    of comments that can be appended to a wiki page whilst the page remains
196    legible.  It would be useful if comments could be paginated into sub-pages.
197
198  * crude flood control - asides from spam attacks (and I am aware of
199    [[plugins/blogspam]]), people can crap flood or just aggressively flame
200    repeatedly. An interesting prevention measure might be to not let an IP
201    post more than 3 sequential comments to a page, or to the site, without
202    at least one other comment being interleaved. I say 3 rather than 2 since
203    correction follow-ups are common.
204
205 -- [[Jon]]
206
207
208 ---
209
210 ## Comment threads
211
212 Any thoughts about implementing some simple threading in the comments?
213
214 Or at least a reply functionality that quotes the subject/contents?
215
216 -- [[iustin]]
217
218 ---
219
220 ## Disabling certain formats for comments
221
222 It seems that comments plugin allows using all enabled formats and
223 there is not way to disable some of them. For my blog, I want to use
224 additional formats for writing posts but I do not want commenters to
225 use those formats because it would be a security problem.
226
227 Any suggestions or hints how to implement this?
228
229 -- [[wentasah]]
230
231 > I've implemented this. See [[todo/Restrict_formats_allowed_for_comments]].
232 > --[[wentasah]]
233
234 ## URLs in anonymous-style comments committed directly via VCS
235
236 [[!template id=gitbranch branch=schmonz/comments-anonymous-url-vcs author="[[schmonz]]"]]
237
238 I recently imported my site from Textpattern into ikiwiki (using
239 an `ikiwiki-import` program that may someday make its way into
240 ikiwiki proper). Textpattern's comments behave much like ikiwiki's
241 anonymous comments, so piping each imported comment through
242 `ikiwiki-comment` and regenerating the site with `comments_allowauthor=1`
243 preserved almost all the information.
244
245 What's missing: if a comment directive has a `url` param, I'd expect
246 the rendered page to href the author's name to that URL. This works
247 as I expect for new comments added via the CGI, but not for imported
248 comments added via the VCS directly.
249
250 My branch has a fix that doesn't break `t/comments.t`, doesn't
251 appear to break anonymous or signed-in comments via the CGI in any
252 way I've tried, and lets me render my (incredibly valuable ;-)
253 imported blog comments with full fidelity. OK to commit?