Commit graph

2399 commits

Author SHA1 Message Date
Timo Tijhof 4197a00409 build: Add --allow-polyfill-parser to phan command
This way it works out of the box during minimal local dev environments
without requiring additional native extensions. The repo is small enough
that it's fast enough either way.

Change-Id: I0c789f266cb01f31bb42cb9f960cae0bb4c293df
2023-12-13 03:06:33 +00:00
Siddharth VP 34a1a297c2 Make repo configuration independent of ObjectFactory specs
Replace $wgGadgetsRepoClass with $wgGadgetsRepo.

Change-Id: I3dc1e29d1c3c65a18c206e7aa50e5bf31a55cc21
2023-12-12 13:15:31 +00:00
jenkins-bot 561254697d Merge "Add tests for cache invalidations in MWGadgetDefinitionRepo" 2023-12-12 07:57:22 +00:00
Siddharth VP c665a90423 Add tests for cache invalidations in MWGadgetDefinitionRepo
Change-Id: I24af0c2fa7524b5d6b5cd2cb151d3617c99a6ab0
2023-12-12 07:35:47 +00:00
Translation updater bot 3927ca48db Localisation updates from https://translatewiki.net.
Change-Id: Icaceda1608a1648d49a847c56bf6b3e01bb5d3d6
2023-12-11 10:43:16 +01:00
jenkins-bot 6f9f46b510 Merge "Further expand test coverage" 2023-12-09 06:17:45 +00:00
Siddharth VP ce486be160 Further expand test coverage
* Separate out tests for MediaWikiGadgetsDefinitionRepo and
Hooks::onGetPreferences. Removed hack in fetchStructuredList() for
overriding page content for tests.
* Add tests for ES6 gadgets. For this, ResourceLoaderModuleTest is
converted back to an integration test.
* Removed createGadgetDefinitionPage() test helper method. Now using
MediaWikiIntegrationTestCase::editPage().
* Fixed GDNamespaceRepoTest failure when GDNamespaceRepo is the active
repo, by clearing WAN process cache.

Change-Id: I26b84576a91f6cb0ebae64c5fc1408666d767911
2023-12-09 09:29:15 +05:30
Translation updater bot cd4b5fcc3e Localisation updates from https://translatewiki.net.
Change-Id: I13aafcaadf909a7e671d6c1d48559e12d340be9c
2023-12-08 14:45:36 +01:00
jenkins-bot 1b2b942fb8 Merge "Change "package gadgets" to "packaged gadgets"" 2023-12-07 11:12:05 +00:00
Translation updater bot 1ea4bc8376 Localisation updates from https://translatewiki.net.
Change-Id: Ib15e99ea7695d7216c3b7199412e9e1501f84cbb
2023-12-07 10:01:47 +01:00
Siddharth VP d12f0f366a Expand test coverage
* Add tests for onBeforePageDisplay hook. A simple gadget repo
  implementation, StaticGadgetRepo, is introduced for this.
* Add integrations tests for various gadget load conditions.
* Add test for onUserGetDefaultOptions hook.
* Add tests for GadgetDefinitionNamespaceRepo.
* Convert ResourceLoaderModuleTest to a unit test.

Change-Id: I275380c2bfcaa44770b3946a0a468eaaabef70c0
2023-12-06 09:18:09 +05:30
Siddharth VP 9d11216d4b Inject services into Hooks
Change-Id: I042d6f33f9ecd2573f25e737bb0ee9a43869eeac
2023-12-06 09:18:09 +05:30
jenkins-bot 9ad0cf1a5a Merge "Make GadgetRepo a service" 2023-12-06 00:48:51 +00:00
Siddharth VP 22752225a1 Make GadgetRepo a service
Turn GadgetRepo into a service, deprecate GadgetRepo::singleton()

Change-Id: I0ab14ca936eec1eead91d4eb0970f898628c8388
2023-12-05 17:38:41 -06:00
jenkins-bot 79f93059cb Merge "Add missing definite articles in messages" 2023-12-05 23:33:00 +00:00
Siddharth VP bf1d6b3e93 Remove gadgets-edit right, use core editsite{css,js,json} rights instead
With GadgetDefinitionNamespaceRepo, there should be separate rights for
editing gadget json as opposed to editing gadget css/js, so that admins
can be granted the former, while the latter remains restricted to
int-admins.

Reusing the MW core rights for site CSS/JS/JSON seems to make the most
sense here. Protection is now applied via GetUserPermissionsErrors hook
rather than as namespace protection.

For editing any non-CSS/JS/JSON pages in the namespace, editsitejs right
is required.

