Index: branches/wmf/1.17wmf1/extensions/WikimediaMobile/WikimediaMobile.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /** |
21 | 21 | * Increment this when the JS file changes |
22 | 22 | */ |
23 | | -$wgWikimediaMobileVersion = '2'; |
| 23 | +$wgWikimediaMobileVersion = '3'; |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * The base URL of the mobile gateway |
Index: branches/wmf/1.17wmf1/extensions/WikimediaMobile/MobileRedirect.js |
— | — | @@ -8,40 +8,18 @@ |
9 | 9 | if ( /(Android|iPhone|iPod|webOS|NetFront|Opera Mini|SEMC-Browser|PlayStation Portable|Nintendo Wii|BlackBerry)/ |
10 | 10 | .test( navigator.userAgent ) ) |
11 | 11 | { |
12 | | - (function () { |
13 | | - function haveStopCookie() { |
14 | | - return (document.cookie.indexOf("stopMobileRedirect=true") >= 0); |
15 | | - } |
| 12 | + |
| 13 | + if ( (document.cookie.indexOf("eRedirect=t") < 0) // Don't redirect if we have the stop cookie ... only testing a subportion of the cookie. Should be REALLY unique! |
| 14 | + && (wgNamespaceNumber >= 0) // Don't redirect special pages |
| 15 | + && (wgAction == "view")) // Don't redirect URLs that aren't simple page views |
| 16 | + { |
| 17 | + // If we've made it here, then we are going ahead with the redirect |
| 18 | + var url = wgWikimediaMobileUrl; |
| 19 | + // If we are NOT on the main page, then set the pageName! |
| 20 | + if (wgPageName != wgMainPageTitle.replace(/ /g, '_')) { |
| 21 | + url += '/' + encodeURI(wgPageName); |
| 22 | + } |
16 | 23 | |
17 | | - function getMobileUrl() { |
18 | | - var mainPage = wgMainPageTitle.replace(/ /g, '_'); |
19 | | - var url = wgWikimediaMobileUrl + '/'; |
20 | | - if (wgPageName == mainPage) { |
21 | | - url += '::Home'; // Special case |
22 | | - } else { |
23 | | - url += encodeURI(wgPageName); |
24 | | - } |
25 | | - url += '?wasRedirected=true'; |
26 | | - return url; |
27 | | - } |
28 | | - |
29 | | - // Don't redirect if we have the stop cookie |
30 | | - if (haveStopCookie()) return; |
31 | | - |
32 | | - // Don't redirect special pages |
33 | | - if (wgNamespaceNumber < 0) return; |
34 | | - |
35 | | - // Don't redirect URLs that aren't simple page views |
36 | | - if (document.location.search && document.location.search.length > 0) { |
37 | | - var params = document.location.search.substr(1).split('&'); |
38 | | - for (var i = 0; i < params.length; i++) { |
39 | | - var paramParts = params[i].split('='); |
40 | | - if (paramParts.length && paramParts[0] != 'title') { |
41 | | - return; |
42 | | - } |
43 | | - } |
44 | | - } |
45 | | - |
46 | | - document.location = getMobileUrl(); |
47 | | - })(); |
| 24 | + document.location = url; |
| 25 | + } |
48 | 26 | } |
Index: branches/wmf/1.17wmf1/extensions/WikimediaMobile/redirector_test.js |
— | — | @@ -0,0 +1,147 @@ |
| 2 | +/* |
| 3 | + WikimediaMobile Redirect Tests |
| 4 | + |
| 5 | + This is a nearly complete test set. As you hit issues, please add UA strings and other combinations that |
| 6 | + may be problematic. |
| 7 | + |
| 8 | + Written by Hampton Catlin |
| 9 | +*/ |
| 10 | + |
| 11 | +var navigator; |
| 12 | +var document; |
| 13 | +var wgAction; |
| 14 | +var wgNamespaceNumber; |
| 15 | +var wgMainPageTitle; |
| 16 | +var wgTitle; |
| 17 | +var wgPageTitle; |
| 18 | +var wgWikimediaMobileUrl; |
| 19 | + |
| 20 | +var runTests = function() { |
| 21 | + shouldRedirect({}); |
| 22 | + testUserAgents(); |
| 23 | + testCookies(); |
| 24 | + testNamespaces(); |
| 25 | + testMainPages(); |
| 26 | +} |
| 27 | + |
| 28 | + |
| 29 | +var runTest = function(options, shouldRedirect) { |
| 30 | + wgAction = options.action || "view"; |
| 31 | + wgNamespaceNumber = options.namespace_number || 0; |
| 32 | + |
| 33 | + wgMainPageTitle = options.main_page_title || "Wikipédia:Accueil principal" |
| 34 | + wgTitle = options.title || "Tokyo Bay" |
| 35 | + wgPageName = options.page_name || "Tokyo_Bay" |
| 36 | + wgWikimediaMobileUrl = options.mobile_site_url || "http://en.m.wikipedia.org/wiki" |
| 37 | + |
| 38 | + // Mock a browser |
| 39 | + navigator = {}; |
| 40 | + document = {location: {search: "?title=" + wgPageName}}; |
| 41 | + |
| 42 | + // Set in browser variables |
| 43 | + navigator.userAgent = options.user_agent || "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"; |
| 44 | + document.cookie = options.cookie || "random=true" |
| 45 | + |
| 46 | + load("MobileRedirect.js") |
| 47 | + // Run against old redirect |
| 48 | + //load("OriginalMobileRedirect.js"); |
| 49 | + |
| 50 | + if(((document.location != null) && (document.location.length > 0)) == shouldRedirect) { |
| 51 | + if(options.should_redirect_to && (document.location != options.should_redirect_to)) { |
| 52 | + print("Should have been redirect to " + options.should_redirect_to) |
| 53 | + print("Instead was sent to " + document.location) |
| 54 | + for(key in options) |
| 55 | + { |
| 56 | + print(" " + key + ": " + options[key]); |
| 57 | + } |
| 58 | + } else { |
| 59 | + print("OK") |
| 60 | + } |
| 61 | + } else { |
| 62 | + if(shouldRedirect) { |
| 63 | + print("FAILED: SHOULD REDIRECT WITH:"); |
| 64 | + } else { |
| 65 | + print("FAILED: SHOULD IGNORE WITH:"); |
| 66 | + } |
| 67 | + |
| 68 | + for(key in options) |
| 69 | + { |
| 70 | + print(" " + key + ": " + options[key]); |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | +} |
| 75 | + |
| 76 | +var shouldRedirect = function(options) { |
| 77 | + runTest(options, true) |
| 78 | +} |
| 79 | + |
| 80 | +var shouldIgnore = function(options) { |
| 81 | + runTest(options, false) |
| 82 | +} |
| 83 | + |
| 84 | +/* ========== ACTUAL TEST CASES ================== */ |
| 85 | + |
| 86 | +var testCookies = function() { |
| 87 | + shouldRedirect({cookie: "StewardVoteEligible_r7=0"}); |
| 88 | + shouldIgnore({cookie: "stopMobileRedirect=true"}) |
| 89 | +} |
| 90 | + |
| 91 | +var testNamespaces = function() { |
| 92 | + shouldRedirect({namespace_number: 2}) |
| 93 | + shouldRedirect({namespace_number: 0}) |
| 94 | + shouldIgnore({namespace_number: -1}) |
| 95 | +} |
| 96 | + |
| 97 | +var testMainPages = function() { |
| 98 | + shouldRedirect({main_page_title: "", title: "", page_name: ""}); |
| 99 | + |
| 100 | + // EN |
| 101 | + shouldRedirect({should_redirect_to: 'http://en.m.wikipedia.org/wiki', main_page_title: 'Main Page', title: 'Main Page', page_name: 'Main_Page'}) |
| 102 | + shouldRedirect({should_redirect_to: 'http://en.m.wikipedia.org/wiki/Main_(river)', main_page_title: 'Main Page', title: 'Main (river)', page_name: 'Main_(river)'}); |
| 103 | + |
| 104 | + // FR |
| 105 | + shouldRedirect({should_redirect_to: 'http://fr.m.wikipedia.org/wiki', main_page_title: 'Wikipédia:Accueil principal', title: 'Accueil principal', page_name: 'Wikipédia:Accueil_principal', mobile_site_url: "http://fr.m.wikipedia.org/wiki"}); |
| 106 | + shouldRedirect({should_redirect_to: 'http://fr.m.wikipedia.org/wiki/Ralph_Waldo_Emerson', main_page_title: 'Wikipédia:Accueil principal', title: 'Ralph Waldo Emerson', page_name: 'Ralph_Waldo_Emerson', mobile_site_url: "http://fr.m.wikipedia.org/wiki"}); |
| 107 | + |
| 108 | + // DE |
| 109 | + shouldRedirect({should_redirect_to: 'http://de.m.wikipedia.org/wiki', main_page_title: 'Wikipedia:Hauptseite', title: 'Hauptseite', page_name: 'Wikipedia:Hauptseite', mobile_site_url: "http://de.m.wikipedia.org/wiki"}); |
| 110 | + shouldRedirect({should_redirect_to: 'http://de.m.wikipedia.org/wiki/Ralph_Waldo_Emerson', main_page_title: 'Wikipedia:Hauptseite', title: 'Ralph Waldo Emerson', page_name: 'Ralph_Waldo_Emerson', mobile_site_url: "http://de.m.wikipedia.org/wiki"}); |
| 111 | +} |
| 112 | + |
| 113 | +var testUserAgents = function() { |
| 114 | + // iPhone |
| 115 | + shouldRedirect({user_agent: "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"}); |
| 116 | + // Android on HTC Desire |
| 117 | + shouldRedirect({user_agent: "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"}); |
| 118 | + // Nintendo Wii |
| 119 | + shouldRedirect({user_agent: "Opera/9.30 (Nintendo Wii; U; ; 2047-7;pt-br)"}); |
| 120 | + // Netfront PDA |
| 121 | + shouldRedirect({user_agent: "Mozilla/5.0 (PDA; NF35WMPRO/1.0; like Gecko) NetFront/3.5"}); |
| 122 | + // Palm Pre |
| 123 | + shouldRedirect({user_agent: "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"}); |
| 124 | + // Safari on Mac OS X |
| 125 | + shouldIgnore({user_agent: "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"}); |
| 126 | + // Chrome on OS X |
| 127 | + shouldIgnore({user_agent: "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"}); |
| 128 | + // iPad |
| 129 | + shouldIgnore({user_agent: "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"}); |
| 130 | + shouldIgnore({user_agent: "Mozilla/5.0 (iPad; U; CPU OS 4_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C5101c Safari/6533.18.5"}); |
| 131 | + // iPhone 4 |
| 132 | + shouldRedirect({user_agent: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.05 Mobile/8A293 Safari/6531.22.7"}); |
| 133 | + // Firefox |
| 134 | + shouldIgnore({user_agent: "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b9pre) Gecko/20101228 Firefox/4.0b9pre"}); |
| 135 | + |
| 136 | + // Android Nexus One Phone |
| 137 | + shouldRedirect({user_agent: "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"}); |
| 138 | + // Android Tablet |
| 139 | + shouldIgnore({user_agent: "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; device Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Safari/533.1"}); |
| 140 | + |
| 141 | + // Fake test strings |
| 142 | + |
| 143 | + // Android, but only with Mobile |
| 144 | + shouldIgnore({user_agent: "Android"}); |
| 145 | + shouldRedirect({user_agent: "Mozilla/5.0 (Android; Mobile/5G77 Safari/525.20"}); |
| 146 | +} |
| 147 | + |
| 148 | +runTests(); |
\ No newline at end of file |
Property changes on: branches/wmf/1.17wmf1/extensions/WikimediaMobile/redirector_test.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 149 | + native |
Index: branches/wmf/1.17wmf1/extensions/WikimediaMobile/WikimediaMobile.i18n.php |
— | — | @@ -195,6 +195,13 @@ |
196 | 196 | 'wikimediamobile-desc' => 'ウィキメディア・モバイルプロジェクト用の MediaWiki サポート機能。http://github.com/hcatlin/wikimedia-mobile でホストされています。', |
197 | 197 | ); |
198 | 198 | |
| 199 | +/** Korean (한국어) |
| 200 | + * @author Albamhandae |
| 201 | + */ |
| 202 | +$messages['ko'] = array( |
| 203 | + 'wikimediamobile-desc' => '미디어위키는 http://github.com/hcatlin/wikimedia-mobile 에서 호스트하고 있는 위키미디어 모바일 프로젝트 기능을 지원합니다.', |
| 204 | +); |
| 205 | + |
199 | 206 | /** Colognian (Ripoarisch) |
200 | 207 | * @author Purodha |
201 | 208 | */ |
— | — | @@ -315,6 +322,13 @@ |
316 | 323 | 'wikimediamobile-desc' => 'Podpora funkcijam MediaWiki za projekt Wikimedia-mobile, gostovan na http://github.com/hcatlin/wikimedia-mobile', |
317 | 324 | ); |
318 | 325 | |
| 326 | +/** Serbian Cyrillic ekavian (Српски (ћирилица)) |
| 327 | + * @author Rancher |
| 328 | + */ |
| 329 | +$messages['sr-ec'] = array( |
| 330 | + 'wikimediamobile-desc' => 'Подршку за мобилну Википедију покреће http://github.com/hcatlin/wikimedia-mobile', |
| 331 | +); |
| 332 | + |
319 | 333 | /** Sundanese (Basa Sunda) |
320 | 334 | * @author Kandar |
321 | 335 | */ |
— | — | @@ -322,6 +336,13 @@ |
323 | 337 | 'wikimediamobile-desc' => 'MediaWiki ngadukung fungsi proyék Wikimédia-balawiri nyayang di http://github.com/hcatlin/wikimedia-mobile', |
324 | 338 | ); |
325 | 339 | |
| 340 | +/** Swedish (Svenska) |
| 341 | + * @author Tobulos1 |
| 342 | + */ |
| 343 | +$messages['sv'] = array( |
| 344 | + 'wikimediamobile-desc' => 'MediaWiki support functions for the Wikimedia-mobile project hosted at http://github.com/hcatlin/wikimedia-mobile', |
| 345 | +); |
| 346 | + |
326 | 347 | /** Telugu (తెలుగు) |
327 | 348 | * @author RanjithSutari |
328 | 349 | */ |
Property changes on: branches/wmf/1.17wmf1/extensions/WikimediaMobile |
___________________________________________________________________ |
Added: svn:mergeinfo |
329 | 350 | Merged /branches/sqlite/extensions/WikimediaMobile:r58211-58321 |
330 | 351 | Merged /trunk/phase3/extensions/WikimediaMobile:r79828,79830,79848,79853,79950-79951,79954,79989,80006-80007,80013,80016,80080,80083,80124,80128,80238,81833 |
331 | 352 | Merged /branches/new-installer/phase3/extensions/WikimediaMobile:r43664-66004 |
332 | 353 | Merged /branches/wmf-deployment/extensions/WikimediaMobile:r60970 |
333 | 354 | Merged /branches/REL1_15/phase3/extensions/WikimediaMobile:r51646 |
334 | 355 | Merged /branches/wmf/1.16wmf4/extensions/WikimediaMobile:r67177,69199,76243,77266 |
335 | 356 | Merged /trunk/extensions/WikimediaMobile:r81458-83112 |