Commit graph

24 commits

Author SHA1 Message Date
Ammarpad 5d3a547c8b Restrict ?withgadget query parameter to opt-in gadgets.
?withgadget query parameters allows for ad-hoc loading of gadgets
(after passing all other basic checks). This was recently added in
I5b30d4e.

In T29766#7611796 Gergo raised concerns about how this can be
potentially abused.

This patch aims to restrict the feature by giving gadgets latitude
to either use it or not depending on the nature of the gadget.

The patch does so by adding `supportsUrlLoad` option that gadgets
(maybe those deemed safe) can use it to opt-in to the parameter.
By default gadgets don't support it, so it can be enabled for each
on a case-by-case basis.

Bug: T29766
Change-Id: Ie64174085e650579d76cc862774a4fe1b3d08396
2022-01-24 00:31:19 +00:00
Siddharth VP f1673c441a Avoid raising exception while trying to change content model of gadget definition
Currently, trying to change content model of a page in gadget definition namespace (via either the special page or the API) raises an exception. This uncaught exception has been replaced with a localisable error message.

Bug: T299303
Change-Id: Iad7d353d03cdfb52bf66aa2c9a12bc71a840577c
2022-01-16 22:43:37 +05:30
Gergő Tisza 6b74e170c0
Add edit link to gadget definition in Special:Gadgets
When using the Gadget definition: namespace, link to the definition
pages from Special:Gadgets. Also change the wording of the links
to edit the names of the gadgets, to disambiguate them.

Change-Id: I327a4cfa9846edec60e1aaafc674cd66f4e0beae
2021-12-31 20:42:37 -08:00
Siddharth VP 7ead5dab61 Allow specifying page actions in definitions
Allow specifying page actions ('view', 'edit', 'history', etc) in
gadget definitions. If specified, the gadget is run only on the given
page action(s).

This is especially useful for default gadgets like RefToolbar[1] and
TextReactions[2] that only need to be loaded while editing.

[1]: https://en.wikipedia.org/wiki/WP:RefToolbar
[2]: https://en.wikipedia.org/wiki/WP:Text_reactions

Bug: T204201
Bug: T63007
Change-Id: Idde71b3f1f6c36cd21539a2312be8f12217a9acc
2022-01-01 00:41:08 +05:30
Siddharth VP 1f7b9d90df Support JSON files in gadgets
The parsed content of JSON files in the gadget is made available from the
gadget's JS files via require(). That is, MediaWiki:Gadget-data.json (or
Gadget:data.json) is available as `require('./data.json')`. This is
supported for both MediaWikiGadgetsDefinitionRepo and
GadgetDefinitionNamespaceRepo. The JSON parsing is done server-side.

JSON can only be used in "package" gadgets - in which the JS files can
also be invoked via require().

Also added a test for GadgetResourceLoaderModule.

Bug: T198758
Depends-On: Ib4556d09c4d393269e32771aab00f59a5f630e1b
Depends-On: Id4589a597ccfc4266b3e63d10f75b146aa7a287a
Change-Id: I21acb46cdd244a39b5cc6963aa763f0113bd1e38
2021-12-27 17:33:21 +00:00
Yuki Shira 2977f44d5e Add Special:MyLanguage for better user experience
Change-Id: Ic41200ae4db72ea6521e4674395f0b31edb9279e
2020-04-23 20:08:45 +09:00
James D. Forrester ed07c92d5a Note that Special:Gadgets provides source code even if you're not a sysop/i-admin
Bug: T238975
Change-Id: I8eeb98a8bc9f83b2de91fa11802a3b3c6f94a7bf
2020-01-16 18:30:34 -08:00
DannyS712 4fc4258fe7 Update gadgets-prefstext regarding interface administrators
Bug: T241634
Change-Id: Ieec3c8381969ec99c52845da0bbc03ea9a0f8959
2019-12-31 05:12:33 +00:00
zoranzoki21 53de932571 Move all apihelp translatable messages to separate files
Bug: T189982
Change-Id: Ifc682634d8403401e2ca4667e34474ed08574f53
2019-01-29 17:11:32 +00:00
Brad Jorsch 30d8e92ba9 API: Split description messages into summary + additional text
See MediaWiki core patch I778bab2b

Change-Id: I7ed2ddd3d4df7db75872db3820189aa061fd4500
2017-06-09 11:59:25 -04:00
jenkins-bot 081cad1dd9 Merge "Add a GadgetUsage link to gadgets-prefstext message in Special:Preferences" 2016-02-13 19:59:18 +00:00
niharika29 75ae3558e7 Add a feature flag to turn off the 'active users' query on GadgetUsage
Currently takes >24 hours to complete on enwiki and thus isn't run
at all. Need a better optimised query. Until that happens, we can
turn it off on enwiki.

