Changeset 1175


Ignore:
Timestamp:
03/20/09 13:07:59 (5 years ago)
Author:
ray
Message:

updated compression script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/contrib/compress_yui.php

    r1152 r1175  
    22// This is script that uses the YUI compressor (http://www.julienlecomte.net/blog/2007/08/11/) 
    33// It yields gradually better results than the dojo comressor, but it produces unreadable code 
    4 die("Run this script to batch-compress the current Xinha snapshot. To run the script, open the file and comment out the die() command"); 
     4//die("Run this script to batch-compress the current Xinha snapshot. To run the script, open the file and comment out the die() command"); 
     5 
     6$repository_url = 'http://svn.xinha.org/trunk'; 
     7$version =''; 
     8$date = date('r'); 
     9 
     10$xinha_root = realpath(dirname(__FILE__).'/..'); 
    511 
    612error_reporting(E_ALL); 
     
    4854        return $files; 
    4955} 
    50 scan("../",0); 
    51 $cwd = getcwd(); 
     56 
     57scan($xinha_root,0); 
     58 
    5259print "Processing ".count($return)." files<br />"; 
    5360 
    54 $prefix = "/* This compressed file is part of Xinha. For uncomressed sources, forum, and bug reports, go to xinha.org */"; 
     61$prefix = "/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */"; 
     62if ($version) $prefix .= "\n/* This file is part of version $version released $date */"; 
    5563$core_prefix = ' 
    5664  /*-------------------------------------------------------------------------- 
     
    6068    --  BSD license)  please read license.txt in this package for details. 
    6169    -- 
    62     --  Copyright (c) 2005-2009 Xinha Developer Team and contributors 
     70    --  Copyright (c) 2005-'.date('Y').' Xinha Developer Team and contributors 
    6371    --   
    6472    --  Xinha was originally based on work by Mihai Bazon which is: 
     
    7280{ 
    7381        set_time_limit ( 60 );  
    74         print "Processing $file<br />"; 
     82        print "Processing $file\n"; 
    7583        flush(); 
     84         
     85        $file_url = $repository_url.str_replace($xinha_root,'',$file); 
     86 
     87        copy($file,$file."_uncompr.js"); 
     88         
     89        $file_prefix = $prefix."\n/* The URL of the most recent uncompressed version of this file is $file_url */"; 
    7690        $ext = preg_replace('/.*?(\.js|\.css)$/','$1',$file); 
    7791         
    7892        file_put_contents($file."_uncompr${ext}", preg_replace('/(\/\/[^\n]*)?(?![*])\\\[\n]/','',file_get_contents($file))); 
    7993 
    80         passthru("echo \"".(preg_match('/XinhaCore.js$/',$file) ? $prefix.$core_prefix : $prefix)."\" > $file && java -jar ${cwd}/yuicompressor-2.4.2.jar  --charset UTF-8 ${file}_uncompr${ext} >> $file 2>&1"); 
     94        passthru("echo \"".(preg_match('/XinhaCore.js$/',$file) ? $file_prefix.$core_prefix : $prefix)."\" > $file && java -jar {$xinha_root}/contrib/yuicompressor-2.4.2.jar  --charset UTF-8 ${file}_uncompr${ext} >> $file 2>&1"); 
    8195        if (preg_match('/\d+:\d+:syntax error/',file_get_contents($file))) 
    8296        { 
Note: See TracChangeset for help on using the changeset viewer.