mirror of
https://github.com/mrclay/minify.git
synced 2025-08-13 17:44:00 +02:00
+ Minify::$uploaderHoursBehind
+ fixed backtrace limit issue in Minify_HTML + default max-age of 30 minutes (instead of 0)
This commit is contained in:
@@ -35,6 +35,19 @@ class Minify {
|
|||||||
// Apache default and what Yahoo! uses..
|
// Apache default and what Yahoo! uses..
|
||||||
const TYPE_JS = 'application/x-javascript';
|
const TYPE_JS = 'application/x-javascript';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many hours behind are the file modification times of uploaded files?
|
||||||
|
*
|
||||||
|
* The mtime of files on Windows can behind what they should be on the server.
|
||||||
|
* 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see setCache()
|
* @see setCache()
|
||||||
* @param mixed $cache object with identical interface as Minify_Cache_File or
|
* @param mixed $cache object with identical interface as Minify_Cache_File or
|
||||||
@@ -179,7 +192,7 @@ class Minify {
|
|||||||
'lastModifiedTime' => self::$_options['lastModifiedTime']
|
'lastModifiedTime' => self::$_options['lastModifiedTime']
|
||||||
,'isPublic' => self::$_options['isPublic']
|
,'isPublic' => self::$_options['isPublic']
|
||||||
);
|
);
|
||||||
if (null !== self::$_options['maxAge']) {
|
if (self::$_options['maxAge'] > 0) {
|
||||||
$cgOptions['maxAge'] = self::$_options['maxAge'];
|
$cgOptions['maxAge'] = self::$_options['maxAge'];
|
||||||
}
|
}
|
||||||
$cg = new HTTP_ConditionalGet($cgOptions);
|
$cg = new HTTP_ConditionalGet($cgOptions);
|
||||||
|
@@ -45,7 +45,7 @@ abstract class Minify_Controller_Base {
|
|||||||
,'encodeLevel' => 9
|
,'encodeLevel' => 9
|
||||||
,'minifierOptions' => array() // no minifier options
|
,'minifierOptions' => array() // no minifier options
|
||||||
,'contentTypeCharset' => 'UTF-8'
|
,'contentTypeCharset' => 'UTF-8'
|
||||||
,'maxAge' => null // no Expires/max-age
|
,'maxAge' => 1800 // 30 minutes
|
||||||
,'quiet' => false // serve() will send headers and output
|
,'quiet' => false // serve() will send headers and output
|
||||||
,'debug' => false
|
,'debug' => false
|
||||||
|
|
||||||
|
@@ -56,15 +56,15 @@ class Minify_HTML {
|
|||||||
,array('Minify_HTML', '_removePreCB')
|
,array('Minify_HTML', '_removePreCB')
|
||||||
, $html);
|
, $html);
|
||||||
|
|
||||||
// remove leading and trailing ws from each line.
|
// trim each line.
|
||||||
// @todo take into account attribute values that span multiple lines.
|
// @todo take into account attribute values that span multiple lines.
|
||||||
$html = preg_replace('/^\\s*(.*?)\\s*$/m', "$1", $html);
|
$html = preg_replace('/^\\s+|\\s+$/m', '', $html);
|
||||||
|
|
||||||
// remove ws around block/undisplayed elements
|
// remove ws around block/undisplayed elements
|
||||||
$html = preg_replace('/\\s*(<\\/?(?:area|base(?:font)?|blockquote|body'
|
$html = preg_replace('/\\s*(<\\/?(?:area|base(?:font)?|blockquote|body'
|
||||||
.'|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
|
.'|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form'
|
||||||
.'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
|
.'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta'
|
||||||
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot)|title'
|
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
|
||||||
.'|ul)\\b[^>]*>)/i', '$1', $html);
|
.'|ul)\\b[^>]*>)/i', '$1', $html);
|
||||||
|
|
||||||
// remove ws between and inside elements.
|
// remove ws between and inside elements.
|
||||||
|
@@ -51,7 +51,9 @@ class Minify_Source {
|
|||||||
}
|
}
|
||||||
$this->_filepath = $spec['filepath'];
|
$this->_filepath = $spec['filepath'];
|
||||||
$this->_id = $spec['filepath'];
|
$this->_id = $spec['filepath'];
|
||||||
$this->lastModified = filemtime($spec['filepath']);
|
$this->lastModified = filemtime($spec['filepath'])
|
||||||
|
// offset for Windows uploaders with out of sync clocks
|
||||||
|
+ round(Minify::$uploaderHoursBehind * 3600);
|
||||||
} elseif (isset($spec['id'])) {
|
} elseif (isset($spec['id'])) {
|
||||||
$this->_id = 'id::' . $spec['id'];
|
$this->_id = 'id::' . $spec['id'];
|
||||||
if (isset($spec['content'])) {
|
if (isset($spec['content'])) {
|
||||||
|
@@ -77,7 +77,8 @@ css hack {
|
|||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="pageHeader">
|
<div id="pageHeader">
|
||||||
<h1><span>css Zen Garden</span></h1>
|
<h1><span>css Zen Garden</span></h1>
|
||||||
<h2><span>The Beauty of <acronym title="Cascading Style Sheets">CSS</acronym> Design</span></h2>
|
<h2><span>The Beauty of <acronym title="Cascading Style Sheets">CSS</acronym>
|
||||||
|
Design</span></h2>
|
||||||
</div>
|
</div>
|
||||||
<pre>
|
<pre>
|
||||||
White space is important here!
|
White space is important here!
|
||||||
|
@@ -10,8 +10,8 @@ function test_Minify()
|
|||||||
global $thisDir;
|
global $thisDir;
|
||||||
|
|
||||||
$minifyTestPath = dirname(__FILE__) . '/_test_files/minify';
|
$minifyTestPath = dirname(__FILE__) . '/_test_files/minify';
|
||||||
$tomorrow = time() + 86400;
|
$tomorrow = $_SERVER['REQUEST_TIME'] + 86400;
|
||||||
$lastModified = time() - 86400;
|
$lastModified = $_SERVER['REQUEST_TIME'] - 86400;
|
||||||
|
|
||||||
// Test 304 response
|
// Test 304 response
|
||||||
|
|
||||||
@@ -24,9 +24,10 @@ function test_Minify()
|
|||||||
,'statusCode' => 304
|
,'statusCode' => 304
|
||||||
,'content' => '',
|
,'content' => '',
|
||||||
'headers' => array(
|
'headers' => array(
|
||||||
'Last-Modified' => gmdate('D, d M Y H:i:s \G\M\T', $lastModified),
|
'Expires' => gmdate('D, d M Y H:i:s \G\M\T', $_SERVER['REQUEST_TIME'] + 1800),
|
||||||
|
'Last-Modified' => gmdate('D, d M Y H:i:s \G\M\T', $lastModified),
|
||||||
'ETag' => "\"{$lastModified}pub\"",
|
'ETag' => "\"{$lastModified}pub\"",
|
||||||
'Cache-Control' => 'max-age=0, public, must-revalidate',
|
'Cache-Control' => 'max-age=1800, public, must-revalidate',
|
||||||
'_responseCode' => 'HTTP/1.0 304 Not Modified',
|
'_responseCode' => 'HTTP/1.0 304 Not Modified',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -101,7 +102,7 @@ function test_Minify()
|
|||||||
,'statusCode' => 200
|
,'statusCode' => 200
|
||||||
,'content' => file_get_contents($minifyTestPath . '/minified.css')
|
,'content' => file_get_contents($minifyTestPath . '/minified.css')
|
||||||
,'headers' => array (
|
,'headers' => array (
|
||||||
'Last-Modified' => gmdate('D, d M Y H:i:s \G\M\T', $lastModified),
|
'Last-Modified' => gmdate('D, d M Y H:i:s \G\M\T', $lastModified),
|
||||||
'ETag' => "\"{$lastModified}pub\"",
|
'ETag' => "\"{$lastModified}pub\"",
|
||||||
'Cache-Control' => 'max-age=0, public, must-revalidate',
|
'Cache-Control' => 'max-age=0, public, must-revalidate',
|
||||||
'Content-Length' => filesize($minifyTestPath . '/minified.css'),
|
'Content-Length' => filesize($minifyTestPath . '/minified.css'),
|
||||||
@@ -116,6 +117,7 @@ function test_Minify()
|
|||||||
,'quiet' => true
|
,'quiet' => true
|
||||||
,'lastModifiedTime' => $lastModified
|
,'lastModifiedTime' => $lastModified
|
||||||
,'encodeOutput' => false
|
,'encodeOutput' => false
|
||||||
|
,'maxAge' => false
|
||||||
));
|
));
|
||||||
|
|
||||||
$passed = assertTrue($expected === $output, 'Minify : CSS and Etag/Last-Modified');
|
$passed = assertTrue($expected === $output, 'Minify : CSS and Etag/Last-Modified');
|
||||||
|
Reference in New Issue
Block a user