Commit graph

44 commits

Author SHA1 Message Date
jdlrobson 298790a944 Upgrade to eslint
We're going to want to use a newer version of JSHint
anyway to support use of ES6 in our browser tests so now
seems a good time to do this.

Bug: T149202
Change-Id: I5526b020cfc12c0e065ad15ed711a0e3a7bff1bc
2017-04-10 14:12:25 +02: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 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
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
divadsn e9102f8d35 Large gap left in footer on pages with no related articles
An empty container was left on the page despite there being no related articles.
This should prevent adding the container on pages with no related articles.

Bug: T147217
Change-Id: I074a12e2d6680403551c436a4b00c3b9ab1c8d09
2016-12-12 22:18:28 +00:00
jenkins-bot 4490e1b9bb Merge "Perf: don't load a module unless necessary" 2016-09-26 15:12:28 +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
Baha 5f98265e7e Increase threshold for loading related articles in the footer
The threshold is now 2 times the window height per Nirzar.

Bug: T144822
Change-Id: Ia72b0532e481211645364a1ed9715f6f07f28fca
2016-09-15 15:11:13 -04:00
Baha 6941c6df9a Change scroll threshold to viewport height * 1.5
The threshold used to test whether related articles need to be
loaded has been changed to the viewport height * 1.5 from the more
complicated formula used earlier.

The change should help with loading related articles more smoothly.
To eliminate the lag completely the related articles need to be
rendered in the back-end.

Bug: T144822
Change-Id: I9d189163b95533ca43fa3d8632f65b280470f12a
2016-09-13 10:25:53 -04:00
jenkins-bot 26d3633b44 Merge "Cache "morelike" requests for all users" 2016-09-06 16:01:09 +00:00
Sam Smith 8b8db66dd1 Cache "morelike" requests for all users
In order to minimize loading time of RA for as many users as possible,
we need to maximize the number of users that can be served by our edge
caches.

Currently, if you're logged in, then the API uses your language by
default and so responses are always private, i.e. they shouldn't be
cached by a shared cache and can be cached by the browser.

By requesting that the response be in the language of the content, the
API ignores your language and responses become public, i.e. they can be
cached in a shared cache and can be cached by the browser.

Changes:
* Add the `uselang=content` parameter to the morelike request
* Add the `maxage=86400` parameter to the morelike request, allowing the
  browser to cache the response for 24 hours, which'll save the device
  even making the request

Bug: T126455
Change-Id: I6216a088d865f27f7cc3725fc311191da42a27ba
2016-09-05 11:33:12 +01: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
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
Baha 8afb02b64a Cache morelike requrests
The cache length is 24 hours.

Bug: T126455
Change-Id: Icd328f70ced16cc43fc0ad62c8a1f49ce71d6369
2016-08-29 15:54:53 -04:00
Baha 9ca3eb6dda Use 'classic_noboostlinks' search profile
Bug: T141398
Change-Id: I0db2d21fe9e4735e27af6071b2190a5829477278
2016-08-29 15:38:09 -04:00
jdlrobson fc7799b9f3 Allow skins a mechanism to decide on placement of related pages
* If a footer-content element is present prepend there
* If no footer-content element given wrap the component in a container that is known to be compatible
with known skins - this has post-content class (for backwards compatiblity with
old Minerva skins) and a class to apply the correct margin to Vector

Bug: T141002
Change-Id: Iac11948f8f5fdaad45d51b905bb7494a84775710
2016-08-23 11:51:33 -07:00
Florian 66a05df808 Remove 70px margin-bottom in mobile view
Combined with the padding top of the footer, this results in a
massive unused white space area between the related articles box
and the footer, which is now removed.

Extra points: Removed unused less import

Bug: T138185
Change-Id: Iaf008977bce3c003fe0fad7c16ed6bf94aef60f9
2016-07-19 18:29:45 +02:00
Tacsipacsi 1b952bde29 Add "noprint" class
Add "noprint" class to the <aside> element containing the suggestions and the header.

