Commit graph

103 commits

Author SHA1 Message Date
jenkins-bot 9a11bcee04 Merge "Replace deprecated @borderRadius var with successor @border-radius-base" 2022-11-09 18:21:42 +00:00
Volker E 2e2159d1b5 styles: Remove linear-gradient vendor properties
All targeted browsers have fallen out of basic support.

Bug: T306486
Change-Id: I3d5d49d2911c72806922bdbba26ab2c8470588f8
2022-11-07 21:02:15 -08:00
gerritbot f3f58c0666 Replace deprecated @borderRadius var with successor @border-radius-base
Replacing deprecated mediawiki.ui `@borderRadius` variable with successor
@border-radius-base.
Former got deprecated in MW 1.35 about 2 years ago. Latter is in alignment
with mediawiki.skin.variables.less standardization. It's also in
accordance to Codex design tokens.

Bug: T322478
Change-Id: I6f9fe0a7d98713a66e1b7e78f105817f428c636f
2022-11-06 22:59:13 +00:00
Jon Robson 2665e3c319 Add TypeScript support
For now it is limited to a single file RelatedPagesGateway.js
For now @types/jquery is requirement due to use of
wikimedia/mw-node-qunit and usage of MediaWiki core methods
and OOUI that use jQuery.

Change-Id: I370826bb3f521dcb5a68491990571ee1c87117ae
2022-04-27 19:11:10 +00: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 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 dfce5b1cb7 RelatedArticles should not use mw.trackSubscribe
Instead export a render method

Bug: T149317
Change-Id: I2b88690d381f896d6a646046574528a2312c91c2
2022-04-18 16:28:14 +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
Volker E 6ea57f8060 Remove outdated browser workarounds
Linear gradients are now supported by all our basic support browsers.

Change-Id: I5563f70f45ab90be6b1073f2c0af7c56d0bd366b
2021-06-22 06:47:26 -07:00
Jdlrobson 80ef6cffb4 Hotfix: loadRelatedArticles should consider existence of container element
If undefined, the offset function will return undefined.

Bug: T281547
Change-Id: I8ae3c1ee1d259c67d597a1891af029e6192008f8
2021-04-30 16:03:28 -07:00
Volker E ba98c5883f Replace deprecated background-image-svg() mixin calls
Use normal `background-image` properties with SVGs now
that IE 8 and Android 2.1 are removed from Grade C.
Also removing PNG fallback image.

Bug: T248062
Change-Id: Ia2a102dfe8865aa0bca93453d01f11ab3ab57149
2020-07-23 22:12:35 -07:00
Ed Sanders ebecd9c144 build: Update eslint-config-wikimedia to 0.16.2
Change-Id: Ib6681e7d5fb03f4fa54823bf0d37e16d37be3416
2020-06-23 20:30:43 +01: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
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
Saint Johann e0547ff7cc Fix background-size on thumbnails
Bug: T229664
Change-Id: I001e3aea67ca09bf657b3895c7e0bcb4c63412ea
2019-08-07 10:53:50 +00: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
Volker E 2d7c4e979e Update 'noimage' to unified 'article' icon
Equivalent to latest 'article' icon in Design Style Guide and OOUI.
Also updating `.list-thumb-none` class to align icon and simplify
maintenance.

Bug: T222717
Change-Id: I49a89afa3d370abc4cf282a0bf8d44ee2751aa78
2019-06-05 17:05:31 -07: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
Jan Drewniak fcd4d1a272 Hygiene: Followup from 191fc2a
pass a collection of jQuery objects to `.append` instead of
and array.

Use `.css` instead of `.attr` to set thumbnail background image.

Change a unit to reflect the escaping pattern of the `.css` method

Bug: T219846
Change-Id: I6359be2db6c7c7a8e4b52296e0801d4ded921b46
2019-05-01 22:28:47 +02:00
Volker E a7e6c196f7 Remove -o-linear-gradient for Opera 11.5, Opera Mobile 12
Removing obsolete vendor property specifically for old subversion
of Opera < 12.1, desktop and mobile.

Change-Id: Id9a8a9fffb594f3973486f7be243329abdc9a5fa
2019-04-17 12:54:23 -07: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
James D. Forrester 2066d438ae build: Upgrade eslint-config-wikimedia from 0.10.1 to 0.11.0
Change-Id: Ie1f3e5f9ead8f69da554fb9a3260fa44b1c91f4e
2019-04-03 16:21:00 -07:00
Volker E 1fc22a3892 Remove .background-size() mixin usage
Removing deprecated LESS `.background-size()` mixin calls.

Bug: T219956
Change-Id: I2602fb46b3ae757ad2f1653ff3862fbc59adfc9c
2019-04-02 19:58:07 -07:00
Ed Sanders 26b15d19b9 build: Update eslint-config-wikimedia to 0.10.1
Change-Id: I01388bfdda108e9e80b32d68983e1d826d0db784
2019-02-10 16:46:48 +00:00
Volker E 9a5d59caee build: Update 'stylelint-config-wikimedia' to v0.5.0 and make pass
Also enabling 'no-descending-specificity' rule and the same time
simplify VE hidden rule.

