mirror of
https://github.com/mrclay/minify.git
synced 2025-08-14 01:54:11 +02:00
Prep for 2.1
min/builder/ : enableBuilder option, better debug behavior HTTP/Encoder.php : phpdoc fix Minify.php : removed setServerCache() Cache/Memcache.php : better docs README : simplified
This commit is contained in:
7
HISTORY
7
HISTORY
@@ -1,13 +1,14 @@
|
|||||||
Minify Release History
|
Minify Release History
|
||||||
|
|
||||||
Version 2.1.0 beta
|
Version 2.1.0
|
||||||
* "min" default app for quick deployment
|
* "min" default configuration for quick deployment
|
||||||
|
* builder app for creating minify URIs
|
||||||
* "debug" mode for revealing original line #s in combined files
|
* "debug" mode for revealing original line #s in combined files
|
||||||
* Relative URIs in CSS file are fixed automatically
|
* Relative URIs in CSS file are fixed automatically
|
||||||
* Conditional GETs always supported
|
* Conditional GETs always supported
|
||||||
* Improved CSS/HTML minifiers
|
* Improved CSS/HTML minifiers
|
||||||
* New "CSS linearizer" which processes @imports server-side
|
* New "CSS linearizer" which processes @imports server-side
|
||||||
* New memcache storage class (default is files)
|
* Experimental memcache cache class (default is files)
|
||||||
* Several bug fixes
|
* Several bug fixes
|
||||||
|
|
||||||
Version 2.0.2 beta (2008-06-24)
|
Version 2.0.2 beta (2008-06-24)
|
||||||
|
45
README
45
README
@@ -4,43 +4,34 @@ Minify is an HTTP content server. It compresses sources of content
|
|||||||
(usually files), combines the result and serves it with appropriate
|
(usually files), combines the result and serves it with appropriate
|
||||||
HTTP headers. These headers can allow clients to perform conditional
|
HTTP headers. These headers can allow clients to perform conditional
|
||||||
GETs (serving content only when clients do not have a valid cache)
|
GETs (serving content only when clients do not have a valid cache)
|
||||||
or tell clients to cache the file until a given date/time.
|
and tell clients to cache the file for a period of time.
|
||||||
More info: http://code.google.com/p/minify/
|
More info: http://code.google.com/p/minify/
|
||||||
|
|
||||||
INSTALLATION AND USAGE: http://code.google.com/p/minify/wiki/UserGuide
|
INSTALLATION AND USAGE:
|
||||||
|
|
||||||
UNIT TESTING & EXAMPLES: http://code.google.com/p/minify/wiki/TestingMinify
|
1. Place the /min/ directory as a child of your DOCUMENT_ROOT
|
||||||
|
directory: i.e. you will have: /home/user/www/public_html/min
|
||||||
|
|
||||||
MINIFY OVERVIEW
|
2. Open http://yourdomain/min/ in a web browser. This will forward
|
||||||
|
you to the Minify URI Builder application, which will help you
|
||||||
|
quickly start using Minify to serve content on your site.
|
||||||
|
|
||||||
Minify works with Minify_Source objects. These usually represent a file
|
UNIT TESTING:
|
||||||
on disk, but a source can also be a string in memory or from a database.
|
|
||||||
Sources with known "last modified" timestamps allow Minify to implement
|
|
||||||
server-side caching and conditional GETs.
|
|
||||||
|
|
||||||
You configure Minify via a Minify_Controller object. The controller
|
1. Place the /min_extras/ directory as a child of your DOCUMENT_ROOT
|
||||||
supplies the sources and default options to serve a request,
|
directory: i.e. you will have: /home/user/www/public_html/min_extras
|
||||||
determining how it's to be responded to. Several controllers are
|
|
||||||
supplied with Minify, but it's also fairly easy to write your own. See
|
|
||||||
the files in /lib/Minify/Controller for examples.
|
|
||||||
|
|
||||||
To use an existing controller, you call Minify::serve(), passing it:
|
2. To run unit tests, access: http://yourdomain/min_extras/unit_tests/test_all.php
|
||||||
1. the name of your controller of choice (without the "Minify_Controller"
|
|
||||||
prefix) or a custom controller object subclassed from Minify_Controller_Base.
|
|
||||||
2. a combined array of controller and Minify options. Eg.:
|
|
||||||
|
|
||||||
// serve a minified javascript file and tell clients to cache it for a
|
Other test_*.php files in that directory can be run to test individual
|
||||||
// year
|
components more verbosely.
|
||||||
Minify::serve('Files', array(
|
|
||||||
'files' => array('/path/to/file1.js', '/path/to/file2.js')
|
|
||||||
,'setExpires' => (time() + 86400 * 365)
|
|
||||||
));
|
|
||||||
|
|
||||||
The above creates an instance of Minify_Controller_Files, which creates
|
|
||||||
source objects from the 'files' option, and supplies other default options.
|
|
||||||
|
|
||||||
FILE ENCODINGS
|
FILE ENCODINGS
|
||||||
|
|
||||||
Minify *should* work fine with files encoded in UTF-8 or other 8-bit
|
Minify *should* work fine with files encoded in UTF-8 or other 8-bit
|
||||||
encodings like ISO 8859/Windows-1252. Leading UTF-8 BOMs are stripped from
|
encodings like ISO 8859/Windows-1252. By default Minify appends
|
||||||
all sources to prevent duplication in output files.
|
";charset=utf-8" to the Content-Type headers it sends.
|
||||||
|
|
||||||
|
Leading UTF-8 BOMs are stripped from all sources to prevent
|
||||||
|
duplication in output files, and files are converted to Unix newlines.
|
||||||
|
@@ -111,4 +111,3 @@ return array(
|
|||||||
QUESTIONS?
|
QUESTIONS?
|
||||||
|
|
||||||
http://groups.google.com/group/minify
|
http://groups.google.com/group/minify
|
||||||
steve@mrclay.org
|
|
||||||
|
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
require dirname(__FILE__) . '/../config.php';
|
require dirname(__FILE__) . '/../config.php';
|
||||||
|
|
||||||
|
if (! $min_enableBuilder) {
|
||||||
|
header('Location: /');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||||
|
@@ -5,13 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Forward empty requests to URI Builder app. After initial setup this
|
|
||||||
* should be set to false.
|
|
||||||
**/
|
|
||||||
$min_forwardToBuilder = true;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For best performance, specify your temp directory here.
|
* For best performance, specify your temp directory here.
|
||||||
* Otherwise Minify will have to load extra code to guess.
|
* Otherwise Minify will have to load extra code to guess.
|
||||||
@@ -20,6 +13,13 @@ $min_forwardToBuilder = true;
|
|||||||
//$min_cachePath = '/tmp';
|
//$min_cachePath = '/tmp';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow use of the Minify URI Builder app. If you no longer need
|
||||||
|
* this, set to false.
|
||||||
|
**/
|
||||||
|
$min_enableBuilder = true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum age of browser cache in seconds. After this period,
|
* Maximum age of browser cache in seconds. After this period,
|
||||||
* the browser will send another conditional GET. You might
|
* the browser will send another conditional GET. You might
|
||||||
@@ -43,7 +43,7 @@ $min_serveOptions['maxAge'] = 1800;
|
|||||||
/**
|
/**
|
||||||
* If you move Minify's lib folder, give the path to it here.
|
* If you move Minify's lib folder, give the path to it here.
|
||||||
*/
|
*/
|
||||||
//$min_libPath = 'lib';
|
//$min_libPath = dirname(__FILE__) . '/lib';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,20 +54,24 @@ $min_groupsOnly = false;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uncomment to enable debug mode. Files will be combined with no
|
* In 'debug' mode, Minify can combine files with no minification and
|
||||||
* minification, and comments will be added to indicate the line #s
|
* add comments to indicate line #s of the original files.
|
||||||
* of the original files. This will allow you to debug the combined
|
*
|
||||||
* file while knowing where to modify the originals.
|
* To allow debugging, set this option to true and add "&debug=1" to
|
||||||
|
* a URI. E.g. /min/?f=script1.js,script2.js&debug=1
|
||||||
*/
|
*/
|
||||||
//$min_serveOptions['debug'] = true;
|
$min_allowDebugFlag = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If you upload files from Windows to a non-Windows server, Windows may report
|
* If you upload files from Windows to a non-Windows server, Windows may report
|
||||||
* incorrect mtimes for the files. Immediately after modifying and uploading a
|
* incorrect mtimes for the files. This may cause Minify to keep serving stale
|
||||||
* file, use the touch command to update the mtime on the server. If the mtime
|
* cache files when source file changes are made too frequently (e.g. more than
|
||||||
* jumps ahead by a number of hours, set this variable to that number. If the mtime
|
* once an hour).
|
||||||
* moves back, this should not be needed.
|
*
|
||||||
|
* Immediately after modifying and uploading a file, use the touch command to
|
||||||
|
* update the mtime on the server. If the mtime jumps ahead by a number of hours,
|
||||||
|
* set this variable to that number. If the mtime moves back, this should not be needed.
|
||||||
*/
|
*/
|
||||||
$min_uploaderHoursBehind = 0;
|
$min_uploaderHoursBehind = 0;
|
||||||
|
|
||||||
|
@@ -31,6 +31,10 @@ if (0 === stripos(PHP_OS, 'win')) {
|
|||||||
Minify::setDocRoot(); // we may be on IIS
|
Minify::setDocRoot(); // we may be on IIS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($min_allowDebugFlag && isset($_GET['debug'])) {
|
||||||
|
$min_serveOptions['debug'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
|
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
|
||||||
|
|
||||||
if (isset($_GET['g'])) {
|
if (isset($_GET['g'])) {
|
||||||
@@ -41,6 +45,7 @@ if (isset($_GET['g'])) {
|
|||||||
$_SERVER['PATH_INFO'] = '/' . $_GET['g'];
|
$_SERVER['PATH_INFO'] = '/' . $_GET['g'];
|
||||||
$min_serveOptions['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
|
$min_serveOptions['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
|
||||||
if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
|
if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
|
||||||
|
// URI is versioned, send far off Expire
|
||||||
$min_serveOptions['maxAge'] = 31536000;
|
$min_serveOptions['maxAge'] = 31536000;
|
||||||
}
|
}
|
||||||
Minify::serve('Groups', $min_serveOptions);
|
Minify::serve('Groups', $min_serveOptions);
|
||||||
@@ -74,14 +79,14 @@ if (isset($_GET['g'])) {
|
|||||||
|
|
||||||
Minify::serve('Version1', $min_serveOptions);
|
Minify::serve('Version1', $min_serveOptions);
|
||||||
|
|
||||||
} elseif ($min_forwardToBuilder) {
|
} elseif ($min_enableBuilder) {
|
||||||
|
|
||||||
header('Location: builder/');
|
header('Location: builder/');
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
header("HTTP/1.0 404 Not Found");
|
header("Location: /");
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ class HTTP_Encoder {
|
|||||||
* but there seem to be remaining, intermittent encoding bugs in patched
|
* but there seem to be remaining, intermittent encoding bugs in patched
|
||||||
* IE6 on the wild web.
|
* IE6 on the wild web.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public static $encodeToIe6 = false;
|
public static $encodeToIe6 = false;
|
||||||
|
|
||||||
|
@@ -48,18 +48,6 @@ class Minify {
|
|||||||
*/
|
*/
|
||||||
public static $uploaderHoursBehind = 0;
|
public static $uploaderHoursBehind = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see setCache()
|
|
||||||
* @param mixed $cache object with identical interface as Minify_Cache_File or
|
|
||||||
* a directory path. (default = '')
|
|
||||||
* @return null
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public static function useServerCache($path = '')
|
|
||||||
{
|
|
||||||
self::setCache($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a cache object (with identical interface as Minify_Cache_File) or
|
* Specify a cache object (with identical interface as Minify_Cache_File) or
|
||||||
* a path to use with Minify_Cache_File.
|
* a path to use with Minify_Cache_File.
|
||||||
@@ -82,8 +70,6 @@ class Minify {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static $_cache = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serve a request for a minified file.
|
* Serve a request for a minified file.
|
||||||
*
|
*
|
||||||
@@ -370,6 +356,11 @@ class Minify {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var mixed Minify_Cache_* object or null (i.e. no server cache is used)
|
||||||
|
*/
|
||||||
|
private static $_cache = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Minify_Controller active controller for current request
|
* @var Minify_Controller active controller for current request
|
||||||
*/
|
*/
|
||||||
|
@@ -19,6 +19,17 @@
|
|||||||
**/
|
**/
|
||||||
class Minify_Cache_Memcache {
|
class Minify_Cache_Memcache {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Minify_Cache_Memcache object, to be passed to
|
||||||
|
* Minify::setCache().
|
||||||
|
*
|
||||||
|
* @param Memcache $memcache already-connected instance
|
||||||
|
*
|
||||||
|
* @param int $expire seconds until expiration (default = 0
|
||||||
|
* meaning the item will not get an expiration date)
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
public function __construct($memcache, $expire = 0)
|
public function __construct($memcache, $expire = 0)
|
||||||
{
|
{
|
||||||
$this->_mc = $memcache;
|
$this->_mc = $memcache;
|
||||||
@@ -97,7 +108,7 @@ class Minify_Cache_Memcache {
|
|||||||
private $_mc = null;
|
private $_mc = null;
|
||||||
private $_exp = null;
|
private $_exp = null;
|
||||||
|
|
||||||
// PHP memory cache of most recently fetched id
|
// cache of most recently fetched id
|
||||||
private $_lm = null;
|
private $_lm = null;
|
||||||
private $_data = null;
|
private $_data = null;
|
||||||
private $_id = null;
|
private $_id = null;
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
* files; i.e. @imports commented out or in string content will still be
|
* files; i.e. @imports commented out or in string content will still be
|
||||||
* processed!
|
* processed!
|
||||||
*
|
*
|
||||||
|
* This has a unit test but should be considered "experimental".
|
||||||
|
*
|
||||||
* @package Minify
|
* @package Minify
|
||||||
* @author Stephen Clay <steve@mrclay.org>
|
* @author Stephen Clay <steve@mrclay.org>
|
||||||
*/
|
*/
|
||||||
|
@@ -3,11 +3,13 @@
|
|||||||
* Class Minify_Packer
|
* Class Minify_Packer
|
||||||
*
|
*
|
||||||
* To use this class you must first download the PHP port of Packer
|
* To use this class you must first download the PHP port of Packer
|
||||||
* and place the file "class.JavaScriptPacker.php" in /lib.
|
* and place the file "class.JavaScriptPacker.php" in /lib (or your
|
||||||
|
* include_path).
|
||||||
* @link http://joliclic.free.fr/php/javascript-packer/en/
|
* @link http://joliclic.free.fr/php/javascript-packer/en/
|
||||||
*
|
*
|
||||||
* Be aware that, as long as HTTP encoding is used, scripts minified
|
* Be aware that, as long as HTTP encoding is used, scripts minified
|
||||||
* with JSMin will provide better client-side performance.
|
* with Minify_Javascript (JSMin) will provide better client-side
|
||||||
|
* performance, as they need not be unpacked in client-side code.
|
||||||
*
|
*
|
||||||
* @package Minify
|
* @package Minify
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user