1
0
mirror of https://github.com/mrclay/minify.git synced 2025-09-15 00:12:14 +02:00

16 Commits
3.0.0 ... 3.0.1

Author SHA1 Message Date
Elan Ruusamäe
6a5b09a00e Merge branch 'travis' 2017-06-08 22:33:53 +03:00
Elan Ruusamäe
93a1edd34b closure: use 20161024 version
this is version the example .min files were created
2017-06-08 22:29:56 +03:00
Elan Ruusamäe
a6531d3481 closure: use specific version
using latest may break our tests as minified result may differ
2017-06-08 22:02:16 +03:00
Elan Ruusamäe
9de63f3acc 3.0.1 release notes 2017-06-08 20:41:20 +03:00
Steve Clay
ed239fbb8b Update CSSmin to v4 2017-06-08 20:38:43 +03:00
Elan Ruusamäe
332f4bc839 cleanup 3.x branch leftover 2017-06-08 20:38:11 +03:00
Steve Clay
79e5a22321 Merge branch '3.x' 2017-05-23 16:24:09 -04:00
Elan Ruusamäe
80c01c6f02 php-cs-fixer fix 2017-04-18 18:24:17 +03:00
Elan Ruusamäe
b6e4b7f152 update cssmin import. resolves #590
refs a1489b2
2017-04-18 18:23:03 +03:00
Elan Ruusamäe
a1489b2d8a bump "tubalmartin/cssmin": "^3.1", fixes #590
https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/issues/39
2017-04-18 18:18:15 +03:00
Steve Clay
d041f763c9 even more relative links 2017-04-03 17:55:56 -04:00
Steve Clay
8056a4a9fb more relative docs links 2017-04-03 17:49:11 -04:00
Steve Clay
e3555570ef relative docs links 2017-04-03 17:47:37 -04:00
Steve Clay
a8304c5fb3 Update README.md 2017-04-03 17:43:17 -04:00
Steve Clay
dfb97a5c85 Checkout branch during install 2017-04-03 17:40:58 -04:00
Steve Clay
4626f6c1e0 HISTORY cleanup 2017-04-03 17:23:31 -04:00
21 changed files with 73 additions and 44 deletions

View File

@@ -8,6 +8,9 @@ php:
- 5.4
- hhvm
env:
- CLOSURE_VERSION: 20161024
matrix:
allow_failures:
- php: hhvm
@@ -25,10 +28,7 @@ install:
- composer update --no-interaction --prefer-source
before_script:
- wget -c https://dl.google.com/closure-compiler/compiler-latest.zip -O vendor/compiler-latest.zip
- unzip -od vendor/closure-compiler vendor/compiler-latest.zip
- ln -sfn ../$(echo vendor/closure-compiler/closure-compiler-*.jar) tests/compiler.jar
- java -jar tests/compiler.jar --version
- tests/dl-closure.sh
script:
- composer validate

View File

@@ -1,18 +1,24 @@
## Version 3.0.0 (unreleased)
* The project root is now what is deployed as `min`
## Version 3.0.1 (2017-06-09)
* Update CSSmin to v4, #599, #590
## Version 3.0.0 (2017-04-03)
* Improved CSS minification via Túbal Martín's CSSMin
* Easier error identification (just see error_log)
* Adds feature to serve static files directly
* Installation requires use of Composer to install dependencies
* Removes JSMin+ (unmaintained, high memory usage)
* Removes DooDigestAuth
* Removes Minify_Loader (uses Composer)
* Removes Minify_Logger (uses Monolog)
* Removes `$min_libPath` option
* The Minify, source, and controller components have changed APIs
* Better CSS minification via Túbal Martín's CSSMin
* Add config option for simply concatenating files
* Add config option for altering creation of Minify/MinApp objects
* Adds config option for simply concatenating files
* Adds config option for altering creation of Minify/MinApp objects
* Missing spec no longer redirects, instead links to docs
* Installation requires use of Composer to install dependencies
* Minify::VERSION is an int that tracks the major version number
* BREAKING: The project root is now what gets deployed as `min`
* BREAKING: Removes JSMin
* BREAKING: Removes JSMin+ (unmaintained, high memory usage)
* BREAKING: Removes DooDigestAuth
* BREAKING: Removes Minify_Loader (uses Composer)
* BREAKING: Removes Minify_Logger (uses Monolog)
* BREAKING: Removes `$min_libPath` option
* BREAKING: The Minify, source, and controller components have changed APIs
## Version 2.3.0 (2016-03-11)
* Adds `$min_concatOnly` option to just concatenate files
@@ -157,4 +163,4 @@
* Replaced old JSMin library with a much faster custom implementation.
## Version 1.0.0 (2007-05-02)
* First release.
* First release.

