MediaWiki extension: ArticleComments (extended)
ArticleComments Extension
| ArticleComments (extended) Release status: beta | |
|---|---|
| Type: | Parser function |
| Description: | Adds inline comment forms to regular Wiki articles. |
| Author: | Jim R. Wilson, Eric Hartwell |
| Version: | 0.5 (2007-04-18) |
| MediaWiki: | >= 1.6 |
| Download: | |
| Added rights: | The MIT License |
The ArticleComments Extension is a MediaWiki extension for adding inline comment forms to regular Wiki articles. It is released under The MIT License.
Once installed, you (or editors of your wiki) may add comment forms to any article. To do so, simply add this text to the body of your page where you'd like the comment form to appear:
<comments />
Anyone is able to leave comments, even if they're anonymous and anonymous users are blocked from editing.
Customization
The original extension code does no Wikitext or HTML filtering on the incoming text. While this is unlikely to cause security issues because the submitted text is rendered through the Wiki parser, it can lead to some ugly displays.
I want the comments to be posted as a compact, tidy list (looking like what may eventually be actual footnotes). The custom MediaWiki:Article-comments-new-comment page looks like this:
<includeonly> </includeonly> * <div class='commentBlock'><nowiki>$6</nowiki> -- $3 $4 $5</div>
- To simplify comment cleanup, I modified the code to add an extra parameter,
$6, which contains the coment content again, but with HTML special characters converted to HTML entities. - Enclosing the uploaded text with
<nowiki>$6</nowiki>tags ensures that the comment is displayed as plain text. - Enclosing the entire thing with a
<nowiki><div>...</div></nowiki>tag causes the comment to wrap onto a single line, regardless of the way it's typed. - The
<includeonly></includeonly>lines are there to force the result to start on a new line, so the leading*is interpreted as a list delimiter. (MediaWiki tends to "eat" single empty lines)
The variables are as follows:
- $1: Submitter said ...
- $2: Comment content
- $3: Username and link to Webpage (if provided)
- $4: Date and time of submission
I've added the following variables:
- $5: IP address of submission
- $6: Coment content, but with HTML special characters converted to HTML entities
Still to do
- More Usable Forms - Controlling Scroll Position
- Maintaining Scroll Position on Postback
- Reset the page scroll position after a PostBack
- Keep the scroll position of a DIV after postback
Technical Details
In addition to providing a parser hook for the <comments> tag, the ArticleComments Extension implements a SpecialPage which acts as the recipient of the submitted comment. Though this special page shows up in Special:Specialpages as Process Comment it is not meant to be accessed directly - only via a comment submission form.
Notice that the content is wrapped in a div of class 'commentBlock'. This is to aid styling via CSS.
Caveats and Gotchas
Looking at the comments left on [/wiki/index.php?title=Talk:ArticleComments_Test_Page Talk:ArticleComments Test Page], it's clear that some users expect to be able to omit the protocol on their Website URL. For example using jimbojw.com instead of http://jimbojw.com. As of version 0.3, the URL field is prefilled with "http://" to help visitors in specifying a website. However, the extensions should probably check for the existence of an accepted protocol and prepend "http://" if absent. This may be implemented in a future version.
Although it makes sense for the comment field to accept arbitrary wikitext (under most circumstances), it does not make sense to allow arbitrary input in the other fields: Name and Website. A future version should disallow arbitrary text by urlencoding the field values.