Page MenuHomePhabricator

Add the ability to configure gadgets on a per site or wiki basis
Closed, ResolvedPublic

Description

Something else I'd like add to the gadget feature requests is allowing users to configure a gadget to some extent. A rough comparison might be using $wgExampleExtensionVariable to set something in LocalSettings.php.

As an example of how this might work in a js environment, take http://dev.wikia.com/wiki/AjaxRC which uses ajax to refresh the content of a page. By default this loads on RecentChanges and WikiActivity (something similar to RecentChanges made by Wikia to be more friendly to new users). However, the pages it loads can be altered to any page imaginable. A typical extra place for it to load might be a forum hub to track the latest changes to threads.

Currently, the user sets the variables and imports the script. If this script were moved to a gadget in it's current state there would be no way to configure it unless you did something like add a site dependency and configure it in MediaWiki:Common.js.

I think a better way would to be to add a way to set variables in a gadget preferences page, with a form that can accept pre-determined types, e.g. string (foo), array (foo, bar, baz, ...), number (12345), boolean (checkbox), etc. These variables could then be set using something like mw.user.gadgetPrefs.set( 'ajaxrc-someVar' ) (possibly namespaced to the gadget?) and then accessed by the gadget using mw.user.gadgetPrefs.get( 'ajaxrc-someVar' ) Ideally, this form would show the default values used as well.

A couple of things to mull over if this gets implemented:

  • Should we allow configuration on a wiki and/or user basis for default gadgets? Perhaps set sub-defaults, e.g. default < wiki < user
  • If global gadgets are introduced gadgets could be identified by hash values rather than names. How could we avoid clashes where the same variable is being inadvertently set twice or more by different scripts?

Version: unspecified
Severity: enhancement

Details

Reference
bz70019

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:43 AM
bzimport set Reference to bz70019.
bzimport added a subscriber: Unknown Object (MLST).

Customization of gadgets is in the roadmap for Gadgets 2.0 (T31272) / 3.0:
https://www.mediawiki.org/wiki/Extension:Gadgets/Roadmap#Gadgets_2.0
https://www.mediawiki.org/wiki/Roadmap/2012/April#MediaWiki_infrastructure

For notes on the implementation, see
https://www.mediawiki.org/wiki/User:Salvatore_Ingala/GSoC_2011_application
https://www.mediawiki.org/wiki/User:Salvatore_Ingala/Notes

However, I believe this will only be done after the implementation of global gadgets is finished...

Krinkle closed this task as Resolved.EditedApr 18 2021, 9:05 PM
Krinkle claimed this task.

It's unclear to me what specifically this task is about. It mentions a lot of things that are loosely related, but the good new is (I think) that they're all resolved.

Task title:

Add the ability to configure gadgets on a per site or wiki basis

Gadgets now have a default option that can be set on a per-wiki basis by interface admins. https://www.mediawiki.org/wiki/Extension:Gadgets#Options

It could also be set by server-admins for one or more wikis by setting the native user options, via $wgDefaultUserOptions.

Task description:

Currently, the user sets the variables and imports the script. If this script were moved to a gadget in it's current state there would be no way to configure it unless you did something like add a site dependency and configure it in MediaWiki:Common.js.

I think a better way would to be to add a way to set variables in a gadget preferences page, […]. These variables could then be set using something like mw.user.gadgetPrefs.set( 'ajaxrc-someVar' ) […]

This sounds like a duplicate of T23897, which I closed as resolved.

MediaWiki now supports the userjs- prefix in the preferences database. Gadgets can be read via mw.user.options.get('…'), and set via mw.Api#setOptions().

https://www.mediawiki.org/wiki/Manual:User_preferences#Gadget_and_user_script_preferences

There is more ideas in this area of course. One of those improvements could be T110014.