r81480 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81479‎ | r81480 | r81481 >
Date:19:45, 3 February 2011
Author:tomasz
Status:resolved (Comments)
Tags:
Comment:
Syncing up to head of trunk from r68098
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/WikimediaMobile (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/WikimediaMobile/MobileRedirect.js (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/WikimediaMobile/WikimediaMobile.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/WikimediaMobile/tests (added) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/WikimediaMobile/WikimediaMobile.php
@@ -5,6 +5,17 @@
66 * at http://github.com/hcatlin/wikimedia-mobile
77 */
88
 9+$wgExtensionCredits['other'][] = array(
 10+ 'path' => __FILE__,
 11+ 'name' => 'WikimediaMobile',
 12+ 'author' => array( 'Tim Starling', 'Brion Vibber', 'Hampton Catlin' ),
 13+ 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaMobile',
 14+ 'descriptionmsg' => 'wikimediamobile-desc',
 15+);
 16+
 17+$dir = dirname(__FILE__) . '/';
 18+$wgExtensionMessagesFiles['WikimediaMobile'] = $dir . 'WikimediaMobile.i18n.php';
 19+
920 /**
1021 * Increment this when the JS file changes
1122 */
Index: branches/wmf/1.16wmf4/extensions/WikimediaMobile/tests/user_agent.js
@@ -0,0 +1,50 @@
 2+/*
 3+ User Agent Tests
 4+
 5+ This is an incomplete test set. As you hit issues, please add strings that
 6+ may be problematic.
 7+
 8+ Written by Hampton Catlin
 9+*/
 10+
 11+var regex = /(Mobile.*Safari|webOS|NetFront|Opera Mini|SEMC-Browser|PlayStation Portable|Nintendo Wii|BlackBerry)/;
 12+
 13+var runTests = function() {
 14+ // iPhone
 15+ shouldRedirect("Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5G77 Safari/525.20");
 16+ // Android on HTC Desire
 17+ shouldRedirect("Mozilla/5.0 (Linux; U; Android 2.1-update1; de-de; HTC Desire 1.19.161.5 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");
 18+ // Nintendo Wii
 19+ shouldRedirect("Opera/9.30 (Nintendo Wii; U; ; 2047-7;pt-br)");
 20+ // Netfront PDA
 21+ shouldRedirect("Mozilla/5.0 (PDA; NF35WMPRO/1.0; like Gecko) NetFront/3.5");
 22+ // Palm Pre
 23+ shouldRedirect("Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0");
 24+ // Safari on Mac OS X
 25+ shouldIgnore("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4");
 26+ // Chrome on OS X
 27+ shouldIgnore("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10");
 28+};
 29+
 30+var doesMatch = function(user_agent) {
 31+ return regex.test(user_agent);
 32+};
 33+
 34+var runTest = function(user_agent, should_be) {
 35+ var result = doesMatch(user_agent);
 36+ if(result == should_be) {
 37+ print("OK");
 38+ } else {
 39+ print("FAIL: '" + user_agent + "'");
 40+ }
 41+};
 42+
 43+var shouldRedirect = function(user_agent) {
 44+ runTest(user_agent, true);
 45+};
 46+
 47+var shouldIgnore = function(user_agent) {
 48+ runTest(user_agent, false);
 49+};
 50+
 51+runTests();
Property changes on: branches/wmf/1.16wmf4/extensions/WikimediaMobile/tests/user_agent.js
___________________________________________________________________
Added: svn:eol-style
152 + native
Index: branches/wmf/1.16wmf4/extensions/WikimediaMobile/MobileRedirect.js
@@ -5,7 +5,7 @@
66 *
77 * You can turn off the redirect by setting the cookie "stopMobileRedirect=true"
88 */
9 -if ( /(Android|iPhone|iPod|webOS|NetFront|Opera Mini|SEMC-Browser|PlayStation Portable|Nintendo Wii|BlackBerry)/
 9+if ( /(Mobile.*Safari|webOS|NetFront|Opera Mini|SEMC-Browser|PlayStation Portable|Nintendo Wii|BlackBerry)/
1010 .test( navigator.userAgent ) )
1111 {
1212 (function () {
@@ -19,7 +19,7 @@
2020 if (wgPageName == mainPage) {
2121 url += '::Home'; // Special case
2222 } else {
23 - url += encodeURIComponent(wgPageName).replace('%2F','/').replace('%3A',':');
 23+ url += encodeURI(wgPageName);
2424 }
2525 url += '?wasRedirected=true';
2626 return url;
Property changes on: branches/wmf/1.16wmf4/extensions/WikimediaMobile
___________________________________________________________________
Modified: svn:mergeinfo
2727 Merged /trunk/extensions/WikimediaMobile:r68099-81377

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68098bumping wikimedia mobile js version for bb redirecttomasz18:35, 15 June 2010

Comments

#Comment by Brion VIBBER (talk | contribs)   08:16, 8 February 2011

The change in MobileRedirect.js appears to have switched iPad from going to the regular site (desired) to pointing to the mobile site (not desired) -- bugzilla:27238.

Will mark it as fixme as well.

Note that switching to the 1.17 branch which doesn't contain this may eliminate the issue for the moment in production.

Status & tagging log