mirror of
https://github.com/mrclay/minify.git
synced 2025-08-11 16:44:44 +02:00
back out HTML minification code
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
class HTMLMin {
|
|
||||||
protected $html = '';
|
|
||||||
|
|
||||||
// -- Public Instance Methods ----------------------------------------------
|
|
||||||
public function __construct($html) {
|
|
||||||
$this->input = $html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
36
minify.php
36
minify.php
@@ -16,7 +16,7 @@
|
|||||||
* @author Ryan Grove <ryan@wonko.com>
|
* @author Ryan Grove <ryan@wonko.com>
|
||||||
* @copyright 2007 Ryan Grove. All rights reserved.
|
* @copyright 2007 Ryan Grove. All rights reserved.
|
||||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||||
* @version 1.0.2 (?)
|
* @version 1.0.1 (2007-05-05)
|
||||||
* @link http://code.google.com/p/minify/
|
* @link http://code.google.com/p/minify/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -76,13 +76,12 @@ if (!defined('MINIFY_USE_CACHE')) {
|
|||||||
* @author Ryan Grove <ryan@wonko.com>
|
* @author Ryan Grove <ryan@wonko.com>
|
||||||
* @copyright 2007 Ryan Grove. All rights reserved.
|
* @copyright 2007 Ryan Grove. All rights reserved.
|
||||||
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
* @license http://opensource.org/licenses/bsd-license.php New BSD License
|
||||||
* @version 1.0.2 (?)
|
* @version 1.0.1 (2007-05-05)
|
||||||
* @link http://code.google.com/p/minify/
|
* @link http://code.google.com/p/minify/
|
||||||
*/
|
*/
|
||||||
class Minify {
|
class Minify {
|
||||||
const TYPE_CSS = 'text/css';
|
const TYPE_CSS = 'text/css';
|
||||||
const TYPE_HTML = 'text/html';
|
const TYPE_JS = 'text/javascript';
|
||||||
const TYPE_JS = 'text/javascript';
|
|
||||||
|
|
||||||
protected $files = array();
|
protected $files = array();
|
||||||
protected $type = self::TYPE_JS;
|
protected $type = self::TYPE_JS;
|
||||||
@@ -135,27 +134,29 @@ class Minify {
|
|||||||
* Minifies the specified string and returns it.
|
* Minifies the specified string and returns it.
|
||||||
*
|
*
|
||||||
* @param string $string JavaScript or CSS string to minify
|
* @param string $string JavaScript or CSS string to minify
|
||||||
* @param string $type content type of the string (either Minify::TYPE_CSS or
|
* @param string $type content type of the string (Minify::TYPE_CSS,
|
||||||
* Minify::TYPE_JS)
|
* Minify::TYPE_HTML, or Minify::TYPE_JS)
|
||||||
* @return string minified string
|
* @return string minified string
|
||||||
*/
|
*/
|
||||||
public static function minify($string, $type = self::TYPE_JS) {
|
public static function minify($string, $type = self::TYPE_JS) {
|
||||||
|
<<<<<<< .working
|
||||||
switch($type) {
|
switch($type) {
|
||||||
case self::TYPE_CSS:
|
case self::TYPE_CSS:
|
||||||
return self::minifyCSS($string);
|
return self::minifyCSS($string);
|
||||||
break;
|
|
||||||
|
|
||||||
case self::TYPE_HTML:
|
case self::TYPE_HTML:
|
||||||
return self::minifyHTML($string);
|
return self::minifyHTML($string);
|
||||||
break;
|
|
||||||
|
|
||||||
case self::TYPE_JS:
|
case self::TYPE_JS:
|
||||||
return self::minifyJS($string);
|
return self::minifyJS($string);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new MinifyInvalidArgumentException('Invalid content type');
|
throw new MinifyInvalidArgumentException('Invalid content type.');
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
return $type === self::TYPE_JS ? self::minifyJS($string) :
|
||||||
|
self::minifyCSS($string);
|
||||||
|
>>>>>>> .merge-right.r41
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Protected Static Methods -----------------------------------------------
|
// -- Protected Static Methods -----------------------------------------------
|
||||||
@@ -165,6 +166,8 @@ class Minify {
|
|||||||
*
|
*
|
||||||
* @param string $css CSS string
|
* @param string $css CSS string
|
||||||
* @return string minified string
|
* @return string minified string
|
||||||
|
* @see minify()
|
||||||
|
* @see minifyJS()
|
||||||
*/
|
*/
|
||||||
protected static function minifyCSS($css) {
|
protected static function minifyCSS($css) {
|
||||||
// Compress whitespace.
|
// Compress whitespace.
|
||||||
@@ -175,6 +178,7 @@ class Minify {
|
|||||||
|
|
||||||
return trim($css);
|
return trim($css);
|
||||||
}
|
}
|
||||||
|
<<<<<<< .working
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minifies the specified HTML string and returns it.
|
* Minifies the specified HTML string and returns it.
|
||||||
@@ -183,13 +187,19 @@ class Minify {
|
|||||||
* @return string minified string
|
* @return string minified string
|
||||||
*/
|
*/
|
||||||
protected static function minifyHTML($html) {
|
protected static function minifyHTML($html) {
|
||||||
|
require_once dirname(__FILE__).'/lib/htmlmin.php';
|
||||||
|
return HTMLMin::minify($html);
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
>>>>>>> .merge-right.r41
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minifies the specified JavaScript string and returns it.
|
* Minifies the specified JavaScript string and returns it.
|
||||||
*
|
*
|
||||||
* @param string $js JavaScript string
|
* @param string $js JavaScript string
|
||||||
* @return string minified string
|
* @return string minified string
|
||||||
|
* @see minify()
|
||||||
|
* @see minifyCSS()
|
||||||
*/
|
*/
|
||||||
protected static function minifyJS($js) {
|
protected static function minifyJS($js) {
|
||||||
require_once dirname(__FILE__).'/lib/jsmin.php';
|
require_once dirname(__FILE__).'/lib/jsmin.php';
|
||||||
@@ -412,7 +422,7 @@ class Minify {
|
|||||||
public function serverCache($return = false) {
|
public function serverCache($return = false) {
|
||||||
$cacheFile = MINIFY_CACHE_DIR.'/minify_'.$this->getHash();
|
$cacheFile = MINIFY_CACHE_DIR.'/minify_'.$this->getHash();
|
||||||
$lastModified = $this->getLastModified();
|
$lastModified = $this->getLastModified();
|
||||||
|
|
||||||
if (is_file($cacheFile) && $lastModified <= filemtime($cacheFile)) {
|
if (is_file($cacheFile) && $lastModified <= filemtime($cacheFile)) {
|
||||||
if ($return) {
|
if ($return) {
|
||||||
return file_get_contents($cacheFile);
|
return file_get_contents($cacheFile);
|
||||||
|
Reference in New Issue
Block a user