On Thu, Mar 13, 2008 at 10:18 AM, Chris Chabot <[EMAIL PROTECTED]> wrote:

> > If you look in our pom.xml, you'll see we have to bypass compression for
> > several files because of yuicompressor's buggy output.
>
>
> caja, opensocial-samplecontainer and syndicator ... for all intents and
> purposes that shouldn't affect me since the PHP version doesn't caja at
> all, and my current thought was to only compress things called
> thru /js/libs:stuff.js and inlined javascript in the gadget, which
> excludes both the sample container and syndicator.js that the mvn build
> process does pick up, so i should be quite safe there :)


Agreed, although I worry about it biting us in the future.

> How would you do this on the fly? Invoking yuicompressor, or using
> something
> > less powerful?
>
>
>
>
> Basicly (in semi-pseudo code) it would mean doing something like:
>
> $out = tempnam('/tmp','compressout');
> if (!$config['debug']) {
>        if (we can't retrieve the cached compressed version) {
>                @exec("java -jar {$path_to}/yuicompressor-2.2.5.jar -o $out
> --type js
> $feature_js_file");


It seems that you could  generalize this:

$input = escapeshellarg($feature_js_file);
$output = escapeshellarg($out_file);
exec(sprintf($command, $input, $output), null, $status);
if ($status === 0) {
  // successfully compressed.
  $minified = file_get_contents($out_file);
}

where $command looks like:

"java -jar yuicompressor-2.2.5.jar -o %2 -type js %1"

by default.

-- 
~Kevin

Reply via email to