Remove Google References

This removes most references to Google, with some
remaining since they may point to things which are still
relevant. References to Google Code, Google Buzz and
Google Maps have been removed
This commit is contained in:
Bob Mottram
2016-03-20 13:06:58 +00:00
parent b2cfbded2e
commit 11c57e7aee
259 changed files with 864 additions and 6577 deletions

View File

@@ -1,11 +1,10 @@
WELCOME TO MINIFY 2.1!
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)
and tell clients to cache the file for a period of time.
More info: http://code.google.com/p/minify/
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)
and tell clients to cache the file for a period of time.
UPGRADING
@@ -15,7 +14,7 @@ See UPGRADING.txt for instructions.
INSTALLATION AND USAGE:
1. Place the /min/ directory as a child of your DOCUMENT_ROOT
1. Place the /min/ directory as a child of your DOCUMENT_ROOT
directory: i.e. you will have: /home/user/www/public_html/min
2. Open http://yourdomain/min/ in a web browser. This will forward
@@ -25,7 +24,7 @@ quickly start using Minify to serve content on your site.
UNIT TESTING:
1. Place the /min_unit_tests/ directory as a child of your DOCUMENT_ROOT
1. Place the /min_unit_tests/ directory as a child of your DOCUMENT_ROOT
directory: i.e. you will have: /home/user/www/public_html/min_unit_tests
2. To run unit tests, access: http://yourdomain/min_unit_tests/test_all.php
@@ -44,10 +43,9 @@ and a couple single-use tools. DO NOT place this on your production server.
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. By default Minify appends
";charset=utf-8" to the Content-Type headers it sends.
";charset=utf-8" to the Content-Type headers it sends.
Leading UTF-8 BOMs are stripped from all sources to prevent
Leading UTF-8 BOMs are stripped from all sources to prevent
duplication in output files, and files are converted to Unix newlines.

View File

@@ -4,7 +4,7 @@ UPGRADING FROM 2.1.*
1. Rename the following files:
/min/config.php --> /min/old_config.php
/min/config.php --> /min/old_config.php
/min/groupsConfig.php --> /min/old_groupsConfig.php
2. Overwrite all files in /min (and /min_unit_tests) with those from this zip.
@@ -21,15 +21,13 @@ UPGRADING FROM 2.1.*
* $min_errorLogger adds the ability to enable FirePHP logging.
6. (optional) Delete /min/old_config.php and the Minify files from your cache
6. (optional) Delete /min/old_config.php and the Minify files from your cache
directory (specified in $min_cachePath).
INSTALLING FRESH
See README.txt for instructions on installing this app for the first time.
SUPPORT
Send a message to http://groups.google.com/group/minify

View File

