Commit graph

1047 commits

Author SHA1 Message Date
Translation updater bot 587877b79a Localisation updates from https://translatewiki.net.
Change-Id: I6633f347b1ba38ee3812bffb839a9cc4a3963834
2017-03-08 22:39:21 +01:00
joakin eff14acbba Tooling: Use latest stable webpack
Webpack 1.14.0 is an old version, switch to using latest stable which
has better documentation, tree shaking, ES2015 modules and a core team
of contributors with funding. See https://webpack.js.org/

Additional changes:
* Recompile the frontend assets

Change-Id: I2c5940276e99dee104d04c6a0b83d8ab36a99df5
2017-03-08 19:27:40 +01:00
Sam Smith d4caff9774 rest: Don't scale unscalable thumbnails
If the image isn't an SVG then it shouldn't be scaled past its original
dimensions. Handle the case where the requested thumbnail can't be
generated on the server as the original is too small ( < 320px,
currently [0]) in the same way.

Moreover, if the image happens to have the exact dimensions that we're
requesting (300px or 600px wide, currently [1]), then use the original
image to avoid unnecessary work/pressure on caches.

Supporting changes:
* Update the SVG_RESTBASE_RESPONSE fixture to use the extension returned
  by RESTBase (and the PageImages extension) for the thumbnail:
  .svg.png.

[0] https://github.com/wikimedia/restbase/blob/master/v1/summary.yaml#L121
[1] https://github.com/wikimedia/mediawiki-extensions-Popups/blob/master/src/constants.js#L2

Bug: T156800
Change-Id: I5d0aa161e80869e4b4f5425d906d1e753047a3a3
2017-03-08 18:44:23 +01:00
jenkins-bot 22a24c9292 Merge "Bundle dist versions of redux and redux-thunk" 2017-03-08 17:08:12 +00:00
jenkins-bot a4d0cb13a4 Merge "Docs: Add adr about running QUnit tests in node" 2017-03-08 17:04:51 +00:00
joakin f1d8dc7d75 Docs: Add adr about running QUnit tests in node
Change-Id: Ie887a88b81dcc120e5e9bf53c9c0bf5886259a2e
2017-03-08 08:59:56 -08:00
joakin 1b81d0fdfa Bundle dist versions of redux and redux-thunk
Instead of importing the modules from sources (which you should do if
you properly define NODE_ENV and use uglifyjs from webpack) import the
already compiled files on the npm packages.

This results in 5kb less on the compiled bundle.

Change-Id: I83732ea79a59b611c117ddcf4c262948c795f642
2017-03-08 12:41:03 +01:00
jenkins-bot f08f7cb012 Merge "Add code coverage reports npm script" 2017-03-08 10:45:29 +00:00
jenkins-bot 36fd908c2d Merge "renderer: Ensure settings cog visible in IE9-11" 2017-03-08 10:22:29 +00:00
jenkins-bot f6e1f74226 Merge "renderer: Ensure images don't overflow container" 2017-03-08 10:21:48 +00:00
Sam Smith 0cf00b04fa renderer: Ensure settings cog visible in IE9-11
Following on from I19e67ae4, IE9-11's treatment of SVG elements that
overflow their containers means that the truncating pseudo-element and
the settings cog is occluded in a portrait-mode preview.

"Pad" the extract horizontally using a margin to force the SVG element
into the correct position.

Bug: T156800
Bug: T139297
Change-Id: I0da6af6d4cbcc69c6465b37714856e59199ae6e4
2017-03-08 09:40:37 +00:00
Sam Smith 57f3d4865e renderer: Ensure images don't overflow container
Unlike modern browsers, IE9-11 (at least) don't hide the overflowing
parts of an SVG image element. Make this explicit by adding the
overflow: hidden property to the preview's container element.

Bug: T156800
Bug: T139297
Change-Id: I19e67ae4584d90c02dc5a2dd1c8bdb5773cd2283
2017-03-08 09:40:37 +00:00
joakin 91fd2dfd50 Hygiene: Remove duplicate file preview/index.js
The same file is on preview/model.js which is the one actually used by
the application. For some reason the file is a duplicate of model.js,
and it is the file that is required on its QUnit tests.

