Commons:Gadgets
Gadgets are standard user scripts which extend the functionality of MediaWiki, the software on which Commons runs, and are available to easily install via a user's Preferences. (Other user scripts are available which must be installed manually.) Individual gadgets can be activated or deactivated (some are activated by default) by visiting your Preferences (you must be logged in) and ticking the relevant box. Most gadgets require JavaScript to be enabled in your browser.
Technical details
Definition
- MediaWiki:Gadgets-definition is where gadgets are installed so that they show up in Preferences
- Gadgets can be restricted to users with certain user rights by adding, for example,
rights=delete
in the gadget definition. Gadgets are loaded by default (including for users not logged in) by addingdefault
. Gadgets can be restricted to logged-in users withrights=upload
.
- Gadgets can be restricted to users with certain user rights by adding, for example,
- Special:Gadgets provides an overview of installed gadgets, with links to the gadgets' script files
- MediaWiki:Common.js loads some scripts automatically
Localization
- Localization within gadgets, where necessary, is handled in various ways. Usually this is within each gadget script, or using a separate subpage (eg MediaWiki:Gadget-HotCat.js/de) but in some cases multiple language versions of the entire script exist. {{Gadget-talk}} categorises localization, and if necessary places scripts in Category:User scripts needing internationalisation.
- Localization of gadget descriptions is done by creating
/xx
subpages of the main (English) gadget description page (eg MediaWiki:Gadget-Cat-a-lot and MediaWiki:Gadget-Cat-a-lot/fr). Special:Preferences, via {{Gadget-desc}}, provides "translate this" links which make this easier.
Templates
- {{Gadget-state}} stores some redundant information about gadgets and should be kept up-to-date. Indicating the default-state of a gadget is requested in phab:T51501
- {{Gadget-desc}} standardises descriptions of gadgets (as displayed in Preferences)
- {{Gadget-help}} and {{Gadget-talk}} standardise headers on gadget help and talk pages
- {{ActivateGadget}} and {{DeactivateGadget}} generate links which, when loaded create a dialog asking the user whether to enable or disable a gadget
- Some gadgets document browser compatibility on a subpage (eg Help:Gadget-PrettyLog/Compatibility); this has a common format but not a template
Limitations
Since MediaWiki 1.18, gadgets (and user CSS/JS) are not loaded on certain special pages, for security reasons. This includes Special:Preferences, breaking the previous means of moving gadgets to other parts of the Preferences. See phab:T20186. phab:T35220 requests a native MediaWiki replacement for what was previously done in Javascript.
Links
- Category:Gadget scripts
- Commons:User Scripts - project to improve gadgets and other user scripts
- MediaWiki talk:Gadgets-definition - discussion
- mw:Extension:Gadgets - the MediaWiki extension which makes gadgets possible
- mw:Extension:Gadgets/Scripts - some gadgets on mediawiki.org
- mw:ResourceLoader - gadget framework; V2, in development, sees substantial changes; see also phab:T31398 and phab:T22153
- Special:GadgetUsage shows the number of active and inactive users who have different gadgets enabled