Brion Vibber wrote:
I'm not a real MediaWiki developer, so it may be a silly question: How hard it is to convert a gadget into an extension? If it's not too hard, wouldn't it be better to redo useful gadgets as extensions? Unless i miss something very basic, this will make them easier to maintain, install, update and localize.
In principle, making an extension based on an existing Gadget should be pretty straightforward, especially with ResourceLoader taking care of more of the details of JS & CSS fetching.
Might be fun to whip up a how-to guide and post it on the tech blog...
That (may or may not be intentionally) sounds like a way to work-around the elephant in the room, which is global preferences.
Gadgets are gadgets.
MZMcBride wrote:
In the case of gadgets, I mostly agree with Tobias: better global support is needed. Though instead of the interwiki transclusion/marking certain pages/etc. hackery, I think global preferences (and by extension, global gadgets) make much more sense. Centralize the "add a purge link" scripts at Meta-Wiki and let everyone use the same code. That seems like a more sane approach than creating Extension:AddAPurgeLink, even if it is easier now with the implementation of ResourceLoader. :-)
MZMcBride
+1
Although global preferences [1] is not fixed yet. Centralized gadgets is already possible. Both with and without resource loader (ie. before and after 1.17).
= Old way = This was only done or HotCats.js on some wikis: == Central wiki == * MediaWiki:Gadget-definitions * foo|foo.js|foo.css * MediaWiki:Gadget-foo This is Foo description. * MediaWiki:Gadget-foo.js alert('foo'); * MediaWiki:Gadget-foo.css body { background: orange; } == Other wiki == * MediaWiki:Gadget-definitions * foo|foo.js * MediaWiki:Gadget-foo This is Foo description. * MediaWiki:Gadget-foo.js importScriptURI( 'http://centralwiki.org/w/index.php?title=MediaWiki:Gadget-foo.js&action=...' ); importStylesheetURI( 'http://centralwiki.org/w/index.php?title=MediaWiki:Gadget-foo.css&action...' );
= New way = This way is promoted in the migration here [2] to start centralizing gadgets and avoid stuff from getting out of date. (navPopups, HotCat, UTCLiveClock, WikiMiniAtlas etc.) :
== Central wiki == * MediaWiki:Gadget-definitions * foo[ResourceLoader]|foo.js|foo.css * MediaWiki:Gadget-foo This is Foo description. * MediaWiki:Gadget-foo.js alert('foo'); * MediaWiki:Gadget-foo.css body { background: orange; }
== Other wiki == * MediaWiki:Gadget-definitions * foo|foo.js * MediaWiki:Gadget-foo This is Foo description. * MediaWiki:Gadget-foo.js mw.loader.load( 'http://centralwiki.org/w/load.php?modules=ext.gadget.foo' );
This new way not only centralizes stuff (like the old way did) but also does all resource loader stuff (1 request, minified, combined, cached)
This is already a huge improvement and can and is being done today. Once global preferences are up and RL 2.0 is in the air, it would be even easier. ie. extra section in Special:Preferences#Gadgets with "global gadgets" and MediaWiki:Gadgets-globaldefinition is used and meta.wikimedia/load.php
-- Krinkle
[1] https://bugzilla.wikimedia.org/show_bug.cgi?id=14950 [2] http://www.mediawiki.org/wiki/RL/MGU#Keep_gadgets_central