[MediaWiki-commits] [Gerrit] Use mw.Uri in bannerController to allow ugly URLs - change (mediawiki...CentralNotice)

2015-01-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Use mw.Uri in bannerController to allow ugly URLs
..


Use mw.Uri in bannerController to allow ugly URLs

We need to switch to ugly URLs in background calls to meta, in
order to override the redirection to mobile URLs (and the extra
round-trip) on mobile devices.

Change-Id: I18e5f36b37c4fe35f627b6e8d3d94fdc209677d6
---
M CentralNotice.modules.php
M modules/ext.centralNotice.bannerController/bannerController.js
2 files changed, 19 insertions(+), 13 deletions(-)

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



diff --git a/CentralNotice.modules.php b/CentralNotice.modules.php
index 7379fab..ce3f819 100644
--- a/CentralNotice.modules.php
+++ b/CentralNotice.modules.php
@@ -123,6 +123,7 @@
'dependencies'  = array(
'jquery.cookie',
'json',
+   'mediawiki.Uri',
'ext.centralNotice.bannerChoiceData',
'ext.centralNotice.bannerController.lib',
),
diff --git a/modules/ext.centralNotice.bannerController/bannerController.js 
b/modules/ext.centralNotice.bannerController/bannerController.js
index 864a00e..9e047fc 100644
--- a/modules/ext.centralNotice.bannerController/bannerController.js
+++ b/modules/ext.centralNotice.bannerController/bannerController.js
@@ -137,7 +137,7 @@
}
},
loadTestingBanner: function ( bannerName, campaign ) {
-   var bannerPageQuery;
+   var bannerPageQuery, url;
 
mw.centralNotice.data.testing = true;
 
@@ -152,8 +152,11 @@
 
// TODO use the new $wgCentralSelectedBannerDispatcher 
here instead
 
+   url = new mw.Uri( mw.config.get( 'wgCentralPagePath' ) 
);
+   url.extend( bannerPageQuery );
+
$.ajax({
-   url: mw.config.get( 'wgCentralPagePath' ) + '?' 
+ $.param( bannerPageQuery ),
+   url:  url.toString(),
dataType: 'script',
cache: true
});
@@ -197,12 +200,12 @@
debug: 
mw.centralNotice.data.getVars.debug
};
 
-   scriptUrl = mw.config.get( 
'wgCentralSelectedBannerDispatcher' ) +
-   '?' + $.param( 
loadBannerQueryParams );
+   scriptUrl = new mw.Uri( mw.config.get( 
'wgCentralSelectedBannerDispatcher' ) );
+   scriptUrl.extend( loadBannerQueryParams 
);
 
// This will call insertBanner() after 
the banner is retrieved
$.ajax( {
-   url: scriptUrl,
+   url: scriptUrl.toString(),
dataType: 'script',
cache: true
} );
@@ -229,11 +232,11 @@
bucket: mw.centralNotice.data.bucket
};
 
-   scriptUrl = mw.config.get( 
'wgCentralBannerDispatcher' ) +
-   '?' + $.param( loadBannerQueryParams );
+   scriptUrl = new mw.Uri( mw.config.get( 
'wgCentralBannerDispatcher' ) );
+   scriptUrl.extend( loadBannerQueryParams );
 
