Commit graph

50 commits

Author SHA1 Message Date
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
jhobs e68d5b6599 Use mw.viewport to check when to load related pages
Does not change distance threshold.

Bug: T135607
Change-Id: I82dfa78e93f4bb7a8a28d038470265e7fd30c423
2016-09-02 12:01:17 -07:00
Kunal Mehta ac5448adcc Use SidebarBeforeOutput hook instead of echo'ing HTML
Ewwwww. This also fixes display in MonoBook.

Change-Id: I5c50722285a0dcf8af09674e3dd80e37128b279a
2016-07-29 20:34:40 -07: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
jenkins-bot 309bf6738c Merge "Mark extension as Beta Feature" into dev 2016-01-16 04:40:36 +00:00
Prateek Saxena 8bfb922c1a Mark extension as Beta Feature
Change-Id: I33d2c1cd7c868e98874328216b16627a7c47dbc4
2016-01-15 18:51:19 +05:30
Baha d2599c5211 Do not load related articles on diff comparision pages
Bug: T122076
Change-Id: I1dc00b3bd76053d353dc31137c4c15a10286184e
2015-12-29 07:57:47 +05:00
jdlrobson c5408e3624 Release 2.1.0
Bug: T121052
Change-Id: I46c7f99b1a54eabf4f8304727f6ea7684f038e14
2015-12-14 09:40:11 -08:00
Sumit Asthana 9623c1cc42 RelatedArticles load after half window scroll
Only triggers RelatedArticles module load and query after user has scrolled
through half the document height.

Bug: T116838
Change-Id: If290988fb7cc187cad37dd4a8a2c4f38abed9bb9
2015-12-08 20:51:16 +05:30
Baha d843523fcf Breaking: Release version 2.0.0
Bug: T119749
Change-Id: I5e159bbe116771b4efef96baa2e85b2dcf783a6f
2015-12-07 21:00:19 +05:00
Sam Smith 040314c504 Configure footer and sidebar placements
Changes:
* Rename $wgRelatedArticlesShowReadMore to $wgRelatedArticlesShowInFooter
* Add $wgRelatedArticlesShowInSidebar, which is truthy by default, and
  short circuit the SkinBuildSidebar and SkinTemplateToolboxEnd hook
  handlers if it is falsy

Bug: T119926
Change-Id: Idf04bf3221ba44d7b898160764fbd6ba83561abb
2015-12-02 11:17:54 +00: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 3e943d79a1 Release version 1.2.0
Bug: T119749
Change-Id: I0038b4400ddc507639a22df7cb85e699cad4a877
2015-11-27 08:32:06 +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
Baha 8cf9b60ab5 Make RelatedArticles soft-depend on Cards
RelatedArticles tries to load the 'ext.cards' module and if
it succeeds it continues with showing the related articles
on the page.

Dependency: I6661527175eb889cec4193b18fa18207f332b4fc
Bug: T117108
Change-Id: I33936a3e9cd5d1f0296e48fd1c2bba77fff4e466
2015-11-18 22:22:10 +05:00
Sam Smith 0fed50e266 Optionally disable Read More using extension data
By default, the Read More feature tries to use editor-curated articles
before using the CirrusSearch morelike: feature. Add a configuration
variable that disables the former behaviour but leave the default in
place.

Changes:

* Add the wgReadMoreOnlyUseCirrusSearch configuration variable, which
  defaults to false, and pass it in to
  mw.relatedArticles.RelatedPagesGateway at construction time
* Add the onlyUseCirrusSearch parameter to
  mw.relatedArticles.RelatedPagesGateway, which controls whether to
  ignore the editorCuratedArticles parameter

Bug: T117443
Change-Id: I0dfa67f4a68e8dc17302fef7ebf8d23c0c1d892c
2015-11-12 12:43:29 +00:00
Baha 3995b7a8ef Add event logging to read more
* Schema is located at https://meta.wikimedia.org/wiki/Schema:RelatedArticles.
* Track 'ready', 'seen', and 'clicked' events.
* The sampling rate can be set using the RelatedArticlesLoggingSamplingRate variable.
  If the variable is not set, sampling will be disabled. The default sampling rate
  is 0.01.
* Events are tracked using a unique user session token.

Dependency: Iea00d534371353c3ae5c06c74a08aa10cb60047b
Bug: T114303
Change-Id: I649d0817cbd10ad734989da548d20ad33e7f7360
2015-11-10 15:23:12 +05:00
Sam Smith 5b5a0b288f Put Read More behind a feature flag
Changes:
* Add the RelatedArticlesShowReadMore feature flag, which is disabled by
  default
* Only consider adding the Read More bootstrap module to the output when
  the feature is enabled

Change-Id: I60fc38115257c9a5dbf04b51dbec7f091574d8f6
2015-11-06 20:12:27 +00:00
jdlrobson e86fc3b159 Fall back to CirrusSearch's morelike: feature
When no related articles have been specified by an editor we instead
hit request pages similar to the current page using the CirrusSearch
extension's "morelike:" feature [0].

Changes:
* Config variable introduced RelatedArticlesUseCirrusSearch which allows
you to turn on use of the CirrusSearch API.
* Introduce a RelatedPagesGateway for dealing with making the API call
  and returning consistent results
* Move the "simple" API call for hydrating related pages fetched from
  the wgRelatedArticles configuration variable into RelatedPagesGateway
* Reduce the bootstrap module to just a bootstrap module!

Bug: T116707
Change-Id: Ia0ced1d7ae57c0939d1f5af275aa9d393f1420b1
2015-11-06 10:23:39 -08:00
jdlrobson 8f191de636 Release version 1.1.0
* Switch default branch to dev for future development

Bug: T117612
Change-Id: I404e412330f9416b863012b5125cbf4fc6d2b4ce
2015-11-04 15:08:10 +05:00
Sam Smith 7c23636954 Add Related Articles section to Minerva
If the page has related articles, is in mainspace, isn't the main page,
and the output is being rendered with the MinervaBeta skin then a
"Related Articles" section is added to the page just before the footer.

Separate loading the information necessary to render the pages, choosing
the renderer, and rendering the data so that multiple skins - currently
Minerva and Vector per the mocks - not just multiple resolutions can all
be handled the same way:

* The bootstrap script (ext.relatedArticles.readMore.bootstrap/index.js)
  for fetches the page image and Wikidata description; loading the
  renderer module; and, finally, notifying the renderer module that it
  should render the data, which it does by emitting
  "ext.relatedArticles.readMore.init" event using mw#track
* The Minerva renderer subscribes to the event and, when it's fired,
  renders the data by passing it to the WatchstarPageList view

Bug: T113635
Change-Id: I651342bdf9796938fa7051828dd13bc6fe774783
2015-10-26 17:13:46 -07: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
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