This patch removes it and points the unit tests to the correct file,
preview/model.js

It was also required by popups.js which was removed in the previous
commit.

Change-Id: Id175a764d9b67fb8d0e8fbf4a4623a3420f76094
2017-03-06 18:07:43 +01:00
joakin 49d4396e7a Hygiene: Remove global variable mw.popups in most places
Now that most unit tests are run in node with common.js for loading
sources there is no reason to keep global variables around exposing all
the sources.

Only exception is the only qunit integration test processLinks.test.js
which still consumes mw.popups.processLinks, which is the only global
variable remaining in the codebase.

Changes:
* Remove references to mw.popups in code comments and reference the JS
  file instead
* Remove popups.js which exposes all common.js modules as global
  variables
* Export mw.popups.processLinks in processLinks.js for testing in
  processLinks.test.js

Change-Id: I91066654b9282f73a80eb1ba5018bd091656c61d
2017-03-06 17:10:35 +01:00
joakin d6497c5a66 Hygiene: Remove stubs files from browser qunit tests
Changes:
* Remove tests/qunit/ext.popups/stubs/ files
* Remove RL module ext.popups.tests.stubs from PopupsHooks.php
* Change PopupsHooksTest to assert 1 qunit resource module instead of 2

Change-Id: Ic6e971b69e4d5898d237c37982f400671412ddda
2017-03-06 17:09:15 +01:00
Baha b40a24c15c Allow showing non-free images when using MediaWiki API
We used to query the MediaWiki API to only return non-free images.
This patch allows us to query the API for images with any license.
The RESTBase end point is already returning images with any license.

Bug: T158632
Change-Id: I9ac60b6f74a7f7eb2cb160ee522c2c3a26dd0858
2017-03-06 11:33:17 +00:00
Translation updater bot 41fcbcc1da Localisation updates from https://translatewiki.net.
Change-Id: I51fbfe4a5f206cd1b211bd91164725402cf67d4c
2017-03-03 22:41:21 +01:00
jenkins-bot 49d5be7552 Merge "Correct 1px offset error in SVG mask." 2017-03-03 17:30:26 +00:00
Derk-Jan Hartman b61c1ef993 Correct 1px offset error in SVG mask.
All the other masks use an 8px offset for the triangle. But this
specific mask used 250 - 243 = 7px offset.

Bug: T153840
Change-Id: Ib72842d18bd844ff37509cf5bf1dedd4e0f99dbc
2017-03-03 11:38:40 -05:00
joakin 04fbc9dea2 Add code coverage reports npm script
Generate code coverage reports based on the node-qunit tests with
istanbul.

Changes:
* Update README with npm run coverage
* Add .istanbul.yml to configure istanbul
* Add npm script "coverage" that runs istanbul and generates the reports

Example report: http://popups-coverage.surge.sh/lcov-report/index.html

Change-Id: I9be8c04b858a3ce6f4e29af2685b79253e3b4dca
2017-03-03 13:34:33 +01:00
joakin c9ab99fe65 Specify es5-shim as a dependency
Popups uses Object.keys, and Redux uses ES5. We need to specify
a dependency on the shim so that it works on ES3 browsers.

See https://phabricator.wikimedia.org/T159164#3069821
The shim will only be loaded when needed, thanks to the es5-skip:
  * https://github.com/wikimedia/mediawiki/blob/ccd0fca/resources/src/es5-skip.js

Bug: T159164
Change-Id: Ib6aa31f985577c5a2704caeb252e67d68607e177
2017-03-03 11:54:30 +01:00
jenkins-bot c7951484b7 Merge "Tooling: Make diffing in check-built-assets verbose" 2017-03-02 16:02:45 +00:00
joakin facf307918 Tooling: Make diffing in check-built-assets verbose
So that it is easier to diagnose what the differences are between the
commited built files and the ones compiled for the check.

