1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-09 07:36:56 +02:00

Prepping 2.1.4 beta release. Issue 185, More helpful Builder messages.

This commit is contained in:
Steve Clay
2010-07-08 04:25:05 +00:00
parent 15de686195
commit 5e0a7b1bf9
12 changed files with 103 additions and 38 deletions

View File

@@ -1,5 +1,20 @@
Minify Release History Minify Release History
Version 2.1.4
* Cookie/bookmarklet-based debug mode. No HTML editing!
* Allows 1 file to be missing w/o complete failure
* Combine multiple groups and files in single URI
* More useful HTML helpers for writing versioned URIs
* More detailed error logging, including minifier exceptions
* Builder offers more helpful messages/PHP environment warnings
* Bypass minification based on filename pattern. e.g. foo.min.js / foo-min.css
* JSMin won't choke on common Closure compiler syntaxes (i+ ++j)
* Better caching in IE6
* Cache ids are influenced by group/file names
* Debug mode for Javascript doesn't break on common XPath strings (Prototype 1.6)
* Removed annoying maxFiles limit
* mbstring.func_overload usage is safer
Version 2.1.3 Version 2.1.3
* HTTP fixes * HTTP fixes
* ETag generation now valid (different when gzipped) * ETag generation now valid (different when gzipped)

View File

@@ -8,6 +8,14 @@ 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/
WORDPRESS USER?
These WP plugins integrate Minify into WordPress's style and script hooks to
get you set up faster.
http://wordpress.org/extend/plugins/wp-minify/
http://wordpress.org/extend/plugins/w3-total-cache/
UPGRADING UPGRADING
See UPGRADING.txt for instructions. See UPGRADING.txt for instructions.

View File

@@ -82,7 +82,7 @@ This pre-selects the following files to be combined under the key "js":
You can now serve these files with this simple URL: You can now serve these files with this simple URL:
http://example.com/min/?g=js http://example.com/min/?g=js
GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
@@ -99,6 +99,14 @@ return array(
); );
COMBINE MULTIPLE GROUPS AND FILES IN ONE URL
E.g.: http://example.com/min/?g=js&f=more/scripts.js
Separate group keys with commas:
http://example.com/min/?g=baseCss,css1&f=moreStyles.css
FAR-FUTURE EXPIRES HEADERS FAR-FUTURE EXPIRES HEADERS
Minify can send far-future (one year) Expires headers. To enable this you must Minify can send far-future (one year) Expires headers. To enable this you must
@@ -106,15 +114,20 @@ add a number to the querystring (e.g. /min/?g=js&1234 or /min/f=file.js&1234)
and alter it whenever a source file is changed. If you have a build process you and alter it whenever a source file is changed. If you have a build process you
can use a build/source control revision number. can use a build/source control revision number.
If you serve files as a group, you can use the utility function Minify_groupUri() You can alternately use the utility function Minify_getUri() to get a "versioned"
to get a "versioned" Minify URI for use in your HTML. E.g.: Minify URI for use in your HTML. E.g.:
<?php <?php
// add /min/lib to your include_path first!
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php'; require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
$jsUri = Minify_groupUri('js'); $jsUri = Minify_getUri('js'); // a key in groupsConfig.php
echo "<script type='text/javascript' src='{$jsUri}'></script>"; echo "<script src='{$jsUri}'></script>";
$cssUri = Minify_getUri(array(
'//css/styles1.css'
,'//css/styles2.css'
)); // a list of files
echo "<link rel=stylesheet href='{$cssUri}'>";
DEBUG MODE DEBUG MODE

View File