$.ajax( {
-   url: scriptUrl,
+   url: scriptUrl.toString,
dataType: 'script',
cache: true
} );
@@ -251,8 +254,9 @@
},
// Record banner impression using old-style URL
recordImpression: function( data ) {
-   var url = mw.config.get( 'wgCentralBannerRecorder' ) + 
'?' + $.param( data );
-   (new Image()).src = url;
+   var url = new mw.Uri( mw.config.get( 
'wgCentralBannerRecorder' ) );
+   url.extend( data );
+   (new Image()).src = url.toString();
},
loadQueryStringVariables: function () {
document.location.search.replace( 
/\??(?:([^=]+)=([^]*)?)/g, function ( str, p1, p2 ) {
@@ -457,13 +461,13 @@
 
// Create landing page links if required
if ( bannerJson.autolink ) {
-  

[MediaWiki-commits] [Gerrit] Use mw.Uri in bannerController to allow ugly URLs - change (mediawiki...CentralNotice)

2014-12-29 Thread AndyRussG (Code Review)
AndyRussG has uploaded a new change for review.

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

Change subject: Use mw.Uri in bannerController to allow ugly URLs
..

Use mw.Uri in bannerController to allow ugly URLs

We need to switch to ugly URLs in background calls to meta, in
order to override the redirection to mobile URLs (and the extra
round-trip) on mobile devices.

Change-Id: I18e5f36b37c4fe35f627b6e8d3d94fdc209677d6
---
M CentralNotice.modules.php
M modules/ext.centralNotice.bannerController/bannerController.js
2 files changed, 19 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice 
refs/changes/74/182074/1

diff --git a/CentralNotice.modules.php b/CentralNotice.modules.php
index 7379fab..ce3f819 100644
--- a/CentralNotice.modules.php
+++ b/CentralNotice.modules.php
@@ -123,6 +123,7 @@
'dependencies'  = array(
'jquery.cookie',
'json',
+   'mediawiki.Uri',
'ext.centralNotice.bannerChoiceData',
'ext.centralNotice.bannerController.lib',
),
diff --git a/modules/ext.centralNotice.bannerController/bannerController.js 
b/modules/ext.centralNotice.bannerController/bannerController.js
index e5247eb..beec85e 100644
--- a/modules/ext.centralNotice.bannerController/bannerController.js
+++ b/modules/ext.centralNotice.bannerController/bannerController.js
@@ -132,7 +132,7 @@
}
},
loadTestingBanner: function ( bannerName, campaign ) {
-   var bannerPageQuery;
+   var bannerPageQuery, url;
 
mw.centralNotice.data.testing = true;
 
@@ -147,8 +147,11 @@
 
// TODO use the new $wgCentralSelectedBannerDispatcher 
here instead
 
+   url = new mw.Uri( mw.config.get( 'wgCentralPagePath' ) 
);
+   url.extend( bannerPageQuery );
+
$.ajax({
-   url: mw.config.get( 'wgCentralPagePath' ) + '?' 
+ $.param( bannerPageQuery ),
+   url:  url.toString(),
dataType: 'script',
cache: true
});
@@ -192,12 +195,12 @@
debug: 
mw.centralNotice.data.getVars.debug
};
 
-   scriptUrl = mw.config.get( 
'wgCentralSelectedBannerDispatcher' ) +
-   '?' + $.param( 
loadBannerQueryParams );
+   scriptUrl = new mw.Uri( mw.config.get( 
'wgCentralSelectedBannerDispatcher' ) );
+   scriptUrl.extend( loadBannerQueryParams 
);
 
// This will call insertBanner() after 
the banner is retrieved
$.ajax( {
-   url: scriptUrl,
+   url: scriptUrl.toString(),
dataType: 'script',
cache: true
} );
@@ -224,11 +227,11 @@
bucket: mw.centralNotice.data.bucket
};
 
-   scriptUrl = mw.config.get( 
'wgCentralBannerDispatcher' ) +
-   '?' + $.param( loadBannerQueryParams );
+   scriptUrl = new mw.Uri( mw.config.get( 
'wgCentralBannerDispatcher' ) );
+   scriptUrl.extend( loadBannerQueryParams );
 
$.ajax( {
-   url: scriptUrl,
+   url: scriptUrl.toString,
dataType: 'script',
cache: true
} );
@@ -246,8 +249,9 @@
},
// Record banner impression using old-style URL
recordImpression: function( data ) {
-   var url = mw.config.get( 'wgCentralBannerRecorder' ) + 
'?' + $.param( data );
-   (new Image()).src = url;
+   var url = new mw.Uri( mw.config.get( 
'wgCentralBannerRecorder' ) );
+   url.extend( data );
+   (new Image()).src = url.toString();
},
loadQueryStringVariables: function () {
document.location.search.replace( 
/\??(?:([^=]+)=([^]*)?)/g, function ( str, p1, p2 ) {
@@ -449,13 +453,13 @@
 
// Create landing page links if required