1
0
mirror of https://github.com/mrclay/minify.git synced 2025-02-24 08:52:50 +01:00
minify/min/index.php
Sam Bauers aceef480c3 Allow definition of custom config directory.
To allow "clean" checkouts of Minify we could use the possibility to define a custom config directory outside the minify directory.

Using this patch a user can define MINIFY_CUSTOM_CONFIG_DIR on a new page outside the minify directory and then include minify's index.php on that page and point their rewrites etc. there instead.

The config.php (and config-test.php) could be copied to the custom directory and edited without causing svn:external/git:submodule conflicts.
2014-02-03 18:19:00 +11:00

79 lines
2.0 KiB
PHP

<?php
/**
* Front controller for default Minify implementation
*
* DO NOT EDIT! Configure this utility via config.php and groupsConfig.php
*
* @package Minify
*/
define('MINIFY_MIN_DIR', dirname(__FILE__));
if (defined('MINIFY_CUSTOM_CONFIG_DIR')) {
define('MINIFY_CONFIG_DIR', MINIFY_CUSTOM_CONFIG_DIR);
} else {
define('MINIFY_CONFIG_DIR', MINIFY_MIN_DIR);
}
// load config
require MINIFY_CONFIG_DIR . '/config.php';
if (isset($_GET['test'])) {
include MINIFY_CONFIG_DIR . '/config-test.php';
}
require "$min_libPath/Minify/Loader.php";
Minify_Loader::register();
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
Minify::setCache(
isset($min_cachePath) ? $min_cachePath : ''
,$min_cacheFileLocking
);
if ($min_documentRoot) {
$_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
Minify::$isDocRootSet = true;
}
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
// auto-add targets to allowDirs
foreach ($min_symlinks as $uri => $target) {
$min_serveOptions['minApp']['allowDirs'][] = $target;
}
if ($min_allowDebugFlag) {
$min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
}
if ($min_errorLogger) {
if (true === $min_errorLogger) {
$min_errorLogger = FirePHP::getInstance(true);
}
Minify_Logger::setLogger($min_errorLogger);
}
// check for URI versioning
if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
$min_serveOptions['maxAge'] = 31536000;
}
if (isset($_GET['g'])) {
// well need groups config
$min_serveOptions['minApp']['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
}
if (isset($_GET['f']) || isset($_GET['g'])) {
// serve!
if (! isset($min_serveController)) {
$min_serveController = new Minify_Controller_MinApp();
}
Minify::serve($min_serveController, $min_serveOptions);
} elseif ($min_enableBuilder) {
header('Location: builder/');
exit();
} else {
header("Location: /");
exit();
}