View File

@@ -21,20 +21,20 @@ Post to the [Google Group](http://groups.google.com/group/minify).
## Installation
See the [install guide](https://github.com/mrclay/minify/blob/master/docs/Install.wiki.md).
See the [install guide](docs/Install.wiki.md).
## Configuration & Usage
(Using 2.x? [Here are the 2.x docs](https://github.com/mrclay/minify/tree/2.x/docs).)
See the [user guide](https://github.com/mrclay/minify/blob/master/docs/UserGuide.wiki.md).
See the [user guide](docs/UserGuide.wiki.md).
Minify also comes with a [URI Builder application](https://github.com/mrclay/minify/blob/master/docs/BuilderApp.wiki.md) that can help you write URLs
Minify also comes with a [URI Builder application](docs/BuilderApp.wiki.md) that can help you write URLs
for use with Minify or configure groups of files.
See the [cookbook](https://github.com/mrclay/minify/blob/master/docs/CookBook.wiki.md) for more advanced options for minification.
See the [cookbook](docs/CookBook.wiki.md) for more advanced options for minification.
More [docs are available](https://github.com/mrclay/minify/tree/master/docs).
More [docs are available](docs).
## Unit Testing
@@ -43,7 +43,7 @@ More [docs are available](https://github.com/mrclay/minify/tree/master/docs).
## Warnings
* Minify is designed for efficiency, but, for very high traffic sites, it will probably serve files slower than your HTTPd due to the CGI overhead of PHP. See the [FAQ](https://github.com/mrclay/minify/blob/master/docs/FAQ.wiki.md#how-fast-is-it) and [CookBook](https://github.com/mrclay/minify/blob/master/docs/CookBook.wiki.md) for more info.
* Minify is designed for efficiency, but, for very high traffic sites, it will probably serve files slower than your HTTPd due to the CGI overhead of PHP. See the [FAQ](docs/FAQ.wiki.md#how-fast-is-it) and [CookBook](docs/CookBook.wiki.md) for more info.
* If you combine a lot of CSS, watch out for [IE's 4096 selectors-per-file limit](http://stackoverflow.com/a/9906889/3779), affects IE 6 through 9.
* 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.

View File

@@ -29,7 +29,7 @@
"mrclay/jsmin-php": "~2",
"mrclay/props-dic": "^2.2",
"php": "^5.3.0 || ^7.0",
"tubalmartin/cssmin": "~2.4.8-p5"
"tubalmartin/cssmin": "~4"
},
"require-dev": {
"firephp/firephp-core": "~0.4.0",

View File

@@ -26,7 +26,7 @@ Short answer: **use Minify 2.1.4+, use a pre-compressed version of your file, an
If the error is in your code, enable [debug mode](Debugging.wiki.md) while debugging your code in Firebug or your favorite browser's Javascript debugger. This will insert comments to allow you to keep track of the individual source locations in the combined file.
If you have Java on your web host, you can use the [wrapper for YUI Compressor](https://github.com/mrclay/minify/blob/master/lib/Minify/YUICompressor.php) instead of JSMin. [This thread](http://groups.google.com/group/minify/browse_thread/thread/f12f25f27e1256fe) shows how a user has done this.
If you have Java on your web host, you can use the [wrapper for YUI Compressor](../lib/Minify/YUICompressor.php) instead of JSMin. [This thread](http://groups.google.com/group/minify/browse_thread/thread/f12f25f27e1256fe) shows how a user has done this.
## Javascript isn't being minified
@@ -48,7 +48,7 @@ Scriptaculous 1.8.2 (and probably all 1.x) has an [autoloader script](http://git
If you upload files using [Coda or Transmit](http://groups.google.com/group/coda-users/browse_thread/thread/572d2dc315ec02e7/) or from a Windows PC to a non-Windows server, your new files may end up with the wrong `mtime` (timestamp) on the server, confusing the cache system.
Setting the [$min\_uploaderHoursBehind option](https://github.com/mrclay/minify/blob/master/config.php#L171) in `config.php` can compensate for this.
Setting the [$min\_uploaderHoursBehind option](../config.php#L171) in `config.php` can compensate for this.
WinSCP has a [Daylight Saving Time option](http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time) that can prevent this issue.

View File

@@ -39,7 +39,7 @@ $min_cachePath = new Minify_Cache_WinCache();
## Closure Compiler API Wrapper
An [experimental wrapper for Google's closure compiler API](https://github.com/mrclay/minify/blob/master/min/lib/Minify/JS/ClosureCompiler.php) is available for compressing Javascript. If the API fails for any reason, JSMin is used as the default backup minifier.
An [experimental wrapper for Google's closure compiler API](../lib/Minify/JS/ClosureCompiler.php) is available for compressing Javascript. If the API fails for any reason, JSMin is used as the default backup minifier.
```php
$min_serveOptions['minifiers'][Minify::TYPE_JS] = array('Minify_JS_ClosureCompiler', 'minify');
```

View File

@@ -47,7 +47,7 @@ $controller = new Minify_Controller_Files($env, $sourceFactory);
## Set up service and controller options
A single array is used for configuring both the behavior of `Minify::serve` (see the [default options](https://github.com/mrclay/minify/blob/master/lib/Minify.php#L73)) and the controller, which has its own option keys.
A single array is used for configuring both the behavior of `Minify::serve` (see the [default options](../lib/Minify.php#L73)) and the controller, which has its own option keys.
The Files controller only needs one key: `files`: the array of sources to be combined and served.

View File

@@ -4,7 +4,7 @@ The simple JSMin algorithm is the most reliable in PHP, but check the [CookBook]
## How fast is it?
If you [serve static files](https://github.com/mrclay/minify/blob/master/static/README.md), it's as fast as your web server, and you should do this for high-traffic sites.
If you [serve static files](../static/README.md), it's as fast as your web server, and you should do this for high-traffic sites.
The PHP-based server is not as fast, but still performs well thanks to an internal cache. Tips:

View File

@@ -36,12 +36,12 @@ cp ${MINIFY}quick-test.css ${MIN}
Edit `min/index.php` to remove the ``die()`` statement and adjust the `vendor` path as needed.
**Note:** This does not install the [URL builder](https://github.com/mrclay/minify/blob/master/docs/BuilderApp.wiki.md), but it's not necessary for operation.
**Note:** This does not install the [URL builder](BuilderApp.wiki.md), but it's not necessary for operation.
## Verifing it works
You can verify it works via these two URLs:
* http://example.org/min/?f=min/quick-test.js
* http://example.org/min/?f=min/quick-test.css
@@ -56,6 +56,6 @@ Write the [Google Group](http://groups.google.com/group/minify) for help.
## More links
* [Usage instructions](https://github.com/mrclay/minify/blob/master/docs/UserGuide.wiki.md)
* [Cookbook](https://github.com/mrclay/minify/blob/master/docs/CookBook.wiki.md) for more advanced options
* [All docs](https://github.com/mrclay/minify/tree/master/docs)
* [Usage instructions](UserGuide.wiki.md)
* [Cookbook](CookBook.wiki.md) for more advanced options
* [All docs](docs)

View File

@@ -79,8 +79,6 @@ Browse to http://example.com/min/builder/
The Minify URI Builder will help you create URIs you can use to minify existing files on your site. You can see screenshots and get a feel for this process from this [walkthrough on mrclay.org](http://mrclay.org/index.php/2008/09/19/minify-21-on-mrclayorg/)
More info here: https://github.com/mrclay/minify/blob/master/MIN.txt
You may want to disable the [BuilderApp](BuilderApp.wiki.md) when not in use.
# Far-future Expires headers
@@ -110,9 +108,9 @@ Known issue: files with comment-like strings/regexps can cause problems in this
# Configuration
See [config.php](https://github.com/mrclay/minify/blob/master/config.php) for general config options.
See [config.php](../config.php) for general config options.
[groupsConfig.php](https://github.com/mrclay/minify/blob/master/groupsConfig.php) holds preset groups of files to minify. (The builder application can help with this).
[groupsConfig.php](../groupsConfig.php) holds preset groups of files to minify. (The builder application can help with this).
[CookBook](CookBook.wiki.md) shows how to customize settings between production/development environments, and between groups.

View File

@@ -517,7 +517,6 @@ class Minify
if ($file
&& !isset($minifyOptions['currentDir'])
&& !isset($minifyOptions['prependRelativePath'])) {
$minifyOptions['currentDir'] = dirname($file);
$source->setMinifierOptions($minifyOptions);
}

View File

@@ -89,6 +89,7 @@ class Minify_CSS
$currentDir = $options['currentDir'];
$docRoot = $options['docRoot'];
$symlinks = $options['symlinks'];
return Minify_CSS_UriRewriter::rewrite($css, $currentDir, $docRoot, $symlinks);
} else {
return Minify_CSS_UriRewriter::prepend($css, $options['prependRelativePath']);

View File

@@ -217,6 +217,7 @@ class Minify_CSS_Compressor
if (preg_match($pattern, $m, $n)) {
// end hack mode after this comment, but preserve the hack and comment content
$this->_inHack = false;
return "/*/{$n[1]}/**/";
}
}
@@ -224,18 +225,21 @@ class Minify_CSS_Compressor
if (substr($m, -1) === '\\') { // comment ends like \*/
// begin hack mode and preserve hack
$this->_inHack = true;
return '/*\\*/';
}
if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */
// begin hack mode and preserve hack
$this->_inHack = true;
return '/*/*/';
}
if ($this->_inHack) {
// a regular comment ends hack mode but should be preserved
$this->_inHack = false;
return '/**/';
}

View File

@@ -52,7 +52,6 @@ class Minify_CSS_UriRewriter
// normalize symlinks in order to map to link
foreach ($symlinks as $link => $target) {
$link = ($link === '//') ? self::$_docRoot : str_replace('//', self::$_docRoot . '/', $link);
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
@@ -272,6 +271,7 @@ class Minify_CSS_UriRewriter
\\s*
\\) # )
/x';
return preg_replace($pattern, 'url($1)', $css);
}
@@ -337,6 +337,7 @@ class Minify_CSS_UriRewriter
private static function _owlifySvgPaths($css)
{
$pattern = '~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)url(\(\s*#\w+\s*\))~';
return preg_replace($pattern, '$1owl$2', $css);
}
@@ -351,6 +352,7 @@ class Minify_CSS_UriRewriter
private static function _unOwlify($css)
{
$pattern = '~\b((?:clip-path|mask|-webkit-mask)\s*\:\s*)owl~';
return preg_replace($pattern, '$1url', $css);
}
}

View File

@@ -4,6 +4,8 @@
* @package Minify
*/
use tubalmartin\CssMin\Minifier as CSSmin;
/**
* Wrapper for CSSmin
*

View File

@@ -62,7 +62,7 @@ class Minify_Cache_APC implements Minify_CacheInterface
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);;
return strlen($this->_data);
}
}
@@ -124,6 +124,7 @@ class Minify_Cache_APC implements Minify_CacheInterface
$ret = apc_fetch($id);
if (false === $ret) {
$this->_id = null;
return false;
}

View File

@@ -109,6 +109,7 @@ class Minify_Cache_File implements Minify_CacheInterface
{
if (!$this->locking) {
readfile($this->path . '/' . $id);
return;
}

View File

@@ -208,7 +208,6 @@ class Minify_Source implements Minify_SourceInterface
if ($this->filepath
&& !isset($this->minifyOptions['currentDir'])
&& !isset($this->minifyOptions['prependRelativePath'])) {
$this->minifyOptions['currentDir'] = dirname($this->filepath);
}
}

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;}
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[*//*! 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 hack{display:none;display:none}</style><link
body{background:#fff}/*]]>*/</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";css hack{display:none;display:none}</style><link
rel="Shortcut Icon"
type="image/x-icon"
href="http://www.csszengarden.com/favicon.ico" /><link

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;}
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">/*! 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 hack{display:none;display:none}</style><link
body{background:#fff}</style><![endif]--><style type="text/css" title="currentStyle" media="screen">@import "/001/001.css";css hack{display:none;display:none}</style><link
rel="Shortcut Icon"
type="image/x-icon"
href="http://www.csszengarden.com/favicon.ico"><link

16
tests/dl-closure.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
set -xe
: ${CLOSURE_VERSION:=20161024}
wget -c https://dl.google.com/closure-compiler/compiler-$CLOSURE_VERSION.zip -O vendor/compiler-$CLOSURE_VERSION.zip
unzip -od vendor/closure-compiler vendor/compiler-$CLOSURE_VERSION.zip
ln -sfn ../vendor/closure-compiler/closure-compiler-v$CLOSURE_VERSION.jar tests/compiler.jar
# test that version matches
out=$(java -jar tests/compiler.jar --version)
version=$(echo "$out" | awk '/Version:/{print $NF}')
version=${version#v}
test "$version" = "$CLOSURE_VERSION"