D3r1ck01 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/241035

Change subject: merged
......................................................................

merged

Change-Id: Iffbd5b993d1d5576af0902fbdc9792129961dc48
---
D resources/mobile.categories.overlays/CategoryApi.js
M resources/mobile.categories.overlays/CategoryGateway.js
D resources/mobile.mediaViewer/ImageApi.js
M resources/mobile.mediaViewer/ImageGateway.js
D resources/mobile.search.api/SearchApi.js
M resources/mobile.search.api/SearchGateway.js
M resources/mobile.search.beta.api/SearchApi.js
M tests/qunit/mobile.mediaViewer/test_ImageGateway.js
M tests/qunit/mobile.search.api/test_SearchGateway.js
M tests/qunit/mobile.search.beta.api/test_SearchApiGateway.js
10 files changed, 6 insertions(+), 362 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/35/241035/1

diff --git a/resources/mobile.categories.overlays/CategoryApi.js 
b/resources/mobile.categories.overlays/CategoryApi.js
deleted file mode 100644
index d222cd7..0000000
--- a/resources/mobile.categories.overlays/CategoryApi.js
+++ /dev/null
@@ -1,65 +0,0 @@
-<<<<<<< HEAD   (a9d094 Removing deprecated modules(7))
-( function ( M ) {
-
-       var CategoryApi,
-               SearchApi = M.require( 'mobile.search.api/SearchApi' );
-
-       /**
-        * Api for CategoryOverlay
-        * @class CategoryApi
-        * @extends SearchApi
-        */
-       CategoryApi = SearchApi.extend( {
-               /**
-                * @inheritdoc
-                */
-               searchNamespace: 14,
-               /**
-                * @inheritdoc
-                */
-               getApiData: function ( query ) {
-                       return {
-                               action: 'query',
-                               list: 'prefixsearch',
-                               pssearch: query,
-                               pslimit: 5,
-                               psnamespace: this.searchNamespace
-                       };
-               },
-
-               /**
-                * Saves the categories passed to this function to the page
-                * @param {String} title Title of the current page (to add the 
categories to)
-                * @param {String} categories List of Categories to add
-                * @returns {jQuery.Deferred}
-                */
-               save: function ( title, categories ) {
-                       return this.postWithToken( 'edit', {
-                               action: 'edit',
-                               title: title,
-                               appendtext: categories,
-                               summary: mw.msg( 
'mobile-frontend-categories-summary' )
-                       } );
-               },
-
-               /**
-                * Returns the categories the title belongs to.
-                * @param {String} title Title of the current page (to add the 
categories to)
-                * @returns {jQuery.Deferred}
-                */
-               getCategories: function ( title ) {
-                       return this.get( {
-                               action: 'query',
-                               prop: 'categories',
-                               titles: title,
-                               clprop: 'hidden',
-                               cllimit: 50 // FIXME: Replace with 
InfiniteScroll
-                       } );
-               }
-       } );
-
-       M.define( 'mobile.categories.overlays/CategoryApi', CategoryApi );
-
-}( mw.mobileFrontend, jQuery ) );
-=======
->>>>>>> BRANCH (0a1581 Merge "Fix media viewer for files with special 
characters")
diff --git a/resources/mobile.categories.overlays/CategoryGateway.js 
b/resources/mobile.categories.overlays/CategoryGateway.js
old mode 100644
new mode 100755
index f5c3807..a25ac6b
--- a/resources/mobile.categories.overlays/CategoryGateway.js
+++ b/resources/mobile.categories.overlays/CategoryGateway.js
@@ -61,6 +61,7 @@
        OO.inheritClass( CategoryGateway, SearchGateway );
        $.extend( CategoryGateway.prototype, prototype );
 
+       M.define( 'mobile.categories.overlays/CategoryApi', CategoryApi );
        M.define( 'mobile.categories.overlays/CategoryGateway', CategoryGateway 
);
 
 }( mw.mobileFrontend, jQuery ) );
