Skip to content
Permalink
Browse files

Collapse "min" into project root and get unit tests working.

Fixes #472
  • Loading branch information...
mrclay committed Sep 28, 2015
1 parent 2720239 commit e596b35fc400611d160183697284401178f1a013
Showing with 133 additions and 94 deletions.
  1. +0 −1 .gitignore
  2. 0 {min → }/.htaccess
  3. +1 −1 MIN.txt
  4. +27 −18 README.md
  5. 0 {min → }/builder/.htaccess
  6. 0 {min → }/builder/_index.js
  7. 0 {min → }/builder/bm.js
  8. 0 {min → }/builder/bm2.js
  9. +5 −5 {min → }/builder/index.php
  10. 0 {min → }/builder/jquery-1.6.3.min.js
  11. +2 −2 {min → }/builder/ocCheck.php
  12. 0 {min → }/builder/rewriteTest.js
  13. +1 −1 {min → }/builder/test.php
  14. +1 −1 composer.json
  15. +1 −1 composer.lock
  16. 0 {min → }/config-test.php
  17. +2 −2 {min → }/config.php
  18. 0 {min → }/groupsConfig.php
  19. +4 −6 {min → }/index.php
  20. 0 {min → }/lib/DooDigestAuth.php
  21. 0 {min → }/lib/HTTP/ConditionalGet.php
  22. 0 {min → }/lib/HTTP/Encoder.php
  23. 0 {min → }/lib/JSMinPlus.php
  24. +1 −1 {min → }/lib/Minify.php
  25. 0 {min → }/lib/Minify/Build.php
  26. 0 {min → }/lib/Minify/CSS.php
  27. 0 {min → }/lib/Minify/CSS/Compressor.php
  28. 0 {min → }/lib/Minify/CSS/UriRewriter.php
  29. 0 {min → }/lib/Minify/CSSmin.php
  30. 0 {min → }/lib/Minify/Cache/APC.php
  31. 0 {min → }/lib/Minify/Cache/File.php
  32. 0 {min → }/lib/Minify/Cache/Memcache.php
  33. 0 {min → }/lib/Minify/Cache/Null.php
  34. 0 {min → }/lib/Minify/Cache/WinCache.php
  35. 0 {min → }/lib/Minify/Cache/XCache.php
  36. 0 {min → }/lib/Minify/Cache/ZendPlatform.php
  37. 0 {min → }/lib/Minify/CacheInterface.php
  38. 0 {min → }/lib/Minify/ClosureCompiler.php
  39. 0 {min → }/lib/Minify/CommentPreserver.php
  40. 0 {min → }/lib/Minify/Controller/Base.php
  41. 0 {min → }/lib/Minify/Controller/Files.php
  42. 0 {min → }/lib/Minify/Controller/Groups.php
  43. 0 {min → }/lib/Minify/Controller/MinApp.php
  44. +1 −1 {min → }/lib/Minify/Controller/Page.php
  45. 0 {min → }/lib/Minify/ControllerInterface.php
  46. 0 {min → }/lib/Minify/DebugDetector.php
  47. 0 {min → }/lib/Minify/Env.php
  48. 0 {min → }/lib/Minify/HTML.php
  49. +1 −1 {min → }/lib/Minify/HTML/Helper.php
  50. 0 {min → }/lib/Minify/ImportProcessor.php
  51. +1 −1 {min → }/lib/Minify/JS/ClosureCompiler.php
  52. 0 {min → }/lib/Minify/LessCssSource.php
  53. 0 {min → }/lib/Minify/Lines.php
  54. +1 −1 {min → }/lib/Minify/Loader.php
  55. 0 {min → }/lib/Minify/Logger.php
  56. 0 {min → }/lib/Minify/Packer.php
  57. 0 {min → }/lib/Minify/ServeConfiguration.php
  58. 0 {min → }/lib/Minify/Source.php
  59. 0 {min → }/lib/Minify/Source/Factory.php
  60. 0 {min → }/lib/Minify/Source/FactoryException.php
  61. 0 {min → }/lib/Minify/SourceInterface.php
  62. 0 {min → }/lib/Minify/SourceSet.php
  63. 0 {min → }/lib/Minify/YUI/CssCompressor.java
  64. 0 {min → }/lib/Minify/YUI/CssCompressor.php
  65. 0 {min → }/lib/Minify/YUICompressor.php
  66. 0 {min → }/lib/MrClay/Cli.php
  67. 0 {min → }/lib/MrClay/Cli/Arg.php
  68. +2 −0 min_extras/cli/minify.php
  69. +2 −0 min_extras/cli/rewrite-uris.php
  70. +1 −1 min_extras/config.php
  71. +3 −3 min_extras/tools/minifyTextarea.php
  72. +1 −1 min_extras/tools/minifyUrl.php
  73. +1 −1 min_extras/tools/testRewriteUri.php
  74. +1 −1 min_unit_tests/HTTP_ConditionalGet/index.php
  75. +1 −1 min_unit_tests/HTTP_Encoder/index.php
  76. +4 −2 min_unit_tests/_inc.php
  77. +2 −3 min_unit_tests/_test_files/js/regexes.min.js
  78. +9 −7 min_unit_tests/test_JSMin.php
  79. +44 −21 min_unit_tests/test_Minify.php
  80. +1 −1 min_unit_tests/test_Minify_CSS.php
  81. +2 −2 min_unit_tests/test_Minify_HTML.php
  82. +1 −1 min_unit_tests/test_Minify_HTML_Helper.php
  83. +6 −3 min_unit_tests/test_Minify_Lines.php
  84. 0 {min → }/quick-test.css
  85. 0 {min → }/quick-test.js
  86. 0 {min → }/quick-test.less
  87. 0 {min → }/quick-testinc.less
  88. 0 {min → }/server-info.php
  89. +3 −3 {min → }/utils.php
