jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/359031 )

Change subject: Remove CardsGateway (unused)
......................................................................


Remove CardsGateway (unused)

Bug: T167647
Change-Id: I7e2a7777a5f28991d77deab520a55d3bd242104b
---
M extension.json
M includes/Hooks.php
D resources/ext.relatedArticles.cards/CardsGateway.js
D tests/qunit/ext.relatedArticles.cards/CardsGateway.js
4 files changed, 1 insertion(+), 231 deletions(-)

Approvals:
  Bmansurov: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index fdb7471..b256e7b 100644
--- a/extension.json
+++ b/extension.json
@@ -83,8 +83,7 @@
                                "resources/ext.relatedArticles.cards/init.js",
                                
"resources/ext.relatedArticles.cards/CardModel.js",
                                
"resources/ext.relatedArticles.cards/CardView.js",
-                               
"resources/ext.relatedArticles.cards/CardListView.js",
-                               
"resources/ext.relatedArticles.cards/CardsGateway.js"
+                               
"resources/ext.relatedArticles.cards/CardListView.js"
                        ],
                        "styles": [
                                
"resources/ext.relatedArticles.cards/styles.less"
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 2b86ac9..8362df4 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -97,7 +97,6 @@
                        ],
                        'scripts' => [
                                'ext.relatedArticles.cards/CardModel.js',
-                               'ext.relatedArticles.cards/CardsGateway.js',
                                'ext.relatedArticles.cards/CardView.js',
                        ]
                ];