Bug: T123551
Change-Id: Ie7de692208028fe788ffd3c901ee4649390203a7
2016-04-17 21:45:10 +02:00
jhobs 40dc624620 Temporary fix for blurry images
Request double the size until pithumbmode is implemented.

Bug: T123549
Change-Id: I773c5a1a68c73f1ed721b1acc729db3d51b8b661
2016-04-11 21:36:06 +00: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 d24e8f01d2 Design review
Changes:
* Reduce the size and increase the spacing of the Related Pages header

Bug: T122030
Change-Id: I26273a1602e2e329b68d23d01c0f75f69b821b92
2016-01-28 19:05:41 +00:00
jdlrobson f13cdafbb1 Remove bottom border on related pages heading
Bug: T122030
Change-Id: Id656acadec617f837046816a9b8b2dfbe756b7f0
2016-01-26 16:00:38 -08:00
Baha 929c249018 Design tweaks to Cards
* Move after the content in Vector
* Make title uppercase

Bug: T122030
Change-Id: I8f33ff4115a6a5d328ebbb924293cd4944bc0143
2016-01-19 21:09:07 +00:00
Baha d2599c5211 Do not load related articles on diff comparision pages
Bug: T122076
Change-Id: I1dc00b3bd76053d353dc31137c4c15a10286184e
2015-12-29 07:57:47 +05:00
jenkins-bot a079805616 Merge "Hygiene: Minor styling improvements" into dev 2015-12-21 03:08:54 +00:00
jdlrobson 302ddedf21 Hygiene: Minor styling improvements
* Using nesting in LESS allows you to easily identify in large stylesheets
what to remove/update when changing a component class/removing it entirely

Change-Id: I9190e16c5db9ba0bd6357f8685268af5e1cb93fe
2015-12-18 17:34:42 +00:00
Baha a3d9b22a66 Fix loading related articles on small screens
Related articles are loaded when the user scrolls past
half the document height, which used to be calculated on
page load. This height, however, changes after all sections
are collapsed on small screens, thus never loading the
related articles for the page. Calculating the document height
just before showing related articles allows us to correctly
decide whether it's time to load the needed modules.

Bug: T121263
Change-Id: I1266894ab763cfb571b14f067086445fb6be1887
2015-12-14 15:34:17 +05:00
jdlrobson ed338bbed5 Disable RelatedArticles when editor enabled
We only want to show it in view mode.
When a reader hits edit, wgAction is view so we add a CSS rule to
hide the widget when that transition occurs.

This means related widget does not show up post edit (you'll need to
refresh but this seems like an acceptable workaround until we can
understand this issue some more)

Bug: T120443
Bug: T120735
Change-Id: If1356906d5f55167c9d1abbed88f433f36b7f390
2015-12-09 16:47:52 -08:00
jenkins-bot 4af4c384dc Merge "RelatedArticles load after half window scroll" into dev 2015-12-08 23:27:24 +00: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
Paladox 8a73239abf Update packages
Update grunt-jscs to 2.4.0

Update grunt-jsonlint to 1.0.6

Change-Id: I34b1f23469a35e64345ee42a183dd74679e50b81
2015-12-07 21:00:56 +00: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
Sam Smith f87807e457 Limit the number of pages to 3
Bug: T116810
Change-Id: I175a1fd26d2041e3c652c80653a73b4211b992e6
2015-11-13 12:01:35 +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
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
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
Sam Smith 816003cb48 Tweak readMore.minerva to reflect upstream changes
As of I6a5b43a, WatchstarPageList requires that options.api be an
instance of mw.Api and fails, loudly, when it isn't passed.

Bug: T117467
Change-Id: I7394dea5ab026de1a6709c56d8db4ff72788b59d
2015-11-02 20:04:37 +00:00
jdlrobson e4685f02be mw.config.get doesn't work that way.
You can't give it a fallback value. This is causing JS errors in
production.

Bug: T116758
Change-Id: Ia459a42250ca6e030025781005e40204f1ede58e
2015-10-29 13:57:50 -07: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