mirror of
https://github.com/mrclay/minify.git
synced 2025-08-29 08:40:11 +02:00
minifyTextarea.php : set charset, + HTML rendering option
Fixed source array casting in controllers Files, Groups, MinApp Changed default from "UTF-8" to "utf-8"
This commit is contained in:
@@ -1,17 +1,52 @@
|
||||
<?php
|
||||
|
||||
$classes = array('Minify_HTML', 'Minify_CSS', 'JSMin', 'JSMinPlus');
|
||||
header('Content-Type: text/html;charset=UTF-8');
|
||||
function getPost($key) {
|
||||
return get_magic_quotes_gpc()
|
||||
? stripslashes($_POST[$key])
|
||||
: $_POST[$key];
|
||||
}
|
||||
|
||||
if (isset($_POST['textIn']) && in_array($_POST['method'], $classes)) {
|
||||
if (isset($_POST['textIn'])) {
|
||||
require '../config.php';
|
||||
$textIn = str_replace("\r\n", "\n", getPost('textIn'));
|
||||
}
|
||||
|
||||
if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
|
||||
require 'Minify.php';
|
||||
|
||||
$textIn = get_magic_quotes_gpc()
|
||||
? stripslashes($_POST['textIn'])
|
||||
: $_POST['textIn'];
|
||||
|
||||
$textIn = str_replace("\r\n", "\n", $textIn);
|
||||
$base = trim(getPost('base'));
|
||||
if ($base) {
|
||||
$textIn = preg_replace(
|
||||
'@(<head\\b[^>]*>)@i'
|
||||
,'$1<base href="' . htmlentities($base) . '" />'
|
||||
,$textIn
|
||||
);
|
||||
}
|
||||
|
||||
$sourceSpec['content'] = $textIn;
|
||||
$sourceSpec['id'] = 'foo';
|
||||
if (isset($_POST['minJs'])) {
|
||||
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin', 'minify');
|
||||
require 'JSMin.php';
|
||||
}
|
||||
if (isset($_POST['minCss'])) {
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
|
||||
require 'Minify/CSS.php';
|
||||
}
|
||||
$source = new Minify_Source($sourceSpec);
|
||||
require_once 'Minify/Logger.php';
|
||||
require_once 'FirePHP.php';
|
||||
Minify_Logger::setLogger(FirePHP::getInstance(true));
|
||||
Minify::serve('Files', array(
|
||||
'files' => $source
|
||||
,'contentType' => Minify::TYPE_HTML
|
||||
));
|
||||
exit();
|
||||
}
|
||||
|
||||
$classes = array('Minify_HTML', 'Minify_CSS', 'JSMin', 'JSMinPlus');
|
||||
|
||||
if (isset($_POST['method']) && in_array($_POST['method'], $classes)) {
|
||||
// easier to just require them all
|
||||
require 'Minify/HTML.php';
|
||||
require 'Minify/CSS.php';
|
||||
@@ -31,6 +66,10 @@ if (isset($_POST['textIn']) && in_array($_POST['method'], $classes)) {
|
||||
$inOutBytes[1] = strlen($textOut);
|
||||
}
|
||||
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
?>
|
||||
<!DOCTYPE html><head><title>minifyTextarea</title></head>
|
||||
<?php
|
||||
if (isset($inOutBytes)) {
|
||||
echo "
|
||||
<table>
|
||||
@@ -39,17 +78,21 @@ if (isset($inOutBytes)) {
|
||||
</table>
|
||||
";
|
||||
}
|
||||
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<p><label>Content<br /><textarea name="textIn" cols="80" rows="35" style="width:99%"><?php
|
||||
<form action="?2" method="post">
|
||||
<p><label>Content<br><textarea name="textIn" cols="80" rows="35" style="width:99%"><?php
|
||||
if (isset($textOut)) {
|
||||
echo htmlspecialchars($textOut);
|
||||
}
|
||||
?></textarea></label></p>
|
||||
<p>Minify with:
|
||||
<?php foreach ($classes as $minClass): ?>
|
||||
<input type="submit" name="method" value="<?php echo $minClass; ?>" />
|
||||
<input type="submit" name="method" value="<?php echo $minClass; ?>">
|
||||
<?php endForEach; ?>
|
||||
</p>
|
||||
<p>...or <input type="submit" name="method" value="Minify and serve"> this HTML to the browser. Also minify:
|
||||
<label>CSS <input type="checkbox" name="minCss" checked></label> :
|
||||
<label>JS <input type="checkbox" name="minJs" checked></label>.
|
||||
<label>Insert BASE element w/ href: <input type="text" name="base" size="20"></label>
|
||||
</p>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user