Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/71749


Change subject: Default to non homepage special casing
......................................................................

Default to non homepage special casing

Homepage special casing should be enabled on a case by case basis
The existence of this encourages hacky markup to make main pages
render nicely on mobile phones rather than address the core problem
and completely revamping the broken page by redefining it in a
responsive fashion.

The other day in irc there was a query about enabling the main page
and the wiki in question would have rendered perfectly in mobile without
any special casing. This makes me thing we should turn it off by default
and explore ways to killing this code altogether.

See corresponding change I0f5a020ed3b283d05a665a98b9985299110b0056

Change-Id: I35d9169a80a928a00f512052d02f90770738d1b4
---
M MobileFrontend.i18n.php
M MobileFrontend.php
M includes/Resources.php
M includes/formatters/MobileFormatter.php
M includes/skins/SkinMobile.php
D javascripts/modules/mf-homepage.js
6 files changed, 13 insertions(+), 41 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/49/71749/1

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 9a2e7b5..f304faf 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -39,7 +39,6 @@
 
        'mobile-frontend-back-to-top-of-section' => 'Jump back a section',
        'mobile-frontend-close-section' => 'Close this section',
-       'mobile-frontend-empty-homepage-text' => 'This homepage needs to be 
configured. 
[https://www.mediawiki.org/wiki/Mobile_Gateway/Mobile_homepage_formatting 
Instructions on how to get this site mobile enabled]',
        'mobile-frontend-regular-site' => 'Desktop view',
        'mobile-frontend-wml-continue' => 'Continue...',
        'mobile-frontend-wml-back' => 'Back...',
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 003bc26..a9e04da 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -231,6 +231,14 @@
 $wgExtMobileFrontend = null;
 
 /**
+ * Whether or not to special case the Main Page. This should only be enabled 
on long established wikis where
+ * the page renders extremely badly on mobile
+ *
+ * @var bool
+ */
+$wgMFHomepageSpecialCasing = false;
+
+/**
  * Make the classes, tags and ids stripped from page content configurable.
  * Each item will be stripped from the page.
  * See $itemsToRemove for more information.
diff --git a/includes/Resources.php b/includes/Resources.php
index 29959c7..327a833 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -77,26 +77,6 @@
                'group' => 'other',
        ),
 
-       'mobile.mainpage.plumbing' => array(
-               'messages' => array(
-                       // mf-homepage.js
-                       'mobile-frontend-empty-homepage-text' => array( 'parse' 
),
-               ),
-               'class' => 'MFResourceLoaderModule',
-               'group' => 'other',
-       ),
-
-       'mobile.mainpage.scripts' => $wgMFMobileResourceBoilerplate + array(
-               'dependencies' => array(
-                       'mobile.startup',
-                       'mobile.mainpage.plumbing',
-               ),
-               'scripts' => array(
-                       'javascripts/modules/mf-homepage.js',
-               ),
-               'group' => 'other',
-       ),
-
        // Filepages
        'mobile.file.styles' => $wgMFMobileResourceBoilerplate + array(
                'dependencies' => array( 'mobile.startup' ),
diff --git a/includes/formatters/MobileFormatter.php 
b/includes/formatters/MobileFormatter.php
index 06ae333..f780c33 100644
--- a/includes/formatters/MobileFormatter.php
+++ b/includes/formatters/MobileFormatter.php
@@ -74,9 +74,7 @@
                if ( $context->isBetaGroupMember() ) {
                        $formatter->disableBackToTop();
                }
-               if ( !$context->isAlphaGroupMember() ) {
-                       $formatter->setIsMainPage( $isMainPage );
-               }
+               $formatter->setIsMainPage( $isMainPage );
                if ( $context->getContentTransformations() && !$isFilePage ) {
                        $formatter->removeImages( $context->imagesDisabled() );
                }
@@ -130,9 +128,12 @@
         * @return string: Processed HTML
         */
        public function getText( $element = null ) {
+               global $wgMFHomepageSpecialCasing;
                wfProfileIn( __METHOD__ );
                if ( $this->mainPage ) {
-                       $element = $this->parseMainPage( $this->getDoc() );
+                       if ( $wgMFHomepageSpecialCasing ) {
+                               $element = $this->parseMainPage( 
$this->getDoc() );
+                       }
                }
                $html = parent::getText( $element );
                wfProfileOut( __METHOD__ );
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index 77ae426..2ea2aa8 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -133,11 +133,6 @@
 
                $modules = parent::getDefaultModules();
 
-               // main page special casing
-               if ( $this->getTitle()->isMainPage() ) {
-                       $modules['mainpage'] = array( 'mobile.mainpage.scripts' 
);
-               }
-
                // flush unnecessary modules
                $modules['content'] = array();
                $modules['legacy'] = array();
diff --git a/javascripts/modules/mf-homepage.js 
b/javascripts/modules/mf-homepage.js
deleted file mode 100644
index 80a891c..0000000
--- a/javascripts/modules/mf-homepage.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// special casing for homepage
-( function( $ ) {
-
-$( function() {
-       $( 'h1.section_0' ).remove();
-       if ( $( '#mainpage' ).children().length === 0 || $( '#content' 
).children().length === 0 ) {
-               $( '<div class="alert warning">' ).html( mw.msg( 
'mobile-frontend-empty-homepage-text' ) ).prependTo( '#content_wrapper' );
-       }
-} );
-
-} ( jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/71749
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35d9169a80a928a00f512052d02f90770738d1b4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to