Bug: T298834
Change-Id: I6ffd5e9467774f1e79ccdce8b6b4739f07be2da8
2023-12-05 20:37:59 +05:30
Translation updater bot 493a7a5dd3 Localisation updates from https://translatewiki.net.
Change-Id: I11b4ef8d7146ea5b8a634636ae6d611183b12441
2023-12-05 09:14:46 +01:00
Translation updater bot 00c22e468d Localisation updates from https://translatewiki.net.
Change-Id: I62f3cfadb62019b716f5c9f51a9010c577b48507
2023-12-04 09:04:15 +01:00
Amir E. Aharoni e2d4e351ad Add missing definite articles in messages
Change-Id: I2c43f1a4a4bc8c98438c0bf8b343efbabb540cd6
2023-12-01 10:44:26 -05:00
Amir E. Aharoni 16b5ee866c Change "package gadgets" to "packaged gadgets"
For consistency between the new message gadgets-validate-json
and the older message gadgets-packaged.

Change-Id: I84f2f11e033ed3a3b6fe855452b34f751e9970b9
2023-12-01 10:05:56 -05:00
Translation updater bot a79ae63c8a Localisation updates from https://translatewiki.net.
Change-Id: I5916d03bd6b986c3eb75146e0f388d06e8f0bd38
2023-12-01 09:39:34 +01:00
Siddharth VP adda8a6649 Show gadget definition validation warnings in Special:Gadgets
Bug: T298334
Change-Id: Id241125b9b8abfb971dfa600ab0df9c6047f2b32
2023-11-30 21:59:04 +00:00
Translation updater bot ceb5a9174a Localisation updates from https://translatewiki.net.
Change-Id: I5190cb31a7028bbfbdd94c5d7993eff06ed071e1
2023-11-30 09:37:59 +01:00
Translation updater bot 9fd869c7a2 Localisation updates from https://translatewiki.net.
Change-Id: I07ccb4abc4772ee8be8ed84c6b256917e1a5cbcf
2023-11-29 08:31:03 +01:00
Translation updater bot 49a12c47e0 Localisation updates from https://translatewiki.net.
Change-Id: Iae953cfe01b3deb01787ee62658352bacc6ae47f
2023-11-27 08:32:21 +01:00
thiemowmde c4680366ac Various PHP code cleanups
… e.g. using modern syntax, or avoiding unnecessarily complex
language features. For example, we don't need to call count() when
all we care about is the boolean "is empty/not empty" information.

Change-Id: I13ae802f64627a79b29d1e57ad71486cb2fb977f
2023-11-22 09:53:48 +01:00
thiemowmde ba496f7f4a Remove meaningless trim() from MediaWikiGadgetsDefinitionRepo
This can't do anything for two reasons:
* There are no spaces in the string after the str_replace. There is
  nothing to trim.
* The regular expression above guarantees the string starts and ends
  with alphanumeric characters. There can't be anything to trim, not
  even underscores.

Change-Id: Iea40aafaa2457cdee9d05f105978627d38d9d5b8
2023-11-20 13:44:08 +01:00
Translation updater bot 2dda194930 Localisation updates from https://translatewiki.net.
Change-Id: I952087d038745e95ebcb52f932a827c073b25aa4
2023-11-13 08:40:55 +01:00
Translation updater bot a6bd9144ac Localisation updates from https://translatewiki.net.
Change-Id: Iee39d6c6330d81431ffc8216d59c7ac7bd8fb199
2023-11-08 13:07:36 +01:00
Translation updater bot b1413814c2 Localisation updates from https://translatewiki.net.
Change-Id: I79ef1b6113b7d037c989906e675b8127be4ab771
2023-11-06 08:56:19 +01:00
Translation updater bot 40d75e5ac5 Localisation updates from https://translatewiki.net.
Change-Id: I86361ee316a11cd3abf99c8a1da4bef67b59ba4b
2023-10-31 09:08:59 +01:00
Timo Tijhof d12bf68c25 docs: Make PHP file headers more consistent
* A fixed license header for the file.

* Move class descriptions, doc tags, author/copyright to the
  class block. Remove MW-core specific "ingroup" tags such as
  "SpecialPage" which has no meaning in an extension and are not
  used by Doxygen.
  Ref https://gerrit.wikimedia.org/r/q/message:ingroup