@@ -29,12 +29,34 @@ if (! $min_enableBuilder) {
exit(); exit();
} }
$setIncludeSuccess = set_include_path(dirname(__FILE__) . '/../lib' . PATH_SEPARATOR . get_include_path());
// we do it this way because we want the builder to work after the user corrects
// include_path. (set_include_path returning FALSE is OK).
try {
require_once 'Solar/Dir.php';
} catch (Exception $e) {
if (! $setIncludeSuccess) {
echo "Minify: set_include_path() failed. You may need to set your include_path "
."outside of PHP code, e.g., in php.ini.";
} else {
echo $e->getMessage();
}
exit();
}
require 'Minify.php';
$cachePathCode = '';
if (! isset($min_cachePath)) {
$detectedTmp = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR);
$cachePathCode = "\$min_cachePath = " . var_export($detectedTmp, 1) . ';';
}
ob_start(); ob_start();
?> ?>
<!DOCTYPE HTML> <!DOCTYPE HTML>
<title>Minify URI Builder</title> <title>Minify URI Builder</title>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<style type="text/css"> <style>
body {margin:1em 60px;} body {margin:1em 60px;}
h1, h2, h3 {margin-left:-25px; position:relative;} h1, h2, h3 {margin-left:-25px; position:relative;}
h1 {margin-top:0;} h1 {margin-top:0;}
@@ -54,7 +76,7 @@ b {color:#c00}
</style> </style>
<body> <body>
<?php if ($symlinkOption): ?> <?php if ($symlinkOption): ?>
<div class=topNote><strong>Note:</strong> It looks like you're running Minify in a user <div class=topNote><strong>Note:</strong> It looks like you're running Minify in a user
directory. You may need the following option in /min/config.php to have URIs directory. You may need the following option in /min/config.php to have URIs
correctly rewritten in CSS output: correctly rewritten in CSS output:
<br><textarea id=symlinkOpt rows=3 cols=80 readonly><?php echo htmlspecialchars($symlinkOption); ?></textarea> <br><textarea id=symlinkOpt rows=3 cols=80 readonly><?php echo htmlspecialchars($symlinkOption); ?></textarea>
@@ -62,15 +84,17 @@ b {color:#c00}
<?php endif; ?> <?php endif; ?>
<p class=topWarning id=jsDidntLoad><strong>Uh Oh.</strong> Minify was unable to <p class=topWarning id=jsDidntLoad><strong>Uh Oh.</strong> Minify was unable to
serve the Javascript for this app. To troubleshoot this, serve Javascript for this app. To troubleshoot this,
<a href="http://code.google.com/p/minify/wiki/Debugging">enable FirePHP debugging</a> <a href="http://code.google.com/p/minify/wiki/Debugging">enable FirePHP debugging</a>
and request the <a id=builderScriptSrc href=#>Minify URL</a> directly. Hopefully the and request the <a id=builderScriptSrc href=#>Minify URL</a> directly. Hopefully the
FirePHP console will report the cause of the error. FirePHP console will report the cause of the error.
</p> </p>
<?php if (! isset($min_cachePath)): ?> <?php if ($cachePathCode): ?>
<p class=topNote><strong>Note:</strong> You can set <code>$min_cachePath</code> <p class=topNote><strong>Note:</strong> <code><?php echo
in /min/config.php to slightly improve performance.</p> htmlspecialchars($detectedTmp); ?></code> was discovered as a usable temp directory.<br>To
slightly improve performance you can hardcode this in /min/config.php:
<code><?php echo htmlspecialchars($cachePathCode); ?></code></p>
<?php endIf; ?> <?php endIf; ?>
<p id=minRewriteFailed class="hide"><strong>Note:</strong> Your webserver does not seem to <p id=minRewriteFailed class="hide"><strong>Note:</strong> Your webserver does not seem to
@@ -138,8 +162,8 @@ by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code><
<h3>Debug Mode</h3> <h3>Debug Mode</h3>
<p>When /min/config.php has <code>$min_allowDebugFlag = <strong>true</strong>;</code> <p>When /min/config.php has <code>$min_allowDebugFlag = <strong>true</strong>;</code>
you can get debug output by appending <code>&amp;debug</code> to a Minify URL, or you can get debug output by appending <code>&amp;debug</code> to a Minify URL, or
by sending the cookie <code>minDebug=&lt;match&gt;</code>, where <code>minDebug=&lt;match&gt;</code> by sending the cookie <code>minDebug=&lt;match&gt;</code>, where <code>&lt;match&gt;</code>
should match the Minify URIs you'd like to debug. This bookmarklet will allow you to should be a string in the Minify URIs you'd like to debug. This bookmarklet will allow you to
set this cookie.</p> set this cookie.</p>
<p><a id=bm2>Minify Debug</a> <small>(right-click, add to bookmarks)</small></p> <p><a id=bm2>Minify Debug</a> <small>(right-click, add to bookmarks)</small></p>
@@ -149,13 +173,20 @@ by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code><
<p>Need help? Check the <a href="http://code.google.com/p/minify/w/list?can=3">wiki</a>, <p>Need help? Check the <a href="http://code.google.com/p/minify/w/list?can=3">wiki</a>,
or post to the <a class=ext href="http://groups.google.com/group/minify">discussion or post to the <a class=ext href="http://groups.google.com/group/minify">discussion
list</a>.</p> list</a>.</p>
<p><small>This app is minified :)</small></p> <p><small>Powered by Minify <?php echo Minify::VERSION; ?></small></p>
<script type="text/javascript" <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script>
<script type="text/javascript">
$(function () { $(function () {
// give Minify a few seconds to serve _index.js before showing scary red warning
$('#jsDidntLoad').hide();
setTimeout(function () {
if (! window.MUB) {
// Minify didn't load
$('#jsDidntLoad').show();
}
}, 3000);
// detection of double output encoding // detection of double output encoding
var msg = '<\p class=topWarning><\strong>Warning:<\/strong> '; var msg = '<\p class=topWarning><\strong>Warning:<\/strong> ';
var url = 'ocCheck.php?' + (new Date()).getTime(); var url = 'ocCheck.php?' + (new Date()).getTime();
@@ -183,7 +214,7 @@ $(function () {
}); });
}); });
</script> </script>
<script type="text/javascript"> <script>
// workaround required to test when /min isn't child of web root // workaround required to test when /min isn't child of web root
var src = location.pathname.replace(/\/[^\/]*$/, '/_index.js').substr(1); var src = location.pathname.replace(/\/[^\/]*$/, '/_index.js').substr(1);
src = "../?f=" + src; src = "../?f=" + src;
@@ -197,8 +228,6 @@ $(function () {
$content = ob_get_clean(); $content = ob_get_clean();
// setup Minify // setup Minify
set_include_path(dirname(__FILE__) . '/../lib' . PATH_SEPARATOR . get_include_path());
require 'Minify.php';
if (0 === stripos(PHP_OS, 'win')) { if (0 === stripos(PHP_OS, 'win')) {
Minify::setDocRoot(); // we may be on IIS Minify::setDocRoot(); // we may be on IIS
} }
@@ -212,9 +241,10 @@ Minify::serve('Page', array(
'content' => $content 'content' => $content
,'id' => __FILE__ ,'id' => __FILE__
,'lastModifiedTime' => max( ,'lastModifiedTime' => max(
// regenerate cache if either of these change // regenerate cache if any of these change
filemtime(__FILE__) filemtime(__FILE__)
,filemtime(dirname(__FILE__) . '/../config.php') ,filemtime(dirname(__FILE__) . '/../config.php')
,filemtime(dirname(__FILE__) . '/../lib/Minify.php')
) )
,'minifyAll' => true ,'minifyAll' => true
,'encodeOutput' => $encodeOutput ,'encodeOutput' => $encodeOutput

View File

@@ -62,7 +62,7 @@ $min_enableBuilder = true;
* 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 = substr(__FILE__, 0, strlen(__FILE__) - 15); //$min_documentRoot = substr(__FILE__, 0, -15);
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT']; //$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];

View File

@@ -30,8 +30,7 @@ class Minify_CommentPreserver {
* Process a string outside of C-style comments that begin with "/*!" * Process a string outside of C-style comments that begin with "/*!"
* *
* On each non-empty string outside these comments, the given processor * On each non-empty string outside these comments, the given processor
* function will be called. The first "!" will be removed from the * function will be called. The comments will be surrounded by
* preserved comments, and the comments will be surrounded by
* Minify_CommentPreserver::$preprend and Minify_CommentPreserver::$append. * Minify_CommentPreserver::$preprend and Minify_CommentPreserver::$append.
* *
* @param string $content * @param string $content
@@ -65,7 +64,7 @@ class Minify_CommentPreserver {
* @param string $in input * @param string $in input
* *
* @return array 3 elements are returned. If a YUI comment is found, the * @return array 3 elements are returned. If a YUI comment is found, the
* 2nd element is the comment and the 1st and 2nd are the surrounding * 2nd element is the comment and the 1st and 3rd are the surrounding
* strings. If no comment is found, the entire string is returned as the * strings. If no comment is found, the entire string is returned as the
* 1st element and the other two are false. * 1st element and the other two are false.
*/ */
@@ -79,7 +78,7 @@ class Minify_CommentPreserver {
} }
$ret = array( $ret = array(
substr($in, 0, $start) substr($in, 0, $start)
,self::$prepend . '/*' . substr($in, $start + 3, $end - $start - 1) . self::$append ,self::$prepend . '/*!' . substr($in, $start + 3, $end - $start - 1) . self::$append
); );
$endChars = (strlen($in) - $end - 2); $endChars = (strlen($in) - $end - 2);
$ret[] = (0 === $endChars) $ret[] = (0 === $endChars)

View File

@@ -52,7 +52,7 @@ abstract class Minify_Controller_Base {
,'quiet' => false // serve() will send headers and output ,'quiet' => false // serve() will send headers and output
,'debug' => false ,'debug' => false
// if you override this, the response code MUST be directly after // if you override these, the response codes MUST be directly after
// the first space. // the first space.
,'badRequestHeader' => 'HTTP/1.0 400 Bad Request' ,'badRequestHeader' => 'HTTP/1.0 400 Bad Request'
,'errorHeader' => 'HTTP/1.0 500 Internal Server Error' ,'errorHeader' => 'HTTP/1.0 500 Internal Server Error'
@@ -148,7 +148,7 @@ abstract class Minify_Controller_Base {
} }
throw new Exception("File '$file' is outside \$allowDirs. If the path is" throw new Exception("File '$file' is outside \$allowDirs. If the path is"
. " resolved via an alias/symlink, look into the \$min_symlinks option." . " resolved via an alias/symlink, look into the \$min_symlinks option."
. " E.g. \$min_symlinks = array('/" . dirname($uri) . "' => '" . dirname($file) . "');"); . " E.g. \$min_symlinks['/" . dirname($uri) . "'] = '" . dirname($file) . "';");
} }
public static function checkNotHidden($file) public static function checkNotHidden($file)

View File

@@ -1,3 +1,3 @@
/* YUI Compressor style comments are preserved */ /*! YUI Compressor style comments are preserved */
body{background:#fff url(/path/to/image.gif) repeat-y} body{background:#fff url(/path/to/image.gif) repeat-y}

View File

@@ -8,7 +8,7 @@ name="robots" content="all" /><title>css Zen Garden: The Beauty in CSS Design</t
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;} is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">/*<![CDATA[*/var i=0;while(++i<10) if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">/*<![CDATA[*/var i=0;while(++i<10)
{}/*]]>*/</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">/*<![CDATA[*/(i<1);/*]]>*/</script> <!--[if IE 6]><style type="text/css">/*<![CDATA[*/ {}/*]]>*/</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">/*<![CDATA[*/(i<1);/*]]>*/</script> <!--[if IE 6]><style type="text/css">/*<![CDATA[*/
/* copyright: you'll need CDATA for this < & */ /*! copyright: you'll need CDATA for this < & */
body{background:white}/*]]>*/</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css body{background:white}/*]]>*/</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
hack{}/**/ /*/*/css hack{}/**/ /*/*/css
hack{}/**/css hack{}/**/css

View File

@@ -8,7 +8,7 @@ name="robots" content="all"><title>css Zen Garden: The Beauty in CSS Design</tit
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;} is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">var i=0;while(++i<10) if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}</script> <script type="text/javascript">var i=0;while(++i<10)
{}</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">(i<1);</script> <!--[if IE 6]><style type="text/css"> {}</script> <script type="text/javascript">i=1;</script> <script type="text/javascript">(i<1);</script> <!--[if IE 6]><style type="text/css">
/* copyright: you'll need CDATA for this < & */ /*! copyright: you'll need CDATA for this < & */
body{background:white}</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css body{background:white}</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";/*\*/css
hack{}/**/ /*/*/css hack{}/**/ /*/*/css
hack{}/**/css hack{}/**/css

View File

@@ -1,5 +1,5 @@
@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px @import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
solid #0f7}div#content solid #0f7}div#content
h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}} h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}}
/* YUI Compressor style comments are preserved */ /*! YUI Compressor style comments are preserved */
body{background:#fff url(/path/to/image.gif) repeat-y} body{background:#fff url(/path/to/image.gif) repeat-y}

View File

@@ -9,10 +9,10 @@ function test_Minify_CommentPreserver()
global $thisDir; global $thisDir;
$inOut = array( $inOut = array(
'/*!*/' => "\n/**/\n" '/*!*/' => "\n/*!*/\n"
,'/*!*/a' => "\n/**/\n1A" ,'/*!*/a' => "\n/*!*/\n1A"
,'a/*!*//*!*/b' => "2A\n/**/\n\n/**/\n3B" ,'a/*!*//*!*/b' => "2A\n/*!*/\n\n/*!*/\n3B"
,'a/*!*/b/*!*/' => "4A\n/**/\n5B\n/**/\n" ,'a/*!*/b/*!*/' => "4A\n/*!*/\n5B\n/*!*/\n"
); );
foreach ($inOut as $in => $expected) { foreach ($inOut as $in => $expected) {