Commit graph

50 commits

Author SHA1 Message Date
Fomafix da8b651cfa Use ?? instead of default value in getRawVal()
Bug: T376245
Change-Id: I068a9976e49014eee3587f0f3fc192f467d28ad0
2024-10-02 10:36:14 +00:00
C. Scott Ananian 28e4254be5 Use appendJsConfigVar to track related page titles
This simplifies the codebase by avoiding some unnecesary custom hooks,
and also improves Parsoid compatibility.

We look for old extensiondata coming from cached pages for
compatibility, but that code can be removed once the ParserCache expires
(T371421) for further simplification.

Bug: T263772
Change-Id: I843a920a0476290a8b0efd5eba4d8d44777d27d0
2024-07-31 10:57:28 -04:00
Umherirrender 63ced7322b Use namespaced classes
Changes to the use statements done automatically via script

Change-Id: I49107af15dcfd8264ebe49fe540402d44a4cd6a4
2024-06-10 20:16:42 +02:00
jenkins-bot 886606fdc5 Merge "Drop MobileDiff check" 2024-04-09 15:57:21 +00:00
Jon Robson b219d6fb5d Drop MobileDiff check
This page is now just a redirect so the reference is no longer
needed.

Bug: T360389
Change-Id: I216fe95e9ace82fc30879a23ece84b568159a01e
2024-04-03 10:01:24 +08:00
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
C. Scott Ananian 703e142c59 Use service framework to access Disambiguator extension, not hard-coded class
The Hooks::isDisambiguationPage() method is deprecated in any case.

Change-Id: Id2a10f2f1be0e38ddb8ebef5d5babb3daac3ce9a
2024-02-02 15:16:54 -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 91915dd6ff Replace empty() with falsy check
empty() should only be used to suppress errors
When the type of the variable is array,
a falsy check is the same (checks for null, false and empty array)
Found by a new phan plugin (T234237)

Change-Id: Iafd6d3bae30038bac2fad967924a9461aa57761b
2023-10-21 21:58:11 +02: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
Umherirrender 54f5923e32 Simplify Hooks::hasRelatedArticles
- Skin is a IContextSource, same as OutputPage, use the skin directly
- Use WebRequest::getRawVal/getCheck
- Move isDisambiguationPage() down a bit, it needs database queries
- Remove unused argument from ::isReadMoreAllowedOnSkin

Bug: T347123
Change-Id: I1b7cdc8bd330624f0a099284f6eabbb3ad62675a
2023-09-22 22:51:28 +02:00
Umherirrender 5bd33d9855 Use ::class for class name resolution
Change-Id: Ib75278e3728c1cd24e568f9f30f5cb32f19c5622
2023-09-20 20:59:19 +02:00
gerritbot 3f4bd5f8e4 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I36a0ac048f3898512e3ccefdb34c5e2e774f790b
2023-08-19 04:18:57 +00:00
Jon Robson 4d883cf58a Pages that do not exist shouldn't output related articles
Bug: T308078
Change-Id: Ie86ea03e4529e74cc5d9f71c973a5ab738ca499b
2022-05-11 19:13:35 +00: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
Reedy cb5b1baecf Use namespaced Disambiguator Hooks class
Change-Id: I1b2e6e4ac6e4612221f1f720356860c16c5aa5ee
2021-10-19 15:58:36 +01: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 ac94e7efad Use QUnitTestModule instead of deprecated ResourceLoaderTestModules
Bug: T232875
Change-Id: I5612a9be65f4d4adf4912645856540dbb04d2b34
2020-05-11 19:53:57 +00:00
Umherirrender 1fa6409ebe Improve param docs
Change-Id: I8debd7a907b8be61f9e6595e461d40fbd1352f63
2020-02-29 22:38:00 +01:00
libraryupgrader dfb3995a90 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 28.0.0 → 29.0.0
  The following sniffs are failing and were disabled:
  * MediaWiki.Commenting.FunctionComment.MissingParamTag

npm:
* eslint-config-wikimedia: 0.11.0 → 0.15.0
  The following rules are failing and were disabled:
  * no-jquery/no-parse-html-literal

* grunt-eslint: 21.0.0 → 22.0.0
* grunt-stylelint: 0.10.1 → 0.13.0
* stylelint-config-wikimedia: 0.6.0 → 0.8.0

Additional changes:
* Also sorted "composer fix" command to run phpcbf last.
* Removing manual reportUnusedDisableDirectives for eslint.

