Page MenuHomePhabricator

Make gadgets easily customizable (merge Gadgets' branch "gadgetprefs" from GSoC 2011)
Open, LowPublic

Description

  • As a gadget developer, I want a standard way to customize gadgets (not copying local implementations from one wiki to another).
  • As a gadget user, I want a nice UI to customize the gadgets I use, without having to learn how to edit a JS/CSS subpage.

The "gadgetprefs" (from GSoC 2011) branch seems to implement that, but is rotting since 2011:
https://phabricator.wikimedia.org/diffusion/EGAD/history/gadgetprefs/

See also

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
ResolvedKrinkle
DeclinedNone
Resolvedkaldari
Resolvedkaldari
ResolvedKrinkle
OpenNone
ResolvedKrinkle
ResolvedKrinkle
ResolvedKrinkle
ResolvedKrinkle
ResolvedKrinkle
DeclinedLegoktm
ResolvedLegoktm
DeclinedLegoktm
ResolvedLegoktm
ResolvedKrenair
ResolvedNone
ResolvedLegoktm
ResolvedLegoktm
ResolvedKrenair
ResolvedLegoktm
Resolvedkaldari
ResolvedKrinkle
Resolved Fhocutt
Resolvedkaldari
Resolvedkaldari
OpenNone
ResolvedNone
ResolvedNone
ResolvedNone
InvalidNone
OpenNone
ResolvedSD0001

Event Timeline

He7d3r raised the priority of this task from to Low.
He7d3r updated the task description. (Show Details)
He7d3r subscribed.
He7d3r renamed this task from Review/Update/Merge/Deploy Gadgets' branch "gadgetprefs" from 2011 to Make gadgets easily customizable (merge Gadgets' branch "gadgetprefs" from GSoC 2011).Oct 17 2016, 1:16 PM
He7d3r updated the task description. (Show Details)
He7d3r added a subscriber: matmarex.

The key advantage of having a built-in way to customise gadgets appears to be that gadgets wouldn't need to implement their own GUIs for this.

With the adoption of the GadgetDefinitionNamespaceRepo, we would have a natural place for defining the spec for preferences within a gadget – the gadget definition page.

{
    ...
    "userPreferences": [
        "customTemplateToUse": { "type": "string", "label": "The custom template to be used" },
        "infiniteScroll": { "type": "boolean", "default": false, "label": "Infinite scroll",  
                "helptip": "Use infinite scroll instead of pagination" },
        "limit": { "type": "number", "default": 50, "label": "The limit", 
               "helptip": "Max entries to be shown per page (not applicable if infinite scroll is used" }
    ]
}

We can have a special page, Special:GadgetPreferences, which renders an OOUI/Codex-based form using the given data types, defaults, labels and helptips. The values entered can be stored as user options, with the option name convention being gadgetpref-<gadget>-<pref>, eg. gadgetpref-twinkle-customTemplateToUse.

Gadgets can then access the prefs from the existing mw.user.options interface. The default values from the pref spec would only be used in the form, and not actually be registered into $wgDefaultUserOptions, since that would bloat mw.user.options for all users on the site, whether they use the gadget or not. So, gadgets would need to use a default value in the gadget code in addition to putting it in the JSON spec, which is a bit sub-optimal but IMO not a deal-breaker as in practise most of the non-boolean prefs won't even have a default.

How does this sound?

How does this sound?

Some remarks:

  • This should not be a separate Special:GadgetPreferences but part of Special:Preferences in Gadgets section, when entire usage of one particular tool can be toggled. If this tool is activated, the preferences GUI should appear immediately below (and vanish if toggled off).
  • The JSON spec should be subpage like MediaWiki:Gadget-myTool/preferences.json, while site configuration might be MediaWiki:Gadget-myTool.json and implementation is at MediaWiki:Gadget-myTool.js
  • Texts do need localization mechanism. A global root may contain English, French, Japanese and German, and on Commons users will expect their user language. Further translations need to be added easily by global collection of local languages.