diff --git a/resources/ext.relatedArticles.cards/CardsGateway.js 
b/resources/ext.relatedArticles.cards/CardsGateway.js
deleted file mode 100644
index 9ea8dda..0000000
--- a/resources/ext.relatedArticles.cards/CardsGateway.js
+++ /dev/null
@@ -1,105 +0,0 @@
-( function ( $, mw ) {
-       'use strict';
-
-       /**
-        * Default thumbnail width in pixels: 80px
-        * @readonly
-        */
-       var THUMB_WIDTH = 80,
-               CardModel = mw.cards.CardModel,
-               CardView = mw.cards.CardView,
-               CardListView = mw.cards.CardListView;
-
-       /**
-        * @ignore
-        * @param {Object} thumb
-        * @return {string}
-        */
-       function isValidThumbnail( thumb ) {
-               return thumb.source.substr( 0, 7 ) === 'http://' || 
thumb.source.substr( 0, 8 ) === 'https://';
-       }
-
-       /**
-        * Gateway for interacting with an API
-        * It can be used to retrieve information about article(s). In the 
future
-        * it can also be used to update that information in the server.
-        *
-        * @class mw.cards.CardsGateway
-        * @param {Object} options
-        * @param {mw.Api} options.api an Api to use.
-        */
-       function CardsGateway( options ) {
-               this.api = options.api;
-       }
-       OO.initClass( CardsGateway );
-
-       /**
-        * Fetch information about articleTitles from the API
-        * How to use:
-        *
-        *     @example
-        *     var gateway = new mw.cards.CardsGateway( { api: new mw.Api() } );
-        *
-        *     // '1' and '2' are page titles, while 200 is the desired 
thumbnail width
-        *     gateway.getCards( ['1', '2'], 200 ).done( function( cards ) {
-        *         $( '#bodyContent' ).append( cards.$el );
-        *     } );
-        *
-        * @param {string[]} articleTitles array of article titles
-        * @param {number} [thumbWidth] Thumbnail width in pixels. Defaults to
-        *  {@link THUMB_WIDTH}
-        * @return {jQuery.Deferred} the result resolves with a
-        *  {@link mw.cards.CardListView card list}
-        */
-       CardsGateway.prototype.getCards = function ( articleTitles, thumbWidth 
) {
-               var article,
-                       cardViews = [],
-                       result = $.Deferred();
-
-               if ( !articleTitles.length ) {
-                       result.resolve( new CardListView( cardViews ) );
-                       return result;
-               }
-
-               this.api.get( {
-                       action: 'query',
-                       prop: 'extracts|pageimages',
-                       explaintext: true,
-                       exlimit: articleTitles.length,
-                       exintro: true,
-                       exsentences: 1,
-                       pithumbsize: thumbWidth || THUMB_WIDTH,
-                       titles: articleTitles.join( '|' ),
-                       'continue': '',
-                       formatversion: 2
-               } ).done( function ( data ) {
-                       if ( data.query && data.query.pages ) {
-                               cardViews = $.map( data.query.pages, function ( 
page ) {
-                                       article = {
-                                               title: page.title,
-                                               url: mw.util.getUrl( page.title 
),
-                                               hasThumbnail: false
-                                       };
-
-                                       if ( page.thumbnail && 
isValidThumbnail( page.thumbnail ) ) {
-                                               article.hasThumbnail = true;
-                                               article.thumbnailUrl = 
page.thumbnail.source;
-                                       }
-
-                                       if ( page.extract ) {
-                                               article.extract = page.extract;
-                                       }
-
-                                       return new CardView( new CardModel( 
article ) );
-                               } );
-                       }
-                       result.resolve( new CardListView( cardViews ) );
-               } ).fail( function () {
-                       result.resolve( new CardListView( cardViews ) );
-               } );
-
-               return result;
-       };
-
-       mw.cards.CardsGateway = CardsGateway;
-}( jQuery, mediaWiki ) );
diff --git a/tests/qunit/ext.relatedArticles.cards/CardsGateway.js 
b/tests/qunit/ext.relatedArticles.cards/CardsGateway.js
deleted file mode 100644
index a263057..0000000
--- a/tests/qunit/ext.relatedArticles.cards/CardsGateway.js
+++ /dev/null
@@ -1,123 +0,0 @@
-( function ( $ ) {
-
-       var CardsGateway = mw.cards.CardsGateway;
-
-       QUnit.module( 'ext.relatedArticles.cards/CardsGateway' );
-
-       QUnit.test( '#getCards resolves with empty list of cards when no titles 
are given', 1, function ( assert ) {
-               var cards = new CardsGateway( { api: new mw.Api() } );
-
-               return cards.getCards( [] ).then( function ( cards ) {
-                       assert.ok( cards.cardViews.length === 0 );
-               } );
-       } );
-
-       QUnit.test( '#getCards processes the result of the API call', 5, 
function ( assert ) {
-               var api = new mw.Api(),
-                       cards = new CardsGateway( { api: api } ),
-                       result = {
-                               query: {
-                                       pages: [
-                                               {
-                                                       pageid: 1,
-                                                       ns: 0,
-                                                       title: 'One'
-                                               },
-                                               {
-                                                       pageid: 2,
-                                                       ns: 0,
-                                                       title: 'Two',
-                                                       extract: 'This is the 
second page.'
-                                               },
-                                               {
-                                                       pageid: 3,
-                                                       ns: 0,
-                                                       title: 'Three',
-                                                       thumbnail: {
-                                                               source: 
'http://foo.bar/baz.jpg',
-                                                               width: 50,
-                                                               height: 38
-                                                       },
-                                                       pageimage: 'baz.jpg'
-                                               },
-
-                                               // [T118553] Thumbnail URLs 
must start with
-                                               // "http[s]://".
-                                               {
-                                                       pageid: 4,
-                                                       ns: 0,
-                                                       title: 'Four',
-                                                       thumbnail: {
-                                                               source: 
'//foo.bar/baz/qux.jpg',
-                                                               width: 50,
-                                                               height: 38
-                                                       },
-                                                       pageimage: 'qux.jpg'
-                                               }
-                                       ]
-                               }
-                       };
-
-               this.sandbox.stub( api, 'get' ).returns( $.Deferred().resolve( 
result ) );
-
-               return cards.getCards( [ 'One', 'Two', 'Three', 'Four' ] 
).then( function ( cards ) {
-                       assert.ok( cards.cardViews.length === 4 );
-
-                       // One: no extract; no thumbnail.
-                       assert.deepEqual( cards.cardViews[ 0 
].model.attributes, {
-                               title: 'One',
-                               url: mw.util.getUrl( 'One' ),
-                               hasThumbnail: false
-                       } );
-
-                       // Two: no thumbnail.
-                       assert.deepEqual( cards.cardViews[ 1 
].model.attributes, {
-                               title: 'Two',
-                               url: mw.util.getUrl( 'Two' ),
-                               hasThumbnail: false,
-                               extract: 'This is the second page.'
-                       } );
-
-                       // Three: no extract.
-                       assert.deepEqual( cards.cardViews[ 2 
].model.attributes, {
-                               title: 'Three',
-                               url: mw.util.getUrl( 'Three' ),
-                               hasThumbnail: true,
-                               thumbnailUrl: 'http://foo.bar/baz.jpg'
-                       } );
-
-                       // Four: invalid thumbnail URL.
-                       assert.deepEqual( cards.cardViews[ 3 
].model.attributes, {
-                               title: 'Four',
-                               url: mw.util.getUrl( 'Four' ),
-                               hasThumbnail: false
-                       } );
-               } );
-       } );
-
-       QUnit.test( '#getCards resolves with empty list of cards when the API 
call fails', 2, function ( assert ) {
-               var api = new mw.Api(),
-                       cards = new CardsGateway( { api: api } ),
-                       getStub = this.sandbox.stub( api, 'get' ),
-                       done1 = assert.async(),
-                       done2 = assert.async();
-
-               getStub.returns( $.Deferred().reject() );
-
-               cards.getCards( [ 'Foo' ] ).then( function ( cards ) {
-                       assert.ok( cards.cardViews.length === 0 );
-               } )
-               .always( done1 );
-
-               // The API call can succeed but return no results, which should
-               // also be handled as a failure.
-               getStub.returns( $.Deferred().resolve( {
-                       query: {}
-               } ) );
-
-               cards.getCards( [ 'Foo' ] ).then( function ( cards ) {
-                       assert.ok( cards.cardViews.length === 0 );
-               } )
-               .always( done2 );
-       } );
-}( jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/359031
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7e2a7777a5f28991d77deab520a55d3bd242104b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/RelatedArticles
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Bmansurov <bmansu...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to