A Wikipedia Mini-hackathon in Delhi
The ad-hoc plan had three parts:
- The execution environment (Concept of userscripts vs gadgets, ResourceLoader)
- The API concepts (Special:ApiSandbox, concept of 'actions' in the API)
- Accessing the API from JS (mediawiki.api module, concept of AJAX)
Here is the account of what they did, written by Yuvi:
"We covered all parts of them slowly, with both Harsh and Sheel working at things until they fully understood what they were doing and why whatever they were doing was working.
I introduced them to the environment first by having them execute code in Chrome's JS Console, and then in their own common.js. Once they understood the context in which the code was getting executed, the 'ResourceLoader default modules'[1]documentation started making sense to them, and they could pick up other modules from there.
We then explored the API via the API Sandbox[2], which is a relatively new (and not very well known) way of letting people play around with the API. It is a massive improvement over the older, non-interactive docs[3], and both Harsh and Sheel were very excited about being able to discover all the things they could do with the API. A fair amount of time was spent messing around with it on different wikipedias (en, hi and gu) and reading bits of the API Documentation[4] to understand the concepts behind the actions - and for filling in the gaps.
Finally we had them use the API from a userscript to make calls. I went through the entire process line by line, explaining how AJAX works and how asynchronous programming works. We traced the flow of code together to understand how the seamingly nonlinear asynchronous programming model works. Then we dug into a bit of how to use the mw.loader module to make dependencies work, and why the same code that was working in the chrome js console was not working in their common.js.
It ended with them trying to port HotCat to their native language wikipedias. Harsh started to explore more about getting started with MediaWiki dev itself (rather than just gadgets), but the clone took a looooong time and we had run out of time by then. I directed him to a WMF tech open chat happening today, and hopefully that could help!
[1].https://www.mediawiki.org/wiki/ResourceLoader/Default_modules
[2].https://en.wikipedia.org/wiki/Special:ApiSandbox
[3].https://en.wikipedia.org/w/api.php
[4].https://www.mediawiki.org/wiki/API:Main_page