1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-12 00:54:35 +02:00

Added 'debug' option to serve() to use Minify_Lines

This commit is contained in:
Steve Clay
2008-06-28 20:23:29 +00:00
parent 46f8993292
commit e77a1cf82c
5 changed files with 95 additions and 12 deletions

View File

@@ -47,6 +47,7 @@ abstract class Minify_Controller_Base {
,'contentTypeCharset' => 'UTF-8'
,'setExpires' => null // use conditional GET
,'quiet' => false // serve() will send headers and output
,'debug' => false
// if you override this, the response code MUST be directly after
// the first space.

View File

@@ -34,18 +34,20 @@ class Minify_Lines {
$lines = explode($eol, $content);
$numLines = count($lines);
// determine left padding
$padTo = max(strlen($numLines), strlen($id));
$padTo = strlen($numLines);
$inComment = false;
for ($i = 0; $i < $numLines; ++$i) {
$n = $i + 1;
$line = $lines[$i];
$note = (('' !== $id) && (1 == $n % 30))
? $id
: $n;
$lines[$i] = self::_addNote($line, $note, $inComment, $padTo);
$i = 0;
while (null !== ($line = array_shift($lines))) {
if (('' !== $id) && (0 == $i % 50)) {
$newLines[] = '';
$newLines[] = "/* {$id} */";
$newLines[] = '';
}
++$i;
$newLines[] = self::_addNote($line, $i, $inComment, $padTo);
$inComment = self::_eolInComment($line, $inComment);
}
return implode($eol, $lines) . $eol;
return implode($eol, $newLines) . $eol;
}
/**
@@ -89,7 +91,7 @@ class Minify_Lines {
private static function _addNote($line, $note, $inComment, $padTo)
{
return $inComment
? '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' * ' . $line
? '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' *| ' . $line
: '/* ' . str_pad($note, $padTo, ' ', STR_PAD_RIGHT) . ' */ ' . $line;
}
}

View File

@@ -90,6 +90,16 @@ class Minify_Source {
: $content;
}
/**
* Get id
*
* @return string
*/
public function getId()
{
return $this->_id;
}
/**
* Verifies a single minification call can handle all sources
*