resourceloader: Allow skins to provide additional styles for any module
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 26 Jun 2014 14:29:31 +0000 (16:29 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 28 Jul 2014 22:53:41 +0000 (00:53 +0200)
commit3971d0646c8e90f27fb79186b15b504ff39d436b
tree8ce5140ccbe6836ff40dbccc8ae4d81f73c0881c
parent4a874cfd5bcef8918898bc175b66098350b39601
resourceloader: Allow skins to provide additional styles for any module

The newly introduced $wgResourceModuleSkinStyles global enables skins to
provide additional stylesheets to existing ResourceLoader module.

This both makes it easier (or at all possible) to override default
styles and lowers the style footprint by making it possible not to
load styles unused on most pages.

----

Example:

Use the file 'foo-styles.css' for the 'mediawiki.foo' module when using
the MySkin skin:

  $wgResourceModuleSkinStyles['myskin'] = array(
    'mediawiki.foo' => 'foo-styles.css',
    'remoteSkinPath' => 'MySkin',
    'localBasePath' => __DIR__,
  );

For detailed documentation, see the doc comment in DefaultSettings.php.
For a practical usage example, see Vector.php.

----

Implementation notes:

* The values defined in $wgResourceModuleSkinStyles are embedded into
  the modules as late as possible (in ResourceLoader::register()).
* Only plain file modules are supported, setting module skin styles
  for other module types has no effect.
* ResourceLoader and ResourceLoaderFileModule now support loading
  files from arbitrary paths to make this possible, defined using
  ResourceLoaderFilePath objects.
  * This required some adjustments in seemingly unrelated places for
    code which didn't handle the paths fully correctly before.
* ResourceLoader and ResourceLoaderFileModule are now a bit more
  tightly coupled than before :(
* Included a tiny example change for the Vector skin, a lot more of
  similar cleanup is possible and planned for the future.
* Many of the non-essential mediawiki.* modules defined in
  Resources.php should be using `'skinStyles' => array( 'default' => … )`
  instead of `'styles' => …` to allow more customizations, this is
  also planned for the future after auditing which ones would actually
  benefit from this.

Change-Id: Ica4ff9696b490e35f60288d7ce1295766c427e87
RELEASE-NOTES-1.24
includes/AutoLoader.php
includes/DefaultSettings.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderFilePath.php [new file with mode: 0644]
resources/Resources.php
skins/Vector/Vector.php
tests/phpunit/structure/ResourcesTest.php