Change-Id: Id5394bda910c8218123a87d4604351fe5ae95d1e
2017-03-02 16:18:13 +01:00
joakin 7bc89d6f17 Hygiene: Fix eslint warnings on processLinks.test.js
Change-Id: I83c213f402c8a39c9d22dc9a6fe3fa9359e6ae37
2017-03-02 13:23:33 +00:00
joakin 6fbe64aba6 Tests: Document why processLinks tests are integration tests
Also, mark the test module as @integration.

Change-Id: I83bf8fa3f4bda0dafbe2a2e458fe9dc9ce68f025
2017-03-02 13:08:53 +00:00
jenkins-bot 3791f245a7 Merge "Tests: Migrate userSettings.test.js to node-qunit" 2017-03-02 11:57:52 +00:00
jenkins-bot bba9e88fda Merge "Tests: Extract createStubMap" 2017-03-01 23:27:31 +00:00
jenkins-bot f11f177351 Merge "Tests: Migrate schema.test.js to node-qunit" 2017-03-01 23:27:30 +00:00
jenkins-bot 2631e27d6c Merge "restbase: Use thumbnail when generating thumbnail" 2017-03-01 22:29:56 +00:00
Translation updater bot 532ef01dfc Localisation updates from https://translatewiki.net.
Change-Id: I3252913bc709e8e12342de890073172eea4781ee
2017-03-01 22:37:26 +01:00
Sam Smith 720cfbdcd7 restbase: Use thumbnail when generating thumbnail
Rather than manipulating the URL of the original image to get the URL of
the appropriately sized thumbnail, manipulate the URL of the thumbnail
image.

While we could manipulate either the thumbnail or original image URL,
there are subtle differences between the two, so manipulating the latter
makes the generateThumbnailData function as simple as possible, e.g. we
don't have to splice in "/thumb" after "/commons".

Also, ensure that the thumbnail's dimensions are scaled appropriately.

Bug: T156800
Change-Id: I6825bad14b1131dc81f23dcf120cf8ffb7d7b4f6
2017-03-01 15:41:50 +00:00
joakin 57854d4176 Tests: Migrate userSettings.test.js to node-qunit
Supporting changes:
* Use mw.Map stub
* Use assert.expect instead of number of assertions in QUnit.test
  (deprecated in newer QUnit)
* Don't specify assert.expect( 1 ), because it is the default (no
  assertions will make the test fail).

Change-Id: I64a3e76917e75b8c6d496f20e5b5dcafb338a46a
2017-03-01 12:47:07 +01:00
joakin 35c7068fbe Tests: Extract createStubMap
Minimal mw.Map stub that covers get with key and a default value

Change-Id: I15d60d78ed86747a94f371fd3df400906f0c6dab
2017-03-01 12:40:42 +01:00
joakin d662bc62b2 Tests: Migrate schema.test.js to node-qunit
Additional changes:
* Stub map with get( key, default ) which is mediawiki specific
  behavior

Change-Id: Ie6c4842604e59b5b06cc5d462216bdaa1784f558
2017-03-01 12:40:42 +01:00
Baha 5d4cc8d15a Allow bucketing anons
* Logged in users bypass bucketing. They keep working as before.
* When Page Previews is configured as a beta feature, logged out users
  won't see the feature.
* If an anonymous user has enabled/disabled the feature using
  the settings cog then they will see or not see the feature
  depending on the value of their setting.
* The other anonymous users are bucketed. By default 90% of these
  users see the feature, the other 10% don't. These numbers can be
  controlled by the config variable `wgPopupsAnonsEnabledSamplingRate`.

Bug: T157700
Change-Id: I5307587b10f4849c4e82d3b064ff759121c2de67
2017-03-01 10:45:32 +00:00
Sam Smith f54f92402c storage: Fix UserSettings#hasIsEnabled
mw.storage#get doesn't take a default value to return if the underlying
storage is disabled or the key is missing. In the former case it'll
return false and in the latter it'll return null, i.e. in neither case
will it return undefined.

