Index: branches/wmf/1.16wmf4/extensions/WikimediaMobile/WikimediaMobile.php |
— | — | @@ -5,6 +5,17 @@ |
6 | 6 | * at http://github.com/hcatlin/wikimedia-mobile |
7 | 7 | */ |
8 | 8 | |
| 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 | + |
9 | 20 | /** |
10 | 21 | * Increment this when the JS file changes |
11 | 22 | */ |
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 |
1 | 52 | + native |
Index: branches/wmf/1.16wmf4/extensions/WikimediaMobile/MobileRedirect.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | * You can turn off the redirect by setting the cookie "stopMobileRedirect=true" |
8 | 8 | */ |
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)/ |
10 | 10 | .test( navigator.userAgent ) ) |
11 | 11 | { |
12 | 12 | (function () { |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | if (wgPageName == mainPage) { |
21 | 21 | url += '::Home'; // Special case |
22 | 22 | } else { |
23 | | - url += encodeURIComponent(wgPageName).replace('%2F','/').replace('%3A',':'); |
| 23 | + url += encodeURI(wgPageName); |
24 | 24 | } |
25 | 25 | url += '?wasRedirected=true'; |
26 | 26 | return url; |
Property changes on: branches/wmf/1.16wmf4/extensions/WikimediaMobile |
___________________________________________________________________ |
Modified: svn:mergeinfo |
27 | 27 | Merged /trunk/extensions/WikimediaMobile:r68099-81377 |