Jump to content

Extension:BoilerPlate

From mediawiki.org
MediaWiki extensions manual
BoilerPlate
Release status: stable
Implementation Example
Description Boilerplate code ready to be substituted to create a new extension with the latest standards and structure in place.
Author(s) Krinkletalk
MediaWiki 1.32+
License GNU General Public License 2.0 or later
Download
  • $wgBoilerPlateVandalizeEachPage
  • $wgBoilerPlateEnableFoo
Quarterly downloads 5 (Ranked 134th)
Translate the BoilerPlate extension if it is available at translatewiki.net

The BoilerPlate extension is a blank extension template. It doesn't really do anything on its own, but provides boilerplate code for an actual MediaWiki extension. It also implements MediaWiki's preferred test automation and continuous integration (see that section below).

You should base your own code on the BoilerPlate extension, but for more in-depth comments and learning you should go and examine the Examples extension.

Usage

[edit]

To use it, enter the following commands to make a clean directory of just the BoilerPlate source code without the Git meta-data and other examples. (Substitute your extension's name for MyExtension.)

cd extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/BoilerPlate.git
cp -r BoilerPlate ./MyExtension
rm -rf ./MyExtension/.git

Then in MyExtension:

  • rename BoilerPlate files to MyExtension.
  • change BoilerPlate variable names, preserving case (i.e. boilerPlatemyExtension).
  • replace "Your Name" in extension.json and i18n files with your name.
  • run git init (if you are going to use Git for version control)

Test automation and continuous integration

[edit]

The BoilerPlate extension implements the standard entry points for test automation, running various code checkers for you that test for errors and enforce part of the MediaWiki coding conventions.

If your extension is hosted on gerrit.wikimedia.org, you can request that Wikimedia's continuous integration machinery run these tests on each commit; see gerrit:226680.

Installation

[edit]

If you want to install this dummy extension on your wiki to see if it works or troubleshoot problems with your adaptation.

  • Download and move the extracted BoilerPlate folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/BoilerPlate
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'BoilerPlate' );
    
  • To verify if the extension is working add $wgBoilerPlateVandalizeEachPage = true; to your LocalSettings.php and check for "BoilerPlate was here" text on any page.
  • Follow the steps in its README to install testing dependencies, then run npm test and composer test.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Earlier MediaWiki releases

[edit]

If you want your extension to be compatible with earlier MediaWiki releases, consult the source code of release branches of the Examples extension.

See also

[edit]