mirror of
https://github.com/mrclay/minify.git
synced 2025-08-26 07:14:37 +02:00
Merge pull request #88 from sambauers/master
Allow definition of custom config directory.
This commit is contained in:
36
MIN.txt
36
MIN.txt
@@ -130,6 +130,42 @@ $cssUri = Minify_getUri(array(
|
|||||||
echo "<link rel=stylesheet href='{$cssUri}'>";
|
echo "<link rel=stylesheet href='{$cssUri}'>";
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$customConfigDirectory = dirname(__FILE__) . '/min-configs';
|
||||||
|
$min_customConfigPaths = array(
|
||||||
|
'base' => $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.:
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
|
||||||
|
|
||||||
|
$jsUri = Minify_getUri('//js/file.js', array('minAppUri' => '/min.php'));
|
||||||
|
echo "<script src='{$jsUri}'></script>";
|
||||||
|
|
||||||
|
|
||||||
DEBUG MODE
|
DEBUG MODE
|
||||||
|
|
||||||
In debug mode, instead of compressing files, Minify sends combined files with
|
In debug mode, instead of compressing files, Minify sends combined files with
|
||||||
|
@@ -9,11 +9,37 @@
|
|||||||
|
|
||||||
define('MINIFY_MIN_DIR', dirname(__FILE__));
|
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
|
// load config
|
||||||
require MINIFY_MIN_DIR . '/config.php';
|
require $min_configPaths['base'];
|
||||||
|
|
||||||
if (isset($_GET['test'])) {
|
if (isset($_GET['test'])) {
|
||||||
include MINIFY_MIN_DIR . '/config-test.php';
|
include $min_configPaths['test'];
|
||||||
}
|
}
|
||||||
|
|
||||||
require "$min_libPath/Minify/Loader.php";
|
require "$min_libPath/Minify/Loader.php";
|
||||||
@@ -53,7 +79,7 @@ if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
|
|||||||
}
|
}
|
||||||
if (isset($_GET['g'])) {
|
if (isset($_GET['g'])) {
|
||||||
// well need groups config
|
// 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'])) {
|
if (isset($_GET['f']) || isset($_GET['g'])) {
|
||||||
// serve!
|
// serve!
|
||||||
|
Reference in New Issue
Block a user