From 07b80668beefe53af039bd7b5aee895b467800d1 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sun, 1 Jun 2014 10:25:11 -0700 Subject: [PATCH] ResourceLoaderFileModule: Implement remoteSkinPath option 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 | 3 ++ .../ResourceLoaderFileModule.php | 7 +++ resources/Resources.php | 46 +++++++++---------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 0779f6b198..7258392205 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index fa9a8f0291..190801c2b0 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -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 diff --git a/resources/Resources.php b/resources/Resources.php index ea7d3975cf..93415a5b92 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 */ -- 2.20.1