Commit graph

74 commits

Author SHA1 Message Date
DannyS712 9471c6f7f9 Hooks: injected needed configuration
To avoid needing to use MediaWikiServices

Change-Id: I37bd3b511632e8e82f48806c272aa18953eea42d
2024-02-07 18:24:23 +00:00
DannyS712 bc9added4f Hooks: inject DisambiguatorLookup as an optional service
Follow-up: Id2a10f2f1be0e38ddb8ebef5d5babb3daac3ce9a
Change-Id: Ib1a0297fd17e1cec0847d68a0c184e3c713f0111
2024-02-05 18:23:47 +00:00
Jon Robson 71de06a682 Simplify the RelatedArticles extension to use Codex CSS components
Changes:
- Removes redundant styles now inside Codex
- With the new component, it's not possible to display 3 cards in a
single line at a tablet resolution, so the media query responsible
is bumped to apply only at the desktop threshold
- Decisions are documented in ADR

Bug: T286835
Change-Id: I493e8e601ccc31b3cf1f16c0b5a8975f12ef336c
2024-01-30 09:16:34 -08:00
James D. Forrester ed9c2ce120 extension.json: Drop 'es6' flag, always true since MediaWiki 1.41
Change-Id: If984ae5118ce72ec150c34d42e628965f0534b30
2024-01-12 19:05:47 -05:00
Umherirrender 97d9d3700b Use namespaced classes
This requires 1.42 for some new names

Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I738fa5cd78d9b662326afc268bc2a90cb1540948
2024-01-05 21:22:56 +01:00
Umherirrender c5b6a8018b Use HookHandlers for core hooks
The use of "HookHandlers" attribute in extension.json makes it possible
to inject services into hook handler classes in a future patch.
Remove optional return from hook handlers

Bug: T346560
Change-Id: I4e42f7cf361e41c3ee687abcf41409a4704b7bf6
2023-09-27 21:02:11 +02:00
James D. Forrester 8eb55200fd build: Update MediaWiki requirement to 1.41
All extensions in Wikimedia production are expected to track MediaWiki's release directly.

Change-Id: I87ce5809b7684edc613540ad203ebc37156d3007
2023-09-14 19:43:39 +00:00
Volker E 8f6fce655b styles: Replace 'mediawiki.ui/variables' call with skin variables
Replacing 'mediawiki.ui/variables.less' `@import`
with new skin-aware 'mediawiki.skin.variables.less' standard.

Also
- replacing several static values with skin variables featuring new
  Codex design tokens for following properties:
  - background-color
  - color
  - border-width, border-style, border-color and border shorthand

Bump required MediaWiki core version to >= v1.41.0.

Bug: T319381
Bug: T332541
Depends-On: I04f9e48a1cf9dee915cf51e1e12b17ff0a595a06
Change-Id: I32c2996dedc9b3a54e1f916623dbe1c4da910083
2023-04-18 11:19:46 -07:00
Jon Robson c2342e281e Targets no longer needed in RelatedArticles
All match current default.

Bug: T328497
Change-Id: I38d93cba683bcc39fb25421b0a197f8ebb4c9923
2023-02-16 11:41:14 -08:00
Jon Robson e5431a1c0b Limit RelatedArticles feature to ES6 browsers
We currently require support for IntersectionObserver.
which is supported on Edge >= 15 (15 has partial support),
Firefox >55, Chrome >58, Safari 12.1, Opera >=38,
iOS Safari >=12.2, Android 100

Full ES6 is supported in Edge >=15, Firefox >=54, Chrome >=51,
Safari >=10, Opera >=38, iOS Safari >=10, so such a change
would only drop support for Edge 15 and Firefox 54.

CSS.escape is guaranteed in all these browsers according to
caniuse, with the only discrepancy being the Edge browser (versions
16-18) so it is also suggested we remove support for those browsers.

Firefox 54 accounts for 0.0026% of page views
Edge 15-18 accounts for 0.069% of page views

Bug: T306355
Change-Id: Id2987e3456607b610c38da9ee157a026d1d00ada
2022-04-27 15:45:42 +00:00
jenkins-bot d043e31869 Merge "[Development] Allow us to pull RelatedArticles from production APIs" 2022-04-18 21:55:19 +00:00
Jon Robson 5f6e311255 Remove unused mediawiki experiments
mw.experiments is never used in this codebase. Presumably this
dates back to when we did A/B tests for this feature.

Change-Id: I7d5bc63349686063ecd2c1fc63d078af91d2c541
2022-04-18 12:53:02 -07:00
Jon Robson dca7580757 [Development] Allow us to pull RelatedArticles from production APIs
useful for testing real world data

Suggested test config:
```
$wgRelatedArticlesUseCirrusSearchApiUrl = "https://en.wikipedia.org/w/api.php";
$wgRelatedArticlesUseCirrusSearch = true;
$wgRelatedArticlesDescriptionSource = 'wikidata';
```

