mirror of
https://github.com/mrclay/minify.git
synced 2025-01-17 21:28:14 +01:00
Make Minify::combine and mix_extra stuff operational (and disabled by default)
This commit is contained in:
parent
f769e35233
commit
a566536f80
@ -398,30 +398,30 @@ class Minify {
|
||||
*
|
||||
* @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.
|
||||
* @param array $options (optional) array of options for serve.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function combine($sources, $options = array())
|
||||
{
|
||||
throw new BadMethodCallException(__METHOD__ . ' needs to be rewritten/replaced');
|
||||
|
||||
$cache = $this->cache;
|
||||
$tmpCache = $this->cache;
|
||||
$this->cache = new Minify_Cache_Null();
|
||||
|
||||
$options = array_merge(array(
|
||||
$env = new Minify_Env();
|
||||
$sourceFactory = new Minify_Source_Factory($env, [
|
||||
'checkAllowDirs' => false,
|
||||
], $this->cache);
|
||||
$controller = new Minify_Controller_Files($env, $sourceFactory);
|
||||
|
||||
$options = array_merge($options, array(
|
||||
'files' => (array)$sources,
|
||||
'quiet' => true,
|
||||
'encodeMethod' => '',
|
||||
'lastModifiedTime' => 0,
|
||||
), $options);
|
||||
|
||||
$sourceFactory = new Minify_Source_Factory($this->env);
|
||||
$controller = new Minify_Controller_Files($this->env, $sourceFactory);
|
||||
));
|
||||
$out = $this->serve($controller, $options);
|
||||
|
||||
$this->cache = $cache;
|
||||
$this->cache = $tmpCache;
|
||||
return $out['content'];
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
die('Must be rewritten for new API');
|
||||
die('Disabled: use this only for testing');
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
@ -39,8 +39,13 @@ if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
|
||||
}
|
||||
$source = new Minify_Source($sourceSpec);
|
||||
Minify_Logger::setLogger(FirePHP::getInstance(true));
|
||||
|
||||
$env = new Minify_Env();
|
||||
$controller = new Minify_Controller_Files($env, new Minify_Source_Factory($env));
|
||||
$minify = new Minify(new Minify_Cache_Null());
|
||||
|
||||
try {
|
||||
Minify::serve('Files', array(
|
||||
$minify->serve($controller, array(
|
||||
'files' => $source
|
||||
,'contentType' => Minify::TYPE_HTML
|
||||
));
|
||||
@ -51,7 +56,7 @@ if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
|
||||
}
|
||||
|
||||
$tpl = array();
|
||||
$tpl['classes'] = array('Minify_HTML', 'JSMin\\JSMin', 'Minify_CSS', 'Minify_CSS');
|
||||
$tpl['classes'] = array('Minify_HTML', 'JSMin\\JSMin', 'Minify_CSS');
|
||||
|
||||
if (isset($_POST['method']) && in_array($_POST['method'], $tpl['classes'])) {
|
||||
|
||||
@ -113,6 +118,9 @@ function sendPage($vars) {
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
?>
|
||||
<!DOCTYPE html><head><title>minifyTextarea</title></head>
|
||||
|
||||
<p><strong>Warning! Please do not place this application on a public site.</strong> This should be used only for testing.</p>
|
||||
|
||||
<?php
|
||||
if (isset($vars['exceptionMsg'])) {
|
||||
echo $vars['exceptionMsg'];
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
die('Must be rewritten for new API');
|
||||
die('Disabled: use this only for testing');
|
||||
|
||||
/**
|
||||
* Fetch and minify a URL (auto-detect HTML/JS/CSS)
|
||||
*/
|
||||
@ -94,6 +95,7 @@ if (isset($_POST['url'])) {
|
||||
|
||||
$sourceSpec['content'] = $content;
|
||||
$sourceSpec['id'] = 'foo';
|
||||
$sourceSpec['contentType'] = $type['minify'];
|
||||
|
||||
if ($type['minify'] === 'text/html') {
|
||||
if (isset($_POST['minJs'])) {
|
||||
@ -103,7 +105,7 @@ if (isset($_POST['url'])) {
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSSmin', 'minify');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$source = new Minify_Source($sourceSpec);
|
||||
|
||||
$sendType = 'text/plain';
|
||||
@ -116,10 +118,11 @@ if (isset($_POST['url'])) {
|
||||
header('Content-Type: ' . $sendType);
|
||||
// using combine instead of serve because it allows us to specify a
|
||||
// Content-Type like application/xhtml+xml IF we need to
|
||||
|
||||
$minify = new Minify(new Minify_Cache_Null());
|
||||
|
||||
try {
|
||||
echo Minify::combine(array($source), array(
|
||||
'contentType' => $type['minify']
|
||||
));
|
||||
echo $minify->combine(array($source));
|
||||
} catch (Exception $e) {
|
||||
header('Content-Type: text/html;charset=utf-8');
|
||||
echo htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8');
|
||||
@ -136,8 +139,7 @@ $ua = get_magic_quotes_gpc()
|
||||
?>
|
||||
<!DOCTYPE html><head><title>Minify URL</title></head>
|
||||
|
||||
<p><strong>Warning! Please do not place this application on a public site.</strong> This should be used
|
||||
only for testing.</p>
|
||||
<p><strong>Warning! Please do not place this application on a public site.</strong> This should be used only for testing.</p>
|
||||
|
||||
<h1>Fetch and Minify a URL</h1>
|
||||
<p>This tool will retrieve the contents of a URL and minify it.
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
die('Must be rewritten for new API');
|
||||
die('Disabled: use this only for testing');
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
@ -52,6 +52,7 @@ if (isset($_POST['css'])) {
|
||||
|
||||
?>
|
||||
<h1>Test <code>Minify_CSS_UriRewriter::rewrite()</code></h1>
|
||||
<p><strong>Warning! Please do not place this application on a public site.</strong> This should be used only for testing.</p>
|
||||
<form action="" method="post">
|
||||
<div><label>document root: <?php echo getInput('docRoot', $defaultDocRoot); ?></label></div>
|
||||
<div><label>symlink: <?php echo getInput('symLink', $defaultSymLink); ?> => <?php echo getInput('symTarget', $defaultSymTarget); ?></label></div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user