'js/libs/jquery/jquery.transit.js',
'js/widget.js'
);
+
+ // Collection of LESS files to be compiled
+ // Filename with no extension, relative to the /style directory in the player build folder
+ public $lessFiles = ['fluidbook'];
+ public $lessFilesExtras = []; // Extra files that will be copied when compiling LESS (eg. used to allow video-js-core.css to be copied)
+
public $specialCSS = array();
public $phonegapStandardPlugins = array('ios' => array('ExternalFileUtil'),
'android' => array('webintent'));
}
/**
- * Helper function to add a unique stylesheet entry to the CSS stack
+ * Helper function to add a unique stylesheet entry to the LESS stack for compilation
* Duplicate paths are ignored.
- * @param $path
+ * @param $path The path of the file relative to the /style folder, without any extension
+ * @param $extra_files Optional array of extra files that should be copied across for use during LESS compilation
*/
- public function addCSS($path) {
- if (!in_array($path, $this->pluginCSS)) {
- $this->pluginCSS[] = $path;
+ public function addLess($path, $extra_files = []) {
+ if (!in_array($path, $this->lessFiles)) {
+ $this->lessFiles[] = $path;
}
+
+ // Make sure no duplicates are added here either
+ $this->lessFilesExtras = array_unique(array_merge($this->lessFilesExtras, $extra_files));
}
protected function writeIndex($numCSS) {
}
protected function _writeLess($variables) {
- $lessFiles = array('fluidbook');
if ($this->widget) {
- $lessFiles[] = 'widget';
+ $this->lessFiles[] = 'widget';
}
foreach ($this->specialCSS as $s) {
- $lessFiles[] = 'special/' . $s;
+ $this->lessFiles[] = 'special/' . $s;
}
$tmp = CubeIT_Files::tmpdir();
$bookVariables[] = '@' . $k . ':' . $v . ';';
}
file_put_contents($tmp . '/book-variables.less', implode("\n", $bookVariables));
- foreach ($lessFiles as $f) {
- copy($this->assets . '/style/' . $f . '.less', $tmp . '/' . $f . '.less');
+
+ // Also copy any "extra" files that might be needed by LESS compilation
+ // (eg. video-js-core.css is needed by videojs.less)
+ foreach ($this->lessFilesExtras as $extra) {
+ $destination_extra = $tmp . '/' . $extra;
+ if (!is_dir(dirname($destination_extra))) mkdir(dirname($destination_extra));
+ copy($this->assets . '/style/' . $extra, $destination_extra);
+ }
+
+ foreach ($this->lessFiles as $f) {
+
+ $source_less = $this->assets . '/style/' . $f . '.less';
+ $destination_less = $tmp . '/' . $f . '.less';
+ $destination_css = 'style/' . $f . '.css';
+
+ if (!file_exists($source_less)) continue;
+
+ // LESS file might be in a subfolder, so create if it doesn't exist
+ if (!is_dir(dirname($destination_less))) mkdir(dirname($destination_less));
+ // Generated CSS file might be in a subfolder, so create if it doesn't exist
+ if (!is_dir(dirname($this->vdir . '/' . $f . '.css'))) mkdir(dirname($this->vdir . '/' . $f . '.css'));
+
+ // Less files must be copied to temporary directory so they'll
+ // have access to the variables generated in book-variables.less
+ copy($source_less, $destination_less);
$less = new CubeIT_CommandLine('lessc');
$less->setArg('plugin', 'less-plugin-clean-css');
- $less->setArg(null, $tmp . '/' . $f . '.less');
- $less->setArg(null, $this->vdir . '/style/' . $f . '.css');
+ $less->setArg(null, $destination_less);
+ $less->setArg(null, $this->vdir . '/' . $destination_css);
$less->execute();
if ($f != 'widget') {
- $this->stylesheets[] = 'style/' . $f . '.css';
+ $this->stylesheets[] = $destination_css;
}
}
}