This will allow us to enable on patchdemo with production content.

Change-Id: I73c0d73d3369f27ed2fd74b37ae71bfc12b6ee57
2022-04-18 16:28:26 +00:00
Jon Robson 4c9904952b Drop OO dependency on gateway
The RelatedPagesGateway is an OO class.
There is no reason for it to be, we don't use any
of it's features e.g. the event emitter

Change-Id: I8f807d35b0ce36ea5764508a66f88d74577e3653
2022-04-18 15:51:43 +00:00
Jon Robson 911d78e8ee [organization] organize file by module
Follow up to I9442b0336e22ca795cc06f76068215266fe81271

Bug: T306228
Change-Id: Ifb1f1937009b098999471cfa5e820a063dc5a4a0
2022-04-18 08:37:22 -07:00
Jon Robson df1ff38877 [Maintenance] Reduce related articles to two modules
1) Merge ext.relatedArticles.readMore and ext.relatedArticles.cards modules

These are always loaded together. No need to have them in separate modules.
In process switch to packagefiles

2) Merge ext.relatedArticles.readMore.bootstrap and ext.relatedArticles.readMore.gateway

Always loaded together.

Bug: T306228
Change-Id: I9442b0336e22ca795cc06f76068215266fe81271
2022-04-14 17:48:37 -07:00
Jon Robson dc2e65a084 Drop outdated references to Cards extension
Previously RelatedArticles required the Cards extension
This code refers to that old state and is cleaned up.

ext.relatedArticles.cards is added a dependency of
ext.relatedArticles.readMore since it now belongs to the same
extension

Change-Id: I4a89ed4256a4ae9fd22b0191748bd47ac3ffc593
2022-03-31 08:14:23 -07:00
jdlrobson 83c2b071c4 Fix loading of related articles via IntersectionObserver
For IntersectionObserver to work the element we listen on needs to
have a non-zero height.

Bug: T223844
Change-Id: I308f646670b112e42b0aaa11c438dbc5cdc5edd8
2021-11-04 12:30:11 -07:00
jdlrobson 923f594916 RelatedArticles should use IntersectionObserver rather than deprecated mediawiki.viewport module
Bug: T284251
Change-Id: Ia3139df0beb24268a1e37b85c755b0d0f62910b5
2021-10-29 14:53:20 -07:00
Reedy 804debdd8e Remove RelatedArticlesFooterWhitelistedSkins
Bug: T277958
Depends-On: I34519c75bafb56b7f042d7bb95eed49b59bb01a8
Change-Id: Id4391badba750d5acc0d03c8caf0165ba5910741
2021-05-03 23:29:06 +00:00
Reedy 2715c27bbe Rename RelatedArticlesFooterWhitelistedSkins to RelatedArticlesFooterAllowedSkins
Bug: T277958
Change-Id: I468a38df92347cc764e0457d4598bedfc4d92efa
2021-04-20 19:00:26 +01:00
James D. Forrester bf6ca72845 extension.json: Simplify hook calls as we only ever use one
Change-Id: Ie835cac5df0697829dcf6f1796d9c4331512a8fc
2020-05-11 19:55:03 +00:00
James D. Forrester ac94e7efad Use QUnitTestModule instead of deprecated ResourceLoaderTestModules
Bug: T232875
Change-Id: I5612a9be65f4d4adf4912645856540dbb04d2b34
2020-05-11 19:53:57 +00:00
James D. Forrester 56416d08e9 Don't try to register "" as a style path, that breaks ResourceLoader
Bug: T248090
Change-Id: Ic1475003f9f00c3593736be1421c93b8b7f5c30f
2020-03-19 15:24:20 +00:00
Ammar Abdulhamid 6abae72d5e Update extension.json to manifest version 2
Bug: T241892
Change-Id: I9c7156df3220389e7fbf94375e9fdb753458f16e
2020-01-04 19:35:20 +01:00
jdlrobson c9ec8dfadf Use mw.util.debounce
jquery.throttle-debounce is deprecated.

Bug: T213426
Change-Id: Ieffe20f44003e7dbb992e88c7927a14629da2db4
2019-10-24 18:49:38 +00:00
Jesús Martínez Novo be3385e6d5 Support other ways to get the description of the page
Currently, the extension queries the prop=description api to fetch the
description, but this api is only available if Wikibaseclient is installed.

Let's support other sources to fetch the page description from, too, or
disable it (by default) to sabe 85 bytes from each response by avoiding the
warning returned from the api when prop=description is not recognized.

A new configuration setting has been added: RelatedArticlesDescriptionSource.
It defaults to false (no description is fetched), but can be set to one of
those string values:

