1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-13 17:44:00 +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:
Steve Clay
2008-09-05 04:22:57 +00:00
parent c873fbc9f0
commit 12dc98c50a
11 changed files with 82 additions and 71 deletions

View File

@@ -1,13 +1,14 @@
Minify Release History
Version 2.1.0 beta
* "min" default app for quick deployment
Version 2.1.0
* "min" default configuration for quick deployment
* builder app for creating minify URIs
* "debug" mode for revealing original line #s in combined files
* Relative URIs in CSS file are fixed automatically
* Conditional GETs always supported
* Improved CSS/HTML minifiers
* 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
Version 2.0.2 beta (2008-06-24)

45
README
View File

@@ -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
HTTP headers. These headers can allow clients to perform conditional
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/
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
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.
UNIT TESTING:
You configure Minify via a Minify_Controller object. The controller
supplies the sources and default options to serve a request,
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.
1. Place the /min_extras/ directory as a child of your DOCUMENT_ROOT
directory: i.e. you will have: /home/user/www/public_html/min_extras
To use an existing controller, you call Minify::serve(), passing it:
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.:
2. To run unit tests, access: http://yourdomain/min_extras/unit_tests/test_all.php
// serve a minified javascript file and tell clients to cache it for a
// year
Minify::serve('Files', array(
'files' => array('/path/to/file1.js', '/path/to/file2.js')
,'setExpires' => (time() + 86400 * 365)
));
Other test_*.php files in that directory can be run to test individual
components more verbosely.
The above creates an instance of Minify_Controller_Files, which creates
source objects from the 'files' option, and supplies other default options.
FILE ENCODINGS
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
all sources to prevent duplication in output files.
encodings like ISO 8859/Windows-1252. By default Minify appends
";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.

View File

@@ -111,4 +111,3 @@ return array(
QUESTIONS?
http://groups.google.com/group/minify
steve@mrclay.org

View File

@@ -2,6 +2,11 @@
require dirname(__FILE__) . '/../config.php';
if (! $min_enableBuilder) {
header('Location: /');
exit();
}
ob_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

View File

@@ -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.
* Otherwise Minify will have to load extra code to guess.
@@ -20,6 +13,13 @@ $min_forwardToBuilder = true;
//$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,
* 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.
*/
//$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
* minification, and comments will be added to indicate the line #s
* of the original files. This will allow you to debug the combined
* file while knowing where to modify the originals.
* In 'debug' mode, Minify can combine files with no minification and
* add comments to indicate line #s of the original files.
*
* 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
* incorrect mtimes for the files. 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.
* incorrect mtimes for the files. This may cause Minify to keep serving stale
* cache files when source file changes are made too frequently (e.g. more than
* once an hour).
*
* 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;

View File

@@ -31,6 +31,10 @@ if (0 === stripos(PHP_OS, 'win')) {
Minify::setDocRoot(); // we may be on IIS
}
if ($min_allowDebugFlag && isset($_GET['debug'])) {
$min_serveOptions['debug'] = true;
}
Minify::$uploaderHoursBehind = $min_uploaderHoursBehind;
if (isset($_GET['g'])) {
@@ -41,6 +45,7 @@ if (isset($_GET['g'])) {
$_SERVER['PATH_INFO'] = '/' . $_GET['g'];
$min_serveOptions['groups'] = (require MINIFY_MIN_DIR . '/groupsConfig.php');
if (preg_match('/&\\d/', $_SERVER['QUERY_STRING'])) {
// URI is versioned, send far off Expire
$min_serveOptions['maxAge'] = 31536000;
}
Minify::serve('Groups', $min_serveOptions);
@@ -74,14 +79,14 @@ if (isset($_GET['g'])) {
Minify::serve('Version1', $min_serveOptions);
} elseif ($min_forwardToBuilder) {
} elseif ($min_enableBuilder) {
header('Location: builder/');
exit();
} else {
header("HTTP/1.0 404 Not Found");
header("Location: /");
exit();
}

View File

@@ -48,7 +48,7 @@ class HTTP_Encoder {
* but there seem to be remaining, intermittent encoding bugs in patched
* IE6 on the wild web.
*
* @var int
* @var bool
*/
public static $encodeToIe6 = false;

View File

@@ -48,18 +48,6 @@ class Minify {
*/
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
* 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.
*
@@ -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
*/

View File

@@ -19,6 +19,17 @@
**/
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)
{
$this->_mc = $memcache;
@@ -97,7 +108,7 @@ class Minify_Cache_Memcache {
private $_mc = null;
private $_exp = null;
// PHP memory cache of most recently fetched id
// cache of most recently fetched id
private $_lm = null;
private $_data = null;
private $_id = null;

View File

@@ -12,6 +12,8 @@
* files; i.e. @imports commented out or in string content will still be
* processed!
*
* This has a unit test but should be considered "experimental".
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/

View File

@@ -3,11 +3,13 @@
* Class Minify_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/
*
* 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
*/