Change-Id: Iab538420d73bbbebfd05cf815ab06773f16da8da
2020-01-15 06:11:54 +00:00
Max Semenik bc24e8a71d Stop passing objects by reference
Bug: T193950
Change-Id: I36dc8a0f887bf11275f9cf3611651ca1091cd9f7
2019-11-14 22:17:56 -08: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
Timo Tijhof 8becbc2b23 Omit 'wgRelatedArticles' from page view HTML when empty
* The extension already uses 'null' as placeholder in RelatedArticles
  instead of empty array. Update the doc comment in RelatedPagesGateway
  to reflect this (its code was already using the default operator
  to fallback to empty array, given empty arrays are not falsey in JS,
  but null is).

* Omit the key from the mw.config output in <head> on page views,
  when the value is null, given this is redundant information and consumes
  additional space.

Bug: T219342
Change-Id: I367f9d9423d66611d73d56f8a769d86d14d3de8b
2019-05-26 13:49:16 +01: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
Kunal Mehta 3b7728f7cf Avoid use of func_get_args()
Change-Id: I7e0fb290be734dcbec39be9bcb9f17551e785de6
2019-03-09 18:36:30 -08: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
Jan Drewniak 6856ef8b5e Renaming QUnit test files from "test_" to "test.js"
Updates QUnit test files from starting with "test_" to ending with
"test.js" in accordance with the Readers Wed coding conventions.

https://www.mediawiki.org/wiki/Reading/Web/Coding_conventions

Bug: T197884
Change-Id: I3c15385d22d308b8b465985ca55e8b802d72dae4
2018-09-19 14:54:48 +02:00
Timo Tijhof f6c23000f2 Remove use of deprecated 'ext.eventLogging.Schema' module
This is the last remaining use of the module name "ext.eventLogging.Schema"
in Wikimedia Git. It is an alias for "ext.eventLogging.subscriber".

Change-Id: Idf295ef9c550ad7f1a19ac0b84e856d606ab8eb3
2018-08-06 17:40:05 +02:00
Kunal Mehta 0837f19dcd Register EventLogging schema in extension.json
Change-Id: I4079f13a6708ad4376b7686c3926cd59ff90aaa7
2018-06-11 18:30:22 -07:00
jdlrobson bd860b29a3 mediawiki.experiments is a dependency of RelatedArticles
Avoid potential race conditions.

Bug: T175064
Change-Id: Ic7eaea8181ce6eb64b4bce571182644105667a5b
2017-09-05 15:54:50 -04: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
Umherirrender 9a83d49ea0 Fix typo in word parser
Change-Id: I01f950621fda1388e1f8fcc79f217d1f639ac357
2017-07-28 17:44:09 +02:00
Umherirrender 548392824d build: Updating mediawiki/mediawiki-codesniffer to 0.10.1
Change-Id: Ie05b9ddc3e351abf4b2b199529b714766055d161
2017-07-26 22:59:51 +02:00
Piotr Miazga 88c7a705e2 Restore default MediaWiki codesniffer configuration
Changes:
 - re-enabled all sniffs
 - fixed code to meet MW code standards

Bug: T170589
Depends-On: Ib7f0bd15dd0a9255e1e5140907e800478b658b92
Change-Id: Idb08a3e105226877804a84b120c70e5defa7398c
2017-07-25 02:46:46 +00: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
Piotr Miazga 9a80069330 Hygiene: Don't use deprecated ConfigFactory::getDefaultInstance()
Changes:
 - use MediaWikiServices::getConfigFactory() instead of depreacted func
 - fix wrong param type for ResourceLoader

Change-Id: Id983f3cc57a4d1d23ef8dd0a52e78320dd51e9ca
2017-01-31 15:24:31 +00:00
Kunal Mehta a4c4f6700f Remove uncessary ParserClearState hook
The ParserOutput object is already reset when state is reset, so there's no
point in setting or unsetting properties on it.

And since the only unit test was deleted, remove the hook for that too.

Change-Id: Idf12365e8c4b14e527d923edc1086bdaf349df32
2016-07-28 15:55:02 -07:00
Kunal Mehta d8329fdbb1 build: Updating mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I3de1f2562898b76b56f5e7aa36b61088331ff52c
2016-05-09 16:59:15 -07:00
Sam Smith 9157e303d2 [Hygiene] Reorganise hooks to reflect placements
There are two positions where the list of related articles is rendered:
the sidebar, and the the footer. Move the hook handlers related to
rendering the former to RelatedArticles\SidebarHooks and those related
to rendering the latter to RelatedArticles\FooterHooks.