- wikidata: What's being used right now on WMF wikis
- textextracts: Extension:TextExtracts provides the prop=extracts api.
- pagedescription: Extension:Description2 provides a description page property, that can be queried by prop=pageprops&ppprop=description

Bug: T230947
Change-Id: I34410334ba9d6db1f686c7efb5722e2a51957145
2019-08-23 20:24:37 +02:00
Isarra b31970084f Use SkinAfterContent hook to place cards in the DOM
This allows skins to determine where the cards appear in a consistent
fashion with other extensions, and require minimal special handling from
the extension itself.

Also change default settings as to when RelatedArticle cards will appear
- keep the whitelist to allow projects to configure their usage such as
in the case of only wanting it on mobile, etc, but now that it should
just work in any given skin, default it to on for all so that it's easier
for the average third party to install for whatever use.

Note that this default setting change will not affect WMF wikis, as
wmgRelatedArticlesFooterWhitelistedSkins is explicitly set in the
wmf-config regardless.

Bug: T181242
Depends-On: I5b0ad889e633fde88c392577ce5373c81fc5486a
Change-Id: Iebd759c0d1a536768d18953f372664df762d9e04
2019-07-26 19:28:49 +00:00
David Causse 51a19570eb Fix wgRelatedArticles*UseCirrusSearch var names in data.json
typo introduced in I5c6809392b0621bd0d58049597f6c0306e572607

Bug: T224879
Change-Id: I195cfd2a32b5a1737aed15d6c463a602ce54d6ad
2019-06-03 15:14:27 +02:00
Timo Tijhof 6a0d64d3f0 Remove 'wgRelatedArticles*CirrusSearch' from page view HTML
Bundle these with the module that needs it instead, this means
1. It is naturally only downloaded on pages where it is needed.
2. It doesn't block download/parse/render of the article HTML.
3. It doesn't delay time to mw.loader.load() for interactive
   functionality.

Bug: T219342
Change-Id: I5c6809392b0621bd0d58049597f6c0306e572607
2019-05-25 22:04:51 +00:00
Timo Tijhof a418550db3 ext.relatedArticles.readMore.bootstrap: Convert to 'packageFiles'
This enables use of module.exports and require() within the module,
and makes it easy to bundle additional data and scripts generated
by the server (without needing to subclass FileModule in PHP).

In particular, to bundle mw.config values with the module.
Currently the extension is adding these to the <head> of all
articles which delays rendering of the article content, and the
time to when JS can start to be fetched.

See <https://phabricator.wikimedia.org/T219342#5116773>.

Bug: T219342
Change-Id: I3f174418af8bfd83b0faabe484226e323714cb5b
2019-05-25 22:03:38 +00:00
Jan Drewniak 191fc2af9d Remove muhogan templates and module
Removes the muhogan module along with the templates and replacing
them with jQuery DOM construction.

Bug: T219846
Change-Id: I246f9c46ea2cc5721ddd57efcf58fae9fd947c58
2019-04-10 17:14:28 +02:00
jdlrobson 6b49ddff1b Remove EventLogging/A-B test code from RelatedArticles
With RelatedArticlesEnabledBucketSize now removed, installation of this
extension will turn it on for 100% users without any mechanism to turn
it off.

Additional changes:
* Bump version
* Add Readers team to contributors

Bug: T202306
Change-Id: I7dc270a06dd3afd4e894c8298165d6d6d4fda8d6
2018-09-20 11:13:13 -07:00
Umherirrender a00a0fdd61 Require MediaWiki 1.31 in extension.json for AutoloadNamespaces
AutoloadNamespaces is a new feature in 1.31

