'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)
+ // 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'),
public function getVideosFormats($poster = true) {
$res = [];
-//
-// if (!$this->phonegap) {
-// $res = array('ogv', 'webm', 'mp4', 'flv');
-// } elseif ($this->phonegap == 'ios') {
-// $res = array('mp4');
-// } else if ($this->phonegap == 'android') {
-// $res = array('webm', 'mp4');
-// }
+ //
+ // if (!$this->phonegap) {
+ // $res = array('ogv', 'webm', 'mp4', 'flv');
+ // } elseif ($this->phonegap == 'ios') {
+ // $res = array('mp4');
+ // } else if ($this->phonegap == 'android') {
+ // $res = array('webm', 'mp4');
+ // }
- $res[] = 'mp4';
+ $res[] = 'mp4';
if ($poster) {
$res[] = 'jpg';
file_put_contents($cacheFile, implode("\n", $lines));
}
- /**
- * Helper function to add a unique script entry to the JS stack.
- * Normally this is a relative path but it can be an external URL.
- * External URLs are added to the pluginJs collection instead of jsFiles.
- * Duplicate paths are ignored.
- * @param $path
- */
- public function addJs($path) {
-
- // If JS is external, it will be included via the pluginJs collection
- // Otherwise, it will be compiled into the main JS file
- $collection = (preg_match('#^https?://#i', $path) === 1) ? 'pluginJs' : 'jsFiles';
-
- if (!in_array($path, $this->$collection)) {
- $this->{$collection}[] = $path;
- }
+ /**
+ * Helper function to add a unique script entry to the JS stack.
+ * Normally this is a relative path but it can be an external URL.
+ * External URLs are added to the pluginJs collection instead of jsFiles.
+ * Duplicate paths are ignored.
+ * @param $path
+ */
+ public function addJs($path) {
+
+ // If JS is external, it will be included via the pluginJs collection
+ // Otherwise, it will be compiled into the main JS file
+ $collection = (preg_match('#^https?://#i', $path) === 1) ? 'pluginJs' : 'jsFiles';
+
+ if (!in_array($path, $this->$collection)) {
+ $this->{$collection}[] = $path;
+ }
}
- /**
- * Helper function to add a unique stylesheet entry to the LESS stack for compilation
- * Duplicate paths are ignored.
- * @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 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));
+ /**
+ * Helper function to add a unique stylesheet entry to the LESS stack for compilation
+ * Duplicate paths are ignored.
+ * @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 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() {
foreach ($finals as $jsfinal => $files) {
$mintime = 0;
- $minimized = $this->assets . '/js/' . $jsfinal . '-min.js';
+ $hash = hash('sha256', json_encode($files));
+ $minimized = $this->assets . '/js/min/' . $jsfinal . '-' . $hash . '-min.js';
+ if (!file_exists(dirname($minimized))) {
+ mkdir(dirname($minimized));
+ }
if (file_exists($minimized)) {
$mintime = filemtime($minimized);
- }
-
- $reminimize = false;
- if ($jsfinal == 'special') {
+ } else {
+ $mintime = 0;
$reminimize = true;
}
+
if (!$reminimize) {
foreach ($files as $file) {
if (filemtime($this->assets . '/' . $file) > $mintime) {
}
if ($reminimize) {
- $js = '';
+ $js = 'var files=' . json_encode($files) . ';';
foreach ($files as $file) {
$js .= file_get_contents($this->assets . '/' . $file);
$js .= ";\n\n";
$uglify->setArg('no-copyright');
$uglify->setArg(null, $tmp);
$uglify->execute();
- //$uglify->debug();
+ $uglify->debug();
+
+
}
$dest = $this->vdir . '/data/' . $jsfinal . '.js';
copy($minimized, $dest);
}
file_put_contents($tmp . '/book-variables.less', implode("\n", $bookVariables));
- // 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);
- }
+ // 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), 0777, true);
+ }
+ 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';
+ $source_less = $this->assets . '/style/' . $f . '.less';
+ $destination_less = $tmp . '/' . $f . '.less';
+ $destination_css = 'style/' . $f . '.css';
- if (!file_exists($source_less)) continue;
+ 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 file might be in a subfolder, so create if it doesn't exist
+ if (!is_dir(dirname($destination_less))) {
+ mkdir(dirname($destination_less), 0777, true);
+ }
+ // 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'), 0777, true);
+ }
// 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);
+ // 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, $destination_less);
}
class videoLink extends wsHTML5Link {
-
- public static function addVideoJS($compiler) {
- $compiler->addJs('js/libs/videojs/video.js');
- $compiler->addLess('videojs/videojs', ['videojs/video-js-core.css']);
- }
+ public static function addVideoJS($compiler) {
+ $compiler->addJs('js/libs/videojs/video.js');
+ $compiler->addLess('videojs/videojs', ['videojs/video-js-core.css']);
+ }
public function getClasses() {
return array_merge(['videoLink'], parent::getClasses());
public function getHTMLContent() {
- static::addVideoJS($this->compiler);
$this->copyExternalFile($this->to, true);
}
public static function makeVideoTag($linkDatas, $w = null, $h = null, $compiler = null) {
+ static::addVideoJS($compiler);
$attributes = static::getVideoAttributes($linkDatas, $w, $h, $compiler);
public function getHTMLContent() {
if ($this->video_service !== 0) {
- return $this->getEmbed();
- }
+ return $this->getEmbed();
+ }
$w = round($this->width * $this->getCssScale());
$h = round($this->height * $this->getCssScale());
public function getURL() {
return '#/video/' . $this->to;
- }
+ }
public function getAdditionnalContent() {
$this->video_auto_start = true; // Videos should always autoplay
$this->compiler->simpleCopyLinkFile($both, 'data/links/zoom_' . $this->id . '.jpg');
- // Perform tidy up and delete temporary files if they exist
- $files_to_delete = ['left', 'leftfile', 'right', 'rightfile', 'both'];
- foreach($files_to_delete as $file) {
- if (isset($$file) && file_exists($$file)) {
- unlink($$file);
- }
- }
+ // Perform tidy up and delete temporary files if they exist
+ $files_to_delete = ['left', 'leftfile', 'right', 'rightfile', 'both'];
+ foreach ($files_to_delete as $file) {
+ if (isset($$file) && file_exists($$file)) {
+ unlink($$file);
+ }
+ }
}