diff --git a/resources/mobile.mediaViewer/ImageApi.js 
b/resources/mobile.mediaViewer/ImageApi.js
deleted file mode 100644
index b665e0c..0000000
--- a/resources/mobile.mediaViewer/ImageApi.js
+++ /dev/null
@@ -1,72 +0,0 @@
-<<<<<<< HEAD   (a9d094 Removing deprecated modules(7))
-( function ( M, $ ) {
-       var sizeBuckets = [ 320, 640, 800, 1024, 1280, 1920, 2560, 2880 ],
-               ImageApi,
-               Api = M.require( 'mobile.startup/api' ).Api;
-
-       /**
-        * Gets the first size larger than or equal to the provided size
-        * @param {Number} size
-        * @ignore.
-        */
-       function findSizeBucket( size ) {
-               var i = 0;
-               while ( size > sizeBuckets[i] && i < sizeBuckets.length - 1 ) {
-                       ++i;
-               }
-               return sizeBuckets[i];
-       }
-
-       /**
-        * API for retrieving image thumbnails for a given page
-        * @class ImageApi
-        * @extends Api
-        */
-       ImageApi = Api.extend( {
-               /** @inheritdoc */
-               initialize: function () {
-                       Api.prototype.initialize.apply( this, arguments );
-                       this._cache = {};
-               },
-
-               /**
-                * Get thumbnail via the API and cache it. Return the result 
from the cache if exists.
-                * @param {String} title Url of image
-                * @returns {jQuery.Deferred} with the image info
-                */
-               getThumb: function ( title ) {
-                       var result = this._cache[title],
-                               imageSizeMultiplier = ( window.devicePixelRatio 
&& window.devicePixelRatio > 1 ) ? window.devicePixelRatio : 1;
-
-                       if ( !result ) {
-                               this._cache[title] = result = $.Deferred();
-
-                               this.get( {
-                                       action: 'query',
-                                       prop: 'imageinfo',
-                                       titles: title,
-                                       formatversion: 2,
-                                       iiprop: [ 'url', 'extmetadata' ],
-                                       // request an image devicePixelRatio 
times bigger than the reported screen size
-                                       // for retina displays and zooming
-                                       iiurlwidth: findSizeBucket( $( window 
).width() * imageSizeMultiplier ),
-                                       iiurlheight: findSizeBucket( $( window 
).height() * imageSizeMultiplier )
-                               } ).done( function ( resp ) {
-                                       if ( resp.query && resp.query.pages ) {
-                                               result.resolve( 
resp.query.pages[0].imageinfo[0] );
-                                       }
-                               } );
-                       }
-
-                       return result;
-               }
-       } );
-
-       M.define( 'mobile.mediaViewer/mediaViewer', {
-               _findSizeBucket: findSizeBucket
-       } );
-       M.define( 'mobile.mediaViewer/ImageApi', ImageApi );
-
-}( mw.mobileFrontend, jQuery ) );
-=======
->>>>>>> BRANCH (0a1581 Merge "Fix media viewer for files with special 
characters")
diff --git a/resources/mobile.mediaViewer/ImageGateway.js 
b/resources/mobile.mediaViewer/ImageGateway.js
old mode 100644
new mode 100755
index f16611d..3ff5ada
--- a/resources/mobile.mediaViewer/ImageGateway.js
+++ b/resources/mobile.mediaViewer/ImageGateway.js
@@ -58,6 +58,10 @@
                }
        };
 
+       M.define( 'mobile.mediaViewer/mediaViewer', {
+               _findSizeBucket: findSizeBucket
+       } );
+       M.define( 'mobile.mediaViewer/ImageApi', ImageApi );
        ImageGateway._findSizeBucket = findSizeBucket;
        M.define( 'mobile.mediaViewer/ImageGateway', ImageGateway );
 
