Jdlrobson has uploaded a new change for review.

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


Change subject: Bug 44070: Define special page modules manually
......................................................................

Bug 44070: Define special page modules manually

Doing so dynamically makes our code harder to read and causes
unnecessary processing. Reverting back to manual definitions

Change-Id: I51bf514c56ebfc459685fcacee822fdab8dc7ce2
---
M MobileFrontend.php
M includes/MobileFrontend.body.php
2 files changed, 93 insertions(+), 109 deletions(-)


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

diff --git a/MobileFrontend.php b/MobileFrontend.php
index 1181d7e..cd2acf6 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -114,19 +114,6 @@
        if ( $wgMFNearby ) {
                $wgSpecialPages['Nearby'] = 'SpecialNearby';
        }
-       /**
-        * dynamically load mobile special page resources
-        *
-        * It would be preferable to load these in the invocation of the 
ResourceLoaderRegisterModules hook,
-        * however there is an issue (still being diagnosed) that is preventing 
$resourceLoader->register()
-        * from loading modules at the bottom of a page. Also, we need at least 
some of these modules
-        * to be loaded in the production version of MobileFrontend, which does 
not currently fully support
-        * ResourceLoader - so the way the modules get included in the skin 
does not play nicely with the hook
-        * (since the hook runs after the modules need to be loaded in the 
skin).
-        * @see ExtMobileFrontend::generateMobileSpecialPageModules()
-        */
-       $specialModules = ExtMobileFrontend::generateMobileSpecialPageModules( 
$wgMFSpecialModuleStubs );
-       $wgResourceModules = array_merge( $wgResourceModules, $specialModules );
 }
 
 // Unit tests
@@ -424,52 +411,102 @@
 );
 
 /**
-  * Stubs for mobile SpecialPage resource modules
-  *
-  * The modules themselves get generated dynamically later
-  * during the invocation of the ResourceLoaderRegisterModules hook.
-  * @see ExtMobileFrontend::registerMobileSpecialPageModules()
-  */
-$wgMFSpecialModuleStubs = array(
-       'mobilediff' => array(
-               'alias' => 'watchlist',
-               'dependencies' => array( 'mobile.stable' ),
+ * A boilerplate containing common properties for all RL modules served to 
mobile site special pages
+ */
+$wgMFMobileSpecialPageResourceBoilerplate = array(
+       'dependencies' => array( 'mobile.stable' ),
+       'localBasePath' => $localBasePath,
+       'remoteExtPath' => $remoteExtPath,
+       'targets' => 'mobile',
+       'mobileTargets' => array(),
+);
+/**
+       * Special page modules
+       *
+       * Note: Use correct names to ensure modules load on pages
+       * Name must be the name of the special page lowercased prefixed by 
'mobile.'
+       * suffixed by '.styles' or '.scripts'
+       */
+$wgResourceModules['mobile.mobilefeedback.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/mobilefeedback.css',
        ),
-       'mobilefeedback' => array( 'css' => true ),
-       'mobileoptions' => array( 'css' => true, 'js' => true ),
-       'nearby' => array( 'js' => true,
-               'messages' => array(
-                       'mobile-frontend-nearby-error',
-                       'mobile-frontend-nearby-refresh',
-                       'mobile-frontend-nearby-title',
-                       'mobile-frontend-nearby-loading',
-                       'mobile-frontend-nearby-distance-report',
-                       'mobile-frontend-nearby-lookup-error',
-                       'mobile-frontend-nearby-noresults',
-               ),
-               'dependencies' => array(
-                       'mobile.stable',
-               ),
+);
+$wgResourceModules['mobile.mobileoptions.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/mobileoptions.css',
        ),
-       'search' => array( 'css' => true ),
-       'watchlist' => array( 'css' => true, 'js' => false,
-               'dependencies' => array( 'mobile.stable' ),
+);
+$wgResourceModules['mobile.mobileoptions.scripts'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'scripts' => array(
+               'javascripts/specials/mobileoptions.js',
        ),
-       'userlogin' => array( 'css' => true, 'js' => true ),
-       // FIXME: temporary hack to get round CentralNotice logout screen
-       'userlogout' => array( 'alias' => 'userlogin' ),
-       'donateimage' => array( 'js' => true,
-               'css' => true,
-               'messages' => array(
-                       'mobile-frontend-photo-upload-generic',
-                       'mobile-frontend-donate-photo-upload-success',
-                       'mobile-frontend-donate-photo-first-upload-success',
-                       'mobile-frontend-donate-image-summary',
-                       'mobile-frontend-listed-image-no-description',
-               ),
-               'dependencies' => array(
-                       'mobile.beta',
-               ),
+);
+$wgResourceModules['mobile.nearby.scripts'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'messages' => array(
+               'mobile-frontend-nearby-error',
+               'mobile-frontend-nearby-refresh',
+               'mobile-frontend-nearby-title',
+               'mobile-frontend-nearby-loading',
+               'mobile-frontend-nearby-distance-report',
+               'mobile-frontend-nearby-lookup-error',
+               'mobile-frontend-nearby-noresults',
+       ),
+       'scripts' => array(
+               'javascripts/specials/nearby.js',
+       ),
+);
+$wgResourceModules['mobile.search.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/search.css',
+       ),
+);
+$wgResourceModules['mobile.watchlist.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/watchlist.css',
+       ),
+);
+$wgResourceModules['mobile.userlogin.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/userlogin.css',
+       ),
+);
+$wgResourceModules['mobile.userlogin.scripts'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'scripts' => array(
+               'javascripts/specials/userlogin.js',
+       ),
+);
+$wgResourceModules['mobile.donateimage.scripts'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'messages' => array(
+               'mobile-frontend-photo-upload-generic',
+               'mobile-frontend-donate-photo-upload-success',
+               'mobile-frontend-donate-photo-first-upload-success',
+               'mobile-frontend-donate-image-summary',
+               'mobile-frontend-listed-image-no-description',
+       ),
+       'scripts' => array(
+               'javascripts/specials/donateimage.js',
+       ),
+);
+$wgResourceModules['mobile.donateimage.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/donateimage.css',
+       ),
+);
+$wgResourceModules['mobile.mobilediff.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/watchlist.css',
+       ),
+);
+// FIXME: temporary hack to get round CentralNotice logout screen
+$wgResourceModules['mobile.userlogout.scripts'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'scripts' => array(
+               'javascripts/specials/userlogin.js',
+       ),
+);
+$wgResourceModules['mobile.userlogout.styles'] = 
$wgMFMobileSpecialPageResourceBoilerplate + array(
+       'styles' => array(
+               'stylesheets/specials/userlogin.css',
        ),
 );
 
