jalmenarez / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add a GET parameter for debugging #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A way to see the original js without minifying it, mainly for debugging/
developing purposes:

In the .htaccess, we need the QSA flag:

RewriteRule ^(.*\.(css|js))$ /minify.php?files=$1 [L,NC,QSA]

And in the minify.php, simply:

if (isset($_GET['debug'])) {
    echo $minify->combine(!($_GET['debug']));
} else {
    echo $minify->combine();
}

So http://www.example.com/js/blabla.js?debug=1 should return the original 
js, without minifying it.

Congrats for the software! It helps me a lot!
Victor

Original issue reported on code.google.com by espiga...@gmail.com on 21 Jul 2007 at 3:24

GoogleCodeExporter commented 9 years ago
I later realized that the hash generated for both versions of a file (debug=0 
and 
debug=1) is the same, when shouldn't. So:

public function getHash() {
    if ( isset($_GET['debug']) && (int)$_GET['debug'] ) $debug = 1;
    return hash('md5', implode('', $this->files). $debug);
}

Cheers,
Victor

Original comment by espiga...@gmail.com on 22 Jul 2007 at 11:32

GoogleCodeExporter commented 9 years ago

Original comment by rgr...@gmail.com on 28 Aug 2007 at 5:18

GoogleCodeExporter commented 9 years ago
With the SVN version this will be easy. Have the user code listen for the GET 
var and
set all the minifiers to use an identity function. Something like:

function identity($content, $options) { return $content; }

$minOptions = array();
if (isset($_GET['debug'])) {
    $minOptions['minifiers'] = array(
        'text/css' => 'identity'
        ,'application/x-javascript' => 'identity'
        ,'text/html' => 'identity'
    )
}

Minify::serve(
    'ControllerName'
    ,array( /* controller options */ )
    ,$minOptions
);

Original comment by mrclay....@gmail.com on 29 Feb 2008 at 2:44

GoogleCodeExporter commented 9 years ago
The controller and Minify options have been combined, so now this would be 
slightly
different:

$options = array();
if (isset($_GET['debug'])) {
    $options['minifiers'] = array(
        'text/css' => 'identity'
        ,'application/x-javascript' => 'identity'
        ,'text/html' => 'identity'
    )
}
Minify::serve('ControllerName', $options);

Original comment by mrclay....@gmail.com on 14 May 2008 at 4:33

GoogleCodeExporter commented 9 years ago
This was added in 2.1.0, can be enabled in /min/config.php

Original comment by mrclay....@gmail.com on 27 Nov 2008 at 3:14