1 ## Why internal pages? (unresolved)
3 Comments are saved as internal pages, so they can never be edited through the CGI,
4 only by direct committers.
6 > So, why do it this way, instead of using regular wiki pages in a
7 > namespace, such as `$page/comments/*`? Then you could use [[plugins/lockedit]] to
8 > limit editing of comments in more powerful ways. --[[Joey]]
10 >> Er... I suppose so. I'd assumed that these pages ought to only exist as inlines
11 >> rather than as individual pages (same reasoning as aggregated posts), though.
13 >> lockedit is actually somewhat insufficient, since `check_canedit()`
14 >> doesn't distinguish between creation and editing; I'd have to continue to use
15 >> some sort of odd hack to allow creation but not editing.
17 >> I also can't think of any circumstance where you'd want a user other than
18 >> admins (~= git committers) and possibly the commenter (who we can't check for
19 >> at the moment anyway, I don't think?) to be able to edit comments - I think
20 >> user expectations for something that looks like ordinary blog comments are
21 >> likely to include "others can't put words into my mouth".
23 >> My other objection to using a namespace is that I'm not particularly happy about
24 >> plugins consuming arbitrary pieces of the wiki namespace - /discussion is bad
25 >> enough already. Indeed, this very page would accidentally get matched by rules
26 >> aiming to control comment-posting... :-) --[[smcv]]
28 >>> Thinking about it, perhaps one way to address this would be to have the suffix
29 >>> (e.g. whether commenting on Sandbox creates sandbox/comment1 or sandbox/c1 or
30 >>> what) be configurable by the wiki admin, in the same way that recentchanges has
31 >>> recentchangespage => 'recentchanges'? I'd like to see fewer hard-coded page
32 >>> names in general, really - it seems odd to me that shortcuts and smileys
33 >>> hard-code the name of the page to look at. Perhaps I could add
34 >>> discussionpage => 'discussion' too? --[[smcv]]
36 >>> (I've now implemented this in my branch. --[[smcv]])
38 >> The best reason to keep the pages internal seems to me to be that you
39 >> don't want the overhead of every comment spawning its own wiki page. --[[Joey]]
43 The plugin now allows multiple comment formats while still using internal
44 pages; each comment is saved as a page containing one `\[[!comment]]` directive,
45 which has a superset of the functionality of [[ikiwiki/directives/format]].
47 ## Access control (unresolved?)
49 By the way, I think that who can post comments should be controllable by
50 the existing plugins opendiscussion, anonok, signinedit, and lockedit. Allowing
51 posting comments w/o any login, while a nice capability, can lead to
52 spam problems. So, use `check_canedit` as at least a first-level check?
55 > This plugin already uses `check_canedit`, but that function doesn't have a concept
56 > of different actions. The hack I use is that when a user comments on, say, sandbox,
57 > I call `check_canedit` for the pseudo-page "sandbox[postcomment]". The
58 > special `postcomment(glob)` [[ikiwiki/pagespec]] returns true if the page ends with
59 > "[postcomment]" and the part before (e.g. sandbox) matches the glob. So, you can
60 > have postcomment(blog/*) or something. (Perhaps instead of taking a glob, postcomment
61 > should take a pagespec, so you can have postcomment(link(tags/commentable))?)
63 > This is why `anonok_pagespec => 'postcomment(*)'` and `locked_pages => '!postcomment(*)'`
64 > are necessary to allow anonymous and logged-in editing (respectively).
66 >> I changed that to move the flag out of the page name, and into a variable that the `match_postcomment`
67 >> function checks for. Other ugliness still applies. :-) --[[Joey]]
69 > This is ugly - one alternative would be to add `check_permission()` that takes a
70 > page and a verb (create, edit, rename, remove and maybe comment are the ones I
71 > can think of so far), use that, and port the plugins you mentioned to use that
72 > API too. This plugin could either call `check_can("$page/comment1", 'create')` or
73 > call `check_can($page, 'comment')`.
75 > One odd effect of the code structure I've used is that we check for the ability to
76 > create the page before we actually know what page name we're going to use - when
77 > posting the comment I just increment a number until I reach an unused one - so
78 > either the code needs restructuring, or the permission check for 'create' would
79 > always be for 'comment1' and never 'comment123'. --[[smcv]]
81 >> Now resolved, in fact --[[smcv]]
83 > Another possibility is to just check for permission to edit (e.g.) `sandbox/comment1`.
84 > However, this makes the "comments can only be created, not edited" feature completely
85 > reliant on the fact that internal pages can't be edited. Perhaps there should be a
86 > `editable_pages` pagespec, defaulting to `'*'`? --[[smcv]]
88 ## comments directive vs global setting (resolved?)
90 When comments have been enabled generally, you still need to mark which pages
91 can have comments, by including the `\[[!comments]]` directive in them. By default,
92 this directive expands to a "post a comment" link plus an `\[[!inline]]` with
93 the comments. [This requirement has now been removed --[[smcv]]]
95 > I don't like this, because it's hard to explain to someone why they have
96 > to insert this into every post to their blog. Seems that the model used
97 > for discussion pages could work -- if comments are enabled, automatically
98 > add the comment posting form and comments to the end of each page.
101 >> I don't think I'd want comments on *every* page (particularly, not the
102 >> front page). Perhaps a pagespec in the setup file, where the default is "*"?
103 >> Then control freaks like me could use "link(tags/comments)" and tag pages
104 >> as allowing comments.
106 >>> Yes, I think a pagespec is the way to go. --[[Joey]]
108 >>>> Implemented --[[smcv]]
111 >> The model used for discussion pages does require patching the existing
112 >> page template, which I was trying to avoid - I'm not convinced that having
113 >> every possible feature hard-coded there really scales (and obviously it's
114 >> rather annoying while this plugin is on a branch). --[[smcv]]
116 >>> Using the template would allow customising the html around the comments
117 >>> which seems like a good thing? --[[Joey]]
119 >>>> The \[[!comments]] directive is already template-friendly - it expands to
120 >>>> the contents of the template `comments_embed.tmpl`, possibly with the
121 >>>> result of an \[[!inline]] appended. I should change `comments_embed.tmpl`
122 >>>> so it uses a template variable `INLINE` for the inline result rather than
123 >>>> having the perl code concatenate it, which would allow a bit more
124 >>>> customization (whether the "post" link was before or after the inline).
125 >>>> Even if you want comments in page.tmpl, keeping the separate comments_embed.tmpl
126 >>>> and having a `COMMENTS` variable in page.tmpl might be the way forward,
127 >>>> since the smaller each templates is, the easier it will be for users
128 >>>> to maintain a patched set of templates. (I think so, anyway, based on what happens
129 >>>> with dpkg prompts in Debian packages with monolithic vs split
130 >>>> conffiles.) --[[smcv]]
132 >>>>> I've switched my branch to use page.tmpl instead; see what you think? --[[smcv]]
134 ## Raw HTML (resolved?)
136 Raw HTML was not initially allowed by default (this was configurable).
138 > I'm not sure that raw html should be a problem, as long as the
139 > htmlsanitizer and htmlbalanced plugins are enabled. I can see filtering
140 > out directives, as a special case. --[[Joey]]
142 >> Right, if I sanitize each post individually, with htmlscrubber and either htmltidy
143 >> or htmlbalance turned on, then there should be no way the user can forge a comment;
144 >> I was initially wary of allowing meta directives, but I think those are OK, as long
145 >> as the comment template puts the \[[!meta author]] at the *end*. Disallowing
146 >> directives is more a way to avoid commenters causing expensive processing than
147 >> anything else, at this point.
149 >> I've rebased the plugin on master, made it sanitize individual posts' content
150 >> and removed the option to disallow raw HTML. Sanitizing individual posts before
151 >> they've been htmlized required me to preserve whitespace in the htmlbalance
152 >> plugin, so I did that. Alternatively, we could htmlize immediately and always
153 >> save out raw HTML? --[[smcv]]
155 >>> There might be some use cases for other directives, such as img, in
158 >>> I don't know if meta is "safe" (ie, guaranteed to be inexpensive and not
159 >>> allow users to do annoying things) or if it will continue to be in the
160 >>> future. Hard to predict really, all that can be said with certainty is
161 >>> all directives will contine to be inexpensive and safe enough that it's
162 >>> sensible to allow users to (ab)use them on open wikis.