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.
This is easy as far as the resource loader goes, but
it
does mean the server has to make this decision based on information in
the gadget's code or the gadget definition page. This is significantly
less flexible than allowing a gadget to just provide a JS function
that returns true or false, but the fact that the decision has to be
made client-side makes it a bit trickier. It's still very much doable,
although the way I proposed is a little bit hacky and we may want to
have the client-side loader support this better.
Is this not what the mediaWiki.load.using() is for? 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() .. }
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.
--michael