Mediawiki-extensions under Debian

From SaruWiki
Revision as of 21:19, 8 February 2009 by Saruman! (talk | contribs) (added non-debian extensions)
Jump to navigation Jump to search

Extensions for MediaWiki

The Debian mediawiki-extensions package

Under Debian 5.0 "Lenny", there exists a package named mediawiki-extensions that contains a number of useful extensions that you're quite likely to find useful. The included extensions are:

  • Cite -- add tags for citation purpose
  • GeSHi -- add tags for syntax highlighting
  • Inputbox -- add predefined HTML forms to wiki pages
  • NewestPages -- show the lsat pages added to the wiki
  • Poem -- add tags for poems
  • SpecialLastUserLogin -- special page to see a user last logins
  • ParserFunctions -- collection of parser functions
  • PageCSS -- parser hook to add per-page CSS
  • FootNote -- add footnote to your article
  • SpecialRenameuser -- special page to rename users
  • LdapAuthentication -- user authentication using LDAP
  • CategoryTree -- dynamic view of the wiki's category structure
  • ConfirmEdit -- very simple text Captcha
  • FancyCaptcha -- more comples image captchas (needs ConfirmEdit)

The installation of this package is, as usual, very straightforward. Run apt-get install mediawiki-extensions, or use aptitude to get this package installed.

After installation, the following directories get created:

/etc/mediawiki-extensions
     |-- extensions-available
     `-- extensions-enabled
/usr/share/mediawiki-extensions
           `-- maintenance
/var/lib/mediawiki/extensions/CategoryTree

Manually enabling or disabling Debian-packaged extensions

The way the package mediawiki-extensions is set up under Debian, means that all extensions themselves are installed in /usr/share/mediawiki-extensions. Furthermore, a symbolic link has been made to each individual extension in the directory /etc/mediawiki-extensions/extensions-available. However, the extensions are not yet "visible" to the Debian-configured MediaWiki. That's because the Debian-configured MediaWiki looks in /etc/mediawiki-extensions/extensions-enabled for all its extensions.

This means you can enable any one of them with just a little symbolic link in /etc/mediawiki-extensions/extensions-enabled, from which you only have to link back to /etc/mediawiki-extensions/extensions-available. Usually, this is accomplished by running a Debian-specific script:

mwenext <extension name>

In this call, the <extension name> is NOT how the extension is named in the MediaWiki special:version page, but the actual filename of the PHP-script, including its extension. E.g. mwenext NewestPages.php. Note that mwenext will not work when you've got WikiFarms, because per WikiFarm the extensions will be in another location. More on that however in the WikiFarm section.

Alternatively, you can manually create the symlink to the extension (i.e. from extensions-enabled to extensions-available):

cd /etc/mediawiki-extensions/extensions-enabled
ln -s ../extensions-available/<extension name>

Disabling is just as easy, with the dedicated script mwdisext <extension name> or by unlinking the corresponding symlink in /etc/mediawiki-extensions/extensions-enabled.

Manually adding non-Debian-packaged extensions

Now the advantage of the way the package mediawiki-extensions is set up under Debian, is that it has set up a whole structure for you to use, including population with some common extensions. Adding your own extensions (either the ones you wrote yourself, or the ones you download from the MediaWiki.org site) is pretty straightforward. Details however might differ if the extension needs its own configuration directories and what have you not. In the following, the simplest case is presented.

Install (unpack) all files of your new extension in /usr/share/mediawiki-extensions. For security, make sure no-one can write these files. Usually, we can make do by having all individual files of the extension owned by root:root, and setting the permissions to 644 (writable for user root, readable for everyone else).

If the extension needs to write data in some configuration directory, then we consider that data to be "configuration data", so the configuration directory should be somewhere under /etc/mediawiki-extensions. The directory should probably be writable by the web server daemon, so making www-data:www-data the owner, and modifying permissions to 755 would most probably be sufficient and safe. The extension itself will expect the configuration directory there where it sits itself, being /usr/share/mediawiki-extensions. If you create a symlink in that directory to your intended configuration directory, then all data the extension will write, will wind up in /etc as Debian intended it. As an example: you could put the configuration files for Group Permissions Manager in /etc/mediawiki-extensions/GroupPermissionsManager/config and create the symlink /usr/share/mediawiki-extensions/config to point there.

Note however, that multiple extensions can request a directory config, and thus all expect /usr/share/mediawiki-extensions/config. If this turns out to be the case, then the config directory might need to be (re)located in /etc/mediawiki-extensions/config. Extension-specific directories however can be stored in their own little subtree off of /etc/mediawiki-extensions.

Now to make the extension actually available, we need to create a symbolic link in /etc/mediawiki-extensions/extensions-available that points to the main PHP file of the extension over in /usr/share/mediawiki-extensions. As with the Debian-specific extensions, this makes them available, but not (yet) enabled. Enabling or disabling the extension is again just a matter of creating a symlink in /etc/mediawiki-extensions/extensions-enabled, just as with the Debian-specific extensions. Note that mwenext will take the name of any extension in /etc/mediawiki-extensions/extensions-available, not just the Debian-specific ones.