Practical Extensions for MediaWiki
Introduction
MediaWiki has extensions that add interesting functionality. The only downside of these extensions is that they can become obsolete with version changes. It’s up to you to decide…however, some are only used occasionally.
Extensions
SpecialRenameuser.php
This extension is provided in Debian repositories, so I recommend installing it with apt. Otherwise, it’s available here. Then you just need to link it:
|
|
Now, if you go to the Special pages, you’ll have the ability to rename a user.
DeleteHistory
I developed this extension (DeleteHistory) myself. It allows you to delete the history of your articles. Besides leaving some traces (passwords, confidential information…), you might wonder why not keep the history.
I had the idea to create it because I previously used SpecialDeleteOldRevisions, but the developer wasn’t reactive enough for my taste to update his extension and make it work everywhere. Moreover, he developed the entire deletion part himself, which certainly has advantages, but also a major disadvantage: it’s not maintained by the MediaWiki team, and if changes to the database happen during an upgrade, the extension must be modified to accommodate these changes.
For my extension, I simply opted for a maintenance script provided by MediaWiki, which removes the problem mentioned above and allows me to be compatible with many different versions.
Depending on your wiki’s purpose, this may or may not be important. But for mine, it’s not very important!
This extension is available here. For those of you who are less interested, let me give you some numbers to consider. In one year of wiki usage, my database was 14 MB. With this extension that removes histories, I was able to reduce it to 4.8 MB. You can see the gain you can achieve by removing histories!
Google Ads
For Google Adsense, you must first create an account and then generate ad banners of your desired size.
Without skin modification
You need to install the PCR GUI Inserts module which will allow you to insert information at various places on your pages. First, activate the extension by adding these lines:
|
|
Bottom section
Here are the lines to add to have a bottom section with Google ads:
|
|
With skin modification
The disadvantage of this method is that when you update MediaWiki, these modifications are likely to be overwritten. You will then have to redo the configuration. Opt for the manual method if you want to be worry-free.
Monobook
Bottom section
Insert these lines in the file mediawiki/skins/Monobook.php:
|
|
To be added below:
|
|
Left section
|
|
And place it above this section:
|
|
Vector
Bottom section
Insert these lines in the file mediawiki/skins/Vector.php:
|
|
To add in this section:
|
|
Left section
Insert these lines in the file mediawiki/skins/Vector.php:
|
|
To add in this section:
|
|
Google Search
Without skin modification
I created an extension that doesn’t require modifying the skin: https://www.mediawiki.org/wiki/Extension:GoogleSearch
All explanations are on the MediaWiki page and it’s very simple, so I won’t rewrite those lines.
With skin modification
Implementing Google search is very practical, as the basic search isn’t always the best. To have a small Google search at the bottom left of your menus, edit the file mediawiki/skins/Monobook.php. You need to place and adapt (obviously you need a Google Adsense account) this text:
|
|
To add below:
|
|
Google Reader
First activate the feeds you want, then add these lines to Monobook.php:
<div id="custom-advert" class ="portlet">
<h5>Watch list</h5>
<div class = "pBody">
<table border="0"><tr><td height="16" align="left">
<script type="text/javascript" src="http://www.google.fr/reader/ui/publisher-fr.js"></script>
<script type="text/javascript" src="http://www.google.fr/reader/public/javascript/user/00168335903816875978/state/com.google/starred?n=8&callback=GRC_p(%7Bc%3A%22blue%22%2Ct%3A%22%22%2Cs%3A%22false%22%2Cb%3A%22false%22%7D)%3Bnew%20GRC"></script>
</td></tr></table>
</div></div>
Adapt these lines to your needs. You need to place this between the two Google searches and you’re done :).
Google Analytics
For this plugin, I recommend first looking at the excellent documentation on the official MediaWiki site. There’s nothing to add :-)
Group Based Access Control
This extension is used to set up ACLs on MediaWiki. Which is very practical :-). Here’s the link:
https://www.mediawiki.org/wiki/Extension:Group_Based_Access_Control
In this example (to be placed on one of the pages):
<accesscontrol>Administrators,,IT-Department,,Sales(ro)</accesscontrol>
- Administrators and IT-Department have all rights
- Sales only has read rights
All of this is fine, but be careful with the search function. When I tried it, it wasn’t great.
Syntax Highlight GeSHi
To colorize your code and number it, use this extension:
https://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi
If you want to keep the dotted lines around your sources, as well as the gray color (just like a <syntaxhighlight lang=text></syntaxhighlight>
), here’s what you need to add to your MediaWiki:Common.css address (e.g., https://www.deimos.fr/mytechnotebook/index.php?title=MediaWiki:Common.css):
|
|
I am very satisfied with it. I’ll let you see how to do it on the link, as installation and configuration take only 2 minutes.
Setting default values
I have the annoying habit of always putting line=1 and start=0. But after a while, it gets annoying! That’s why there are default variables, and here are the ones I’ve modified:
|
|
If the changes aren’t visible right away, run the update.php maintenance script:
|
|
Piwik
Piwik is an equivalent to Google Analytics, but free. It allows you to have statistics of your website with nice graphs etc… There is a plugin to insert code into each page (necessary), but it’s obsolete and has security flaws. So we will use another module that will allow us to insert this type of code easily.
You need to install the PCR GUI Inserts module which will allow you to insert information at various places on your pages. Activate the extension first by adding these lines:
# PCR Extension for Piwik / Google Ads
require_once("$IP/extensions/pcr/pcr_guii.php");
Insert into MediaWiki’s configuration file:
|
|
UsabilityInitiative
This extension (UsabilityInitiative) allows you to activate many new features that came with MediaWiki version 1.16 and the Vector theme.
MediaWiki 1.16
Download the extension and place it in the extensions folder. Then, here are the lines I added to LocalSettings.php to have additional features:
|
|
As you can see, I activated the WikiEditor and the collapsible menu (Sidebar).
MediaWiki 1.17
In version 1.17, everything has been split up. So I use WikiEditor and Vector to get back the features I was interested in from version 1.16. Once installed in the extensions, activate everything:
|
|
Change the skins for all your users
Here’s a solution to change the skin of all users who are still on Monobook to Vector (the script is in the maintenance folder):
|
|
MobileDetect
MobileDetect is a simple solution to have a semblance of a version optimized for smartphones. This extension loads the “Chick” theme by default when the detected User Agent is a PDA/Smartphone. This solution is handy when you don’t want to set up a complex system to make the pages as well adapted as possible to portable devices.
Put the code in the “extensions” folder, then add this to your LocalSettings.php:
|
|
Your MediaWiki is ready for mobile devices :-)
DumpHTML
This extension is very practical because it allows you to dump your wiki in HTML format with images and everything else for offline use. Download the extension, then all you have to do is execute it with some optional parameters to get a good result. For my part, I made a script that dumps the wiki and compresses it. Here’s the script:
|
|
CharInsert
CharInsert is an extension that allows you to add a small bar in edit mode with the wiki code that we use most often or the one that is most difficult to find. The goal is to simplify page editing as much as possible.
Download and install the extension. Once done, you need to create the following page https://wiki.deimos.fr/mytechnotebook/index.php?title=MediaWiki:Edittools#
Insert the text you want with the <charinsert>+</charinsert>
tags, and put in the middle the code you want (use + so that your cursor automatically goes to this point after insertion):
<!-- Any text entered here will be displayed under the edit boxes or file upload forms. -->
<!-- Text here will be shown below edit and upload forms. -->
<!-- Please don't translate this page with sub pages (it will render support of that menu for your language very likely unmaintainable) -->
<div id="specialchars" class="my-buttons" style="margin-top:10px; border:1px solid #aaaaaa; padding:1px; text-align:center; font-size:110%;" title="Click on the wanted special character.">
<p class="specialbasic" id="Standard">
<charinsert>__TOC__</charinsert> ·
<charinsert>[[:Image:+|thumb|Name]]</charinsert> ·
<charinsert>[[:Media:+]]</charinsert> ·
<charinsert>[[:Image:+]]</charinsert> ·
<charinsert>[[Category:+]]</charinsert>
<br />
<charinsert><pre></charinsert> ·
<charinsert></pre></charinsert> ·
<charinsert><nowiki><syntaxhighlight lang=text></nowiki>+</charinsert> ·
<br />
<charinsert><nowiki>{{command|+|<syntaxhighlight lang=text></nowiki></charinsert> ·
<charinsert><nowiki>{{config|+|<syntaxhighlight lang=text></nowiki></charinsert> ·
</p>
</div>
Then, to make it visually clean, add this to the Commoncss (https://wiki.deimos.fr/mytechnotebook/index.php?title=MediaWiki:Common.css)
|
|
Now when editing an article, you will have your new toolbar.
Cite
The Cite extension allows you to have a references section. Until today, I managed it manually, but now I use this extension which allows me to make automatic links. It’s practical and beautiful. However, we can make it even more beautiful by editing the CSS:
|
|
Next, we’ll update a few fields:
On the MediaWiki:Cite_references_link_one page:
<li id="$1">[[#$2|?]] $3</li>
To be replaced by:
<li id="$1">[[#$2|^]] $3</li>
On the MediaWiki:Cite_references_link_many page:
<li id="$1">? $2 $3</li>
To be replaced by:
<li id="$1">^ $2 $3</li>
On the MediaWiki:Cite_references_link_many_format page:
[[#$1|<sup>$2</sup>]]
To be replaced by:
[[#$1|<sup>$3</sup>]]
Boilerplate
This is really the essential extension, it allows you to create a “template” page when creating a blank page. Needless to say, it’s very useful. Installation is very easy and explained on the https://www.mediawiki.org/wiki/Extension:Boilerplate site. Then, you just need to fill in your page that will serve as a template https://www.deimos.fr/mytechnotebook/index.php?title=Boilerplate.
MsUpload
I had been telling myself for a long time that I should find an extension that does multi-file uploads. And I’m very happy to have found one that’s well-made, pretty, and as usual simple to set up. It’s MsUpload. To install it, simply unzip the desired version into the extensions folder and add this to the LocalSettings file:
$wgMSU_ShowAutoKat = false; #autocategorisation
$wgMSU_CheckedAutoKat = false; #checkbox: checked = true/false
$wgMSU_debug = false;
require_once("$IP/extensions/MsUpload/msupload.php");
When editing, a blue bar will appear, and you can just drag and drop.
SphinxSearch
SphinxSearch replaces the basic search provided by MediaWiki, which is not fulltext. Explaining how to set this up here would be too long, so there is a dedicated article about it.
Last updated 02 Aug 2013, 15:04 CEST.