Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GET parameter for debugging #158

Closed
mrclay opened this issue Sep 3, 2015 · 5 comments
Closed

Add a GET parameter for debugging #158

mrclay opened this issue Sep 3, 2015 · 5 comments

Comments

@mrclay
Copy link
Owner

mrclay commented Sep 3, 2015

Originally reported on Google Code with ID 13

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

Reported by espigares on 2007-07-21 15:24:48

@mrclay
Copy link
Owner Author

mrclay commented Sep 3, 2015

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

Reported by espigares on 2007-07-22 11:32:25

@mrclay
Copy link
Owner Author

mrclay commented Sep 3, 2015

Reported by rgrove on 2007-08-28 17:18:56

  • Status changed: Accepted

@mrclay
Copy link
Owner Author

mrclay commented Sep 3, 2015

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
);

Reported by mrclay.org on 2008-02-29 02:44:25

@mrclay
Copy link
Owner Author

mrclay commented Sep 3, 2015

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);

Reported by mrclay.org on 2008-05-14 16:33:30

  • Status changed: WontFix

@mrclay
Copy link
Owner Author

mrclay commented Sep 3, 2015

This was added in 2.1.0, can be enabled in /min/config.php

Reported by mrclay.org on 2008-11-27 15:14:21

  • Status changed: Verified

@mrclay mrclay closed this as completed Sep 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant