r86621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86620‎ | r86621 | r86622 >
Date:13:31, 21 April 2011
Author:catrope
Status:deferred
Tags:
Comment:
WikimediaMobile: Merge r84193 (make mobile redirect script work in the head) from 1.17wmf1 to trunk
Modified paths:
  • /trunk/extensions/WikimediaMobile/MobileRedirect.js (modified) (history)
  • /trunk/extensions/WikimediaMobile/WikimediaMobile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaMobile/WikimediaMobile.php
@@ -19,7 +19,7 @@
2020 /**
2121 * Increment this when the JS file changes
2222 */
23 -$wgWikimediaMobileVersion = '6';
 23+$wgWikimediaMobileVersion = '7';
2424
2525 /**
2626 * The base URL of the mobile gateway
@@ -33,6 +33,14 @@
3434 function wfWikimediaMobileAddJs( &$outputPage, &$skin ) {
3535 global $wgOut, $wgExtensionAssetsPath, $wgWikimediaMobileVersion;
3636
 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;" ) );
3745 $wgOut->addHeadItem( 'mobileredirect', Html::linkedScript(
3846 "$wgExtensionAssetsPath/WikimediaMobile/MobileRedirect.js?$wgWikimediaMobileVersion"
3947 ) );
Index: trunk/extensions/WikimediaMobile/MobileRedirect.js
@@ -9,8 +9,8 @@
1010 .test( navigator.userAgent ) )
1111 {
1212 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
1515 {
1616 // If we've made it here, then we are going ahead with the redirect
1717
@@ -18,7 +18,6 @@
1919 if (wgPageName != wgMainPageTitle.replace(/ /g, '_')) {
2020 wgWikimediaMobileUrl += '/' + encodeURI(wgPageName);
2121 }
22 -
2322 document.location = wgWikimediaMobileUrl;
2423 }
2524 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r841931.17wmf1: Commit live hacks I applied some time ago to make MobileReidrect.js...catrope18:45, 17 March 2011

Status & tagging log