enabling minifying of javascript again and added new option to debug concatination by setting debug flag for minify

This commit is contained in:
Ralf Becker 2014-01-10 16:08:13 +00:00
parent 1742d07374
commit e3dc74eef6
3 changed files with 17 additions and 11 deletions

View File

@ -341,6 +341,7 @@
<select name="newsettings[debug_minify]"> <select name="newsettings[debug_minify]">
<option value="">{lang_No} - {lang_Default}</option> <option value="">{lang_No} - {lang_Default}</option>
<option value="True"{selected_debug_minify_True}>{lang_Yes}</option> <option value="True"{selected_debug_minify_True}>{lang_Yes}</option>
<option value="debug"{selected_debug_minify_debug}>{lang_Debug}</option>
</select> </select>
</td> </td>
</tr> </tr>

View File

@ -1033,19 +1033,19 @@ abstract class egw_framework
// add all css files from self::includeCSS // add all css files from self::includeCSS
$max_modified = 0; $max_modified = 0;
$debug_minify = (bool)$GLOBALS['egw_info']['server']['debug_minify']; $debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
$base_path = $GLOBALS['egw_info']['server']['webserver_url']; $base_path = $GLOBALS['egw_info']['server']['webserver_url'];
if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH); if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
$css_file = ''; $css_files = '';
foreach(self::$css_include_files as $n => $path) foreach(self::$css_include_files as $n => $path)
{ {
foreach(self::resolve_css_includes($path) as $path) foreach(self::resolve_css_includes($path) as $path)
{ {
if (($mod = filemtime(EGW_SERVER_ROOT.$path)) > $max_modified) $max_modified = $mod; if (($mod = filemtime(EGW_SERVER_ROOT.$path)) > $max_modified) $max_modified = $mod;
if ($debug_minify) if ($debug_minify || substr($path, -8) == '/app.css') // do NOT include app.css, as it changes from app to app
{ {
$css_file .= '<link href="'.$GLOBALS['egw_info']['server']['webserver_url'].$path.'?'.$mod.'" type="text/css" rel="StyleSheet" />'."\n"; $css_files .= '<link href="'.$GLOBALS['egw_info']['server']['webserver_url'].$path.'?'.$mod.'" type="text/css" rel="StyleSheet" />'."\n";
} }
else else
{ {
@ -1057,12 +1057,14 @@ abstract class egw_framework
{ {
$css = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/inc/min/?'; $css = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/inc/min/?';
if ($base_path && $base_path != '/') $css .= 'b='.substr($base_path, 1).'&'; if ($base_path && $base_path != '/') $css .= 'b='.substr($base_path, 1).'&';
$css .= 'f='.$css_file . '&'.$max_modified; $css .= 'f='.$css_file .
$css_file = '<link href="'.$css.'" type="text/css" rel="StyleSheet" />'."\n"; ($GLOBALS['egw_info']['server']['debug_minify'] === 'debug' ? '&debug' : '').
'&'.$max_modified;
$css_files = '<link href="'.$css.'" type="text/css" rel="StyleSheet" />'."\n".$css_files;
} }
return array( return array(
'app_css' => $app_css, 'app_css' => $app_css,
'css_file' => $css_file, 'css_file' => $css_files,
); );
} }
@ -1596,7 +1598,7 @@ abstract class egw_framework
static public function get_script_links($return_pathes=false, $clear_files=false) static public function get_script_links($return_pathes=false, $clear_files=false)
{ {
// RB: disabled minifying (debug=true), 'til I found time to fix it // RB: disabled minifying (debug=true), 'til I found time to fix it
$debug_minify = true;//(bool)$GLOBALS['egw_info']['server']['debug_minify']; $debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
$files = ''; $files = '';
$to_include = $to_minify = array(); $to_include = $to_minify = array();
$max_modified = 0; $max_modified = 0;
@ -1607,7 +1609,8 @@ abstract class egw_framework
if (($mod = filemtime(EGW_SERVER_ROOT.$path)) > $max_modified) $max_modified = $mod; if (($mod = filemtime(EGW_SERVER_ROOT.$path)) > $max_modified) $max_modified = $mod;
// for now minify does NOT support query parameters, nor php files generating javascript // for now minify does NOT support query parameters, nor php files generating javascript
if ($debug_minify || $query || substr($path, -3) != '.js' || strpos($path,'ckeditor') !== false) if ($debug_minify || $query || substr($path, -3) != '.js' || strpos($path,'ckeditor') !== false ||
substr($path, -7) == '/app.js') // do NOT include app.js, as it changes from app to app
{ {
$path .= '?'. $mod.($query ? '&'.$query : ''); $path .= '?'. $mod.($query ? '&'.$query : '');
$to_include[] = $path; $to_include[] = $path;
@ -1622,7 +1625,9 @@ abstract class egw_framework
$base_path = $GLOBALS['egw_info']['server']['webserver_url']; $base_path = $GLOBALS['egw_info']['server']['webserver_url'];
if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH); if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH);
$path = '/phpgwapi/inc/min/?'.($base_path && $base_path != '/' ? 'b='.substr($base_path, 1).'&' : ''). $path = '/phpgwapi/inc/min/?'.($base_path && $base_path != '/' ? 'b='.substr($base_path, 1).'&' : '').
'f='.implode(',', $to_minify) . '&'.$max_modified; 'f='.implode(',', $to_minify) .
($GLOBALS['egw_info']['server']['debug_minify'] === 'debug' ? '&debug' : '').
'&'.$max_modified;
// need to include minified javascript before not minified stuff like jscalendar-setup, as it might depend on it // need to include minified javascript before not minified stuff like jscalendar-setup, as it might depend on it
array_unshift($to_include, $path); array_unshift($to_include, $path);
} }

View File

@ -36,7 +36,7 @@ $min_errorLogger = false;
* In 'debug' mode, Minify combines files with no minification and adds comments * In 'debug' mode, Minify combines files with no minification and adds comments
* to indicate line #s of the original files. * to indicate line #s of the original files.
*/ */
$min_allowDebugFlag = false; $min_allowDebugFlag = true;
/** /**