Change-Id: I0ee5de22a50d8aec3bd0f52744119de074651158
2018-07-07 12:00:25 +02:00
Kunal Mehta eacbd18d3a Switch to PSR-4 autoloader
Change-Id: I1add76d094ea8a122442bfe06fbd67c3c819b9fa
2018-06-11 18:34:07 -07:00
Kunal Mehta 0837f19dcd Register EventLogging schema in extension.json
Change-Id: I4079f13a6708ad4376b7686c3926cd59ff90aaa7
2018-06-11 18:30:22 -07:00
Kunal Mehta 1e57f034bd Use SPDX 3.0 license identifier
SPDX released version 3 of their license list (<https://spdx.org/licenses/>),
which changed the FSF licenses to explicitly end in -only or -or-later
instead of relying on an easy to miss + symbol.

Bug: T183858
Change-Id: Id06c20eb9e1d97b6b8aa1fd2195ec1002066690d
2018-03-02 15:35:10 -08:00
Umherirrender 72bf976e12 Rename file ResourceLoaderMuhoganModule.php to match class
Change-Id: Ibdabb503fbbe6c17f041943cae8fa6ee4dbdfe20
2017-12-09 23:15:30 +01:00
jdlrobson ab788e7f41 Merge footer hooks with Hooks
per Baha's suggestion we have no need for two Hooks files now
so let's merge them

Bug: T165991
Change-Id: I12c62aef837f50589297477f46bdf0f0d6b5536a
2017-08-10 15:10:30 -05:00
jdlrobson 94ecc2d917 Breaking change: Remove Sidebar code from RelatedArticles
RelatedArticles will now only render related articles in the footer of
skins.

Bump version to 3.0.0

Bug: T165991
Change-Id: Ia4e28c0ed76b3aff37c0aea8eb713923312ba23c
2017-08-10 12:44:58 -05:00
jenkins-bot 38ac4650e0 Merge "Make number of RelatedArticles configurable" 2017-07-06 21:09:06 +00:00
jdlrobson 9126c7d0ef Make number of RelatedArticles configurable
Wikivoyage pages have more than 3 related articles as they make use
of the {{#related:}}  magic word.

After speaking with Nirzar we should allow this project to show more than 3.
This change allows this while keeping the existing behaviour on other wikis and
will pave the way for removing a bunch of code from this extension.

Additional changes:
* Cleanup skinStyles definitions
* Limit cards to 30% maximum width and give margin top to account for
situations where the number of cards are multiple of 3
** In Minerva hardcode the max-width to pixels.
* Margins are switched from hardcoded 10px to percentage based. Yes
this changes the right margin slightly but is more maintable and visually
the same.

Bug: T164765
Change-Id: I41119de3228c2df799f740d4bd00082101c21b97
2017-07-06 11:17:47 -07:00
Sam Smith f4c82d3a33 Hygiene: SamplingRate -> BucketSize
In order to avoid further confusion, clarify that we're bucketing users
for experiments.

Bug: T167236
Depends-On: I752cdf068ca25bffb38229380785e7da1a208049
Change-Id: I6508ab8fa3d436ae295eb047e170fdc5417d25fc
2017-06-20 05:26:29 +01:00
jdlrobson 4598d9b567 Remove CardsGateway (unused)
Bug: T167647
Change-Id: I7e2a7777a5f28991d77deab520a55d3bd242104b
2017-06-14 13:10:01 -07:00
jdlrobson 6dee0147f4 Migrate Cards code to RelatedArticles
* Move across all files
* Rename ext-card- prefix to ext-related-articles- prefix
** Since all code using these prefixes is JS
  we do not have to worry about cached HTML

Bug: T137021
Change-Id: I784fd132c36329fa0dcc49fe2804460061940347
2017-06-07 08:35:53 -07:00
jdlrobson dbb73c389d Remove Related Articles from desktop beta features
This change removes RelatedArticles from beta features.
It repurposes the BlacklistSkins config to be a whitelist that describes
when related pages should be shown in the footer.

To avoid enabling related pages on desktop, this depends on a config
change that makes use of the new configuration option.

Simplify browser tests to reflect the new status quo.

Bug: T146436
Bug: T160076
Depends-On: I522e0182d1c3d9261bd0561c3ec0c789b6431c7a
Change-Id: I84da1fb33a901a6365375d00d192af35422ff0b0
2017-04-04 23:01:36 +00:00
Baha 13c630343e Do not lazy-load an event logging module
Since we're always depending on the event logging module, we can
make it a dependency in extension.json, rather than loading it
lazily.

Bug: T157375
Change-Id: Ia57f390586e123c6010a7daf23a3d851daf079ce
2017-03-06 14:30:39 -05:00
Baha a40286c800 Hygiene: lazy-load event logging code
This allows us to decouple the event logging code from the
`ext.relatedArticles.readMore' module. As a result we'll be able to
log events without loading the above mentioned module.

Bug: T157375
Change-Id: I55cf4f40cafc88d6baeb5cc1b41fc2d6bcd2fbb9
2017-03-01 14:45:32 -05:00
Piotr Miazga 0806dbdb42 Use mw.experiment to enable related pages only to subset of users
Changes:
 - introduced new config variable: RelatedArticlesEnabledSamplingRate
 - do not trigger RelatedArticles clientside scripts if feature is disabled
 - do not log events when navigator.sendBeacon is not available

Bug: T156039
Change-Id: I7e9773131c5b9aea9e9fb554d4508842cdedede7
2017-01-30 23:29:32 +01:00
Baha 9c1404ce99 Allow blacklisting skins for showing ReadMore in footer
Introduce a new config variable `RelatedArticlesFooterBlacklistedSkins`
to control skins that are allowed to show ReadMore in the footer.
As before Minerva beta mode is always allowed to show.

Depends-on: I366c8656a0f14a7069053b2e6199caac20471ea4
Depends-on: Ie4ac3c11e81eeea9f5b4a7161a64477cb5d60f07
Bug: T144047
Change-Id: I1663ab25083d9d907f288e60d506831bebb67945
2016-09-26 15:26:03 +00:00