diff --git a/MIN.txt b/MIN.txt index dbeff0f..e7181d7 100644 --- a/MIN.txt +++ b/MIN.txt @@ -130,6 +130,42 @@ $cssUri = Minify_getUri(array( echo ""; +STORING CONFIG FILES OUTSIDE THE MINIFY DIRECTORY + +It is possible to store config files (min/config.php, min/config-test.php, +min/groupsConfig.php) in a custom directory outside the Minify directory. This is +useful if you wish to include Minify as an external dependency inside another +project via SVN external or Git submodule inclusion. + +For example, let's assume you have a Minify directory "min" in your site root. Then +you could create a new directory called "min-configs" in the site root. Copy any +config files you wish to modify to "min-configs", and modify as desired. + +Then create a new file, for example "min.php" in your site root. The contents of +this file could look like this: + + $customConfigDirectory . '/config.php', + 'test' => $customConfigDirectory . '/config-test.php', + 'groups' => $customConfigDirectory . '/groupsConfig.php' +); + +include_once 'min/index.php'; + +You would then reference min.php in your JS and CSS links instead of min/index.php. + +This method will affect those using the Minify_getUri() function. You will need +to add options to calls to that function, e.g.: + + '/min.php')); +echo ""; + + DEBUG MODE In debug mode, instead of compressing files, Minify sends combined files with @@ -142,4 +178,4 @@ Known issue: files with comment-like strings/regexps can cause problems in this QUESTIONS? -http://groups.google.com/group/minify \ No newline at end of file +http://groups.google.com/group/minify diff --git a/min/index.php b/min/index.php index 79b047d..6f00ffd 100644 --- a/min/index.php +++ b/min/index.php @@ -9,11 +9,37 @@ define('MINIFY_MIN_DIR', dirname(__FILE__)); +// set config path defaults +$min_configPaths = array( + 'base' => MINIFY_MIN_DIR . '/config.php', + 'test' => MINIFY_MIN_DIR . '/config-test.php', + 'groups' => MINIFY_MIN_DIR . '/groupsConfig.php' +); + +// check for custom config paths +if (!empty($min_customConfigPaths)) { + // check for each config in the custom path + foreach ($min_configPaths as $key => $path) { + if (!empty($min_customConfigPaths[$key])) { + continue; + } + if (!file_exists($min_customConfigPaths[$key])) { + continue; + } + if (!is_readable($min_customConfigPaths[$key])) { + continue; + } + // reassign the path for this config to custom + $min_configPaths[$key] = $min_customConfigPaths[$key]; + } + unset($key, $path); +} + // load config -require MINIFY_MIN_DIR . '/config.php'; +require $min_configPaths['base']; if (isset($_GET['test'])) { - include MINIFY_MIN_DIR . '/config-test.php'; + include $min_configPaths['test']; } require "$min_libPath/Minify/Loader.php"; @@ -53,7 +79,7 @@ if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) { } if (isset($_GET['g'])) { // well need groups config - $min_serveOptions['minApp']['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php'); + $min_serveOptions['minApp']['groups'] = (require $min_configPaths['groups']); } if (isset($_GET['f']) || isset($_GET['g'])) { // serve! @@ -69,4 +95,4 @@ if (isset($_GET['f']) || isset($_GET['g'])) { } else { header("Location: /"); exit(); -} \ No newline at end of file +}