Commit graph

55 commits

Author SHA1 Message Date
Umherirrender 72bf976e12 Rename file ResourceLoaderMuhoganModule.php to match class
Change-Id: Ibdabb503fbbe6c17f041943cae8fa6ee4dbdfe20
2017-12-09 23:15:30 +01: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
jenkins-bot 70787d2d70 Merge "Breaking change: Remove Sidebar code from RelatedArticles" 2017-08-10 18:26:08 +00: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
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 f748c5907e Add limit via ResourceLoaderGetConfigVars
Using MakeGlobalVariablesScript hook will add config variables to
the HTML meaning cached HTML will not be able to access it leaving
it as undefined. This will mess up any existing caching.

Additional changes:
Because I'm paranoid, make sure that value is never undefined.

Bug: T170648
Change-Id: Icb8e34104c57b1e69b7e035ef89d5b4c3371132f
2017-07-14 16:42:53 -07: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
jenkins-bot 750f3d73fd Merge "Hygiene: SamplingRate -> BucketSize" 2017-06-22 18:40:08 +00:00
Kunal Mehta 87b7254eaf build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.FunctionComment.Missing.Public

Change-Id: I591fd0cd60147b9f5ddd3d1b9e74f79a0bb3f595
2017-06-20 00:20:19 -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 26e4e8d1fd Schema:RelatedArticles revision update
Log the `feature-enabled` event for users who are eligible to see the
ReadMore feature. Otherwise log the 'feature-disabled' event.

Suporting changes:
* Register the latest version of the RelatedArticles schema.

Bug: T157375
Change-Id: I1557de88c7602aa066833bd55b83e6ee51d27178
2017-03-06 10:48:35 +00: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
jdlrobson 36dfaccd2f Always show RelatedArticles to users who opted into beta feature
Additional change:
* Correct how we expose RelatedArticlesEnabledSamplingRate so that
it includes the wg prefix and is consistent with other config values

Bug: T157372
Change-Id: I274de542cf461de60f903ddbc0353a4116016007
2017-02-07 16:05:26 -08:00
jenkins-bot 3a8127954a Merge "Do not disable footer feature when BetaFeatures is not installed" 2017-02-03 10:11:35 +00:00
Gergő Tisza 3cf6d638f7 Do not disable footer feature when BetaFeatures is not installed
Bug: T146436
Change-Id: I0ac855cdace3f40977ca3af3cfc187856532bba8
2017-02-03 09:51:28 +00:00
Piotr Miazga 8a3aa6fba8 Hygiene: Instead of non-testable class_exists use ExtensionRegistry
Changes:
 - use ExtensionRegistry to check Disambiguator extension existence

Change-Id: Ibb1fa899fe3b07074ef5c69911d0b7a4e09336ae
2017-02-01 10:37:11 +00: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
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
Baha 613ed40d23 Perf: don't load a module unless necessary
Move logic that loads related articles in the footer to PHP from JS.
This prevents us from shipping an RL module to a client and not showing
related articles.

Also, make sure not to load related articles in footer on
Special:MobileDiff.

Bug: T144047
Change-Id: I73e39ee6b1223699cd8ac739902315d163d98c3b
2016-09-26 08:01:07 +01:00
jdlrobson f960e7b651 Remove styles for old Minerva design
This CSS rule exists for Minerva's old footer. Considering Related
pages is currently only in mobile beta and the new footer should go
live before related pages does. The cost of maintaining 2 related
pages Minerva designs is not worth it.

In a follow up patch the read more container class will be reintroduced
to Minerva

Change-Id: I2d5c4e73c0cfa3f1107a0fd195d3e09f4e14ef2a
2016-09-02 11:56:17 -07:00
Jdlrobson 4b53afc983 Don't hit the DB unnecessarily
If $wgRelatedArticlesShowInFooter is false, then we'll still test
whether or not the page is a disambiguation page with the Disambiguator
extension. Unfortunately, DisambiguatorHooks::isDisambiguationPage hits
the DB.

Order the tests in RelatedArticles\FooterHooks::onBeforePageDisplay from
least expensive to most expensive so that the DB is queried only when it
must be.

This version of the patch takes into account namespace.

Bug: T127068
Bug: T144409
Change-Id: Ie6ddaa4e9bd8326c8b84dc400b78e9a4f4d0d78d
2016-08-31 20:13:05 +01:00
Jdlrobson 9e67ef6590 Revert "Don't hit the DB unnecessarily"
We forgot how namespaces work:
Catchable fatal error: Argument 1 passed to RelatedArticles\FooterHooks::isDisambiguationPage() must be an instance of RelatedArticles\Title, Title given in /srv/mediawiki/php-master/extensions/RelatedArticles/includes/FooterHooks.php on line 48

This reverts commit 9ede8913c7.

Change-Id: If0f1481854815c12613771041685c7837a95ec65
2016-08-31 18:57:41 +00:00
Sam Smith 9ede8913c7 Don't hit the DB unnecessarily
If $wgRelatedArticlesShowInFooter is false, then we'll still test
whether or not the page is a disambiguation page with the Disambiguator
extension. Unfortunately, DisambiguatorHooks::isDisambiguationPage hits
the DB.

Order the tests in RelatedArticles\FooterHooks::onBeforePageDisplay from
least expensive to most expensive so that the DB is queried only when it
must be.

Bug: T127068
Change-Id: Ie3e7e410026cf354d831ae3c2134cfc0957eb8db
2016-08-31 09:38:34 +01:00
Baha b486500ba5 Add documentation
Bug: T127068
Change-Id: I5b640f8fe90cb2b07e7e5113e5dff398684c0c68
2016-08-29 15:59:57 -04:00
Sumit Asthana cea66f6cda Disable related articles on disambiguation pages
Uses DisambiguatorHooks to prevent related pages module addition on
disambiguation pages.

Bug: T127068
Change-Id: I166712d7e5df26ad00c725f3e4fe23ec074b3329
2016-08-24 04:12:45 +05:30
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
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
Baha cfc73ff5c9 Remove the isElementInViewport function
Use mw.viewport.isElementInViewport instead.

Bug: T124317
Change-Id: I621aa4c21d673d8d431bb38ba094271b570ca93c
2016-04-07 12:23:38 -04:00
Baha f4400ec5c9 Fix RelatedPages placement in Monobook
* Load skin specific styles only in that skin;
* Vector styles are default for all skins unless overwritten;
* Allow monobook styles to inherit from vector styles;
* Do not load visual editor related rules in minerva;
* Remove an unused CSS rule.

Bug: T126149
Change-Id: I1e657de7a45fb4812c42ca7b99624b585dc4b7dd
2016-02-23 14:13:09 -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 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
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
jenkins-bot b83e1bdc58 Merge "Optionally disable Read More using extension data" into dev 2015-11-12 15:55:01 +00: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
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
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