mirror of
https://github.com/mrclay/minify.git
synced 2025-08-14 01:54:11 +02:00
rework classloader
- make it available in config - always use classloader, no manual require - compatible for future composer alternative
This commit is contained in:
@@ -22,11 +22,9 @@ if (0 === strpos($_SERVER["SERVER_SOFTWARE"], 'Apache/')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/../lib/Minify/Loader.php';
|
||||||
require dirname(__FILE__) . '/../config.php';
|
require dirname(__FILE__) . '/../config.php';
|
||||||
|
|
||||||
require "$min_libPath/Minify/Loader.php";
|
|
||||||
Minify_Loader::register();
|
|
||||||
|
|
||||||
if (! $min_enableBuilder) {
|
if (! $min_enableBuilder) {
|
||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
die('This application is not enabled. See http://code.google.com/p/minify/wiki/BuilderApp');
|
die('This application is not enabled. See http://code.google.com/p/minify/wiki/BuilderApp');
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
* @package Minify
|
* @package Minify
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/../lib/Minify/Loader.php';
|
||||||
|
|
||||||
$_oc = ini_get('zlib.output_compression');
|
$_oc = ini_get('zlib.output_compression');
|
||||||
|
|
||||||
// allow access only if builder is enabled
|
// allow access only if builder is enabled
|
||||||
@@ -20,7 +22,6 @@ if (isset($_GET['hello'])) {
|
|||||||
// try to prevent double encoding (may not have an effect)
|
// try to prevent double encoding (may not have an effect)
|
||||||
ini_set('zlib.output_compression', '0');
|
ini_set('zlib.output_compression', '0');
|
||||||
|
|
||||||
require $min_libPath . '/HTTP/Encoder.php';
|
|
||||||
HTTP_Encoder::$encodeToIe6 = true; // just in case
|
HTTP_Encoder::$encodeToIe6 = true; // just in case
|
||||||
$he = new HTTP_Encoder(array(
|
$he = new HTTP_Encoder(array(
|
||||||
'content' => 'World!'
|
'content' => 'World!'
|
||||||
|
@@ -57,7 +57,6 @@ $min_allowDebugFlag = false;
|
|||||||
* To use APC/Memcache/ZendPlatform for cache storage, require the class and
|
* To use APC/Memcache/ZendPlatform for cache storage, require the class and
|
||||||
* set $min_cachePath to an instance. Example below:
|
* set $min_cachePath to an instance. Example below:
|
||||||
*/
|
*/
|
||||||
//require dirname(__FILE__) . '/lib/Minify/Cache/APC.php';
|
|
||||||
//$min_cachePath = new Minify_Cache_APC();
|
//$min_cachePath = new Minify_Cache_APC();
|
||||||
|
|
||||||
|
|
||||||
@@ -72,6 +71,7 @@ $min_allowDebugFlag = false;
|
|||||||
* second line. The third line might work on some Apache servers.
|
* second line. The third line might work on some Apache servers.
|
||||||
*/
|
*/
|
||||||
$min_documentRoot = '';
|
$min_documentRoot = '';
|
||||||
|
//$min_documentRoot = dirname(dirname(dirname(__FILE__)));
|
||||||
//$min_documentRoot = substr(__FILE__, 0, -15);
|
//$min_documentRoot = substr(__FILE__, 0, -15);
|
||||||
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
|
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
|
||||||
|
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
define('MINIFY_MIN_DIR', dirname(__FILE__));
|
define('MINIFY_MIN_DIR', dirname(__FILE__));
|
||||||
|
|
||||||
|
require MINIFY_MIN_DIR . '/lib/Minify/Loader.php';
|
||||||
|
|
||||||
// set config path defaults
|
// set config path defaults
|
||||||
$min_configPaths = array(
|
$min_configPaths = array(
|
||||||
'base' => MINIFY_MIN_DIR . '/config.php',
|
'base' => MINIFY_MIN_DIR . '/config.php',
|
||||||
@@ -28,9 +30,6 @@ if (isset($_GET['test'])) {
|
|||||||
include $min_configPaths['test'];
|
include $min_configPaths['test'];
|
||||||
}
|
}
|
||||||
|
|
||||||
require "$min_libPath/Minify/Loader.php";
|
|
||||||
Minify_Loader::register();
|
|
||||||
|
|
||||||
// use an environment object to encapsulate all input
|
// use an environment object to encapsulate all input
|
||||||
$server = $_SERVER;
|
$server = $_SERVER;
|
||||||
if ($min_documentRoot) {
|
if ($min_documentRoot) {
|
||||||
|
@@ -17,12 +17,26 @@ class Minify_Loader {
|
|||||||
$file .= strtr($class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . '.php';
|
$file .= strtr($class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . '.php';
|
||||||
if (is_readable($file)) {
|
if (is_readable($file)) {
|
||||||
require $file;
|
require $file;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$map = array(
|
||||||
|
'JavascriptPacker' => 'class.JavaScriptPacker.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isset($map[$class])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@include $map[$class];
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function register()
|
public static function register()
|
||||||
{
|
{
|
||||||
$inst = new self();
|
$inst = new self();
|
||||||
spl_autoload_register(array($inst, 'loadClass'));
|
spl_autoload_register(array($inst, 'loadClass'));
|
||||||
|
return $inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Minify_Loader::register();
|
||||||
|
@@ -14,14 +14,6 @@
|
|||||||
* @package Minify
|
* @package Minify
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (false === (@include 'class.JavaScriptPacker.php')) {
|
|
||||||
trigger_error(
|
|
||||||
'The script "class.JavaScriptPacker.php" is required. Please see: http:'
|
|
||||||
.'//code.google.com/p/minify/source/browse/trunk/min/lib/Minify/Packer.php'
|
|
||||||
,E_USER_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minify Javascript using Dean Edward's Packer
|
* Minify Javascript using Dean Edward's Packer
|
||||||
*
|
*
|
||||||
|
@@ -10,9 +10,8 @@
|
|||||||
* @package Minify
|
* @package Minify
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! class_exists('Minify_Loader', false)) {
|
if (!class_exists('Minify_Loader', false)) {
|
||||||
require dirname(__FILE__) . '/lib/Minify/Loader.php';
|
require dirname(__FILE__) . '/lib/Minify/Loader.php';
|
||||||
Minify_Loader::register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
$pathToLib = dirname(dirname(__DIR__)) . '/min/lib';
|
$pathToLib = dirname(dirname(__DIR__)) . '/min/lib';
|
||||||
|
|
||||||
require "$pathToLib/Minify/Loader.php";
|
require "$pathToLib/Minify/Loader.php";
|
||||||
Minify_Loader::register();
|
|
||||||
|
|
||||||
$cli = new MrClay\Cli;
|
$cli = new MrClay\Cli;
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
$pathToLib = dirname(dirname(__DIR__)) . '/min/lib';
|
$pathToLib = dirname(dirname(__DIR__)) . '/min/lib';
|
||||||
|
|
||||||
require "$min_libPath/Minify/Loader.php";
|
require "$min_libPath/Minify/Loader.php";
|
||||||
Minify_Loader::register();
|
|
||||||
|
|
||||||
$cli = new MrClay\Cli;
|
$cli = new MrClay\Cli;
|
||||||
|
|
||||||
|
@@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
require dirname(__FILE__) . '/../min/config.php';
|
require dirname(__FILE__) . '/../min/config.php';
|
||||||
|
|
||||||
require "$min_libPath/Minify/Loader.php";
|
|
||||||
Minify_Loader::register();
|
|
||||||
|
|
||||||
$minifyCachePath = isset($min_cachePath)
|
$minifyCachePath = isset($min_cachePath)
|
||||||
? $min_cachePath
|
? $min_cachePath
|
||||||
: '';
|
: '';
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/../../min/lib/Minify/Loader.php';
|
||||||
|
|
||||||
function getPost($key) {
|
function getPost($key) {
|
||||||
return get_magic_quotes_gpc()
|
return get_magic_quotes_gpc()
|
||||||
? stripslashes($_POST[$key])
|
? stripslashes($_POST[$key])
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
* Fetch and minify a URL (auto-detect HTML/JS/CSS)
|
* Fetch and minify a URL (auto-detect HTML/JS/CSS)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/../../min/lib/Minify/Loader.php';
|
||||||
|
|
||||||
function getPost($key) {
|
function getPost($key) {
|
||||||
if (! isset($_POST[$key])) {
|
if (! isset($_POST[$key])) {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/../../min/lib/Minify/Loader.php';
|
||||||
|
|
||||||
header('Content-Type: text/html;charset=utf-8');
|
header('Content-Type: text/html;charset=utf-8');
|
||||||
|
|
||||||
function h($str) { return htmlspecialchars($str, ENT_QUOTES); }
|
function h($str) { return htmlspecialchars($str, ENT_QUOTES); }
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
|
require dirname(__FILE__) . '/../../min/lib/Minify/Loader.php';
|
||||||
require 'HTTP/ConditionalGet.php';
|
|
||||||
|
|
||||||
// emulate regularly updating document
|
// emulate regularly updating document
|
||||||
$every = 20;
|
$every = 20;
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
ini_set('display_errors', 'on');
|
ini_set('display_errors', 'on');
|
||||||
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../min/lib'));
|
require dirname(__FILE__) . '/../../min/lib/Minify/Loader.php';
|
||||||
require 'HTTP/Encoder.php';
|
|
||||||
|
|
||||||
if (!isset($_GET['test'])) {
|
if (!isset($_GET['test'])) {
|
||||||
$type = 'text/html';
|
$type = 'text/html';
|
||||||
@@ -56,5 +55,3 @@ $he = new HTTP_Encoder(array(
|
|||||||
));
|
));
|
||||||
$he->encode();
|
$he->encode();
|
||||||
$he->sendAll();
|
$he->sendAll();
|
||||||
|
|
||||||
?>
|
|
@@ -1,10 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require dirname(__FILE__) . '/../min/lib/Minify/Loader.php';
|
||||||
require dirname(__FILE__) . '/../min/config.php';
|
require dirname(__FILE__) . '/../min/config.php';
|
||||||
|
|
||||||
require "$min_libPath/Minify/Loader.php";
|
|
||||||
Minify_Loader::register();
|
|
||||||
|
|
||||||
// set cache path and doc root if configured
|
// set cache path and doc root if configured
|
||||||
$minifyCachePath = isset($min_cachePath)
|
$minifyCachePath = isset($min_cachePath)
|
||||||
? $min_cachePath
|
? $min_cachePath
|
||||||
|
Reference in New Issue
Block a user