Page MenuHomePhabricator

Investigation: Global gadgets
Closed, ResolvedPublic5 Story Points

Description

Early investigation on the Global gadgets wish.

  • How's Kunal doing with shadow namespaces? Can we/should we help with that?
  • Talk to Yuri about his ideas of making global gadgets without shadow namespaces.
  • Would it be possible to implement some sort of global gadget system with just Gadgets 2.0 and some hackery? i.e. without shadow namespaces?

As gadgets only need load Javascript and CSS, and don't transclude or parse page content in any way (other than system messages), they don't need to take advantage of shadow namespaces (T91162).

There appear to be three remaining options:

  1. a global loading system akin to GlobalCssJs to load CSS and JS modules from a remote wiki;
  2. a (hacky?) page copy tool that, on request from site admins, keep sets of gadget pages up to date with a remote wiki;
  3. allow the Gadgets extension to load JS & CSS resources from files, and move all global gadgets into a new WikimediaGadgets extension and load them from there.

Access to edit gadgets

At the moment, local administrators can edit gadgets. If a central repository stores gadget code in the current normal locations (i.e. as system messages), then all administrators will need to become administrators on that wiki — or, rather, all gadget maintainers would need to be administrators (because it would no longer be necessary for all wikis to make changes to globalized gadgets; they could instead ask the maintainers to do this). A system of reporting bugs and suggesting improvements would perhaps need to be more structured than it is currently for most gadgets (see also T71445).

If gadgets were in extension files, the normal methods of Git use, code review, continuous-integration etc. would all apply. This would raise a barrier to editing for some, but wikis would still be able to edit their local gadgets as they do now; it would just be global gadgets that require the greater level of code control.

Localization

In the first two options above, gadgets could get localized messages from datasets (.tab files) stored on Commons (for example, Data:I18n/Template:Graphs.tab). This would mean that anyone would be able to update translations (translating being restricted to admins of the gadget repository wiki was one of the worries raised in the Wishlist proposal).

If there were to be a code-review process for the gadget code, it could perhaps serve just as well for submitting translations. Gadgets in extension files would have their i18n files loaded as normal extensions do, and could be registered on translatewiki.net etc.

Gadget repository

The global loading option would require a single central wiki in which to store gadgets. At the 2017 Dev Summit it was decided that a new wiki would be set up for cross-wiki templates (with a view to one day making it globally-transcludable). Global gadgets could be housed in the same place, or maybe on Meta. Wherever they're located, the gadgets of course wouldn't have to be enabled on that wiki (as they often would deal with things irrelevant to the central wiki).

The page copy option could be set up to copy gadgets from any wiki, so for example gadgets that are only used on one project (e.g. a quiz tool for Wikiversity) could be hosted on any of that project's wikis and copied to the others. And existing gadgets could stay wherever they currently are, with the wikis that are currently manually keeping them up to date having an easier way of doing this. There appears to be some benefit to allowing gadget developers to carry on as they are, without forcing a new wiki on them. The copying tool could also be made to copy gadget code in from a Git repository, if that were desirable (e.g. in order to have code review elsewhere).

The Extension-based option would work as all other extensions do. It would also mean 3rd party wikis could easily use the gadgets as well. Individual wikis would still need to make particular gadgets available for their users to enable.

Gadget manager

Gadgets 2.0 will include a much nicer manager interface (T31398) for admins to edit the gadget definitions (name, scripts, styles, dependencies, category, etc.). Nothing has happened with it since July 2015 though (although it sounds like it is still definitely going to happen).

The three proposed solutions here woudn't change the way the gadget manager works: gadget definitions would still work on a per-wiki bases, because at the moment there's no proposal to be able to disable an installed gadget (and no one wants all gadgets to be available on all wikis).

If gadget scripts and styles were loaded from a global repository, they could still just be referenced in a gadget definition; if they're to be copied locally then of course nothing would change from the status quo. If they're to be loaded from an extension, then the UI would need to give an indication of whether they're being overridden on-wiki.

Per-wiki or -user customisation