Change-Id: Idad811e7fca681883fccbc961c70f49e2b356c02
2019-01-16 19:26:36 -08:00
Volker E 68e0e12794 Increase headline color contrast slightly to conform to AA ratio
Bug: T208343
Change-Id: I31d3c0a06de9597a8fc1367a7d3b906b8ffe9921
2018-10-30 12:33:45 -07: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
Fomafix 00405b0309 Remove mediaWiki and jQuery from eslint globals
Remove all mappings in the closures like in
I7cf2426cde597259e8c6f3f6f615a1a81a0ca82b in core.

Change-Id: Ie9a2fadb8e276774784a4937bb5c3ec11f213352
2018-09-15 17:54:03 +00:00
Fomafix 0464e7a7c0 Remove eslint rule "no-use-before-define": 1
Add no-use-before-define to the line where the rules is violated.

Change-Id: Ieb50b11292cff6b40fdd5f06c76d61bb01e86e4c
2018-08-17 13:29:08 +02:00
Fomafix 0fa064728f Use native JavaScript instead of jQuery
Replace
* $.each( array, function ( index, value ) { ... } ) by
  array.forEach( function ( value ) { ... } )

* $.map( array, function ( value ) { ... } ) by
  array.map( function ( value ) { ... } )

* $.isArray( var ) by
  Array.isArray( var )

* $.isFunction( var ) by
  typeof var === 'function'

Change-Id: I450f5a75eb9c3fe20517da02986b0a491ebca67a
2018-08-17 12:45:12 +02:00
Stephen Niedzielski 4e92ea4680 Fix: replace deviceTabletWidth w/ width-breakpoint-tablet in LESS
T140804 dropped the support for deviceTabletWidth in core
(https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/451648/9/includes/DefaultSettings.php).

Bug: T202021
Change-Id: I0d215bcd66654ac8646e6cc66f673e7e7b7fe945
2018-08-16 09:23:56 -05:00
jdlrobson efb41140a5 Contain code in own call stack
Per Timo's recommendation on Ife362f43d061d32fb0441dd1136fb11b46b475ae
use then instead of done for callback handling

Change-Id: I18dbfff59cb90a5076aa6f3b077ba9c264f7c139
2018-06-19 11:41:25 -07:00
jenkins-bot d76a4fde65 Merge "Correctly remove node without exception" 2018-06-06 10:42:44 +00:00
jdlrobson 7f7b2022a7 Correctly remove node without exception
$( '.read-more-container' ).get( 0 ) returns a DOMElement not a
jQuery object so there is no remove method. This will throw a
JavaScript exception.

It seems JavaScript exceptions can impact the loading of Wikidata
Page banners.

Bug: T152185
Change-Id: Ife362f43d061d32fb0441dd1136fb11b46b475ae
2018-06-06 11:27:06 +01:00
Jan Drewniak 816bda69c5 Replace pageterms with description API
Bug: T190953
Change-Id: Ia188a7bdc4d3533d6ee0e9bb06fa62da4b759c66
2018-04-13 10:02:14 +02:00
Stephen Niedzielski bc70678d22 Fix: wait to show related articles until ready
Wait until the Document is ready before appending related articles to
avoid the "last edited" link appended in afterwards.

This fix is untested as I've been unable to repro the issue reported.

Bug: T187479
Change-Id: Ieefaf644040ea057a65649a3ce14de3531ec2e72
2018-02-22 08:53:17 -06:00
Volker E 2e0c5719ea Unify SVG markup
Align SVG markup across Foundation products by
- unifying XML declaration,
- removing `enable-background` as it's deprecated and
- unifying whitespace.

Bug: T178867
Change-Id: I32972de815484fa89bd7cdacbbcd65f4663a4161
2017-12-18 19:43:17 -08:00
Ed Sanders 10de1deaf4 build: Update eslint and stylelint
Change-Id: I82bfb5fbfea4997f3048305574d2ff7d28ecd1b8
2017-10-09 15:37:28 +01:00
Volker E 6add5a1eac Align 'noimage' to WikimediaUI color palette
Aligning 'noimage' to overhauled color palette, background-color
equaling footer color and icon color going to closest,
minimally higher contrast color `#72777d`.

Bug: T172850
Change-Id: I949db4983910ef6609124adbfcd3c0d31a7f7eb4
2017-08-25 06:12:14 -07:00
Volker E 581a247d70 Replace abandoned colors with current WikimediaUI ones
Replacing abandoned `@colorGray8` (`#888`) & `@colorGray9` (`#999`)
with slightly increased contrast, WCAG 2.0 level AA conformant,
`@colorGray7` from WikimediaUI color palette.

Bug: T172850
Change-Id: I750261b83cc79c32e9ccdb2d69bb5e396b20ed35
2017-08-09 17:49:35 -04: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
jdlrobson 9b75e0b372 Hygiene: Remove unnecessary variable
Improves readability...

Change-Id: Ib0e9cbc083e6c0a384c81815b470063698e0595f
2017-07-14 16:15:35 -07:00