Commit graph

1159 commits

Author SHA1 Message Date
Sam Smith f6db973fb9 renderer: Really ensure images don't overflow
... container.

I19e67ae4 hide the overflowing parts of the SVG image element in IE9-11
for a number of cases but not all of them, e.g. see T139297#3089714.
Moving the overflow: hidden property to the SVG element fixes the above
case and is clearer.

Tested in IE9-11 on Windows 7, and Chrome (56.0.2924.87) on macOS Sierra
(10.12.3).

Bug: T139297
Change-Id: I9c397d7333766b40abbf14b6ade96788f5023dfa
2017-03-17 10:58:27 +00:00
Translation updater bot 091141f931 Localisation updates from https://translatewiki.net.
Change-Id: Ic1ff37744b072cb5c662f5920b0d5418209f79f1
2017-03-16 23:25:49 +01:00
Piotr Miazga aa81d6aaad Show Page Preview on mouseenter and keyup events
Changes:
 - remove focus events listeners as they are triggered after switching tabs
 - show PagePreview on keyup event

Bug: T158631
Change-Id: I7533f896604e0e0a8ea6e900ae4f7d12b6458836
2017-03-16 21:16:44 +01:00
jenkins-bot 1156075adf Merge "i18n: changes to Page previews in beta tab of preferences" 2017-03-16 11:09:41 +00:00
jdlrobson ded774528b i18n: changes to Page previews in beta tab of preferences
* Add full stop
* Simplify description
* Rename from Hovercards to Page previews

Bug: T153599
Change-Id: I0f6fc5aa6b29070b44b452bf73b7d16117d4ecef
2017-03-15 18:56:24 +00:00
Sam Smith a5e1cab732 Hygiene: Remove createRootReducer
Redux.combineReducers is equally self-documenting.

Change-Id: I726fbc782fbb59aad0c8dd3c8eb168a302415e6c
2017-03-15 13:23:23 +01:00
Sam Smith c5675842a3 Hygiene: Remove createBoundActions
Redux.bindActionCreators is equally self-documenting.

Change-Id: Ib10023b4d3a4d6dae0a7aca40f04c3f37abf05dd
2017-03-15 13:23:11 +01:00
Translation updater bot 816bb489da Localisation updates from https://translatewiki.net.
Change-Id: I122aa4599d57a3a7e13cb59cd380a3b9c2601f81
2017-03-14 22:46:29 +01:00
Sam Smith c10c3c3771 renderer: Remove attributes don't set them to ''
IE doesn't appear to update/redraw the SVG image element when Setting
its clip-path attribute to '', not removing it. This is problematic as
the attribute is always set to a default value (in the createThumbnail
function) before the preview is laid out.

Bug: T160237
Change-Id: I4559ff5018b8f4ecf06f6f5d9462a999d9726b94
2017-03-14 08:46:05 -04:00
Baha 9a94300858 Log events to statsv for monitoring PagePreviews performance
For logging to work:
1. $wgWMEStatsdBaseUri needs to point to a valid statsv endpoint,
   e.g. 'https://en.wikipedia.org/beacon/statsv'.
2. $wgPopupsStatsvSamplingRate needs to be set. Note that the codebase
   already contains the EventLogging functionality, which is configured
   separately. Separately configuring different logging mechanisms
   allows us to avoid sampling mistakes that may arise while choosing
   one or the other. For example, let's say we want to use EventLogging for
   10% of users and statsv for 5%. We'd sample all users into two
   buckets: 50/50. And then we'd have to set the sampling rates as
   20% and 10% respectively, only because of the bucketing above. To avoid
   this kind of complications, separate sampling rates are used for each
   logging mechanism. This, of course, may result in situations where a
   session is logged via both EventLogging and statsv.
3. The WikimediaEvents extension needs to be installed. The extension
   adds the `ext.wikimediaEvents` module to the output page. The
   logging functionality is delegated to this module.

Notable changes:
* The FETCH_START and FETCH_END actions are converted to a timed action.
* The experiments stub used in tests has been extracted to the stubs
  file.

Logged data is visualized at
https://grafana.wikimedia.org/dashboard/db/reading-web-page-previews

Bug: T157111
Change-Id: If3f1a06f1f623e8e625b6c30a48b7f5aa9de24db
2017-03-14 08:51:10 +00:00
Sam Smith 568b7a09a1 rest: Always scale thumbnail's largest dimension
... thumbnails.

A good example of the difference in behaviour of the PageImages API is
here <T156800#3087507>. The API defers to File#transform, which scales
the largest dimension of an image, not always the width, e.g. if an
image is 1000px x 2000px and the request is for a thumbnail "of 1800px",
then the thumbnail will be 900px x 1800px.

Bug: T156800
Change-Id: I64bc2244ee78a594298d8637233b0da1083700eb
2017-03-10 10:44:37 +00:00
Piotr Miazga 5328cf4681 Hygiene: Move EXTRACT_LENGTH to constants
Keep all configuration-like values in one file.
Changes:
 - moved EXTRACT_LENGTH to constants.js file

Change-Id: Ibe5ecfc60f2c09a30a9ecb3586bc5fb6a7365476
2017-03-09 22:08:10 +00:00
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