2010/9/8 Michael Dale <mdale(a)wikimedia.org>rg>:
On 09/07/2010 12:19 AM, Roan Kattouw wrote:
2010/9/7 Platonides<Platonides(a)gmail.com>om>:
I see. It would have to be a hook into the
resource loader.
You don't need a hook in the server-side PHP part of the resource
loader, as determining which modules to load on that side is already
supported. The Gadgets extension's PHP code could inspect variables
like $wgTitle->getNamespace() and determine whether to load a certain
gadget or not.
This would of-course result in mangled cache for every page context that
had a different set of page conditionals. Its better to do as you say
bellow and have thin loader code check javascript conditionals and then
fire off the loading of the gadget as needed.
I see your argument how separating gadget loading into a separate
request might be better so as to avoid cache mangling, but I hadn't
really considered that and was looking for ways to tack gadget loading
onto the request loading statically requested modules (through
$wgOut), which is possible by a custom loader.
Is this not what the mediaWiki.load.using() is for?
Yes, that's what you'd use in a thin loader module that then loads
other gadgets as needed, but it'd result in loading the requested
modules in a separate request (which seems to be what you want).
Are wiki page names
addressable as loadable modules? Ie can you request
mediaWiki.load.using(['MediaWiki:MyGadgetDepenency.js',
'MediaWiki:MyGadget.js', 'MediaWiki:MyGadget.css' ] , function(){ ...
MyGadget.doStuff() .. }
No, that's not supported.
This was supported in the old resource loader via
special WT: resource
name pretext, but perhapse could be implemented more cleverly in the new
resource loader. But would be nice to preserve the basic principal of
being able to grab multiple wikipages in a single request, as to support
more module gadget code.
I don't believe we should necessarily support retrieval of arbitrary
wiki pages this way, but that's not needed for Gadgets: there's a
gadgets definition list listing all available gadgets, so Gadgets can
simply register each gadget as a module (presumably named something
like gadget-gadgetname).
Roan Kattouw (Catrope)