Gadgets (wiki.gg)
Gadgets are pieces of JS and/or CSS code that wiki admins can install to enable additional wiki functionality. Gadgets not marked as hidden
can be toggled on or off per-user through Special:Preferences, allowing users to switch features on or off as they please. They can also be made opt-in or opt-out through the use (or not use) of the default
keyword, for features that won't apply or appeal to most users.
Defining a gadget
To define a gadget, starting with MediaWiki 1.43, create a subpage of MediaWiki:Gadgets (with an s), for example, MediaWiki:Gadgets/name-of-gadget . You should see the following default JSON code if you are at the right place:
{
"settings": {
"section": "",
"package": true,
"default": false,
"hidden": false,
"supportsUrlLoad": false
},
"loadConditions": {
"actions": [],
"categories": [],
"namespaces": [],
"contentModels": [],
"rights": []
},
"module": {
"pages": [],
"dependencies": [],
"peers": [],
"messages": [],
"type": "general"
}
}
In the "pages"
list, you will define subpages of the gadget definition. For example, if you create the gadget MediaWiki:Gadgets/example and then say the content will be at "main.js", then you can edit the content at MediaWiki:Gadgets/example/main.js .
When you save your gadget, you'll be able to click links to visit each of the subpages.
Interface message for preferences
The interface message for Special:Preferences is the only part of the gadget that will NOT be a subpage of MediaWiki:Gadgets/name-of-gadget
. For technical reasons, slashes are not permitted in interface messages, so this will still be edited at MediaWiki:Gadget-name-of-gadget
.
Case sensitivity
Please note that gadget names are case sensitive! MediaWiki:Gadgets/name-of-gadget
and MediaWiki:Gadgets/Name-of-gadget
are different from each other!
A note on system messages
Show advanced information (may be confusing to novice users)
Expert MediaWiki users might notice that the gadget naming convention could conflict with some system message; if MediaWiki:Gadgets
is an existing system message, then MediaWiki:Gadgets/es
should be the Spanish translation of the string, but in our version of this extension, that page is a gadget definition. Fortunately, MediaWiki:Gadgets
is not a system message in use. This potential conflict is what happens when the namespace for interface text is reused for other purposes.
An earlier draft of this extension had the definition at gadget-name.json
instead of gadget-name
, but we removed the .json
part because:
- This way if you want to move a gadget you can move one page and include all subpages (technically two, there's also the system message)
- This makes breadcrumbs take you back to the definition whenever you are on a code page
- It's a bit easier to document
Parameters
Section | Parameter | Type (or allowed values) | Description |
---|---|---|---|
settings |
section |
string | What section of Special:Preferences the gadget should be defined at. Here, you are writing a system message key, which can then be defined at MediaWiki:Gadget-section-nameOfTheSection. |
settings |
package |
boolean | If set to true , and multiple JS files are listed, then the assumption will be that the first JS file listed loads the others, and ResourceLoader does not need to load all files individually. Does not apply to CSS-only gadgets, and if there is only a single JS file present, the value doesn't have any effect.
|
settings |
default |
boolean | Enable this gadget for all anonymous users, and also by default for all logged-in users. |
settings |
hidden |
boolean | Do not offer opt-out for this gadget at Special:Preferences. This makes sense for gadgets that are part of core functionality, such as the styles for DRUID infoboxes or RANGER navboxes, but should probably be set to false for most gadgets involving JS or any ancillary styles that a user may not want (such as a width constraint). |
settings |
supportsUrlLoad |
boolean | Make the gadget available to be loaded with the ?withgadget URL query parameter.
|
loadConditions |
actions |
array of strings | If set, only load the gadget in these actions. For example, [ "edit", "history" ] .
|
loadConditions |
categories |
array of strings | If set, only load the gadget in these categories. Some normalization is performed, so:
|
loadConditions |
namespaces |
array of integers | If set, only load the gadget in these namespaces. For example, [ 0, 2 ] .
|
loadConditions |
contentModels |
array of strings | If set, only load the gadget in these content models. For example, [ "wikitext" ] .
|
loadConditions |
rights |
array of strings | If set, only load the gadget for users with these rights. For example, [ "delete" ] . A list of all user rights on your wiki can be found at Special:ListGroupRights .
|
module |
pages |
array of strings | The pages where the code can be found, will be subpages of MediaWiki:Gadgets/name-of-gadget
|
module |
dependencies |
array of strings | Any modules that need to be loaded before this gadget, for example mediawiki.api or a different gadget (ext.gadgets.some-other-gadget )
|
module |
peers |
array of strings | Any CSS-only gadgets (styles type) that need to be loaded before this gadget and its dependencies, for example [ "druidInfoboxesStyles" ] . Their styles will be applied even if JavaScript is disabled.
|
module |
messages |
array of strings | Any interface messages, localized for the current user, that need to be loaded before this gadget. For example [ "otherlanguages" ] will load MediaWiki:otherlanguages . A list of all interface messages on your wiki can be found at Special:AllMessages .
|
module |
type |
"general" , "styles" |
Set to styles for CSS-only gadgets that should be available immediately on page load (rather than when the JS loads)
|
Viewing existing gadgets
Please use Special:Gadgets to view all gadgets.
Some available gadgets
These gadgets can be imported to your wiki if you want.
UI elements
Editors
- purge - part of the default loadout wiki
- nullEdit
- uploadMultipleFiles - part of the default loadout wiki
- hotCat
Article utility
Profiles
- userProfile - part of the default loadout wiki
- blueUsers