diff --git a/resources/mobile.search.api/SearchApi.js 
b/resources/mobile.search.api/SearchApi.js
deleted file mode 100644
index 9ee6f72..0000000
--- a/resources/mobile.search.api/SearchApi.js
+++ /dev/null
@@ -1,222 +0,0 @@
-<<<<<<< HEAD   (a9d094 Removing deprecated modules(7))
-/**
- * API for search
- * @extends Api
- * @class SearchApi
- */
-( function ( M, $ ) {
-
-       var SearchApi,
-               Page = M.require( 'mobile.startup/Page' ),
-               Api = M.require( 'mobile.startup/api' ).Api;
-
-       /**
-        * @class SearchApi
-        * @extends Api
-        */
-       SearchApi = Api.extend( {
-               /** @inheritdoc */
-               initialize: function () {
-                       Api.prototype.initialize.apply( this, arguments );
-                       this.searchCache = {};
-               },
-
-               /**
-                * The namespace to search in.
-                * @type {Number}
-                */
-               searchNamespace: 0,
-
-               /**
-                * Get the data used to do the search query api call.
-                * @method
-                * @param {String} query to search for
-                * @return {Object}
-                */
-               getApiData: function ( query ) {
-                       return {
-                               action: 'query',
-                               generator: 'prefixsearch',
-                               gpssearch: query,
-                               gpsnamespace: this.searchNamespace,
-                               gpslimit: 15,
-                               prop: 'pageimages',
-                               piprop: 'thumbnail',
-                               pithumbsize: mw.config.get( 
'wgMFThumbnailSizes' ).tiny,
-                               pilimit: 15,
-                               redirects: '',
-                               list: 'prefixsearch',
-                               pssearch: query,
-                               pslimit: 15
-                       };
-               },
-
-               /**
-                * Escapes regular expression wildcards (metacharacters) by 
adding a \\ prefix
-                * @param {String} str a string
-                * @return {Object} a regular expression that can be used to 
search for that str
-                * @private
-                */
-               _createSearchRegEx: function ( str ) {
-                       str = str.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, 
'\\$&' );
-                       return new RegExp( '^(' + str + ')', 'ig' );
-               },
-
-               /**
-                * Takes a label potentially beginning with term
-                * and highlights term if it is present with strong
-                * @param {String} label a piece of text
-                * @param {String} term a string to search for from the start
-                * @return {String} safe html string with matched terms 
encapsulated in strong tags
-                * @private
-                */
-               _highlightSearchTerm: function ( label, term ) {
-                       label = $( '<span>' ).text( label ).html();
-                       term = $( '<span>' ).text( term ).html();
-
-                       return label.replace( this._createSearchRegEx( term ), 
'<strong>$1</strong>' );
-               },
-
-               /**
-                * Return data used for creating {Page} objects
-                * @param {String} query to search for
-                * @param {Object} info page info from the API
-                * @return {Object} data needed to create a {Page}
-                * @private
-                */
-               _getPageData: function ( query, info ) {
-                       return {
-                               id: info.pageid,
-                               displayTitle: this._highlightSearchTerm( 
info.displayTitle || info.title, query ),
-                               title: info.title,
-                               url: mw.util.getUrl( info.title ),
-                               thumbnail: info.thumbnail
-                       };
-               },
-
-               /**
-                * Process the data returned by the api call.
-                * FIXME: remove filtering of redirects once the upstream bug 
has been fixed:
-                * https://bugzilla.wikimedia.org/show_bug.cgi?id=73673
-                * @param {String} query to search for
-                * @param {Object} data from api
-                * @return {Array}
-                * @private
-                */
-               _processData: function ( query, data ) {
-                       var self = this,
-                               results = [],
-                               pages = {},
-                               redirects = {},
-                               pageIds = [];
-
-                       if ( data.query ) {
-                               // get redirects into an easily searchable shape
-                               if ( data.query.redirects ) {
-                                       $.each( data.query.redirects, function 
( i, redirect ) {
-                                               redirects[redirect.from] = 
redirect.to;
-                                       } );
-                               }
-                               if ( data.query.prefixsearch ) {
-                                       // some queryies (like CategoryApi) 
only have prefixsearch
-                                       if ( data.query.pages ) {
-                                               // get results into an easily 
searchable shape
-                                               $.each( data.query.pages, 
function ( i, result ) {
-                                                       pages[result.title] = 
result;
-                                               } );
-                                       }
-
-                                       // We loop through the prefixsearch 
results (rather than the pages
-                                       // results) here in order to maintain 
the correct order.
-                                       $.each( data.query.prefixsearch, 
function ( i, page ) {
-                                               var info, title = page.title,
-                                                       id = page.pageid,
-                                                       mwTitle;
-
-                                               // Is this a redirect? If yes, 
get the target.
-                                               if ( redirects[title] ) {
-                                                       id = 
pages[redirects[title]].pageid;
-                                               }
-
-                                               if ( id && data.query.pages && 
data.query.pages[id] ) {
-                                                       info = 
data.query.pages[id];
-                                               }
-
-                                               if ( $.inArray( id, pageIds ) 
=== -1 ) {
-                                                       if ( info ) {
-                                                               // return all 
possible page data
-                                                               pageIds.push( 
id );
-                                                               results.push( 
self._getPageData( query, info ) );
-                                                       } else {
-                                                               mwTitle = 
mw.Title.newFromText( page.title, self._searchNamespace );
-
-                                                               results.push( {
-                                                                       id: 
page.pageid,
-                                                                       
heading: self._highlightSearchTerm( page.title, query ),
-                                                                       title: 
page.title,
-                                                                       
displayTitle: mwTitle.getNameText(),
-                                                                       url: 
mwTitle.getUrl()
-                                                               } );
-                                                       }
-                                               }
-                                       } );
-                               }
-                       }
-
-                       return results;
-               },
-
-               /**
-                * Perform a search for the given query.
-                * @method
-                * @param {String} query to search for
-                * @return {jQuery.Deferred}
-                */
-               search: function ( query ) {
-                       var result = $.Deferred(),
-                               request,
-                               self = this;
-
-                       if ( !this.isCached( query ) ) {
-                               request = this.get( this.getApiData( query ) )
-                                       .done( function ( data ) {
-                                               // resolve the Deferred object
-                                               result.resolve( {
-                                                       query: query,
-                                                       results: $.map( 
self._processData( query, data ), function ( item ) {
-                                                               return new 
Page( item );
-                                                       } )
-                                               } );
-                                       } )
-                                       .fail( function () {
-                                               // reset cached result, it 
maybe contains no value
-                                               self.searchCache[query] = 
undefined;
-                                               // reject
-                                               result.reject();
-                                       } );
-
-                               // cache the result to prevent the execution of 
one search query twice in one session
-                               this.searchCache[query] = result.promise( {
-                                       abort: request.abort
-                               } );
-                       }
-
-                       return this.searchCache[query];
-               },
-
-               /**
-                * Check if the search has already been performed in given 
session.
-                * @method
-                * @param {String} query
-                * @return {Boolean}
-                */
-               isCached: function ( query ) {
-                       return Boolean( this.searchCache[ query ] );
-               }
-       } );
-
-       M.define( 'mobile.search.api/SearchApi', SearchApi );
-
-}( mw.mobileFrontend, jQuery ) );
-=======
->>>>>>> BRANCH (0a1581 Merge "Fix media viewer for files with special 
characters")
diff --git a/resources/mobile.search.api/SearchGateway.js 
b/resources/mobile.search.api/SearchGateway.js
old mode 100644
new mode 100755
index c88f4f7..cfa00d9
--- a/resources/mobile.search.api/SearchGateway.js
+++ b/resources/mobile.search.api/SearchGateway.js
@@ -206,6 +206,7 @@
                }
        };
 