This seems to mostly be down to gadget design, with the general idea being that there's a local Json config page that controls whatever is required (and could also, if required, be a user's subpage). But see also T110014: Make gadgets easily customizable (merge Gadgets' branch "gadgetprefs" from GSoC 2011) which will result in a nice UI for this sort of cusomization.

Configuration should be optional, with the gadget able to function (or at least not fail) without it. Globalizing gadgets doesn't depend on this, other than perhaps some particular gadgets that are currently doing this in a not-very-portable way.

Switching gadgets to 'global'

There are lots of gadgets that have been copied or imported to multiple wikis (see the statistics on Meta) and many have been modified after import — some just for configuration purposes (e.g. to modify a URL), some to fix bugs (where the same bug fix is rolled out manually to the various places the gadget is used (see the revision histories of formWizard on meta and enwp for example), and some to introduce new features that are just required on a specific wiki.

Once global gadgets are available, it should be possible to keep these local ones running as-is, and for users to gradually switch over to global equivalents as bugs are fixed and code centralised. This probably just means that global gadgets will need to be given new names so they aren't overridden by the pre-existing pages (in the globally-loading scenario, a remote page would not be loaded if there's already a local one of the same name).

The first global gadgets would probably be those that'd work towards T158462: Identify high-use gadgets and ensure that they have proper long-term maintenance.

Summary

It seems like the best option (i.e. quick, least disruptive, but still sensible and not too hacky) is to modify the Gadgets extension to load modules and messages from a new WikimediaGadgets extension (or, perhaps, any extension that chooses to define a ext.gadget.* module?). The Gadgets extension would still work as it currently does for loading on-wiki JS and CSS (and the configuration could be done with either of the existing systems: MediaWiki:Gadgets-definition or Gadgets: namespace). This solution would make it harder for casual editors to make changes to these Gadgets, but that is probably a good thing as the gadgets chosen for globalisation are the more stable, highly-used, hopefully-stable ones that would benefit for some greater control.

Event Timeline

DannyH created this task.Dec 15 2016, 5:11 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 15 2016, 5:11 PM
Qgil added a subscriber: Qgil.Dec 16 2016, 2:20 PM
He7d3r added a subscriber: He7d3r.Dec 16 2016, 7:00 PM
kaldari updated the task description. (Show Details)Dec 20 2016, 10:33 PM
kaldari set the point value for this task to 5.Dec 20 2016, 10:37 PM
kaldari moved this task from To be estimated/discussed to Estimated on the Community-Tech board.

@Legoktm, could you shed some light on shadow namespaces project status? :)
We'd like to help, if possible.

Also, #3 above.

With relation to: T71445: Implement a sane code-review process for MediaWiki JS/CSS pages on Wikimedia sites

If there was some sort of Git-based code-review process for wiki-pages, it could possibly serve as a system for global gadgets as well?

Samwilson moved this task from Ready to In Development on the Community-Tech-Sprint board.
Samwilson updated the task description. (Show Details)Feb 22 2017, 6:07 AM
He7d3r updated the task description. (Show Details)Feb 22 2017, 6:47 PM
Samwilson updated the task description. (Show Details)Feb 23 2017, 8:31 AM
Qgil removed a subscriber: Qgil.Feb 23 2017, 12:25 PM
Samwilson updated the task description. (Show Details)Feb 27 2017, 5:37 AM
Samwilson updated the task description. (Show Details)Feb 28 2017, 5:12 AM
Samwilson updated the task description. (Show Details)Mar 1 2017, 6:34 AM
Samwilson updated the task description. (Show Details)Mar 2 2017, 5:55 AM
kaldari closed this task as Resolved.Mar 3 2017, 1:00 AM
kaldari added a subscriber: kaldari.

Nice work on the investigation! Personally, I'm skeptical of moving gadget code into an extension since that would more-or-less make the WMF responsible for it rather than the community, but it might make sense for a small number of highly used gadgets.

DannyH moved this task from Estimated to Archive on the Community-Tech board.Mar 14 2017, 6:49 PM