Foxtrott has submitted this change and it was merged.
Change subject: Use relative paths
......................................................................
Use relative paths
This will enable installation of the skin in other directories then the
standard .../skins. However it still expects some layout assumptions to be
true. The expected layout is
+- skins
| +- chameleon
+- extensions
| +- Bootstrap
+- vendor
+- twitter
+- bootstrap
This patch enables bundling the skins and its dependencies as a package (tar
file or whatever).
Change-Id: I793c9c965e04e84642b7c816ce4c6f3af0177ae9
---
M src/Hooks/SetupAfterCache.php
M tests/phpunit/Hooks/SetupAfterCacheTest.php
2 files changed, 65 insertions(+), 35 deletions(-)
Approvals:
Foxtrott: Verified; Looks good to me, approved
diff --git a/src/Hooks/SetupAfterCache.php b/src/Hooks/SetupAfterCache.php
index 5dcbff7..9c31a13 100644
--- a/src/Hooks/SetupAfterCache.php
+++ b/src/Hooks/SetupAfterCache.php
@@ -61,6 +61,8 @@
* @return self
*/
public function process() {
+
+ $this->setInstallPaths();
$this->addLateSettings();
$this->registerCommonBootstrapModules();
$this->registerExternalLessModules();
@@ -79,6 +81,19 @@
foreach ( $this->configuration as $key => $value ) {
$configuration[ $key ] = $value;
}
+ }
+
+ /**
+ * Set local and remote base path of the Chameleon skin
+ */
+ protected function setInstallPaths() {
+
+ $dirParts = explode( DIRECTORY_SEPARATOR, __DIR__ );
+ array_pop( $dirParts );
+ array_pop( $dirParts );
+
+ $this->configuration[ 'chameleonLocalPath' ] = implode( '/',
$dirParts );
+ $this->configuration[ 'chameleonRemotePath' ] = str_replace(
$this->configuration[ 'IP' ], $this->configuration[ 'wgScriptPath' ],
$this->configuration[ 'chameleonLocalPath' ] );
}
protected function addLateSettings() {
@@ -104,8 +119,8 @@
}
$this->configuration[ 'wgResourceModules' ][
'skin.chameleon.jquery-sticky' ] = array(
- 'localBasePath' => $this->configuration[
'wgStyleDirectory' ] . implode( DIRECTORY_SEPARATOR, array( '', 'chameleon',
'resources' ) ),
- 'remoteBasePath' => $this->configuration[
'wgScriptPath' ] . '/skins/chameleon/resources',
+ 'localBasePath' => $this->configuration[
'chameleonLocalPath' ] . '/resources',
+ 'remoteBasePath' => $this->configuration[
'chameleonRemotePath' ] . '/resources',
'group' => 'skin.chameleon',
'skinScripts' => array( 'chameleon' => array(
'jquery-sticky/jquery.sticky.js', 'Components/Modifications/sticky.js' ) )
);
@@ -134,8 +149,8 @@
}
$this->bootstrapManager->addExternalModule(
- $this->configuration[ 'wgStyleDirectory' ] .
'/chameleon/styles/' . 'core.less',
- $this->configuration[ 'wgStylePath' ] .
'/chameleon/styles/'
+ $this->configuration[ 'chameleonLocalPath' ] .
'/styles/core.less',
+ $this->configuration[ 'chameleonRemotePath' ] .
'/styles/'
);
}
@@ -165,6 +180,10 @@
}
}
+ /**
+ * @param $id
+ * @return bool
+ */
private function hasConfiguration( $id ) {
return isset( $this->configuration[ $id ] );
}
@@ -177,6 +196,11 @@
return $this->hasConfiguration( $id ) && is_array(
$this->configuration[ $id ] );
}
+ /**
+ * @param $localFile
+ * @param $remotePath
+ * @return array
+ */
private function matchAssociativeElement( $localFile, $remotePath ) {
if ( is_integer( $localFile ) ) {
diff --git a/tests/phpunit/Hooks/SetupAfterCacheTest.php
b/tests/phpunit/Hooks/SetupAfterCacheTest.php
index ca10619..03c8651 100644
--- a/tests/phpunit/Hooks/SetupAfterCacheTest.php
+++ b/tests/phpunit/Hooks/SetupAfterCacheTest.php
@@ -89,15 +89,15 @@
$bootstrapManager->expects( $this->at( 3 ) )
->method( 'addExternalModule' )
->with(
- $this->equalTo( $this->dummyExternalModule ),
+ $this->equalTo( $this->dummyExternalModule ),
$this->equalTo( 'someRemoteWeDontCheck' ) );
$bootstrapManager->expects( $this->never() )
->method( 'setLessVariable' );
$mixedExternalStyleModules = array(
- $this->dummyExternalModule ,
- $this->dummyExternalModule => 'someRemoteWeDontCheck'
+ $this->dummyExternalModule,
+ $this->dummyExternalModule => 'someRemoteWeDontCheck'
);
$configuration = array(
@@ -170,7 +170,7 @@
->method( 'setLessVariable' )
->with(
$this->equalTo( 'foo' ),
- $this->equalTo( '999px') );
+ $this->equalTo( '999px' ) );
$externalLessVariables = array(
'foo' => '999px'
@@ -178,10 +178,10 @@
$configuration = array(
'egChameleonExternalLessVariables' =>
$externalLessVariables,
- 'IP' => 'notTestingIP',
- 'wgScriptPath' =>
'notTestingwgScriptPath',
- 'wgStyleDirectory' =>
'notTestingwgStyleDirectory',
- 'wgStylePath' =>
'notTestingwgStylePath'
+ 'IP' => 'notTestingIP',
+ 'wgScriptPath' =>
'notTestingwgScriptPath',
+ 'wgStyleDirectory' =>
'notTestingwgStyleDirectory',
+ 'wgStylePath' =>
'notTestingwgStylePath'
);
$instance = new SetupAfterCache(
@@ -227,15 +227,29 @@
->disableOriginalConstructor()
->getMock();
+ $IP = dirname( dirname( dirname( dirname( dirname( __DIR__ ) )
) ) );
+
$defaultConfiguration = array(
- 'IP' => 'notTestingIP',
- 'wgScriptPath' => 'notTestingwgScriptPath',
- 'wgStyleDirectory' =>
'notTestingwgStyleDirectory',
- 'wgStylePath' =>
'notTestingwgStylePath',
- 'wgResourceModules' => array(),
+ 'IP' => $IP,
+ 'wgScriptPath' => 'notTestingwgScriptPath',
+ 'wgStyleDirectory' => 'notTestingwgStyleDirectory',
+ 'wgResourceModules' => array(),
);
- $configurationToBeAdjusted = $configuration + $defaultConfiguration;
+ $expected[ 'chameleonLocalPath' ] = $IP . '/skins/chameleon';
+ $expected[ 'chameleonRemotePath' ] = $defaultConfiguration[
'wgScriptPath' ] . '/skins/chameleon';
+
+ $expected[ 'wgResourceModules' ] = array();
+ $expected[ 'wgResourceModules' ][
'skin.chameleon.jquery-sticky' ] = array(
+ 'localBasePath' => $expected[ 'chameleonLocalPath' ] .
'/resources',
+ 'remoteBasePath' => $expected[ 'chameleonRemotePath' ]
. '/resources',
+ 'group' => 'skin.chameleon',
+ 'skinScripts' => array(
+ 'chameleon' => array(
'jquery-sticky/jquery.sticky.js', 'Components/Modifications/sticky.js' )
+ )
+ );
+
+ $configurationToBeAdjusted = $configuration +
$defaultConfiguration;
$instance = new SetupAfterCache(
$bootstrapManager,
@@ -244,15 +258,7 @@
$instance->process();
- $expected[ 'wgResourceModules' ] = array();
- $expected[ 'wgResourceModules' ][
'skin.chameleon.jquery-sticky' ] = array(
- 'localBasePath' => $defaultConfiguration[
'wgStyleDirectory' ] . implode( DIRECTORY_SEPARATOR, array( '', 'chameleon',
'resources' ) ),
- 'remoteBasePath' => $defaultConfiguration[
'wgScriptPath' ] . '/skins/chameleon/resources',
- 'group' => 'skin.chameleon',
- 'skinScripts' => array( 'chameleon' => array(
'jquery-sticky/jquery.sticky.js', 'Components/Modifications/sticky.js' ) )
- );
-
- $this->assertEquals(
+ $this->assertEquals(
$expected + $defaultConfiguration,
$configurationToBeAdjusted
);
@@ -265,12 +271,12 @@
$provider = array();
- $provider[] = array(
+ $provider[ ] = array(
array(),
array()
);
- $provider[] = array(
+ $provider[ ] = array(
array(
'wgVisualEditorSupportedSkins' => array(),
),
@@ -279,7 +285,7 @@
)
);
- $provider[] = array(
+ $provider[ ] = array(
array(
'egChameleonEnableVisualEditor' => true,
),
@@ -288,10 +294,10 @@
)
);
- $provider[] = array(
+ $provider[ ] = array(
array(
'egChameleonEnableVisualEditor' => true,
- 'wgVisualEditorSupportedSkins' => array(
'foo'),
+ 'wgVisualEditorSupportedSkins' => array( 'foo'
),
),
array(
'egChameleonEnableVisualEditor' => true,
@@ -299,7 +305,7 @@
)
);
- $provider[] = array(
+ $provider[ ] = array(
array(
'egChameleonEnableVisualEditor' => true,
'wgVisualEditorSupportedSkins' => array(
'foo', 'chameleon' ),
@@ -310,7 +316,7 @@
)
);
- $provider[] = array(
+ $provider[ ] = array(
array(
'egChameleonEnableVisualEditor' => false,
'wgVisualEditorSupportedSkins' => array(
'chameleon', 'foo' => 'chameleon', 'foo' ),
@@ -328,7 +334,7 @@
$provider = array();
- $provider[] = array(
+ $provider[ ] = array(
array(
'key1' => 'value1',
'key2' => 'value2',
--
To view, visit https://gerrit.wikimedia.org/r/172106
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I793c9c965e04e84642b7c816ce4c6f3af0177ae9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits