r67331 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67330‎ | r67331 | r67332 >
Date:09:48, 4 June 2010
Author:tstarling
Status:deferred
Tags:
Comment:
Adding WikimediaMobile to 1.16wmf4 for pilot deployment.
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/WikimediaMobile (added) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/WikimediaMobile/WikimediaMobile.php
@@ -0,0 +1,36 @@
 2+<?php
 3+
 4+/**
 5+ * MediaWiki support functions for the wikimedia-mobile project hosted
 6+ * at http://github.com/hcatlin/wikimedia-mobile
 7+ */
 8+
 9+/**
 10+ * Increment this when the JS file changes
 11+ */
 12+$wgWikimediaMobileVersion = '1';
 13+
 14+/**
 15+ * The base URL of the mobile gateway
 16+ */
 17+$wgWikimediaMobileUrl = 'http://en.m.wikipedia.org/wiki';
 18+
 19+
 20+$wgHooks['BeforePageDisplay'][] = 'wfWikimediaMobileAddJs';
 21+$wgHooks['MakeGlobalVariablesScript'][] = 'wfWikimediaMobileVars';
 22+
 23+function wfWikimediaMobileAddJs( &$outputPage, &$skin ) {
 24+ global $wgOut, $wgExtensionAssetsPath, $wgWikimediaMobileVersion;
 25+
 26+ $wgOut->addScript( Html::linkedScript(
 27+ "$wgExtensionAssetsPath/WikimediaMobile/MobileRedirect.js?$wgWikimediaMobileVersion"
 28+ ) );
 29+ return true;
 30+}
 31+
 32+function wfWikimediaMobileVars( &$vars ) {
 33+ global $wgWikimediaMobileUrl;
 34+ $vars['wgWikimediaMobileUrl'] = $wgWikimediaMobileUrl;
 35+ return true;
 36+}
 37+
Property changes on: branches/wmf/1.16wmf4/extensions/WikimediaMobile/WikimediaMobile.php
___________________________________________________________________
Name: svn:eol-style
138 + native
Index: branches/wmf/1.16wmf4/extensions/WikimediaMobile/MobileRedirect.js
@@ -0,0 +1,47 @@
 2+/** Mobile Redirect Helper
 3+ *
 4+ * Redirects to a wikimedia-mobile installation for viewers on iPhone, iPod
 5+ * Touch, Palm Pre, and Android devices.
 6+ *
 7+ * You can turn off the redirect by setting the cookie "stopMobileRedirect=true"
 8+ */
 9+if ( /(Android|iPhone|iPod|webOS|NetFront|Opera Mini|SEMC-Browser|PlayStation Portable|Nintendo Wii)/
 10+ .test( navigator.userAgent ) )
 11+{
 12+ (function () {
 13+ function haveStopCookie() {
 14+ return (document.cookie.indexOf("stopMobileRedirect=true") >= 0);
 15+ }
 16+
 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 += encodeURIComponent(wgPageName).replace('%2F','/').replace('%3A',':');
 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+ })();
 48+}
Property changes on: branches/wmf/1.16wmf4/extensions/WikimediaMobile/MobileRedirect.js
___________________________________________________________________
Name: svn:eol-style
149 + native

Status & tagging log