diff --git a/includes/MobileFrontend.body.php b/includes/MobileFrontend.body.php
index 04ff07d..8cb9446 100644
--- a/includes/MobileFrontend.body.php
+++ b/includes/MobileFrontend.body.php
@@ -211,59 +211,6 @@
                wfProfileOut( __METHOD__ );
        }
 
-       /**
-        * Prepares module definitions for mobile SpecialPages
-        *
-        * @param array $specialModuleStubs
-        *      the key is the name of the special page you want to target 
(lowercased)
-        *      the value of the array is an array with 3 recognised keys:
-        *              - alias: names another key in $specialModuleStubs that 
this special page shares resources for
-        *              - css: boolean that identifies there is a corresponding 
stylesheet for this module in stylesheets/specials/<modulename>.css where 
modulename is the key (special page name lowercased)
-        *              - js: boolean that identifies there is a corresponding 
javascript file for this module in javascripts/specials/<modulename>.css  where 
modulename is the key
-        * @return array
-        *      Formatted and mergable with $wgResourceModules
-        */
-       public static function generateMobileSpecialPageModules( 
$specialModuleStubs ) {
-               global $wgMFMobileResourceBoilerplate;
-
-               $modules = array();
-               foreach( $specialModuleStubs as $moduleName => $moduleMakeup ) {
-                       $module = $wgMFMobileResourceBoilerplate;
-
-                       if ( isset( $moduleMakeup[ 'dependencies' ] ) ) {
-                               $module[ 'dependencies' ] = $moduleMakeup[ 
'dependencies' ];
-                       } else {
-                               $module[ 'dependencies' ] = array( 
'mobile.startup' );
-                       }
-
-                       if ( isset( $moduleMakeup[ 'messages' ] ) ) {
-                               $module[ 'messages' ] = $moduleMakeup[ 
'messages' ];
-                       }
-
-                       // allow special pages to use the same stylesheets / 
scripts as other special pages
-                       if ( isset( $moduleMakeup[ 'alias' ] ) ) {
-                               $resourceName = $moduleMakeup[ 'alias' ];
-                               $moduleMakeup = $specialModuleStubs[ 
$resourceName ];
-                       } else {
-                               $resourceName = $moduleName;
-                       }
-
-                       if ( isset( $moduleMakeup[ 'js' ] ) ) {
-                               $id = 'mobile.' . $moduleName . '.scripts';
-                               $modules[$id] = $module;
-                               $modules[$id]['scripts'] = array( 
"javascripts/specials/$resourceName.js" );
-                       }
-
-                       if ( isset( $moduleMakeup[ 'css' ] ) ) {
-                               $id = 'mobile.' . $moduleName . '.styles';
-                               $modules[$id] = $module;
-                               $modules[$id][ 'styles' ] = array( 
"stylesheets/specials/$resourceName.css" );
-                       }
-               }
-               return $modules;
-       }
-}
-
 class MobileFrontendSiteModule extends ResourceLoaderSiteModule {
        protected function getPages( ResourceLoaderContext $context ) {
                global $wgMobileSiteResourceLoaderModule;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I51bf514c56ebfc459685fcacee822fdab8dc7ce2
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