Change-Id: Idde57905d828e63309bfdc360a3a09e64e291304
2015-12-02 11:10:04 +00:00
Baha 18990e6631 Correctly show related articles on desktop
When $wgRelatedArticlesShowReadMore was false, while deciding
whether to show related articles on the sidebar,
we used to incorrectly consider whether BetaFeatures was
enabled for the user. BetaFeatures should only be used
for enabling ReadMore and not for showing related articles
on the sidebar.

We also used to show the beta features option for ReadMore
even when the ReadMore feature was disabled. Now we only
show that option if ReadMore is enabled.

Also rename isAbleToShowRelatedPages to isInSidebar to make
the function less confusing.

Bug: T119926
Change-Id: Ia5e44d94bb20660af711772cab7e3a59f98c931f
2015-12-02 06:08:19 +05:00
Baha 95ea0b0ef7 Make RelatedArticles available as a beta feature
Hide the related articles from the sidebar if ReadMore is enabled.
Otherwise leave as is because it's used in WikiVoyage.

Bug: T117444
Change-Id: I3879ae1e53de301b0d3f5f2c066f8e8de7c1c223
2015-11-25 20:43:51 +05:00
jhobs d08962d12d [Hygiene] Rename internal uses of "article" to "page"
Leave all public-facing uses of "article" (including classes) because
the extension is remaining named RelatedArticles. Replace all other
instances with "page" for consistency with other extensions.

Bug: T117908
Change-Id: Ib0f258f26b0d11cfe8a598dbd90ff37afbbe36ac
2015-11-13 19:03:39 -05:00
Sam Smith 239705928d Remove CustomData extension dependency
The related pages stored via CustomData  will have been migrated to the
cached ParserOutput class over the last 30 days, per I30bd17f, so all
interactions with/references to CustomData can be removed.

Bug: T115019
Change-Id: I36919d2443f0ee02ac6baf9a4d2228b028b2e6ed
2015-11-10 17:03:06 +00:00
Sam Smith aa30f477bd Clear extension data in ParserClearState handler
While the related parser function sets the accumulated related pages as
extension data on the parser output
(see RelatedArticles\Hooks::onFuncRelated). The ParserClearState
handler, however, sets the empty list as a property, which is then
stored in the DB.

Changes:

* Make RelatedArticles\Hooks::onParserClearState use
  ParserOutput#setExtensionData, mirroring ::onFuncRelated
* Add a unit test for the the handler

Bug: T115698
Change-Id: I3deaf1e8ee78944250c3f26315ee2450b444a035
2015-10-16 20:33:52 +01:00
Sam Smith 45787910d3 Hygiene: Fix PHPCS errors
Also, add more detail to the
RelatedArticles\Hooks::onOutputPageParserOutput DocBlock.

Change-Id: I484ebfe255bc07a11d84f518014c8cc4f73f62db
2015-10-14 11:31:50 +01:00
jdlrobson 8782824cfc Remove CustomData dependency
Since CustomData was written ParserOutput now supports the setting
and getting of properties. This patch switches RelatedArticles to use
that. I'm not sure if any other extensions depend on CustomData but
it seems to have served its purpose.

Bug: T114915
Change-Id: I30bd17fd8c43422fe7ab6f58a74565674e15ba1d
2015-10-08 15:57:44 -07:00
Sam Smith 7995ce4a42 Use extension registration
Add extension.json and populate it with information from both
RelatedArticles.php and the RelatedArticles extension wiki page [0].

Migrate the hook handlers to static functions operating on static data
rather than having a single, global instance of RelatedArticles so that
the hook handler definitions can be added to extension.json easily.

N.B. During testing the handlers for both the SkinBuildSidebar and
SkinTemplateToolboxEnd appeared to have the same effect so the TODO was
removed but not the handler for the former.

Additional changes include:

* RelatedArticles.class.php -> includes/RelatedArticles.php
* RelatedArticles -> RelatedArticles\Hooks
* Documenting all of the methods of RelatedArticles\Hooks

[0] https://www.mediawiki.org/wiki/Extension:RelatedArticles

Bug: T87965
Change-Id: I9944b9186746386ee18ca28657bb547c00ae2b8c
2015-10-07 15:54:07 +01:00