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 = '6'; |
| 23 | +$wgWikimediaMobileVersion = '7'; |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * The base URL of the mobile gateway |
— | — | @@ -33,6 +33,14 @@ |
34 | 34 | function wfWikimediaMobileAddJs( &$outputPage, &$skin ) { |
35 | 35 | global $wgOut, $wgExtensionAssetsPath, $wgWikimediaMobileVersion; |
36 | 36 | |
| 37 | + global $wgTitle, $wgRequest, $wgWikimediaMobileUrl; |
| 38 | + $ns = $wgTitle->getNamespace(); |
| 39 | + $action = FormatJson::encode( $wgRequest->getVal( 'action', 'view' ) ); |
| 40 | + $page = FormatJson::encode( $wgTitle->getPrefixedDBkey() ); |
| 41 | + $mainpage = Title::newMainPage(); |
| 42 | + $mp = FormatJson::encode( $mainpage ? $mainpage->getPrefixedText() : null ); |
| 43 | + $url = FormatJson::encode( $wgWikimediaMobileUrl ); |
| 44 | + $wgOut->addHeadItem( 'mobileredirectvars', Html::inlineScript( "wgNamespaceNumber=$ns;wgAction=$action;wgPageName=$page;wgMainPageTitle=$mp;wgWikimediaMobileUrl=$url;" ) ); |
37 | 45 | $wgOut->addHeadItem( 'mobileredirect', Html::linkedScript( |
38 | 46 | "$wgExtensionAssetsPath/WikimediaMobile/MobileRedirect.js?$wgWikimediaMobileVersion" |
39 | 47 | ) ); |
Index: branches/wmf/1.17wmf1/extensions/WikimediaMobile/MobileRedirect.js |
— | — | @@ -9,8 +9,8 @@ |
10 | 10 | .test( navigator.userAgent ) ) |
11 | 11 | { |
12 | 12 | if ( (document.cookie.indexOf("irect=t") < 0) // Don't redirect if we have the stop cookie ... only testing a subportion of the cookie. Should be REALLY unique! |
13 | | - && (!document.getElementsByClassName || document.getElementsByClassName( 'ns--1' ).length == 0) |
14 | | - && (document.location.href.indexOf( 'action=' ) == -1 || document.location.href.indexOf( 'action=view' ) != -1 )) // Don't redirect URLs that aren't simple page views |
| 13 | + && (wgNamespaceNumber >= 0) // Don't redirect special pages |
| 14 | + && (wgAction == "view")) // Don't redirect URLs that aren't simple page views |
15 | 15 | { |
16 | 16 | // If we've made it here, then we are going ahead with the redirect |
17 | 17 | |
— | — | @@ -18,7 +18,6 @@ |
19 | 19 | if (wgPageName != wgMainPageTitle.replace(/ /g, '_')) { |
20 | 20 | wgWikimediaMobileUrl += '/' + encodeURI(wgPageName); |
21 | 21 | } |
22 | | - |
23 | 22 | document.location = wgWikimediaMobileUrl; |
24 | 23 | } |
25 | 24 | } |