@@ -23,7 +23,7 @@ Let's say you want to serve this file:
Here's the "Minify URL" for this file:
http://example.com/min/?f=wp-content/themes/default/default.css
In other words, the "f" argument is set to the file path from root without the
In other words, the "f" argument is set to the file path from root without the
initial "/". As CSS files may contain relative URIs, Minify will automatically
"fix" these by rewriting them as root relative.
@@ -59,8 +59,8 @@ In (X)HTML files, don't forget to replace any "&" characters with "&".
SPECIFYING ALLOWED DIRECTORIES
By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
you'd prefer to limit Minify's access to certain directories, set the
$min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
you'd prefer to limit Minify's access to certain directories, set the
$min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
to the /js and /themes/default directories, use:
$min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
@@ -68,27 +68,27 @@ $min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
GROUPS: FASTER PERFORMANCE AND BETTER URLS
For the best performance, edit groupsConfig.php to pre-specify groups of files
to be combined under preset keys. E.g., here's an example configuration in
For the best performance, edit groupsConfig.php to pre-specify groups of files
to be combined under preset keys. E.g., here's an example configuration in
groupsConfig.php:
return array(
'js' => array('//js/Class.js', '//js/email.js')
return array(
'js' => array('//js/Class.js', '//js/email.js')
);
This pre-selects the following files to be combined under the key "js":
http://example.com/js/Class.js
http://example.com/js/email.js
You can now serve these files with this simple URL:
http://example.com/min/?g=js
GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
In the groupsConfig.php array, the "//" in the file paths is a shortcut for
the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
or relative to the DOC_ROOT:
or relative to the DOC_ROOT:
return array(
'js' => array(
@@ -102,8 +102,8 @@ return array(
FAR-FUTURE EXPIRES HEADERS
Minify can send far-future (one year) Expires headers. To enable this you must
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
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
can use a build/source control revision number.
If you serve files as a group, you can use the utility function Minify_groupUri()
@@ -113,7 +113,7 @@ to get a "versioned" Minify URI for use in your HTML. E.g.:
// add /min/lib to your include_path first!
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
$jsUri = Minify_groupUri('js');
$jsUri = Minify_groupUri('js');
echo "<script type='text/javascript' src='{$jsUri}'></script>";
@@ -128,5 +128,3 @@ Known issue: files with comment-like strings/regexps can cause problems in this
QUESTIONS?
http://groups.google.com/group/minify

View File

@@ -1,4 +1,4 @@
<?php
<?php
if (phpversion() < 5) {
exit('Minify requires PHP5 or greater.');
@@ -41,12 +41,12 @@ b {color:#c00}
</head>
<?php if (! isset($min_cachePath)): ?>
<p class=topNote><strong>Note:</strong> Please set <code>$min_cachePath</code>
<p class=topNote><strong>Note:</strong> Please set <code>$min_cachePath</code>
in /min/config.php to improve performance.</p>
<?php endIf; ?>
<p id=minRewriteFailed class="hide"><strong>Note:</strong> Your webserver does not seem to
support mod_rewrite (used in /min/.htaccess). Your Minify URIs will contain "?", which
support mod_rewrite (used in /min/.htaccess). Your Minify URIs will contain "?", which
<a href="http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/"
>may reduce the benefit of proxy cache servers</a>.</p>
@@ -100,9 +100,9 @@ available URIs to add.</p>
</div>
<h3>Combining CSS files that contain <code>@import</code></h3>
<p>If your CSS files contain <code>@import</code> declarations, Minify will not
<p>If your CSS files contain <code>@import</code> declarations, Minify will not
remove them. Therefore, you will want to remove those that point to files already
in your list, and move any others to the top of the first file in your list
in your list, and move any others to the top of the first file in your list
(imports below any styles will be ignored by browsers as invalid).</p>
<p>If you desire, you can use Minify URIs in imports and they will not be touched
by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code></p>
@@ -110,13 +110,8 @@ by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code><
</div><!-- #app -->
<hr>
<p>Need help? Search or post to the <a class=ext
href="http://groups.google.com/group/minify">Minify discussion list</a>.</p>
<p><small>This app is minified :) <a class=ext
href="http://code.google.com/p/minify/source/browse/trunk/min/builder/index.php">view
source</a></small></p>
<script type="text/javascript"
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
@@ -127,11 +122,11 @@ $(function () {
$.get(url, function (ocStatus) {
$.get(url + '&hello=1', function (ocHello) {
if (ocHello != 'World!') {
msg += 'It appears output is being automatically compressed, interfering '
msg += 'It appears output is being automatically compressed, interfering '
+ ' with Minify\'s own compression. ';
if (ocStatus == '1')
msg += 'The option "zlib.output_compression" is enabled in your PHP configuration. '
+ 'Minify set this to "0", but it had no effect. This option must be disabled '
+ 'Minify set this to "0", but it had no effect. This option must be disabled '
+ 'in php.ini or .htaccess.';
else
msg += 'The option "zlib.output_compression" is disabled in your PHP configuration '

View File

@@ -6,7 +6,7 @@
* modifications to preserve some comments (see below). Also, rather than using
* stdin/stdout, JSMin::minify() accepts a string as input and returns another
* string as output.
*
*
* Comments containing IE conditional compilation are preserved, as are multi-line
* comments that begin with "/*!" (for documentation purposes). In the latter case
* newlines are inserted around the comment to enhance readability.
@@ -47,7 +47,6 @@
* @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
* @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
* @license http://opensource.org/licenses/mit-license.php MIT License
* @link http://code.google.com/p/jsmin-php/
*/
class JSMin {
@@ -56,7 +55,7 @@ class JSMin {
const ACTION_KEEP_A = 1;
const ACTION_DELETE_A = 2;
const ACTION_DELETE_A_B = 3;
protected $a = "\n";
protected $b = '';
protected $input = '';
@@ -64,7 +63,7 @@ class JSMin {
protected $inputLength = 0;
protected $lookAhead = null;
protected $output = '';
/**
* Minify Javascript
*
@@ -76,7 +75,7 @@ class JSMin {
$jsmin = new JSMin($js);
return $jsmin->min();
}
/**
* Setup process
*/
@@ -85,7 +84,7 @@ class JSMin {
$this->input = str_replace("\r\n", "\n", $input);
$this->inputLength = strlen($this->input);
}
/**
* Perform minification, return result
*/
@@ -95,7 +94,7 @@ class JSMin {
return $this->output;
}
$this->action(self::ACTION_DELETE_A_B);
while ($this->a !== null) {
// determine next command
$command = self::ACTION_KEEP_A; // default
@@ -106,13 +105,13 @@ class JSMin {
} elseif ($this->a === "\n") {
if ($this->b === ' ') {
$command = self::ACTION_DELETE_A_B;
} elseif (false === strpos('{[(+-', $this->b)
} elseif (false === strpos('{[(+-', $this->b)
&& ! $this->isAlphaNum($this->b)) {
$command = self::ACTION_DELETE_A;
}
} elseif (! $this->isAlphaNum($this->a)) {
if ($this->b === ' '
|| ($this->b === "\n"
|| ($this->b === "\n"
&& (false === strpos('}])+-"\'', $this->a)))) {
$command = self::ACTION_DELETE_A_B;
}
@@ -122,7 +121,7 @@ class JSMin {
$this->output = trim($this->output);
return $this->output;
}
/**
* ACTION_KEEP_A = Output A. Copy B to A. Get the next B.
* ACTION_DELETE_A = Copy B to A. Get the next B.
@@ -182,7 +181,7 @@ class JSMin {
// end case ACTION_DELETE_A_B
}
}
protected function isRegexpLiteral()
{
if (false !== strpos("\n{;(,=:[!&|?", $this->a)) { // we aren't dividing
@@ -207,7 +206,7 @@ class JSMin {
}
return false;
}
/**
* Get next char. Convert ctrl char to space.
*/
@@ -231,7 +230,7 @@ class JSMin {
}
return $c;
}
/**
* Get next char. If is ctrl character, translate to a space or newline.
*/
@@ -240,7 +239,7 @@ class JSMin {
$this->lookAhead = $this->get();
return $this->lookAhead;
}
/**
* Is $c a letter, digit, underscore, dollar sign, escape, or non-ASCII?
*/
@@ -248,7 +247,7 @@ class JSMin {
{
return (preg_match('/^[0-9a-zA-Z_\\$\\\\]$/', $c) || ord($c) > 126);
}
protected function singleLineComment()
{
$comment = '';
@@ -264,7 +263,7 @@ class JSMin {
}
}
}
protected function multipleLineComment()
{
$this->get();
@@ -290,7 +289,7 @@ class JSMin {
$comment .= $get;
}
}
/**
* Get the next character, skipping over comments.
* Some comments may be preserved.

View File

@@ -1,6 +1,6 @@
<?php
/**
* Class Minify
* Class Minify
* @package Minify
*/
@@ -8,7 +8,7 @@
* Minify_Source
*/
require_once 'Minify/Source.php';
/**
* Minify - Combines, minifies, and caches JavaScript and CSS files on demand.
*
@@ -25,30 +25,29 @@ require_once 'Minify/Source.php';
* @author Stephen Clay <steve@mrclay.org>
* @copyright 2008 Ryan Grove, Stephen Clay. All rights reserved.
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @link http://code.google.com/p/minify/
*/
class Minify {
const VERSION = '2.1.3';
const TYPE_CSS = 'text/css';
const TYPE_HTML = 'text/html';
// there is some debate over the ideal JS Content-Type, but this is the
// Apache default and what Yahoo! uses..
const TYPE_JS = 'application/x-javascript';
/**
* How many hours behind are the file modification times of uploaded files?
*
*
* 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
* 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.
*
* @var int $uploaderHoursBehind
*/
public static $uploaderHoursBehind = 0;
/**
* If this string is not empty AND the serve() option 'bubbleCssImports' is
* NOT set, then serve() will check CSS files for @import declarations that
@@ -57,18 +56,18 @@ class Minify {
*
* @var string $importWarning
*/
public static $importWarning = "/* See http://code.google.com/p/minify/wiki/CommonProblems#@imports_can_appear_in_invalid_locations_in_combined_CSS_files */\n";
public static $importWarning = "";
/**
* Specify a cache object (with identical interface as Minify_Cache_File) or
* a path to use with Minify_Cache_File.
*
* If not called, Minify will not use a cache and, for each 200 response, will
*
* If not called, Minify will not use a cache and, for each 200 response, will
* need to recombine files, minify and encode the output.
*
* @param mixed $cache object with identical interface as Minify_Cache_File or
* a directory path, or null to disable caching. (default = '')
*
*
* @param bool $fileLocking (default = true) This only applies if the first
* parameter is a string.
*
@@ -83,76 +82,76 @@ class Minify {
self::$_cache = $cache;
}
}
/**
* Serve a request for a minified file.
*
* Serve a request for a minified file.
*
* Here are the available options and defaults in the base controller:
*
* 'isPublic' : send "public" instead of "private" in Cache-Control
*
* 'isPublic' : send "public" instead of "private" in Cache-Control
* headers, allowing shared caches to cache the output. (default true)
*
*
* 'quiet' : set to true to have serve() return an array rather than sending
* any headers/output (default false)
*
*
* 'encodeOutput' : set to false to disable content encoding, and not send
* the Vary header (default true)
*
* 'encodeMethod' : generally you should let this be determined by
*
* 'encodeMethod' : generally you should let this be determined by
* HTTP_Encoder (leave null), but you can force a particular encoding
* to be returned, by setting this to 'gzip' or '' (no encoding)
*
*
* 'encodeLevel' : level of encoding compression (0 to 9, default 9)
*
*
* 'contentTypeCharset' : appended to the Content-Type header sent. Set to a falsey
* value to remove. (default 'utf-8')
*
* value to remove. (default 'utf-8')
*
* 'maxAge' : set this to the number of seconds the client should use its cache
* before revalidating with the server. This sets Cache-Control: max-age and the
* Expires header. Unlike the old 'setExpires' setting, this setting will NOT
* prevent conditional GETs. Note this has nothing to do with server-side caching.
*
*
* 'rewriteCssUris' : If true, serve() will automatically set the 'currentDir'
* minifier option to enable URI rewriting in CSS files (default true)
*
*
* 'bubbleCssImports' : If true, all @import declarations in combined CSS
* files will be move to the top. Note this may alter effective CSS values
* due to a change in order. (default false)
*
*
* 'debug' : set to true to minify all sources with the 'Lines' controller, which
* eases the debugging of combined files. This also prevents 304 responses.
* @see Minify_Lines::minify()
*
* 'minifiers' : to override Minify's default choice of minifier function for
* a particular content-type, specify your callback under the key of the
*
* 'minifiers' : to override Minify's default choice of minifier function for
* a particular content-type, specify your callback under the key of the
* content-type:
* <code>
* // call customCssMinifier($css) for all CSS minification
* $options['minifiers'][Minify::TYPE_CSS] = 'customCssMinifier';
*
*
* // don't minify Javascript at all
* $options['minifiers'][Minify::TYPE_JS] = '';
* </code>
*
*
* 'minifierOptions' : to send options to the minifier function, specify your options
* under the key of the content-type. E.g. To send the CSS minifier an option:
* under the key of the content-type. E.g. To send the CSS minifier an option:
* <code>
* // give CSS minifier array('optionName' => 'optionValue') as 2nd argument
* // give CSS minifier array('optionName' => 'optionValue') as 2nd argument
* $options['minifierOptions'][Minify::TYPE_CSS]['optionName'] = 'optionValue';
* </code>
*
* 'contentType' : (optional) this is only needed if your file extension is not
*
* 'contentType' : (optional) this is only needed if your file extension is not
* js/css/html. The given content-type will be sent regardless of source file
* extension, so this should not be used in a Groups config with other
* Javascript/CSS files.
*
*
* Any controller options are documented in that controller's setupSources() method.
*
*
* @param mixed instance of subclass of Minify_Controller_Base or string name of
* controller. E.g. 'Files'
*
*
* @param array $options controller/serve options
*
*
* @return mixed null, or, if the 'quiet' option is set to true, an array
* with keys "success" (bool), "statusCode" (int), "content" (string), and
* "headers" (array).
@@ -163,18 +162,18 @@ class Minify {
// make $controller into object
$class = 'Minify_Controller_' . $controller;
if (! class_exists($class, false)) {
require_once "Minify/Controller/"
. str_replace('_', '/', $controller) . ".php";
require_once "Minify/Controller/"
. str_replace('_', '/', $controller) . ".php";
}
$controller = new $class();
}
// set up controller sources and mix remaining options with
// controller defaults
$options = $controller->setupSources($options);
$options = $controller->analyzeSources($options);
self::$_options = $controller->mixInDefaultOptions($options);
// check request validity
if (! $controller->sources) {
// invalid request!
@@ -192,14 +191,14 @@ class Minify {
);
}
}
self::$_controller = $controller;
if (self::$_options['debug']) {
self::_setupDebug($controller->sources);
self::$_options['maxAge'] = 0;
}
// determine encoding
if (self::$_options['encodeOutput']) {
if (self::$_options['encodeMethod'] !== null) {
@@ -208,7 +207,7 @@ class Minify {
} else {
// sniff request header
require_once 'HTTP/Encoder.php';
// depending on what the client accepts, $contentEncoding may be
// depending on what the client accepts, $contentEncoding may be
// 'x-gzip' while our internal encodeMethod is 'gzip'. Calling
// getAcceptedEncoding(false, false) leaves out compress and deflate as options.
list(self::$_options['encodeMethod'], $contentEncoding) = HTTP_Encoder::getAcceptedEncoding(false, false);
@@ -216,7 +215,7 @@ class Minify {
} else {
self::$_options['encodeMethod'] = ''; // identity (no encoding)
}
// check client cache
require_once 'HTTP/ConditionalGet.php';
$cgOptions = array(
@@ -246,12 +245,12 @@ class Minify {
$headers = $cg->getHeaders();
unset($cg);
}
if (self::$_options['contentType'] === self::TYPE_CSS
&& self::$_options['rewriteCssUris']) {
reset($controller->sources);
while (list($key, $source) = each($controller->sources)) {
if ($source->filepath
if ($source->filepath
&& !isset($source->minifyOptions['currentDir'])
&& !isset($source->minifyOptions['prependRelativePath'])
) {
@@ -259,11 +258,11 @@ class Minify {
}
}
}
// check server cache
if (null !== self::$_cache) {
// using cache
// the goal is to use only the cache methods to sniff the length and
// the goal is to use only the cache methods to sniff the length and
// output the content, as they do not require ever loading the file into
// memory.
$cacheId = 'minify_' . self::_getCacheId();
@@ -271,9 +270,9 @@ class Minify {
? $cacheId . '.gz'
: $cacheId;
// check cache for valid entry
$cacheIsReady = self::$_cache->isValid($fullCacheId, self::$_options['lastModifiedTime']);
$cacheIsReady = self::$_cache->isValid($fullCacheId, self::$_options['lastModifiedTime']);
if ($cacheIsReady) {
$cacheContentLength = self::$_cache->getSize($fullCacheId);
$cacheContentLength = self::$_cache->getSize($fullCacheId);
} else {
// generate & cache content
$content = self::_combineMinify();
@@ -291,7 +290,7 @@ class Minify {
// still need to encode
$content = gzencode($content, self::$_options['encodeLevel']);
}
// add headers
$headers['Content-Length'] = $cacheIsReady
? $cacheContentLength
@@ -327,17 +326,17 @@ class Minify {
);
}
}
/**
* Return combined minified content for a set of sources
*
* No internal caching will be used and the content will not be HTTP encoded.
*
*
* @param array $sources array of filepaths and/or Minify_Source objects
*
*
* @param array $options (optional) array of options for serve. By default
* these are already set: quiet = true, encodeMethod = '', lastModifiedTime = 0.
*
*
* @return string
*/
public static function combine($sources, $options = array())
@@ -354,13 +353,13 @@ class Minify {
self::$_cache = $cache;
return $out['content'];
}
/**
* On IIS, create $_SERVER['DOCUMENT_ROOT']
*
*
* @param bool $unsetPathInfo (default false) if true, $_SERVER['PATH_INFO']
* will be unset (it is inconsistent with Apache's setting)
*
*
* @return null
*/
public static function setDocRoot($unsetPathInfo = false)
@@ -380,22 +379,22 @@ class Minify {
Minify_Logger::log("setDocRoot() set DOCUMENT_ROOT to \"{$_SERVER['DOCUMENT_ROOT']}\"");
}
}
/**
* @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
*/
protected static $_controller = null;
/**
* @var array options for current request
*/
protected static $_options = null;
/**
* Set up sources to use Minify_Lines
*
@@ -413,7 +412,7 @@ class Minify {
);
}
}
/**
* Combines sources and minifies the result.
*
@@ -422,7 +421,7 @@ class Minify {
protected static function _combineMinify()
{
$type = self::$_options['contentType']; // ease readability
// when combining scripts, make sure all statements separated and
// trailing single line comment is terminated
$implodeSeparator = ($type === self::TYPE_JS)
@@ -439,7 +438,7 @@ class Minify {
$defaultMinifier = isset(self::$_options['minifiers'][$type])
? self::$_options['minifiers'][$type]
: false;
if (Minify_Source::haveNoMinifyPrefs(self::$_controller->sources)) {
// all source have same options/minifier, better performance
// to combine, then minify once
@@ -449,7 +448,7 @@ class Minify {
$content = implode($implodeSeparator, $pieces);
if ($defaultMinifier) {
self::$_controller->loadMinifier($defaultMinifier);
$content = call_user_func($defaultMinifier, $content, $defaultOptions);
$content = call_user_func($defaultMinifier, $content, $defaultOptions);
}
} else {
// minify each source with its own options and minifier, then combine
@@ -464,18 +463,18 @@ class Minify {
if ($minifier) {
self::$_controller->loadMinifier($minifier);
// get source content and minify it
$pieces[] = call_user_func($minifier, $source->getContent(), $options);
$pieces[] = call_user_func($minifier, $source->getContent(), $options);
} else {
$pieces[] = $source->getContent();
$pieces[] = $source->getContent();
}
}
$content = implode($implodeSeparator, $pieces);
}
if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) {
$content = self::_handleCssImports($content);
}
// do any post-processing (esp. for editing build URIs)
if (self::$_options['postprocessorRequire']) {
require_once self::$_options['postprocessorRequire'];
@@ -485,11 +484,11 @@ class Minify {
}
return $content;
}
/**
* Make a unique cache id for for this request.
*
* Any settings that could affect output are taken into consideration
*
* Any settings that could affect output are taken into consideration
*
* @return string
*/
@@ -497,13 +496,13 @@ class Minify {
{
return md5(serialize(array(
Minify_Source::getDigest(self::$_controller->sources)
,self::$_options['minifiers']
,self::$_options['minifiers']
,self::$_options['minifierOptions']
,self::$_options['postprocessor']
,self::$_options['bubbleCssImports']
)));
}
/**
* Bubble CSS @imports to the top or prepend a warning if an
* @import is detected not at the top.

View File

@@ -12,7 +12,6 @@
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
*/
class Minify_CSS {
@@ -36,10 +35,10 @@ class Minify_CSS {
* the desired files. For this to work, the files *must* exist and be
* visible by the PHP process.
*
* 'symlinks': (default = array()) If the CSS file is stored in
* 'symlinks': (default = array()) If the CSS file is stored in
* a symlink-ed directory, provide an array of link paths to
* target paths, where the link paths are within the document root. Because
* paths need to be normalized for this to work, use "//" to substitute
* target paths, where the link paths are within the document root. Because
* paths need to be normalized for this to work, use "//" to substitute
* the doc root in the link paths (the array keys). E.g.:
* <code>
* array('//symlink' => '/real/target/path') // unix

View File

@@ -1,6 +1,6 @@
<?php
/**
* Class Minify_CSS_Compressor
* Class Minify_CSS_Compressor
* @package Minify
*/
@@ -9,24 +9,23 @@
*
* This is a heavy regex-based removal of whitespace, unnecessary
* comments and tokens, and some CSS value minimization, where practical.
* Many steps have been taken to avoid breaking comment-based hacks,
* Many steps have been taken to avoid breaking comment-based hacks,
* including the ie5/mac filter (and its inversion), but expect tricky
* hacks involving comment tokens in 'content' value strings to break
* minimization badly. A test suite is available.
*
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
* @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
*/
class Minify_CSS_Compressor {
/**
* Minify a CSS string
*
*
* @param string $css
*
*
* @param array $options (currently ignored)
*
*
* @return string
*/
public static function process($css, $options = array())
@@ -34,51 +33,51 @@ class Minify_CSS_Compressor {
$obj = new Minify_CSS_Compressor($options);
return $obj->_process($css);
}
/**
* @var array options
*/
protected $_options = null;
/**
* @var bool Are we "in" a hack?
*
*
* I.e. are some browsers targetted until the next comment?
*/
protected $_inHack = false;
/**
* Constructor
*
*
* @param array $options (currently ignored)
*
*
* @return null
*/
private function __construct($options) {
$this->_options = $options;
}
/**
* Minify a CSS string
*
*
* @param string $css
*
*
* @return string
*/
protected function _process($css)
{
$css = str_replace("\r\n", "\n", $css);
// preserve empty comment after '>'
// http://www.webdevout.net/css-hacks#in_css-selectors
$css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);
// preserve empty comment between property and value
// http://css-discuss.incutio.com/?page=BoxModelHack
$css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);
$css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);
// apply callback to all valid comments (and strip out surrounding ws
$css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@'
,array($this, '_commentCB'), $css);
@@ -86,10 +85,10 @@ class Minify_CSS_Compressor {
// remove ws around { } and last semicolon in declaration block
$css = preg_replace('/\\s*{\\s*/', '{', $css);
$css = preg_replace('/;?\\s*}\\s*/', '}', $css);
// remove ws surrounding semicolons
$css = preg_replace('/\\s*;\\s*/', ';', $css);
// remove ws around urls
$css = preg_replace('/
url\\( # url(
@@ -98,11 +97,11 @@ class Minify_CSS_Compressor {
\\s*
\\) # )
/x', 'url($1)', $css);
// remove ws between rules and colons
$css = preg_replace('/
\\s*
([{;]) # 1 = beginning of block or rule separator
([{;]) # 1 = beginning of block or rule separator
\\s*
([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter)
\\s*
@@ -110,7 +109,7 @@ class Minify_CSS_Compressor {
\\s*
(\\b|[#\'"]) # 3 = first character of a value
/x', '$1$2:$3', $css);
// remove ws in selectors
$css = preg_replace_callback('/
(?: # non-capture
@@ -124,41 +123,41 @@ class Minify_CSS_Compressor {
{ # open declaration block
/x'
,array($this, '_selectorsCB'), $css);
// minimize hex colors
$css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i'
, '$1#$2$3$4$5', $css);
// remove spaces between font families
$css = preg_replace_callback('/font-family:([^;}]+)([;}])/'
,array($this, '_fontFamilyCB'), $css);
$css = preg_replace('/@import\\s+url/', '@import url', $css);
// replace any ws involving newlines with a single newline
$css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);
// separate common descendent selectors w/ newlines (to limit line lengths)
$css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);
// Use newline after 1st numeric value (to limit line lengths).
$css = preg_replace('/
((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value
\\s+
/x'
,"$1\n", $css);
// prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/
$css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);
return trim($css);
}
/**
* Replace what looks like a set of selectors
* Replace what looks like a set of selectors
*
* @param array $m regex matches
*
*
* @return string
*/
protected function _selectorsCB($m)
@@ -166,19 +165,19 @@ class Minify_CSS_Compressor {
// remove ws around the combinators
return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]);
}
/**
* Process a comment and return a replacement
*
*
* @param array $m regex matches
*
*
* @return string
*/
protected function _commentCB($m)
{
$hasSurroundingWs = (trim($m[0]) !== $m[1]);
$m = $m[1];
// $m is the comment content w/o the surrounding tokens,
$m = $m[1];
// $m is the comment content w/o the surrounding tokens,
// but the return value will replace the entire comment.
if ($m === 'keep') {
return '/**/';
@@ -220,19 +219,19 @@ class Minify_CSS_Compressor {
$this->_inHack = false;
return '/**/';
}
// Issue 107: if there's any surrounding whitespace, it may be important, so
// Issue 107: if there's any surrounding whitespace, it may be important, so
// replace the comment with a single space
return $hasSurroundingWs // remove all other comments
? ' '
: '';
}
/**
* Process a font-family listing and return a replacement
*
*
* @param array $m regex matches
*
* @return string
*
* @return string
*/
protected function _fontFamilyCB($m)
{

View File

@@ -1,6 +1,6 @@
<?php
/**
* Class Minify_Controller_Page
* Class Minify_Controller_Page
* @package Minify
*/
@@ -8,30 +8,29 @@ require_once 'Minify/Controller/Base.php';
/**
* Controller class for serving a single HTML page
*
* @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/
class Minify_Controller_Page extends Minify_Controller_Base {
/**
* Set up source of HTML content
*
*
* @param array $options controller and Minify options
* @return array Minify options
*
*
* Controller options:
*
*
* 'content': (required) HTML markup
*
*
* 'id': (required) id of page (string for use in server-side caching)
*
*
* 'lastModifiedTime': timestamp of when this content changed. This
* is recommended to allow both server and client-side caching.
*
* 'minifyAll': should all CSS and Javascript blocks be individually
* minified? (default false)
*
* 'minifyAll': should all CSS and Javascript blocks be individually
* minified? (default false)
*
* @todo Add 'file' option to read HTML file.
*/
@@ -58,13 +57,13 @@ class Minify_Controller_Page extends Minify_Controller_Base {
unset($options['minifyAll']);
}
$this->sources[] = new Minify_Source($sourceSpec);
$options['contentType'] = Minify::TYPE_HTML;
return $options;
}
protected $_loadCssJsMinifiers = false;
/**
* @see Minify_Controller_Base::loadMinifier()
*/
@@ -79,4 +78,3 @@ class Minify_Controller_Page extends Minify_Controller_Base {
parent::loadMinifier($minifierCallback); // load Minify/HTML.php
}
}

View File

@@ -4,27 +4,26 @@
*
* To use this class you must first download the PHP port of Packer
* and place the file "class.JavaScriptPacker.php" in /lib (or your
* include_path).
* 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, as they need not be unpacked in
* client-side code.
*
* @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'
'The script "class.JavaScriptPacker.php" is required.'
,E_USER_ERROR
);
}
/**
* Minify Javascript using Dean Edward's Packer
*
*
* @package Minify
*/
class Minify_Packer {