+       M.define( 'mobile.search.api/SearchApi', SearchApi );
        /**
         * A deprecated wrapper which is only here whilst Gather uses it.
         * FIXME: Please remove this class as soon as Gather has been updated.
diff --git a/resources/mobile.search.beta.api/SearchApi.js 
b/resources/mobile.search.beta.api/SearchApi.js
old mode 100644
new mode 100755
index 3a1de3b..ad5c9c3
--- a/resources/mobile.search.beta.api/SearchApi.js
+++ b/resources/mobile.search.beta.api/SearchApi.js
@@ -1,4 +1,3 @@
-<<<<<<< HEAD   (a9d094 Removing deprecated modules(7))
 
 ( function ( M ) {
        var SearchApi = M.require( 'mobile.search.api/SearchApi' ),
@@ -42,5 +41,3 @@
        M.define( 'mobile.search.beta.api/SearchApi', SearchApiBeta );
 
 }( mw.mobileFrontend ) );
-=======
->>>>>>> BRANCH (0a1581 Merge "Fix media viewer for files with special 
characters")
diff --git a/tests/qunit/mobile.mediaViewer/test_ImageGateway.js 
b/tests/qunit/mobile.mediaViewer/test_ImageGateway.js
old mode 100644
new mode 100755
diff --git a/tests/qunit/mobile.search.api/test_SearchGateway.js 
b/tests/qunit/mobile.search.api/test_SearchGateway.js
old mode 100644
new mode 100755
diff --git a/tests/qunit/mobile.search.beta.api/test_SearchApiGateway.js 
b/tests/qunit/mobile.search.beta.api/test_SearchApiGateway.js
old mode 100644
new mode 100755

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffbd5b993d1d5576af0902fbdc9792129961dc48
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: D3r1ck01 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to