Bug: T121484
Change-Id: Idcf2a8a1cdf5ce4c2f6a631ef980be5a48ca547b
2015-12-18 19:30:45 +00:00
julius 162c86cee4 Add a GadgetUsage link to gadgets-prefstext message in Special:Preferences
Add a link for Special:GadgetUsage to the [[MediaWiki:Gadgets-prefstext]].

Bug: T120976
Change-Id: I352bdc19c494b9c1aa33e39654ddcd57a3d63b45
2015-12-18 13:12:39 +05:30
niharika29 0815999bec Append default gadgets to Special:GadgetUsage table with 'Default' in place of stats
Bug: T121133
Change-Id: I14cfb352d6dec9edfbb4d3ed7bd3e0545e4f1eab
2015-12-16 07:13:10 +00:00
niharika29 0c498ae7b6 Add column for active users to Special:GadgetUsage
Bug: T116894
Change-Id: Iea6db379064f7ea959a4f0f3d0010e92ea2f04a2
2015-12-07 19:53:33 +00:00
Kaldari 0845d37598 Merge "Implement Gadgets definition namespace repo" 2015-11-20 18:03:02 +00:00
Kunal Mehta 519f30355e Implement Gadgets definition namespace repo
Implements:
* Gadget definition content and content handler
* Basic validation for gadget definition content
* GadgetDefinitionNamespace implementation of GadgetRepo
* DataUpdates upon editing/deletion of Gadget definition pages
* EditFilterMerged hook for improved error messages
* 'GadgetsRepoClass' option to switch GadgetRepo implementation used
* Lazy-load the GadgetResourceLoaderModule class so we don't need to
load each individual gadget object unless its needed

Note that Special:Gadgets's export feature intentionally doesn't work
yet, and will be fixed in a follow up patch.

Bug: T106177
Change-Id: Ib11db5fb0f7b46793bfa956cf1367f1dc1059b1c
2015-11-20 12:01:21 -06:00
niharika29 dfb8034ae1 Add note about excluding default gadgets in Special:GadgetUsage
Change-Id: Ia2cb867a90e8b7ff820722342e67d1b9aba88293
2015-11-12 05:13:42 +00:00
niharika29 be8091a288 Add a special page to show number of users for each gadget on the wiki
Bug: T115152
Change-Id: Id1e245f8fdb2fc6a764682ae34937f35af24bd7c
2015-10-23 15:02:23 +00:00
jenkins-bot e8be573463 Merge "Set up "Gadget" and "Gadget definition" namespaces" 2015-08-09 02:48:00 +00:00
Kunal Mehta e6b8b57d9b Set up "Gadget" and "Gadget definition" namespaces
Register the "Gadget", "Gadget definition", and their respective talk
namespaces. It will not be possible to create any pages in the Gadget
and Gadget definition namespaces due to the "gadgets-edit" and "gadgets-
definition-edit" rights not being granted to any groups.

Depends on Iaf8b44d02adf9 in MediaWiki core.

Change-Id: Ia88c774cc0decc252a4a4277d14822048db95801
2015-08-08 01:39:56 -07:00
Timo Tijhof 29e7a9193d Don't load legacy gadget scripts
The time has come to stop supporting legacy gadgets that haven't
migrated to ResourceLoader yet.

For many Gadgets, migrating to ResourceLoader will be as easy
as adding "[ResourceLoader]" to its definition on MediaWiki:Gadgets-definition.

However for older gadgets, they may need more maintenance. Though
similarly they may've already been malfunctioning silently.

The most common techniques used by legacy scripts, and what their
equivalents are in modern JavaScript, see:
<https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)>

Ref T107399.

Change-Id: Ia5f7323a40a28541515ef3a3f5079f1cc940f392
2015-08-07 01:00:40 +00:00
Brad Jorsch 48c47e1cf0 Add i18n for API module help
MediaWiki core change I04b1a384 added support for i18n of API module
help. This takes advantage of that while still maintaining backwards
compatibility with earlier versions of MediaWiki.

Once support for MediaWiki before 1.25 is dropped, the methods marked
deprecated in this patch may be removed.

Change-Id: I67395aff48185f3e09da31b51a08aa2541fe6a17
2014-10-29 16:37:38 -04:00
Siebrand Mazeland 5d28ca240d Migrate to JSON i18n
Procedure per https://www.mediawiki.org/wiki/Manual:GenerateJsonI18n.php
with shim.

Change-Id: I1cc79cf4bade15ba469f5c407604416b85b74731
2014-03-27 10:02:52 +01:00