ResourceLoaderFileModule: Implement remoteSkinPath option
authorDaniel Friesen <daniel@nadir-seen-fire.com>
Sun, 1 Jun 2014 17:25:11 +0000 (10:25 -0700)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 17 Jun 2014 14:05:19 +0000 (16:05 +0200)
remoteSkinPath works the same as remoteExtPath but is relative to skins/ instead of extensions/

This will allow skins to register modules using:
 $wgResourceModules['skin.myskin'] = array(
   // ...
   'localBasePath' => __DIR__,
   'remoteSkinPath' => 'myskin',
 );

Instead of using:
 'remoteBasePath' => $GLOBALS['wgStylePath'] . '/myskin', // or
 'remoteBasePath' => &$GLOBALS['wgStylePath'],

Change-Id: I0e8c4a37a224e9528c9c5aa5417f0f56dbb89b97

RELEASE-NOTES-1.24
includes/resourceloader/ResourceLoaderFileModule.php
resources/Resources.php

index 0779f6b..7258392 100644 (file)
@@ -75,6 +75,9 @@ production.
   Special:Log, but more are to come.
 * Special:MostLinkedTemplates is no longer limited to transclusions from the
   Template namespace.
+* Skins can now use 'remoteSkinPath' when defining ResourceLoader modules.
+  This works the same as 'remoteExtPath' but is relative to the skins/ folder
+  instead of the extensions/ folder.
 
 === Bug fixes in 1.24 ===
 * (bug 49116) Footer copyright notice is now always displayed in user language
index fa9a8f0..190801c 100644 (file)
@@ -181,6 +181,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *         'remoteBasePath' => [base path],
         *         // Equivalent of remoteBasePath, but relative to $wgExtensionAssetsPath
         *         'remoteExtPath' => [base path],
+        *         // Equivalent of remoteBasePath, but relative to $wgStylePath
+        *         'remoteSkinPath' => [base path],
         *         // Scripts to always include
         *         'scripts' => [file path string or array of file path strings],
         *         // Scripts to include in specific language contexts
@@ -232,6 +234,11 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                        $this->remoteBasePath = $wgExtensionAssetsPath . '/' . $options['remoteExtPath'];
                }
 
+               if ( isset( $options['remoteSkinPath'] ) ) {
+                       global $wgStylePath;
+                       $this->remoteBasePath = $wgStylePath . '/' . $options['remoteSkinPath'];
+               }
+
                foreach ( $options as $member => $option ) {
                        switch ( $member ) {
                                // Lists of file paths
index ea7d397..93415a5 100644 (file)
@@ -83,28 +83,28 @@ return array(
         */
        'mediawiki.skinning.elements' => array(
                'styles' => array(
-                       'common/commonElements.css' => array( 'media' => 'screen' ),
+                       'commonElements.css' => array( 'media' => 'screen' ),
                ),
-               'remoteBasePath' => $GLOBALS['wgStylePath'],
-               'localBasePath' => $GLOBALS['wgStyleDirectory'],
+               'remoteSkinPath' => 'common',
+               'localBasePath' => $GLOBALS['wgStyleDirectory'] . '/common',
        ),
        'mediawiki.skinning.content' => array(
                'styles' => array(
-                       'common/commonElements.css' => array( 'media' => 'screen' ),
-                       'common/commonContent.css' => array( 'media' => 'screen' ),
+                       'commonElements.css' => array( 'media' => 'screen' ),
+                       'commonContent.css' => array( 'media' => 'screen' ),
                ),
-               'remoteBasePath' => $GLOBALS['wgStylePath'],
-               'localBasePath' => $GLOBALS['wgStyleDirectory'],
+               'remoteSkinPath' => 'common',
+               'localBasePath' => $GLOBALS['wgStyleDirectory'] . '/common',
        ),
        'mediawiki.skinning.interface' => array(
                // Used in the web installer. Test it after modifying this definition!
                'styles' => array(
-                       'common/commonElements.css' => array( 'media' => 'screen' ),
-                       'common/commonContent.css' => array( 'media' => 'screen' ),
-                       'common/commonInterface.css' => array( 'media' => 'screen' ),
+                       'commonElements.css' => array( 'media' => 'screen' ),
+                       'commonContent.css' => array( 'media' => 'screen' ),
+                       'commonInterface.css' => array( 'media' => 'screen' ),
                ),
-               'remoteBasePath' => $GLOBALS['wgStylePath'],
-               'localBasePath' => $GLOBALS['wgStyleDirectory'],
+               'remoteSkinPath' => 'common',
+               'localBasePath' => $GLOBALS['wgStyleDirectory'] . '/common',
        ),
 
        'mediawiki.skinning.content.parsoid' => array(
@@ -131,31 +131,31 @@ return array(
        'skins.vector.styles' => array(
                // Used in the web installer. Test it after modifying this definition!
                'styles' => array(
-                       'vector/screen.less' => array( 'media' => 'screen' ),
-                       'vector/screen-hd.less' => array( 'media' => 'screen and (min-width: 982px)' ),
+                       'screen.less' => array( 'media' => 'screen' ),
+                       'screen-hd.less' => array( 'media' => 'screen and (min-width: 982px)' ),
                ),
-               'remoteBasePath' => $GLOBALS['wgStylePath'],
-               'localBasePath' => $GLOBALS['wgStyleDirectory'],
+               'remoteSkinPath' => 'vector',
+               'localBasePath' => $GLOBALS['wgStyleDirectory'] . '/vector',
        ),
        'skins.monobook.styles' => array(
                'styles' => array(
-                       'monobook/main.css' => array( 'media' => 'screen' ),
+                       'main.css' => array( 'media' => 'screen' ),
                ),
-               'remoteBasePath' => $GLOBALS['wgStylePath'],
-               'localBasePath' => $GLOBALS['wgStyleDirectory'],
+               'remoteSkinPath' => 'monobook',
+               'localBasePath' => $GLOBALS['wgStyleDirectory'] . '/monobook',
        ),
        'skins.vector.js' => array(
                'scripts' => array(
-                       'vector/collapsibleTabs.js',
-                       'vector/vector.js',
+                       'collapsibleTabs.js',
+                       'vector.js',
                ),
                'position' => 'top',
                'dependencies' => array(
                        'jquery.throttle-debounce',
                        'jquery.tabIndex',
                ),
-               'remoteBasePath' => $GLOBALS['wgStylePath'],
-               'localBasePath' => $GLOBALS['wgStyleDirectory'],
+               'remoteSkinPath' => 'vector',
+               'localBasePath' => $GLOBALS['wgStyleDirectory'] . '/vector',
        ),
 
        /* jQuery */