Bug: T157700
Change-Id: I3f653c11468e17b64765e85ebb3b8f03e311352a
2017-03-01 10:45:32 +00:00
Translation updater bot e4ea8df42e Localisation updates from https://translatewiki.net.
Change-Id: I8368aec050f5dce8712b0a3412ad65a3cf5a227e
2017-02-28 23:09:29 +01:00
jenkins-bot 3a050ffa6a Merge "Tests: Migrate {integration,actions}.test.js to node qunit" 2017-02-27 22:01:16 +00:00
Translation updater bot 3b839adcb9 Localisation updates from https://translatewiki.net.
Change-Id: I8100875e4ba82e4338bfd9927daa1fdded12e391
2017-02-27 22:31:37 +01:00
joakin 82e315b124 Tests: Migrate {integration,actions}.test.js to node qunit
Because of the globals mw.popups.wait usage and mocking in both actions
and integration, they need to be migrated in a single step, fixing them
both to require wait.js and mock using mock-require instead of the
global variable.

Additional changes:
* Fix FIXMEs about actions.js using the global mw.popups.wait instead of
  the require one.
* Fix the unit tests to use require mocking for wait.js instead of
  global variable mocking in both integration and actions tests
* Change tests that use deferreds and promises to be async qunit tests
  (Deferreds are asynchronous with jQuery in node, apparently they
  weren't in the browser)
* Change integration.test.js to use require on Redux and ReduxThunk

Change-Id: I8e3e87b158bd11c9620e77d0a73e611cf9e82183
2017-02-27 18:17:28 +01:00
jenkins-bot 7a54c13ec4 Merge "truncation: Fix fade direction for RTL previews" 2017-02-27 17:12:14 +00:00
Sam Smith 938a4b85d4 Hygiene: Remove checkin instrumentation
The "checkin" part of the Popups schema was superseded by the
ReadingDepth schema, the implementation of which is tracked by T155639.

As well as removing all checkin-related code, update the Popups schema
to the latest version - the version that doesn't have the checkin
property.

Bug: T155639
Depends-On: I762ec3fc91decf3cffa869dbd783faf62f01329a
Change-Id: If764917b6e121e1f9db980a4efa30c0f7a166197
2017-02-27 14:48:47 +00:00
Sam Smith 84a60c4db7 truncation: Fix fade direction for RTL previews
CSSJanus v1.1.3 doesn't appear to flip the "to right" argument for the
linear-gradient CSS function. As with the position of the truncating
element in I0d50a8b5, the direction of the gradient doesn't vary with
the text direction of the current page but that of the target page.

Bug: T158858
Change-Id: I4b6fcf68bdf57722348513f12c7b19f80b2545c4
2017-02-27 11:51:40 +00:00
Ebrahim Byagowi b64260b1cc i18n: Fix popups fade on RTL
Bug: T158858
Change-Id: I0d50a8b55ebdfb8167e36ba520fd6e7cfd4be717
2017-02-27 08:59:53 +00:00
Translation updater bot 367cfb6cf4 Localisation updates from https://translatewiki.net.
Change-Id: I5ebfcd0f1bed264d7552be64b52271b7cec63fd3
2017-02-25 22:35:18 +01:00
Translation updater bot 566d40627f Localisation updates from https://translatewiki.net.
Change-Id: I7002d1548d934f1579909d203f082d9de6dcf77d
2017-02-24 22:38:42 +01:00
Translation updater bot bbf47538c9 Localisation updates from https://translatewiki.net.
Change-Id: I724c1274f31cc1ae7fa983bb4451e38bbc09be1e
2017-02-23 23:00:27 +01:00
jenkins-bot 3d61accb81 Merge "Tests: Migrate previewBehavior.test.js to node qunit" 2017-02-23 09:49:07 +00:00
jenkins-bot eb4950c200 Merge "Tests: Migrate settingsDialog.test.js to node qunit" 2017-02-23 09:46:54 +00:00
jenkins-bot 1e834083f3 Merge "Tests: Migrate gateway/rest.test.js to node qunit" 2017-02-23 09:45:48 +00:00