Change-Id: I13d9b0ff7a3150180196c9fa58f8a321b14edd22
2023-10-30 18:10:58 -04:00
jenkins-bot 1ebcbafc89 Merge "Namespace special page classes" 2023-10-30 18:42:37 +00:00
Translation updater bot b7dd0f13ef Localisation updates from https://translatewiki.net.
Change-Id: Ibb6418b354a7855c84f06295e850346364149e45
2023-10-30 17:59:19 +01:00
Siddharth VP a7309d2b1f Namespace special page classes
Change-Id: I005f6674c9cc80c5c9e26ae84acfbceebb43734e
2023-10-30 21:13:41 +05:30
Translation updater bot 319d422398 Localisation updates from https://translatewiki.net.
Change-Id: I6066ae836d62f1e775bb51a9812d16f1ba7d9e86
2023-10-23 09:50:38 +02:00
Translation updater bot 03086af912 Localisation updates from https://translatewiki.net.
Change-Id: I5728c9fcfef16a3dafc9454da7af0df14a2873c3
2023-10-19 08:42:03 +02:00
Translation updater bot a41504a35e Localisation updates from https://translatewiki.net.
Change-Id: I964d878120eb5c6322eaafa16b10fee211dd3764
2023-10-11 08:45:33 +02:00
Translation updater bot 01e10d087f Localisation updates from https://translatewiki.net.
Change-Id: I3138832673c480df0de80eabbc995d5b3d94ba2b
2023-10-10 08:52:13 +02:00
Translation updater bot 6419638558 Localisation updates from https://translatewiki.net.
Change-Id: I873f4d3a742895e56ec8bb7bf3eeea946049808a
2023-10-09 08:56:01 +02:00
Translation updater bot 6221493052 Localisation updates from https://translatewiki.net.
Change-Id: Ie5a41080ecc5ac1d4e16f830aa28b868591a2c80
2023-10-04 09:08:16 +02:00
Translation updater bot c8e21c9f1d Localisation updates from https://translatewiki.net.
Change-Id: I503126feeed44e3768fa423e9d5ca7f152506666
2023-10-02 10:57:19 +02:00
Translation updater bot 2d525ce1c9 Localisation updates from https://translatewiki.net.
Change-Id: Ic5f986af6a9f022eb8afe71ef6f3769a8dbaccaa
2023-09-26 08:43:55 +02:00
Translation updater bot 81dc3dd6f5 Localisation updates from https://translatewiki.net.
Change-Id: I9d0c8fb0f71850781d1dd0d44a7c8d34607dc3da
2023-09-25 08:46:19 +02:00
jenkins-bot 8284344e6e Merge "Add support for content models in definitions" 2023-09-22 23:29:53 +00:00
Translation updater bot 08860aabdc Localisation updates from https://translatewiki.net.
Change-Id: Ib0b01c291aa4389f1a5443cb7a4dc57868a7a9f4
2023-09-22 08:46:54 +02:00
Siddharth VP 72cbb64069 Add support for content models in definitions
Adds a contentModels option to gadget definitions to restrict gadgets to
run in pages of the given content models only.

Use-cases include gadgets for tabular data[1] (for Tabular
.JsonConfig model), for editing map data[2] (for Map.JsonConfig model),
and for showing links in code pages[3] (restricted to javascript, css,
json, and scribunto models), as well as common gadgets like ProveIt[4]
which can be restricted to wikitext model.

[1]: https://commons.wikimedia.org/wiki/MediaWiki:Gadget-TabularImportExport.js
[2]: https://fr.wikipedia.org/wiki/MediaWiki:Gadget-KartoEditor.js
[3]: https://en.wiktionary.org/wiki/MediaWiki:Gadget-CodeLinks.js
[4]: https://commons.wikimedia.org/wiki/Help:Gadget-ProveIt

Bug: T204201
Bug: T63007
Change-Id: I7dcfc21d674ead8d710e7f77d13bf18bcad15079
2023-09-21 22:27:22 +05:30
Translation updater bot 3c50a61ebe Localisation updates from https://translatewiki.net.
Change-Id: Ia00896b807bb2bc9d9dbd17c0d8ddfca68b85bef
2023-09-21 10:15:48 +02:00
brandonxlf ec69cea0e3 Add support for namespaces in definitions
Adds a "namespaces" option to the gadget definition, which takes a
list of namespace IDs. Enabled gadgets will only load when the
viewed page is in one of the required namespaces.

Bug: T204201
Bug: T63007
Change-Id: I7f797e35352b242ad78704074e98c6569a1adf91
2023-09-20 14:50:33 -07:00
Timo Tijhof 5aaa843a28 tests: Enforce parity between Gadget::serializeDefinition and toArray
Follows-up 087ab65e24 (Ieae6706537). To avoid silent mistakes such
as during development of T63007 (I7f797e35352b242).

Bug: T303194
Change-Id: If675f8d02ed3fee768af3d2b4912249319ae9ef4
2023-09-20 14:41:33 -07:00