Gadget kitchen/de

Willkommen in der „Gadget Kitchen“. Irgendwann sollen hier Entwickler ihre Arbeit an Benutzerskripten und Gadgets koordinieren können, um damit die MediaWiki-Community zu unterstützen. Im Moment ist es noch ein einfaches Tutorial, um schnell loslegen zu können.

Was sind Benutzerskripte und Gadgets?
Eine der schönsten Eigenschaften von MediaWiki ist, dass im Prinzip jede und jeder sofort Software-Erweiterungen schreiben und mit anderen Usern teilen kann.


 * Benutzerskripte sind für alle zugänglich und in JavaScript geschrieben.
 * Gadgets sind ebenfalls Benutzerskripte. Sie werden von einem Wiki-Admin zu MediaWiki:Gadgets-definition hinzugefügt. Dadurch stehen sie im Tab Gadgets allen eingeloggten Usern zur Verfügung.

Wenn bei dir eine eigene Version von MediaWiki läuft, muss aktiviert sein, damit Benutzerskripte funktionieren. Die Gadgets extension muss installiert sein, damit Skripte in den Rang von Gadgets befördert werden können. Beides ist bei fast allen Seiten der Wikimedia Foundation (z.B. Wikipedia), der Fall.

Um angenehmer arbeiten zu können, solltest du die CodeEditor extension in deinem Wiki installiert haben.

Gleich ausprobieren!

 * 1) Stell sicher, dass du eingeloggt bist und gehe dann auf Special:MyPage/common.js. Diese Datei enthält personalisiertes JavaScript, das bei jeder Seitenansicht geladen wird.

Ich will mehr damit machen!
Kopiere die Inhalte von MediaWiki:Tutorial-QuickRC.js in Special:MyPage/common.js.

The result should be the same as above, but now you can modify the script, play with it, and replace it with something else entirely.

Clicking "Preview" (or using the keyboard shortcut, typically ) in the editor will also execute the latest version of the script. This is a good way to iterate without saving the page. But remember, nothing is saved until you press "Save page".

Gibt es noch mehr Tutorials?

 * MediaWiki:Tutorial-QuickRC.js - mw.loader, mw.util, mw.html, API usage, jQuery UI dialog, mw.user, jQuery AJAX, jQuery event binding
 * VisualEditor/Gadgets - A tutorial specifically for VisualEditor gadgets.
 * OOUI - A javascript library for creating pop-up windows specifically for use on mediawiki sites available on most WMF hosted wikis. The library can be used in gadgets.

Was hat es mit dem ResourceLoader auf sich?
ResourceLoader is a core feature of MediaWiki that intelligently delivers JavaScript and CSS assets to users and readers. Because Gadgets are coded in JavaScript, as a Gadget coder you're bound to interact with ResourceLoader. Starting with MediaWiki 1.26, gadgets must use ResourceLoader (T107399).

Your gadget should load useful ResourceLoader modules instead of "reinventing the wheel."


 * Modules — A list of JavaScript libraries, jQuery plugins and MediaWiki utilities that already exist within ResourceLoader for you to reuse.
 * Developing with ResourceLoader — A list of useful practices, like enabling the debug mode and help with debugging.

Changes to ResourceLoader ("Gadgets 2.0") will make managing gadgets even simpler.

Woran kann ich arbeiten?

 * If you want to write features that directly help Wikimedia project contributors, there are some pages that are used to coordinate requests. On the English Wikipedia, there is w:Wikipedia:User scripts/Requests.
 * We're also collecting requests here: Gadget Kitchen/Requests

Wie verwende ich mein Skript in anderen Wikis?
Let's say you want to run the script on English Wikipedia instead of MediaWiki.org. You can't use  to import a page of JavaScript from a different wiki, but you can tell ResourceLoader to load your code. Visit your common.js on English Wikipedia and add the following:

Of course, you could also load the user script you just created by changing MediaWiki:Tutorial-QuickRC.js in the URI above to. Ta-da! It's really that easy to customize your experience on one of the largest web sites on the planet.

If your gadget uses the MediaWiki API, add the " " parameter to the API URL if you are trying to make an API request that would violate the same-origin policy (e.g. making a request to the Commons API from Wikipedia). This triggers the use of JSONP and enforces certain restrictions.

Tipps zum Thema JS?

 * Writing a gadget:
 * Check out the JavaScript coding conventions to write JavaScript that complies with MediaWiki's style.
 * Also see the ResourceLoader good practices.
 * Learning JavaScript links to some helpful resources to write faster performing code.
 * Compatibility - check compatibility


 * Debugging:
 * Read the Google Chrome developer tools documentation or Firebug documentation to get the most out of the powerful debugging tools built into your browser.
 * If you experience issues with cached versions of scripts, it can be helpful to disable all caching. Click the settings (gears) icon in the Chrome developer console and select "Disable cache", or click "Disable Browser Cache" in the Net panel's dropdown menu in Firebug.
 * The ExternalArticles extension can be used to work on gadget code in an external IDE (it will update the corresponding wiki pages every time a file is saved).


 * Review: Gadgets are developed by community and as of today there is no formal code review required for them (see discussion T71445). However, it is strongly recommended to follow best practices!


 * audit-resources: You should not load external resources that may harm users privacy. For example in WMF wikis, the following domains are considered safe:
 * .wiktionary.org
 * .wikimedia.org,
 * *.wikibooks.org
 * *.wikisource.org
 * *.wikisource.org
 * *.wikiversity.org
 * *.wikinews.org
 * *.wikiquote.org
 * *.wikidata.org
 * *.wikivoyage.org
 * www.mediawiki.org

There is a Jenkins job (where??) for automatic check of this principle

Where can I find more docs?
These are key resources:
 * Wikipedia:User scripts on the English Wikipedia and its alternatives in other languages are the primary hubs for user script and gadget development in Wikipedia. The guide has tons of useful information to get you started.
 * the jQuery docs are essential for every JavaScript developer
 * the MediaWiki web service API documentation will also be very useful
 * List of gadgets by popularity in Wikimedia projects
 * Wikipedia:Gadget page on English Wikipedia
 * A written resource as backup for in-person training sessions