From ce1e4425c2fc96f581428207edab040e42387bbc Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 14 May 2012 23:15:53 +0200 Subject: Combine and minimize core and default app js files --- lib/minimizer/js.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lib/minimizer/js.php (limited to 'lib/minimizer') diff --git a/lib/minimizer/js.php b/lib/minimizer/js.php new file mode 100644 index 00000000000..4ddaa79d81a --- /dev/null +++ b/lib/minimizer/js.php @@ -0,0 +1,62 @@ +appendIfExist(OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) { + + // Is it in apps and overwritten by the theme? + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script$fext.js" )) { + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script.js" )) { + + // Is it part of an app? + }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script$fext.js" )) { + }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script.js" )) { + + // Is it in the owncloud root but overwritten by the theme? + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script$fext.js" )) { + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script.js" )) { + + // Is it in the owncloud root ? + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$script$fext.js" )) { + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$script.js" )) { + + // Is in core but overwritten by a theme? + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script$fext.js" )) { + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script.js" )) { + + // Is it in core? + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$script$fext.js" )) { + }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$script.js" )) { + + }else{ + echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + die(); + } + } + return $this->files; + } + + public function minimizeFiles($files) { + $js_out = ''; + foreach($files as $file_info) { + $file = $file_info[0] . '/' . $file_info[2]; + $js_out .= '/* ' . $file . ' */' . "\n"; + $js_out .= file_get_contents($file); + } + $js_out = JavaScriptMinifier::minify($js_out); + return $js_out; + } +} -- cgit v1.2.3