Extension:Livelets
From MediaWiki.org
|
Livelets Release status: beta |
|
|---|---|
| Implementation | Parser functions, Ajax |
| Description | Use simple template-syntax to create live portlets that can update automatically when changed. |
| Author(s) | User:Nad |
| Version | 0.2.6 (2007-11-05) |
| MediaWiki | >1.6.0 |
| Download | no link |
| Added rights | LGPL |
The idea of this extension is to allow live articles to be transcluded which are loaded in a separate request using MediaWiki's ajax functionality. Later the ajax will also allow these embedded articles (which we call livelets) to be kept up to date automatically when they change. It uses parser-functions syntax to make it very similar in usage to normal templates.
Contents |
[edit] Installation
To install this extension, copy OrganicDesign:Livelets.php and save into your extensions directory or in a subdirectory thereof. The file then needs to be included in your LocalSettings.php file as usual.
[edit] Ajax
The Livelets extension can use Ajax technology to allow forms or links to work asyncronously (i.e. not involving a page reload). The content in the server's response can be directed to replace a particular portion of the page identified by it's id attribute. Livelets used to use the MooTools JavaScript framework for its Ajax functionality, but now it only requires the inbuilt MediaWiki Ajax functions. These must be enabled by setting $wgUseAjax to true in your LocalSettings.php file before the inclusion of Livelets as in the following example.
$wgUseAjax = true;
include("$IP/extensions/Livelets/Livelets.php");
- Note: Livelets ajax functionality requires a version of skins/common/ajax.js from at least MediaWiki 1.8.x.
[edit] Wait Image
You may also like to include a small animation which displays when very large live content is being retrieved so the user knows that something is happening. We use the following "daisy" image on our site, but any image will do. Save it as wait.gif in the livelets directory and ensure that it is accessible by the web server.
[edit] Current State & Usage
Currently the livelet only loads once using Ajax after the page content has loaded and is not dynamically kept up to date. It's used in a similar way to transcluding a template as follows:
{{#live:MyArticle}}
[edit] Uses
The OrganicDesign site uses a livelet in the sidebar to load the main tree which can be very large for some users and would cause the site to be sluggish if it had to load the whole tree for each new page request. Having the large content in a livelet speeds up the site in two ways, firstly the large content only starts loading after the main page is loaded and accessible. And secondly, because the large content is a separate request with its own static URL, it can be cached locally by the browser.
[edit] Live Updates Using SWF
| WARNING: the code or configuration described here poses a major security risk.
Problem: Vulnerable to Cross-site scripting attacks, because it passes user input directly to the browser. This may lead to user accounts being hijacked, among other things. |
The default installation of Livelets uses Ajax technology which is used by many extensions and by the MediaWiki code itself and is considered safe. The problem with ajax however, is that changes cannot propagate automatically from the server to the clients, the clients must poll the server at a regular interval to see if any changes have taken place. Using SWF technology allows a fully asynchronous connection to be established between the server and the clients making the system fully event driven without any regular polling involved. However this method raises some security concerns as outlined by the XSS alert template above.
The SWF functionality is not complete enough for use yet, but will require the following additional files to be installed into the livelet extension directory:
- livelets.pl
- livelets.swf - compiled from livelets.as using the Flashlets extension
[edit] Todo
- ajax polling of header for auto-updating
- perl/swf for asynchronous update (no polling)
[edit] Change log
- Version 0.2.6: Missing pagename parameter in AJAX request
- Version 0.2.5: Removed dependence on Mootools and no longer requires a separate javascript file