@@ -1,5 +1,4 @@
/test
/docs
/.idea/
.DS_Store
/vendor/
File renamed without changes.
@@ -145,7 +145,7 @@ Then create a new file, for example "min.php" in your site root. The contents of
this file could look like this:

<?php
$customConfigDirectory = dirname(__FILE__) . '/min-configs';
$customConfigDirectory = __DIR__ . '/min-configs';
$min_customConfigPaths = array(
'base' => $customConfigDirectory . '/config.php',
'test' => $customConfigDirectory . '/config-test.php',
@@ -24,15 +24,29 @@ Unfortunately we can't support the WordPress plugins here.
Installation
------------

Place the `/min/` directory as a child of your DOCUMENT_ROOT
directory: i.e. you will have: `/home/example/www/min`
Installation requires PHP 5.3+, SSH access, and access to tools like `git` and `composer` or the privileges to install them.

You can see verify that it is working by visiting these two URLs:
- http://example.org/min/?f=min/quick-test.js
- http://example.org/min/?f=min/quick-test.css
```bash
cd /path/to/public_html
git clone https://github.com/mrclay/minify.git min
cd min
composer install
```

What this does:

1. Inside your DOCUMENT_ROOT directory, we clone this repo. Otherwise you may [download](https://github.com/mrclay/minify/archive/master.zip) and extract the zip file.
1. We rename this directory `min`. E.g. You will have something like: `/home/example/public_html/min`
1. We `cd` into it and run `composer install` to install the dependencies.

You can verify that it is working by visiting these two URLs:

* http://example.org/min/?f=min/quick-test.js
* http://example.org/min/?f=min/quick-test.css

If your server supports mod_rewrite, this URL should also work:
- http://example.org/min/f=min/quick-test.js

* http://example.org/min/f=min/quick-test.js

Configuration & Usage
---------------------
@@ -54,22 +68,17 @@ Support
Unit Testing
------------

1. Place the /min_unit_tests/ directory as a child of your DOCUMENT_ROOT
directory: i.e. you will have: /home/example/www/min_unit_tests

2. To run unit tests, access: http://example.org/min_unit_tests/test_all.php

(If you wish, the other test_*.php files can be run to test individual
components with more verbose output.)

3. Remove /min_unit_tests/ from your DOCUMENT_ROOT when you are done.
1. Open the file `min_unit_tests/_inc.php`.
1. Enable the file by commenting out the `die()` statement.
1. Access: http://example.org/min/min_unit_tests/test_all.php (If you wish, the other test_*.php files can be run to test individual components with more verbose output.)
1. Re-disable the `_inc.php` file when you are done.

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.
* 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.
* 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.
* 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.

Acknowledgments
---------------
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -12,13 +12,13 @@
$userDir = DIRECTORY_SEPARATOR . $m[1] . DIRECTORY_SEPARATOR;
if (false !== strpos(__FILE__, $userDir)) {
$sm = array();
$sm["//~{$m[1]}"] = dirname(dirname(__FILE__));
$sm["//~{$m[1]}"] = dirname(__DIR__);
$array = str_replace('array (', 'array(', var_export($sm, 1));
$symlinkOption = "\$min_symlinks = $array;";
}
}
require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/../config.php';
if (! $min_enableBuilder) {
@@ -159,7 +159,7 @@
</div><!-- #app -->

<hr>
<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="https://github.com/mrclay/minify/tree/master/docs">wiki</a>,
or post to the <a class=ext href="http://groups.google.com/group/minify">discussion
list</a>.</p>
<p><small>Powered by Minify <?php echo Minify::VERSION; ?></small></p>
@@ -239,8 +239,8 @@
'lastModifiedTime' => max(
// regenerate cache if any of these change
filemtime(__FILE__),
filemtime(dirname(__FILE__) . '/../config.php'),
filemtime(dirname(__FILE__) . '/../lib/Minify.php')
filemtime(__DIR__ . '/../config.php'),
filemtime(__DIR__ . '/../lib/Minify.php')
),
'minifyAll' => true,
'encodeOutput' => $encodeOutput,
File renamed without changes.
@@ -5,12 +5,12 @@
* @package Minify
*/
require __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../bootstrap.php';
$_oc = ini_get('zlib.output_compression');
// allow access only if builder is enabled
require dirname(__FILE__) . '/../config.php';
require __DIR__ . '/../config.php';
if (! $min_enableBuilder) {
header('Location: /');
exit;
File renamed without changes.
@@ -6,7 +6,7 @@
$_oc = ini_get('zlib.output_compression');
// allow access only if builder is enabled
require dirname(__FILE__) . '/../config.php';
require __DIR__ . '/../config.php';
if (! $min_enableBuilder) {
exit;
}
@@ -17,7 +17,7 @@
"wiki": "https://github.com/mrclay/minify/blob/master/docs"
},
"autoload": {
"classmap": ["min/lib/"]
"classmap": ["lib/"]
},
"require": {
"ext-pcre": "*",

Some generated files are not rendered by default. Learn more.

File renamed without changes.
@@ -10,7 +10,7 @@
/**
* Allow use of the Minify URI Builder app. Only set this to true while you need it.
*/
$min_enableBuilder = false;
$min_enableBuilder = true;
/**
@@ -78,7 +78,7 @@
* second line. The third line might work on some Apache servers.
*/
$min_documentRoot = '';
//$min_documentRoot = dirname(dirname(dirname(__FILE__)));
//$min_documentRoot = dirname(dirname(__DIR__));
//$min_documentRoot = substr(__FILE__, 0, -15);
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
File renamed without changes.
@@ -7,15 +7,13 @@
* @package Minify
*/
require __DIR__ . '/../bootstrap.php';
define('MINIFY_MIN_DIR', dirname(__FILE__));
require __DIR__ . '/bootstrap.php';
// set config path defaults
$min_configPaths = array(
'base' => MINIFY_MIN_DIR . '/config.php',
'test' => MINIFY_MIN_DIR . '/config-test.php',
'groups' => MINIFY_MIN_DIR . '/groupsConfig.php',
'base' => __DIR__ . '/config.php',
'test' => __DIR__ . '/config-test.php',
'groups' => __DIR__ . '/groupsConfig.php',
);
// check for custom config paths
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -84,7 +84,7 @@ public function getDefaultOptions()
'encodeLevel' => 9,
'minifiers' => array(
Minify::TYPE_JS => array('JSMin', 'minify'),
Minify::TYPE_JS => array('JSMin\\JSMin', 'minify'),
Minify::TYPE_CSS => array('Minify_CSS', 'minify'),
Minify::TYPE_HTML => array('Minify_HTML', 'minify'),
),
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -53,7 +53,7 @@ public function createConfiguration(array $options) {
// this will be the 2nd argument passed to Minify_HTML::minify()
$sourceSpec['minifyOptions'] = array(
'cssMinifier' => array('Minify_CSS', 'minify')
,'jsMinifier' => array('JSMin', 'minify')
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
);
unset($options['minifyAll']);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -115,7 +115,7 @@ public function setGroup($key, $checkLastModified = true)
$this->_groupKey = $key;
if ($checkLastModified) {
if (! $this->groupsConfigFile) {
$this->groupsConfigFile = dirname(dirname(dirname(dirname(__FILE__)))) . '/groupsConfig.php';
$this->groupsConfigFile = dirname(dirname(dirname(__DIR__))) . '/groupsConfig.php';
}
if (is_file($this->groupsConfigFile)) {
$gc = (require $this->groupsConfigFile);
File renamed without changes.
@@ -68,7 +68,7 @@ class Minify_JS_ClosureCompiler {
/**
* @var callable Function to minify JS if service fails. Default is JSMin
*/
protected $fallbackMinifier = array('JSMin', 'minify');
protected $fallbackMinifier = array('JSMin\\JSMin', 'minify');
/**
* Minify JavaScript code via HTTP request to a Closure Compiler API
File renamed without changes.
File renamed without changes.
@@ -13,7 +13,7 @@
class Minify_Loader {
public function loadClass($class)
{
$file = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR;
$file .= strtr($class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . '.php';
if (is_readable($file)) {
require $file;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
die('Must be rewritten for new API');
require __DIR__ . '/../../bootstrap.php';
$cli = new MrClay\Cli;
@@ -1,6 +1,8 @@
#!/usr/bin/php
<?php
die('Must be rewritten for new API');
require __DIR__ . '/../../bootstrap.php';
$cli = new MrClay\Cli;
@@ -2,7 +2,7 @@
// using same lib path and cache path specified in /min/config.php
require dirname(__FILE__) . '/../min/config.php';
require __DIR__ . '/../config.php';
$minifyCachePath = isset($min_cachePath)
? $min_cachePath
@@ -31,7 +31,7 @@ function h($txt) {
$sourceSpec['content'] = $textIn;
$sourceSpec['id'] = 'foo';
if (isset($_POST['minJs'])) {
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin', 'minify');
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin\\JSMin', 'minify');
}
if (isset($_POST['minCss'])) {
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
@@ -50,15 +50,15 @@ function h($txt) {
}
$tpl = array();
$tpl['classes'] = array('Minify_HTML', 'JSMin', 'Minify_CSS', 'Minify_CSSmin', 'JSMinPlus');
$tpl['classes'] = array('Minify_HTML', 'JSMin\\JSMin', 'Minify_CSS', 'Minify_CSSmin', 'JSMinPlus');
if (isset($_POST['method']) && in_array($_POST['method'], $tpl['classes'])) {
$args = array($textIn);
if ($_POST['method'] === 'Minify_HTML') {
$args[] = array(
'cssMinifier' => array('Minify_CSS', 'minify')
,'jsMinifier' => array('JSMin', 'minify')
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
);
}
$func = array($_POST['method'], 'minify');
@@ -96,7 +96,7 @@ function sniffType($headers) {
if ($type['minify'] === 'text/html') {
if (isset($_POST['minJs'])) {
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin', 'minify');
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin\\JSMin', 'minify');
}
if (isset($_POST['minCss'])) {
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
@@ -26,7 +26,7 @@ function getInput($name, $default = '', $size = 50) {
}
}
$defaultCurrentDir = dirname(__FILE__);
$defaultCurrentDir = __DIR__;
$defaultDocRoot = realpath($_SERVER['DOCUMENT_ROOT']);
$defaultSymLink = '//symlinkPath';
$defaultSymTarget = ($defaultCurrentDir[0] === '/') ? '/tmp' : 'C:\\WINDOWS\\Temp';
@@ -28,7 +28,7 @@
require '_include.php';
echo send_slowly(get_content(array(
send_slowly(get_content(array(
'title' => $title
,'explain' => $explain
)));
@@ -33,7 +33,7 @@
ob_end_clean();
} elseif ($_GET['test'] == '1') {
$content = file_get_contents(dirname(__FILE__) . '/green.png');
$content = file_get_contents(__DIR__ . '/green.png');
$type = 'image/png';
} elseif ($_GET['test'] == '2') {
@@ -1,7 +1,9 @@
<?php
// comment this out to run tests
die('This script is disabled.');
require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/../min/config.php';
require __DIR__ . '/../config.php';
// set cache path and doc root if configured
$minifyCachePath = isset($min_cachePath)
@@ -23,7 +25,7 @@
header('Content-Type: text/plain;charset=utf-8');
$thisDir = dirname(__FILE__);
$thisDir = __DIR__;
/**
* pTest - PHP Unit Tester
@@ -1,3 +1,2 @@
function testIssue74(){return /'/;}
!function(s){return /^[£$€?.]/.test(s);}();typeof
/ ' /;x=/ [/] /;1/foo;(2)/foo;function(){return/foo/};function(){return typeof/foo/};
function testIssue74(){return/'/;}
!function(s){return/^[£$€?.]/.test(s);}();typeof/ ' /;x=/ [/] /;1/foo;(2)/foo;function(){return/foo/};function(){return typeof/foo/};

0 comments on commit e596b35

Please sign in to comment.
You can’t perform that action at this time.