Foxtrott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/172106
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, 46 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/chameleon
refs/changes/06/172106/1
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..f64eb3f 100644
--- a/tests/phpunit/Hooks/SetupAfterCacheTest.php
+++ b/tests/phpunit/Hooks/SetupAfterCacheTest.php
@@ -227,15 +227,29 @@
->disableOriginalConstructor()
->getMock();
+ $IP = dirname( dirname( dirname( dirname( dirname( __DIR__ )
))));
+
$defaultConfiguration = array(
- 'IP' => 'notTestingIP',
+ 'IP' => $IP,
'wgScriptPath' => 'notTestingwgScriptPath',
'wgStyleDirectory' =>
'notTestingwgStyleDirectory',
- 'wgStylePath' =>
'notTestingwgStylePath',
'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
);
--
To view, visit https://gerrit.wikimedia.org/r/172106
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I793c9c965e04e84642b7c816ce4c6f3af0177ae9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits