Sunday, April 28, 2013

Note: The internal name is used as part of the name of a form field and must follow the rules defined for NAME attribute values. This means it must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), Gadgets hyphens (-), underscores (_), colons (:), and periods (.).

MediaWiki1.11+ (current version requires 1.19, versions for older MediaWiki (1.11+) are available here or from Git

Each line in MediaWiki:Gadgets-definition that starts with one or more (asterisks) characters defines a gadget; it must have the following form:

whitespace can be omitted. Single option can either consist of single option name (in this case it is a flag option), or contain a comma-separated list of values:

The first field ( in the example) is the gadgets internal name, and references a system message (MediaWiki:Gadget- in the example) that contains a short description of the gadget, using wiki syntax.

Selection of some gadgets at the user preferences in de.wikipediaThe list of available gadgets is defined on MediaWiki:Gadgets-definition. Once created with at least one valid gadget, gadgets defined there show up in the Gadgets section of Special:Preferences, so users can pick the gadgets they would like to use. An overview of the gadgets defined by MediaWiki:Gadgets-definition is also shown on Special:Gadgets, along with links to the respective system messages, for easy editing.

Gadgets are made up of JavaScript and/or GadgetsCSS snippets located on pages in the MediaWiki namespace. Each gadget is defined by a line in MediaWiki:Gadgets-definition, providing a name and description for the gadget, and a list of the JS and CSS snippets that it uses (see the Usage section below).

frobinatorcommonStuff.jsfrob.jsfrob.csspretty.css l33tcommonStuff.jstools.jsl33t.js

[options (can be omitted)] page names

Every gadget that at least partially uses ResourceLoader (that is, that has styles or compatible scripts) has its own RL module. The modules are named ext.gadget.gadget name.

Copy the Gadgets directory into the extensions folder of your MediaWiki installation. Then add the following lines to your LocalSettings.php file (near the end):

ImprovedDeletion [rights=delete] ImprovedDeletion.js

Options format:

option = value1, value2, value3

Here, we ask ResourceLoader to load modules jquery.ui and jquery.effects.clip with mygadget. Note that gadgets cant depend on scripts from pages, static files or external URLs, only on modules already registered in ResourceLoader. To make a script from a page depend on another script from a page, each should be a gadget which registers itself as a module in ResourceLoader,new york asian escort then they can be made to have dependencies.

ResourceLoaderNoneMarks gadgets scripts as compatible with ResourceLoader.?dependenciesComma-separated ResourceLoader module namesSee list of modules available by deult. Note that this option has no effect if current gadget has no ResourceLoader-compatible resources (i.e. no styles and scripts not marked as compatible).?rightsComma-separated privilege namesDisable the gadget (and make it invisible in preferences) for users who do not have these privileges.?skinsComma-separated skin namesMakes the gadget visible in preferences only to users who have these skins.?deultNoneMakes the gadget enabled by deult for everyone (including anons!) having the required user rights. Registered users can still disable it in their preferences.1.18You can specify extra dependencies for your gadgets, for example:

The list of gadgets in MediaWiki:Gadgets-definition can be broken into sections using lines that start and end with two or more = (equals) characters, enclosing the name of a system message that defines the sections name - for example:

mygadget[ResourceLoaderdependencies=jquery.ui, jquery.effects.clip]mygadget.jsmygadget.css

To make the gadget available only to users with appropriate permissions, set the rights option. For example,

This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable ExtensionGadgets?and works well enough to be used by such high-traffic websites. Look for this extensions name in Wikimedias CommonSettings.php and InitialiseSettings.php configuration files to see where its installed. A full list of the extensions installed on a particular wiki can be seen on the wikis Special:Version page.

modrollback[ResourceLoaderrights=rollback][ResourceLoaderrights=purge][ResourceLoaderrights=patrol,rollback,markbotedits,delete]Ajax_sysop.js

Text is available under the Creative Commons Attribution/Share-Alike License; additional terms may apply. See Terms of Use for details.

The remaining fields on the line refer to the JavaScript or CSS code that makes up the gadget, contained in system messages (MediaWiki:Gadget-mygadget.js and MediaWiki:Gadget-mygadget.css in the example); the names of those messages must end with .js or .css, respectively. A gadget can use any number of code messages, specifically, common code can be put into a code message used by several gadgets, in addition to their own specific code, e.g:

Since Gadgets reside in the MediaWiki namespace (the list defining the gadgets as well as the actual code snippets), only sysops (aka wiki admins) can edit the code. This is as it should be: only users especially trusted by the wiki community should be able to edit JavaScript code that is used by other users, since JavaScript can easily be used to hijack accounts or spy on people.

Bugs:reportThe Gadgets extension provides a way for users to pick JavaScript or CSS based gadgets that other wiki users provide.

makes the gadget available only to users who can actually delete pages. Note that restrictions are based on permissions, not user groups like administrators or bureaucrats. Here are some real examples:

This would define a new section, with the title defined on the page MediaWiki:Gadget-section-intece-gadgets.

Each gadgets CSS is always loaded via the ResourceLoader. However, older JavaScript is often incompatible with RL, so every gadget must be explicitly marked as compatible in order to have its scripts loaded by RL. Otherwise, plain old script src=/w/index.php?title=MediaWiki:Gadget-&ill be used.

ExampleWikimedia Commons: Gadget overview, user preferences (click Gadgets; you need to be logged in of course)

== intece-gadgets ==

[option1 option2 ... optionN]

No comments:

Post a Comment