r84193 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84192‎ | r84193 | r84194 >
Date:18:45, 17 March 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: Commit live hacks I applied some time ago to make MobileReidrect.js work in the <head>
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/WikimediaMobile/MobileRedirect.js (modified) (history)
  • /branches/wmf/1.17wmf1/extensions/WikimediaMobile/WikimediaMobile.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/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: branches/wmf/1.17wmf1/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 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r86621WikimediaMobile: Merge r84193 (make mobile redirect script work in the head) ...catrope13:31, 21 April 2011

Status & tagging log