Diglin_UIOptimization - Version 1.4.0

Version Notes

- Version 1.4.0: Move themes files to the folder app/design/frontend/base/default, update yuicompressor to version 2.4.7, generate css/js file per store and not globally
- Version 1.3.1: fix Paypal donation button
- Version 1.3.0: improve canonical url generation, improve some configuration parameters, remove the option JS Packer because incompatible with Magento
- Version 1.2.0: improve compatibility with compilation feature of Magento, add a js/css flush button directly in the configuration page
- Version 1.1.0: rewrite some classes of the minify libraries to respect PHP 5 and prevent some errors, change the module name, make it compatible with compilation feature of Magento, add canonical url feature for SEO
- Version 1.0.10: fix type for css files stored in /js/ folder
- Version 1.0.9: make correct package for Magento prior to 1.5
- Version 1.0.8: make it compatible with 1.5 and some improvements.
- Version 1.0.2: add cron task to allow to update compressed/minified js/css files periodically
- Version 1.0.1: fix a missing config element class, this class seems to exists only since 1.4.1 or more

Download this release

Release Info

Developer Magento Core Team
Extension Diglin_UIOptimization
Version 1.4.0
Comparing to
See all releases


Code changes from version 1.3.0 to 1.4.0

Files changed (104) hide show
  1. app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Hint.php +2 -3
  2. app/code/community/Diglin/UIOptimization/Block/Optimize/Head.php +3 -3
  3. app/code/community/Diglin/UIOptimization/Helper/Data.php +13 -12
  4. app/code/community/Diglin/UIOptimization/etc/config.xml +1 -1
  5. app/design/frontend/{default → base}/default/layout/uioptimization.xml +0 -0
  6. app/design/frontend/{default → base}/default/template/uioptimization/canonicalurl.phtml +23 -23
  7. app/design/frontend/{default → base}/default/template/uioptimization/w3ccssvalidator.phtml +0 -0
  8. app/design/frontend/{default → base}/default/template/uioptimization/w3chtmlvalidator.phtml +0 -0
  9. lib/Diglin/.DS_Store +0 -0
  10. lib/Diglin/yuicompressor-2.4.6/LICENSE.TXT +0 -54
  11. lib/Diglin/yuicompressor-2.4.6/ant.properties +0 -8
  12. lib/Diglin/yuicompressor-2.4.6/build.xml +0 -69
  13. lib/Diglin/yuicompressor-2.4.6/doc/CHANGELOG +0 -257
  14. lib/Diglin/yuicompressor-2.4.6/doc/README +0 -145
  15. lib/Diglin/yuicompressor-2.4.6/lib/jargs-1.0.jar +0 -0
  16. lib/Diglin/yuicompressor-2.4.6/ports/js/cssmin.js +0 -231
  17. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/Bootstrap.java +0 -23
  18. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/CssCompressor.java +0 -304
  19. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JarClassLoader.java +0 -158
  20. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java +0 -1317
  21. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JavaScriptIdentifier.java +0 -55
  22. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JavaScriptToken.java +0 -28
  23. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java +0 -160
  24. lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/YUICompressor.java +0 -255
  25. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Decompiler.java +0 -908
  26. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Decompiler.java.orig +0 -910
  27. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Parser.java +0 -2160
  28. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Parser.java.orig +0 -2159
  29. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Token.java +0 -406
  30. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/Token.java.orig +0 -417
  31. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/TokenStream.java +0 -1365
  32. lib/Diglin/yuicompressor-2.4.6/src/org/mozilla/javascript/TokenStream.java.orig +0 -1398
  33. lib/Diglin/yuicompressor-2.4.6/tests/README +0 -6
  34. lib/Diglin/yuicompressor-2.4.6/tests/_munge.js +0 -8
  35. lib/Diglin/yuicompressor-2.4.6/tests/_munge.js.min +0 -1
  36. lib/Diglin/yuicompressor-2.4.6/tests/_string_combo.js +0 -5
  37. lib/Diglin/yuicompressor-2.4.6/tests/_string_combo.js.min +0 -1
  38. lib/Diglin/yuicompressor-2.4.6/tests/_syntax_error.js +0 -73
  39. lib/Diglin/yuicompressor-2.4.6/tests/_syntax_error.js.min +0 -1
  40. lib/Diglin/yuicompressor-2.4.6/tests/background-position.css +0 -2
  41. lib/Diglin/yuicompressor-2.4.6/tests/background-position.css.min +0 -1
  42. lib/Diglin/yuicompressor-2.4.6/tests/border-none.css +0 -5
  43. lib/Diglin/yuicompressor-2.4.6/tests/border-none.css.min +0 -1
  44. lib/Diglin/yuicompressor-2.4.6/tests/box-model-hack.css +0 -9
  45. lib/Diglin/yuicompressor-2.4.6/tests/box-model-hack.css.min +0 -1
  46. lib/Diglin/yuicompressor-2.4.6/tests/bug2527974.css +0 -10
  47. lib/Diglin/yuicompressor-2.4.6/tests/bug2527974.css.min +0 -1
  48. lib/Diglin/yuicompressor-2.4.6/tests/bug2527991.css +0 -19
  49. lib/Diglin/yuicompressor-2.4.6/tests/bug2527991.css.min +0 -1
  50. lib/Diglin/yuicompressor-2.4.6/tests/bug2527998.css +0 -4
  51. lib/Diglin/yuicompressor-2.4.6/tests/bug2527998.css.min +0 -1
  52. lib/Diglin/yuicompressor-2.4.6/tests/bug2528034.css +0 -5
  53. lib/Diglin/yuicompressor-2.4.6/tests/bug2528034.css.min +0 -1
  54. lib/Diglin/yuicompressor-2.4.6/tests/charset-media.css +0 -9
  55. lib/Diglin/yuicompressor-2.4.6/tests/charset-media.css.min +0 -1
  56. lib/Diglin/yuicompressor-2.4.6/tests/color.css +0 -7
  57. lib/Diglin/yuicompressor-2.4.6/tests/color.css.min +0 -1
  58. lib/Diglin/yuicompressor-2.4.6/tests/comment.css +0 -3
  59. lib/Diglin/yuicompressor-2.4.6/tests/comment.css.min +0 -1
  60. lib/Diglin/yuicompressor-2.4.6/tests/concat-charset.css +0 -15
  61. lib/Diglin/yuicompressor-2.4.6/tests/concat-charset.css.min +0 -1
  62. lib/Diglin/yuicompressor-2.4.6/tests/decimals.css +0 -3
  63. lib/Diglin/yuicompressor-2.4.6/tests/decimals.css.min +0 -1
  64. lib/Diglin/yuicompressor-2.4.6/tests/dollar-header.css +0 -7
  65. lib/Diglin/yuicompressor-2.4.6/tests/dollar-header.css.min +0 -3
  66. lib/Diglin/yuicompressor-2.4.6/tests/float.js +0 -2
  67. lib/Diglin/yuicompressor-2.4.6/tests/float.js.min +0 -1
  68. lib/Diglin/yuicompressor-2.4.6/tests/font-face.css +0 -6
  69. lib/Diglin/yuicompressor-2.4.6/tests/font-face.css.min +0 -1
  70. lib/Diglin/yuicompressor-2.4.6/tests/ie5mac.css +0 -5
  71. lib/Diglin/yuicompressor-2.4.6/tests/ie5mac.css.min +0 -1
  72. lib/Diglin/yuicompressor-2.4.6/tests/media-empty-class.css +0 -16
  73. lib/Diglin/yuicompressor-2.4.6/tests/media-empty-class.css.min +0 -1
  74. lib/Diglin/yuicompressor-2.4.6/tests/media-multi.css +0 -3
  75. lib/Diglin/yuicompressor-2.4.6/tests/media-multi.css.min +0 -1
  76. lib/Diglin/yuicompressor-2.4.6/tests/media-test.css +0 -3
  77. lib/Diglin/yuicompressor-2.4.6/tests/media-test.css.min +0 -1
  78. lib/Diglin/yuicompressor-2.4.6/tests/opacity-filter.css +0 -14
  79. lib/Diglin/yuicompressor-2.4.6/tests/opacity-filter.css.min +0 -1
  80. lib/Diglin/yuicompressor-2.4.6/tests/preserve-new-line.css +0 -6
  81. lib/Diglin/yuicompressor-2.4.6/tests/preserve-new-line.css.min +0 -3
  82. lib/Diglin/yuicompressor-2.4.6/tests/preserve-strings.css +0 -7
  83. lib/Diglin/yuicompressor-2.4.6/tests/preserve-strings.css.min +0 -1
  84. lib/Diglin/yuicompressor-2.4.6/tests/pseudo-first.css +0 -16
  85. lib/Diglin/yuicompressor-2.4.6/tests/pseudo-first.css.min +0 -1
  86. lib/Diglin/yuicompressor-2.4.6/tests/pseudo.css +0 -4
  87. lib/Diglin/yuicompressor-2.4.6/tests/pseudo.css.min +0 -1
  88. lib/Diglin/yuicompressor-2.4.6/tests/special-comments.css +0 -13
  89. lib/Diglin/yuicompressor-2.4.6/tests/special-comments.css.min +0 -9
  90. lib/Diglin/yuicompressor-2.4.6/tests/star-underscore-hacks.css +0 -5
  91. lib/Diglin/yuicompressor-2.4.6/tests/star-underscore-hacks.css.min +0 -1
  92. lib/Diglin/yuicompressor-2.4.6/tests/string-in-comment.css +0 -8
  93. lib/Diglin/yuicompressor-2.4.6/tests/string-in-comment.css.min +0 -1
  94. lib/Diglin/yuicompressor-2.4.6/tests/suite.rhino +0 -3
  95. lib/Diglin/yuicompressor-2.4.6/tests/suite.sh +0 -62
  96. lib/Diglin/yuicompressor-2.4.6/tests/webkit-transform.css +0 -2
  97. lib/Diglin/yuicompressor-2.4.6/tests/webkit-transform.css.min +0 -1
  98. lib/Diglin/yuicompressor-2.4.6/tests/zeros.css +0 -6
  99. lib/Diglin/yuicompressor-2.4.6/tests/zeros.css.min +0 -1
  100. lib/Diglin/yuicompressor/.DS_Store +0 -0
  101. lib/Diglin/{yuicompressor-2.4.6/build/yuicompressor-2.4.6.jar → yuicompressor/yuicompressor-2.4.7.jar} +0 -0
  102. lib/Diglin/{yuicompressor-2.4.6/lib/rhino-1.6R7.jar → yuicompressor/yuicompressor.jar} +0 -0
  103. package.xml +7 -5
  104. skin/frontend/{default → base}/default/css/w3c-validator.css +0 -0
app/code/community/Diglin/UIOptimization/Block/Adminhtml/Config/Source/Hint.php CHANGED
@@ -35,9 +35,8 @@ class Diglin_UIOptimization_Block_Adminhtml_Config_Source_Hint
35
'label' => Mage::helper('adminhtml')->__('Flush JavaScript/CSS Cache'),
36
'onclick' => "setLocation('" . $this->getUrl('*/cache/cleanMedia') ."');",
37
));
38
-
39
- return '<p><form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input name="cmd" type="hidden" value="_s-xclick" /> <input name="hosted_button_id" type="hidden" value="9SFPE62WPWG2U" /> <input alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" type="image" /> <img src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" border="0" alt="" width="1" height="1" /> </form>Please, Invite me for a drink for the hard work done. Thank you in advance for your donation</p>
40
<p><strong>Diglin_UIOptimization Version: '.$version.'</strong></p><p>' . $block->toHtml() .' ('. $this->__('You will be redirected to the Cache Management page with a successful message') .')</p>';
41
-
42
}
43
}
35
'label' => Mage::helper('adminhtml')->__('Flush JavaScript/CSS Cache'),
36
'onclick' => "setLocation('" . $this->getUrl('*/cache/cleanMedia') ."');",
37
));
38
+
39
+ return '<p><a href="javascript:window.open(\'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y66QHLU5VX5BC\')"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" alt="Donate via Paypal" /> </a>Please, Invite me for a drink for the hard work done. Thank you in advance for your donation</p>
40
<p><strong>Diglin_UIOptimization Version: '.$version.'</strong></p><p>' . $block->toHtml() .' ('. $this->__('You will be redirected to the Cache Management page with a successful message') .')</p>';
41
}
42
}
app/code/community/Diglin/UIOptimization/Block/Optimize/Head.php CHANGED
@@ -106,7 +106,7 @@ class Diglin_UIOptimization_Block_Optimize_Head extends Mage_Page_Block_Html_Hea
106
$minifier = 'Diglin_Minify_YUICompressor';
107
$method = 'minifyCss';
108
// init Minify class with YUI Compressor
109
- Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS . 'yuicompressor-2.4.6' . DS . 'build' . DS . 'yuicompressor-2.4.6.jar' ;
110
Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
111
if(strlen($config['java_path']) > 0){
112
Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
@@ -206,7 +206,7 @@ class Diglin_UIOptimization_Block_Optimize_Head extends Mage_Page_Block_Html_Hea
206
case 'yuicompressor':
207
$minifier = 'Diglin_Minify_YUICompressor';
208
$method = 'minifyJs';
209
- Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS .'yuicompressor-2.4.6' . DS . 'build' . DS . 'yuicompressor-2.4.6.jar' ;
210
Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
211
if(strlen($config['java_path']) > 0){
212
Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
@@ -366,4 +366,4 @@ class Diglin_UIOptimization_Block_Optimize_Head extends Mage_Page_Block_Html_Hea
366
}
367
return $this->_data['urlKey'];
368
}
369
- }
106
$minifier = 'Diglin_Minify_YUICompressor';
107
$method = 'minifyCss';
108
// init Minify class with YUI Compressor
109
+ Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS . 'yuicompressor' . DS . 'yuicompressor.jar' ;
110
Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
111
if(strlen($config['java_path']) > 0){
112
Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
206
case 'yuicompressor':
207
$minifier = 'Diglin_Minify_YUICompressor';
208
$method = 'minifyJs';
209
+ Diglin_Minify_YUICompressor::$jarFile = Mage::getBaseDir('lib') . DS . 'Diglin' . DS .'yuicompressor' . DS . 'yuicompressor.jar' ;
210
Diglin_Minify_YUICompressor::$tempDir = Mage::getBaseDir('tmp');
211
if(strlen($config['java_path']) > 0){
212
Diglin_Minify_YUICompressor::$javaExecutable = $config['java_path'];
366
}
367
return $this->_data['urlKey'];
368
}
369
+ }
app/code/community/Diglin/UIOptimization/Helper/Data.php CHANGED
@@ -19,7 +19,7 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract
19
{
20
/**
21
* Retreive some basic information depending on the type of file: original path, destination path, type, name, static
22
- *
23
* @param string $name
24
* @param string $type
25
* @param bool $static
@@ -29,23 +29,24 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract
29
{
30
$info = array();
31
$designPackage = Mage::getDesign();
32
-
33
$orgname = $name;
34
if(!$static){
35
$info['orgskin_path'] = $designPackage->getFilename ( $orgname, array ('_type' => 'skin' ) );
36
}else{
37
$info['orgskin_path'] = Mage::getBaseDir() . DS . 'js'. DS . $name;
38
}
39
-
40
$orgpath = explode ( DS, $info['orgskin_path'] );
41
if (count ( $orgpath ) > 1 && !$static) {
42
// Get the theme of the original file
43
$info['theme_name'] = $orgpath [count ( $orgpath ) - (count ( explode ( '/', $orgname ) ) + 1)];
44
}
45
$suffixFilename = (Mage::app()->getStore()->isCurrentlySecure())?'-ssl':'';
46
$name = substr ( $name, 0, strpos($name, '.' . $type) );
47
$name = $name . $suffixFilename .'_cp.'.$type;
48
-
49
$file_path = explode('/', $name);
50
if(count($file_path) > 1){
51
$name = array_pop($file_path);
@@ -58,30 +59,30 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract
58
$info['new_name'] = $name;
59
$info['type'] = $type;
60
$info['static'] = $static;
61
-
62
$targetDir = $this->initMergerDir ( $type );
63
if (! $targetDir) {
64
$info['success'] = false;
65
return $info;
66
}
67
-
68
if(!$static){
69
$info['targetPath'] = $targetDir . DS . 'skin' . DS . $info['theme_name'] . DS . $info['file_path'];
70
}else{
71
$info['targetPath'] = $targetDir . DS . $info['file_path'];
72
}
73
$info['targetPathFile'] = $info['targetPath'] . DS . $name;
74
-
75
if(!file_exists($info['targetPath'])){
76
$ioFile = new Diglin_Io_File();
77
$ioFile->mkdir($info['targetPath'], 0755, true);
78
}
79
-
80
return $info;
81
}
82
/**
83
* Provide the path URL of the filesystem for js or css files compressed or not
84
- *
85
* @param array $info
86
* @param string|array $mergeCallback
87
* @return string
@@ -105,7 +106,7 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract
105
}
106
}
107
}
108
-
109
/**
110
* Make sure merger dir exists and writeable
111
* Also can clean it up
@@ -131,10 +132,10 @@ class Diglin_UIOptimization_Helper_Data extends Mage_Core_Helper_Abstract
131
}
132
return false;
133
}
134
-
135
/**
136
* Add trailing slash if necessary
137
- *
138
* @param string $url
139
*/
140
public function getTrailingSlash ($url)
19
{
20
/**
21
* Retreive some basic information depending on the type of file: original path, destination path, type, name, static
22
+ *
23
* @param string $name
24
* @param string $type
25
* @param bool $static
29
{
30
$info = array();
31
$designPackage = Mage::getDesign();
32
+
33
$orgname = $name;
34
if(!$static){
35
$info['orgskin_path'] = $designPackage->getFilename ( $orgname, array ('_type' => 'skin' ) );
36
}else{
37
$info['orgskin_path'] = Mage::getBaseDir() . DS . 'js'. DS . $name;
38
}
39
+
40
$orgpath = explode ( DS, $info['orgskin_path'] );
41
if (count ( $orgpath ) > 1 && !$static) {
42
// Get the theme of the original file
43
$info['theme_name'] = $orgpath [count ( $orgpath ) - (count ( explode ( '/', $orgname ) ) + 1)];
44
}
45
$suffixFilename = (Mage::app()->getStore()->isCurrentlySecure())?'-ssl':'';
46
+ $suffixFilename.= '_'.Mage::app()->getStore()->getId();
47
$name = substr ( $name, 0, strpos($name, '.' . $type) );
48
$name = $name . $suffixFilename .'_cp.'.$type;
49
+
50
$file_path = explode('/', $name);
51
if(count($file_path) > 1){
52
$name = array_pop($file_path);
59
$info['new_name'] = $name;
60
$info['type'] = $type;
61
$info['static'] = $static;
62
+
63
$targetDir = $this->initMergerDir ( $type );
64
if (! $targetDir) {
65
$info['success'] = false;
66
return $info;
67
}
68
+
69
if(!$static){
70
$info['targetPath'] = $targetDir . DS . 'skin' . DS . $info['theme_name'] . DS . $info['file_path'];
71
}else{
72
$info['targetPath'] = $targetDir . DS . $info['file_path'];
73
}
74
$info['targetPathFile'] = $info['targetPath'] . DS . $name;
75
+
76
if(!file_exists($info['targetPath'])){
77
$ioFile = new Diglin_Io_File();
78
$ioFile->mkdir($info['targetPath'], 0755, true);
79
}
80
+
81
return $info;
82
}
83
/**
84
* Provide the path URL of the filesystem for js or css files compressed or not
85
+ *
86
* @param array $info
87
* @param string|array $mergeCallback
88
* @return string
106
}
107
}
108
}
109
+
110
/**
111
* Make sure merger dir exists and writeable
112
* Also can clean it up
132
}
133
return false;
134
}
135
+
136
/**
137
* Add trailing slash if necessary
138
+ *
139
* @param string $url
140
*/
141
public function getTrailingSlash ($url)
app/code/community/Diglin/UIOptimization/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
<config>
3
<modules>
4
<Diglin_UIOptimization>
5
- <version>1.3.0</version>
6
</Diglin_UIOptimization>
7
</modules>
8
2
<config>
3
<modules>
4
<Diglin_UIOptimization>
5
+ <version>1.4.0</version>
6
</Diglin_UIOptimization>
7
</modules>
8
app/design/frontend/{default → base}/default/layout/uioptimization.xml RENAMED
File without changes
app/design/frontend/{default → base}/default/template/uioptimization/canonicalurl.phtml RENAMED
@@ -1,24 +1,24 @@
1
- <?php
2
- /**
3
- * Diglin
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- *
12
- *
13
- * @category Diglin
14
- * @package Diglin_UIOptimization
15
- * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
- */
18
-
19
- /*@var $this Rissip_UIOptimization_Block_Optimize_Head */
20
- $canonicalUrl = htmlspecialchars($this->getCanonicalUrl());
21
- if(Mage::getStoreConfigFlag('uioptimization/seo/enabled') && $canonicalUrl) :
22
- ?>
23
- <link rel="canonical" href="<?php echo $canonicalUrl; ?>" />
24
<?php endif; ?>
1
+ <?php
2
+ /**
3
+ * Diglin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ *
13
+ * @category Diglin
14
+ * @package Diglin_UIOptimization
15
+ * @copyright Copyright (c) 2011-2012 Diglin (http://www.diglin.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /*@var $this Rissip_UIOptimization_Block_Optimize_Head */
20
+ $canonicalUrl = htmlspecialchars($this->getCanonicalUrl());
21
+ if(Mage::getStoreConfigFlag('uioptimization/seo/enabled') && $canonicalUrl) :
22
+ ?>
23
+ <link rel="canonical" href="<?php echo $canonicalUrl; ?>" />
24
<?php endif; ?>
app/design/frontend/{default → base}/default/template/uioptimization/w3ccssvalidator.phtml RENAMED
File without changes
app/design/frontend/{default → base}/default/template/uioptimization/w3chtmlvalidator.phtml RENAMED
File without changes
lib/Diglin/.DS_Store ADDED
Binary file
lib/Diglin/yuicompressor-2.4.6/LICENSE.TXT DELETED
@@ -1,54 +0,0 @@
1
- YUI Compressor Copyright License Agreement (BSD License)
2
-
3
- Copyright (c) 2010, Yahoo! Inc.
4
- All rights reserved.
5
-
6
- Redistribution and use of this software in source and binary forms,
7
- with or without modification, are permitted provided that the following
8
- conditions are met:
9
-
10
- * Redistributions of source code must retain the above
11
- copyright notice, this list of conditions and the
12
- following disclaimer.
13
-
14
- * Redistributions in binary form must reproduce the above
15
- copyright notice, this list of conditions and the
16
- following disclaimer in the documentation and/or other
17
- materials provided with the distribution.
18
-
19
- * Neither the name of Yahoo! Inc. nor the names of its
20
- contributors may be used to endorse or promote products
21
- derived from this software without specific prior
22
- written permission of Yahoo! Inc.
23
-
24
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
-
35
- This software also requires access to software from the following sources:
36
-
37
- The Jarg Library v 1.0 ( http://jargs.sourceforge.net/ ) is available
38
- under a BSD License � Copyright (c) 2001-2003 Steve Purcell,
39
- Copyright (c) 2002 Vidar Holen, Copyright (c) 2002 Michal Ceresna and
40
- Copyright (c) 2005 Ewan Mellor.
41
-
42
- The Rhino Library ( http://www.mozilla.org/rhino/ ) is dually available
43
- under an MPL 1.1/GPL 2.0 license, with portions subject to a BSD license.
44
-
45
- Additionally, this software contains modified versions of the following
46
- component files from the Rhino Library:
47
-
48
- [org/mozilla/javascript/Decompiler.java]
49
- [org/mozilla/javascript/Parser.java]
50
- [org/mozilla/javascript/Token.java]
51
- [org/mozilla/javascript/TokenStream.java]
52
-
53
- The modified versions of these files are distributed under the MPL v 1.1
54
- ( http://www.mozilla.org/MPL/MPL-1.1.html )
lib/Diglin/yuicompressor-2.4.6/ant.properties DELETED
@@ -1,8 +0,0 @@
1
- src.dir = src
2
- lib.dir = lib
3
- doc.dir = doc
4
- build.dir = build
5
- product.name = yuicompressor
6
- version.number = 2.4.6
7
- jar.name = ${product.name}-${version.number}.jar
8
- dist.package.name = ${product.name}-${version.number}
lib/Diglin/yuicompressor-2.4.6/build.xml DELETED
@@ -1,69 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <project name="YUI Compressor" default="build.jar" basedir=".">
3
-
4
- <target name="clean" depends="-load.properties">
5
- <delete dir="${build.dir}" quiet="true"/>
6
- </target>
7
-
8
- <target name="-load.properties">
9
- <property file="ant.properties"/>
10
- </target>
11
-
12
- <target name="-init" depends="-load.properties">
13
- <mkdir dir="${build.dir}"/>
14
- </target>
15
-
16
- <target name="build.classes" depends="-init">
17
- <mkdir dir="${build.dir}/classes"/>
18
- <javac srcdir="${src.dir}"
19
- destdir="${build.dir}/classes"
20
- includes="**/*.java"
21
- deprecation="off"
22
- debug="on"
23
- source="1.4">
24
- <classpath>
25
- <pathelement location="${lib.dir}/jargs-1.0.jar"/>
26
- <pathelement location="${lib.dir}/rhino-1.6R7.jar"/>
27
- </classpath>
28
- </javac>
29
- </target>
30
-
31
- <target name="build.jar" depends="build.classes">
32
- <mkdir dir="${build.dir}/jar"/>
33
- <!-- The order is important here. Rhino MUST be unjarred first!
34
- (some of our own classes will override the Rhino classes) -->
35
- <unjar src="${lib.dir}/jargs-1.0.jar" dest="${build.dir}/jar"/>
36
- <unjar src="${lib.dir}/rhino-1.6R7.jar" dest="${build.dir}/jar"/>
37
- <copy todir="${build.dir}/jar">
38
- <fileset dir="${build.dir}/classes" includes="**/*.class"/>
39
- </copy>
40
- <jar destfile="${build.dir}/${jar.name}" basedir="${build.dir}/jar">
41
- <manifest>
42
- <attribute name="Main-Class" value="com.yahoo.platform.yui.compressor.Bootstrap"/>
43
- </manifest>
44
- </jar>
45
- </target>
46
-
47
- <target name="build.dist.package" depends="build.jar">
48
- <mkdir dir="${build.dir}/${dist.package.name}"/>
49
- <mkdir dir="${build.dir}/${dist.package.name}/build"/>
50
- <copy file="${build.dir}/${jar.name}" todir="${build.dir}/${dist.package.name}/build"/>
51
- <copy todir="${build.dir}/${dist.package.name}">
52
- <fileset dir=".">
53
- <include name="ant.properties"/>
54
- <include name="build.xml"/>
55
- <include name="LICENSE.TXT"/>
56
- <include name="doc/**/*"/>
57
- <include name="lib/**/*"/>
58
- <include name="ports/**/*"/>
59
- <include name="src/**/*"/>
60
- <include name="tests/**/*"/>
61
- <exclude name="**/.git"/>
62
- </fileset>
63
- </copy>
64
- <zip destfile="${build.dir}/${dist.package.name}.zip"
65
- basedir="${build.dir}"
66
- includes="${dist.package.name}/**/*"/>
67
- </target>
68
-
69
- </project>
lib/Diglin/yuicompressor-2.4.6/doc/CHANGELOG DELETED
@@ -1,257 +0,0 @@
1
- YUI Compressor 2.4.6, 2011-04-15
2
- -------------------------------
3
- + Show usage information when started without arguments.
4
-
5
- YUI Compressor 2.4.5, 2011-03-13
6
- -------------------------------
7
- + Default file encoding changed from system default to UTF-8.
8
- + Errors/messages/usage info all are sent to stderr.
9
- + Removed unnecessary warning about short undeclared global symbols.
10
- + Added support for processing multiple files with a single invokation
11
- + $ in CSS files doesn't throw exceptions
12
- + white space in ! important comments preserved in CSS
13
- + fix in greedy empty CSS declaration blocks removal
14
- + safe handling of strings and comments in CSS files
15
- + shorter alpha opacity CSS filers
16
- + shorter Mac/IE5 hack -> /*\*/ hack {mac: 1} /**/
17
- + JS port of the CSS minifier
18
- + safe @media queries handling
19
- + stripping the trailing ; in CSS declaration blocks
20
- + shorter border:none->0 where applicable
21
- + fixed transform-origin: 0 0 [bug 2528060]
22
- + tests++
23
-
24
- YUI Compressor 2.4.4, 2010-10-20
25
- + Interim 2.4.5 release
26
-
27
- YUI Compressor 2.4.3, 2009-12-07
28
- -------------------------------
29
- + Changed custodian to ci-tools@
30
-
31
-
32
- YUI Compressor 2.4.2, 2008-11-10
33
- --------------------------------
34
- + Preserved comments shouldn't prevent obfuscation (Thanks to Matjaz Lipus)
35
-
36
-
37
- YUI Compressor 2.4.1, 2008-10-28
38
- --------------------------------
39
-
40
- + Use preferentially lower case letters for obfuscated variable names.
41
- Since JavaScript keywords use lower case letters most often, this
42
- improves the efficiency of any compression algorithm (gzipping)
43
- used after minification.
44
- + Don't append a semi-colon at the end of a JavaScript file when the
45
- last token is a special comment.
46
-
47
- YUI Compressor 2.4, 2008-10-21
48
- ------------------------------
49
-
50
- + Allowed the YUI Compressor (which uses a modified version of Rhino)
51
- to work alongside the original (unmodified) rhino library by using
52
- a custom class loader.
53
- + Added all that's necessary to build the YUI Compressor to the
54
- downloable package.
55
- + Fixed unnecessary white space after return / typeof when possible.
56
-
57
- YUI Compressor 2.3.6, 2008-07-10
58
- --------------------------------
59
-
60
- + Fixed a few minor bugs with the CSS compressor
61
- + Changed packaging. The original Rhino library, which is used to build the
62
- YUI Compressor, is not part of the downloadable archive. Too many people
63
- put it in their classpath, generating a lot of invalid bugs.
64
-
65
- YUI Compressor 2.3.5, 2008-02-08
66
- --------------------------------
67
-
68
- + Added a warning when more than one 'var' statement is used in a single scope.
69
- Automatic coalescence is extremely complicated, and would be unsafe if not
70
- done properly.
71
-
72
- YUI Compressor 2.3.4, 2008-02-07
73
- --------------------------------
74
-
75
- + Expanded the list of reserved words used by isValidIdentifier()
76
-
77
- YUI Compressor 2.3.3, 2008-02-04
78
- --------------------------------
79
-
80
- + C-style comments starting with /*! are preserved. This is especially
81
- useful with comments containing copyright/license information.
82
-
83
- YUI Compressor 2.3.2, 2008-02-01
84
- --------------------------------
85
-
86
- + Compressing an empty JS file throws an error [SourceForge bug #1884207]
87
- + When a string is the first token in a function body, it was removed from
88
- the compressed file [SourceForge bug #1884314]
89
-
90
- YUI Compressor 2.3.1, 2008-01-30
91
- --------------------------------
92
-
93
- + Added test against list of reserved words in method isValidIdentifier.
94
-
95
- YUI Compressor 2.3, 2008-01-28
96
- ------------------------------
97
-
98
- + Always output a ';' at the end of a minified JavaScript file. This allows
99
- the concatenating of several minified files without the fear of introducing
100
- a syntax error.
101
- + Removed all System.exit() statements. Throw exceptions instead. This is
102
- especially useful when running the compressor from within a J2EE container.
103
- [SourceForge bug #1834750]
104
- + Transform obj["foo"] into obj.foo whenever possible, saving 3 bytes.
105
- + Transform 'foo': ... into foo: ... whenever possible, saving 2 bytes.
106
- + Added support for multi-line string literals [SourceForge bug #1871453]
107
- + Added support for unescaped slashes inside character classes in regexp.
108
- + Minor performance improvements.
109
- + Preserve the escaping for an octal representation of a character in string
110
- literals [SourceForge bug #1844894]
111
-
112
- var a = '\001';
113
-
114
- + CSS: Preserve comments that hide CSS rules from IE Mac:
115
-
116
- /* Hides from IE-mac \*/
117
- ...
118
- /* End hide from IE-mac */
119
-
120
- + CSS: Added support for box model hack [SourceForge bug #1862107]
121
-
122
- div.content {
123
- width:400px;
124
- voice-family: "\"}\"";
125
- voice-family:inherit;
126
- width:300px;
127
- }
128
-
129
- YUI Compressor 2.2.5, 2007-10-09
130
- --------------------------------
131
-
132
- + Remove line terminator after escape in string literals.
133
-
134
- YUI Compressor 2.2.4, 2007-10-01
135
- --------------------------------
136
-
137
- + Fixed the way quote characters are counted in string literals
138
- [SourceForge bug #1804576]
139
- + Do not use a regular expression using non-greedy matching to remove CSS
140
- comments (if the comment is more than 800 characters long or so, a stack
141
- overflow exception gets thrown) Instead, use good old parsing...
142
- + Fix unnecessary quote escaping in string literals.
143
-
144
- YUI Compressor 2.2.3, 2007-09-28
145
- --------------------------------
146
-
147
- + Transform </script into <\/script instead of replacing all </ into <\/.
148
- + Fixed bug related to the shortening of hexadecimal color codes (the string
149
- "1px solid #aabbcc" became "1px solid#abc", missing a required white space)
150
- + Added --preserve-strings option to specify that concatenated string literals
151
- should never be merged.
152
- + Do not convert \uXXXX and \xXX escape sequences to their unicode equivalent.
153
-
154
- YUI Compressor 2.2.2, 2007-09-27
155
- --------------------------------
156
-
157
- + Fixed regression related to the optimization of the amount of escaping
158
- in string literals and the concatenation of string literals.
159
- + Modified the Rhino tokenizer to handle JScript conditional comments
160
- natively (instead of hacking around the fact that Rhino is not keeping
161
- track of comments)
162
- + Transform </ into <\/ in string literals. This is especially useful if the
163
- code is written to a script block in an HTML document. This renders the old
164
- hack '<scr'+'ipt ...><'+'/script>' completely useless.
165
- + When converting decimal rgb color values to hexadecimal color values,
166
- prepend a '0' if the value is less than 16. Otherwise, rgb(0,124,114)
167
- for instance becomes #07c72, which is incorrect.
168
- + In CSS files, do not change color names into their corresponding color
169
- codes (and vice-versa) due to the high potential of introducing bugs
170
- (rolled back from 2.2.1)
171
-
172
- YUI Compressor 2.2.1, 2007-09-25
173
- --------------------------------
174
-
175
- + Optimize quote escaping in JavaScript string literals by using the best quote
176
- character (' or " depending on the occurrence of this character in the string)
177
- + Fixed minor bug in the CSS compressor. Colors should not be shortened in
178
- filter: chroma(color="#FFFFFF");
179
- Otherwise, it makes the filter break in Internet Explorer.
180
- + In CSS files, change color names into their corresponding color codes
181
- (and vice-versa) if that change yields any savings.
182
-
183
- YUI Compressor 2.2, 2007-09-18
184
- ------------------------------
185
-
186
- + Don't obfuscate function argument named $super if it is the first function
187
- argument listed. This is to support Prototype 1.6's heretic implementation.
188
- + Added support for stdin/stdout (see README for more info)
189
- + Shorten colors from rgb(51,102,153) to #336699 in CSS files.
190
- + Shorten values from 0.8em to .8em in CSS files.
191
- + Added support for Internet Explorer's conditional comments in JavaScript
192
- files. Note that the presence of a conditional comment inside a function
193
- (i.e. not in the global scope) will reduce the level of compression for the
194
- same reason the use of 'eval' or 'with' reduces the level of compression
195
- (conditional comments, which do not get parsed, may refer to local variables,
196
- which get obfuscated) In any case, the use of Internet Explorer's conditional
197
- comment is to be avoided.
198
-
199
- YUI Compressor 2.1.2, 2007-08-31
200
- --------------------------------
201
-
202
- + Added --preserve-semi option
203
- + Modified --line-break option
204
-
205
- YUI Compressor 2.1.1, 2007-08-30
206
- --------------------------------
207
-
208
- + Fixed missing space in CSS background:url('foo.png')no-repeat
209
- causing a background not to appear on Internet Explorer.
210
-
211
- YUI Compressor 2.1, 2007-08-29
212
- ------------------------------
213
-
214
- + Pass the --line-break option to the CSS compressor.
215
- + Allow the output file to overwrite the input file (with version 2.0,
216
- in this case, the output file was always empty)
217
- + Remove spaces before and after '(' and ')' as in background:url('xxx');
218
- + Merge (if possible) string literals that are appended in JavaScript files.
219
- This not only makes the code smaller, it makes the code faster,
220
- but allows you to maintain some readability in your source code.
221
- + Handle constructs such as a + ++ b or a + + "1" (in which case the
222
- space between the operators must be kept!) and other similar cases...
223
- + Pass ErrorReporter instance to the constructor of class JavaScriptCompressor
224
- (as suggested by David Bernard for his integration of the YUI Compressor
225
- as a maven plugin)
226
-
227
- YUI Compressor 2.0, 2007-08-27
228
- ------------------------------
229
-
230
- + Switched from Rhino 1.6R6 to Rhino 1.6R7
231
- + Integrated Isaac Schlueter's CSS compressor.
232
- + Refactored code to make it easier to use the compressor from a servlet
233
- environment or another Java app (no need to pass in file names anymore)
234
- + Output a white-space character after 'throw' only when necessary.
235
- + Output a white-space character after 'break' and 'continue' when followed
236
- by a label.
237
-
238
- YUI Compressor 1.1, 2007-08-20
239
- ------------------------------
240
-
241
- + Java source now in package com.yahoo.platform.yui.compressor
242
- + Added --line-break option that adds a line feed character after each
243
- semi-colon character (may help debugging with the MS Script debugger)
244
- + Added support for missing JavaScript features (get, set, const)
245
- + Do not show the entire stack trace when the input file cannot be found.
246
- + Removed the randomization of obfuscated symbols. When compressed code is
247
- checked in CVS, unchanged files would otherwise end up being versioned.
248
- + Added web-based front-end to the YUI Compressor as part of the dist package.
249
- + Added a public entry point that makes the YUI Compressor easy to integrate
250
- with an already existing Java application.
251
- + Simplified code by using the same parsing routines used to build the symbol
252
- tree while looking for undeclared symbols.
253
- + Count how many times each identifier is used, and display a warning when an
254
- identifier seems to be unused (code cannot safely be removed automatically)
255
- + Remove ';' when followed by a '}'. This yields an additional ~1.5% savings
256
- on yahoo-dom-event.js compared to the JSMin version.
257
- + Output a white-space character after 'return' and 'case' only when necessary.
lib/Diglin/yuicompressor-2.4.6/doc/README DELETED
@@ -1,145 +0,0 @@
1
- ==============================================================================
2
- YUI Compressor
3
- ==============================================================================
4
-
5
- NAME
6
-
7
- YUI Compressor - The Yahoo! JavaScript and CSS Compressor
8
-
9
- SYNOPSIS
10
-
11
- Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]
12
-
13
- Global Options
14
- -h, --help Displays this information
15
- --type <js|css> Specifies the type of the input file
16
- --charset <charset> Read the input file using <charset>
17
- --line-break <column> Insert a line break after the specified column number
18
- -v, --verbose Display informational messages and warnings
19
- -o <file> Place the output into <file> or a file pattern.
20
- Defaults to stdout.
21
-
22
- JavaScript Options
23
- --nomunge Minify only, do not obfuscate
24
- --preserve-semi Preserve all semicolons
25
- --disable-optimizations Disable all micro optimizations
26
-
27
- DESCRIPTION
28
-
29
- The YUI Compressor is a JavaScript compressor which, in addition to removing
30
- comments and white-spaces, obfuscates local variables using the smallest
31
- possible variable name. This obfuscation is safe, even when using constructs
32
- such as 'eval' or 'with' (although the compression is not optimal is those
33
- cases) Compared to jsmin, the average savings is around 20%.
34
-
35
- The YUI Compressor is also able to safely compress CSS files. The decision
36
- on which compressor is being used is made on the file extension (js or css)
37
-
38
- GLOBAL OPTIONS
39
-
40
- -h, --help
41
- Prints help on how to use the YUI Compressor
42
-
43
- --line-break
44
- Some source control tools don't like files containing lines longer than,
45
- say 8000 characters. The linebreak option is used in that case to split
46
- long lines after a specific column. It can also be used to make the code
47
- more readable, easier to debug (especially with the MS Script Debugger)
48
- Specify 0 to get a line break after each semi-colon in JavaScript, and
49
- after each rule in CSS.
50
-
51
- --type js|css
52
- The type of compressor (JavaScript or CSS) is chosen based on the
53
- extension of the input file name (.js or .css) This option is required
54
- if no input file has been specified. Otherwise, this option is only
55
- required if the input file extension is neither 'js' nor 'css'.
56
-
57
- --charset character-set
58
- If a supported character set is specified, the YUI Compressor will use it
59
- to read the input file. Otherwise, it will assume that the platform's
60
- default character set is being used. The output file is encoded using
61
- the same character set.
62
-
63
- -o outfile
64
-
65
- Place output in file outfile. If not specified, the YUI Compressor will
66
- default to the standard output, which you can redirect to a file.
67
- Supports a filter syntax for expressing the output pattern when there are
68
- multiple input files. ex:
69
- java -jar yuicompressor.jar -o '.css$:-min.css' *.css
70
- ... will minify all .css files and save them as -min.css
71
-
72
- -v, --verbose
73
- Display informational messages and warnings.
74
-
75
- JAVASCRIPT ONLY OPTIONS
76
-
77
- --nomunge
78
- Minify only. Do not obfuscate local symbols.
79
-
80
- --preserve-semi
81
- Preserve unnecessary semicolons (such as right before a '}') This option
82
- is useful when compressed code has to be run through JSLint (which is the
83
- case of YUI for example)
84
-
85
- --disable-optimizations
86
- Disable all the built-in micro optimizations.
87
-
88
- NOTES
89
-
90
- + If no input file is specified, it defaults to stdin.
91
-
92
- + Supports wildcards for specifying multiple input files.
93
-
94
- + The YUI Compressor requires Java version >= 1.4.
95
-
96
- + It is possible to prevent a local variable, nested function or function
97
- argument from being obfuscated by using "hints". A hint is a string that
98
- is located at the very beginning of a function body like so:
99
-
100
- function fn (arg1, arg2, arg3) {
101
- "arg2:nomunge, localVar:nomunge, nestedFn:nomunge";
102
-
103
- ...
104
- var localVar;
105
- ...
106
-
107
- function nestedFn () {
108
- ....
109
- }
110
-
111
- ...
112
- }
113
-
114
- The hint itself disappears from the compressed file.
115
-
116
- + C-style comments starting with /*! are preserved. This is useful with
117
- comments containing copyright/license information. For example:
118
-
119
- /*!
120
- * TERMS OF USE - EASING EQUATIONS
121
- * Open source under the BSD License.
122
- * Copyright 2001 Robert Penner All rights reserved.
123
- */
124
-
125
- becomes:
126
-
127
- /*
128
- * TERMS OF USE - EASING EQUATIONS
129
- * Open source under the BSD License.
130
- * Copyright 2001 Robert Penner All rights reserved.
131
- */
132
-
133
- MODIFIED RHINO FILES
134
-
135
- YUI Compressor uses a modified version of the Rhino library
136
- (http://www.mozilla.org/rhino/) The changes were made to support
137
- JScript conditional comments, preserved comments, unescaped slash
138
- characters in regular expressions, and to allow for the optimization
139
- of escaped quotes in string literals.
140
-
141
- COPYRIGHT AND LICENSE
142
-
143
- Copyright (c) 2011 Yahoo! Inc. All rights reserved.
144
- The copyrights embodied in the content of this file are licensed
145
- by Yahoo! Inc. under the BSD (revised) open source license.
lib/Diglin/yuicompressor-2.4.6/lib/jargs-1.0.jar DELETED
Binary file
lib/Diglin/yuicompressor-2.4.6/ports/js/cssmin.js DELETED
@@ -1,231 +0,0 @@
1
- /**
2
- * cssmin.js
3
- * Author: Stoyan Stefanov - http://phpied.com/
4
- * This is a JavaScript port of the CSS minification tool
5
- * distributed with YUICompressor, itself a port
6
- * of the cssmin utility by Isaac Schlueter - http://foohack.com/
7
- * Permission is hereby granted to use the JavaScript version under the same
8
- * conditions as the YUICompressor (original YUICompressor note below).
9
- */
10
-
11
- /*
12
- * YUI Compressor
13
- * http://developer.yahoo.com/yui/compressor/
14
- * Author: Julien Lecomte - http://www.julienlecomte.net/
15
- * Copyright (c) 2011 Yahoo! Inc. All rights reserved.
16
- * The copyrights embodied in the content of this file are licensed
17
- * by Yahoo! Inc. under the BSD (revised) open source license.
18
- */
19
- var YAHOO = YAHOO || {};
20
- YAHOO.compressor = YAHOO.compressor || {};
21
- YAHOO.compressor.cssmin = function (css, linebreakpos) {
22
-
23
- var startIndex = 0,
24
- endIndex = 0,
25
- i = 0, max = 0,
26
- preservedTokens = [],
27
- comments = [],
28
- token = '',
29
- totallen = css.length,
30
- placeholder = '';
31
-
32
- // collect all comment blocks...
33
- while ((startIndex = css.indexOf("/*", startIndex)) >= 0) {
34
- endIndex = css.indexOf("*/", startIndex + 2);
35
- if (endIndex < 0) {
36
- endIndex = totallen;
37
- }
38
- token = css.slice(startIndex + 2, endIndex);
39
- comments.push(token);
40
- css = css.slice(0, startIndex + 2) + "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + (comments.length - 1) + "___" + css.slice(endIndex);
41
- startIndex += 2;
42
- }
43
-
44
- // preserve strings so their content doesn't get accidentally minified
45
- css = css.replace(/("([^\\"]|\\.|\\)*")|('([^\\']|\\.|\\)*')/g, function (match) {
46
- var i, max, quote = match.substring(0, 1);
47
-
48
- match = match.slice(1, -1);
49
-
50
- // maybe the string contains a comment-like substring?
51
- // one, maybe more? put'em back then
52
- if (match.indexOf("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_") >= 0) {
53
- for (i = 0, max = comments.length; i < max; i = i + 1) {
54
- match = match.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", comments[i]);
55
- }
56
- }
57
-
58
- // minify alpha opacity in filter strings
59
- match = match.replace(/progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/gi, "alpha(opacity=");
60
-
61
- preservedTokens.push(match);
62
- return quote + "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___" + quote;
63
- });
64
-
65
- // strings are safe, now wrestle the comments
66
- for (i = 0, max = comments.length; i < max; i = i + 1) {
67
-
68
- token = comments[i];
69
- placeholder = "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___";
70
-
71
- // ! in the first position of the comment means preserve
72
- // so push to the preserved tokens keeping the !
73
- if (token.charAt(0) === "!") {
74
- preservedTokens.push(token);
75
- css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
76
- continue;
77
- }
78
-
79
- // \ in the last position looks like hack for Mac/IE5
80
- // shorten that to /*\*/ and the next one to /**/
81
- if (token.charAt(token.length - 1) === "\\") {
82
- preservedTokens.push("\\");
83
- css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
84
- i = i + 1; // attn: advancing the loop
85
- preservedTokens.push("");
86
- css = css.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
87
- continue;
88
- }
89
-
90
- // keep empty comments after child selectors (IE7 hack)
91
- // e.g. html >/**/ body
92
- if (token.length === 0) {
93
- startIndex = css.indexOf(placeholder);
94
- if (startIndex > 2) {
95
- if (css.charAt(startIndex - 3) === '>') {
96
- preservedTokens.push("");
97
- css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
98
- }
99
- }
100
- }
101
-
102
- // in all other cases kill the comment
103
- css = css.replace("/*" + placeholder + "*/", "");
104
- }
105
-
106
-
107
- // Normalize all whitespace strings to single spaces. Easier to work with that way.
108
- css = css.replace(/\s+/g, " ");
109
-
110
- // Remove the spaces before the things that should not have spaces before them.
111
- // But, be careful not to turn "p :link {...}" into "p:link{...}"
112
- // Swap out any pseudo-class colons with the token, and then swap back.
113
- css = css.replace(/(^|\})(([^\{:])+:)+([^\{]*\{)/g, function (m) {
114
- return m.replace(":", "___YUICSSMIN_PSEUDOCLASSCOLON___");
115
- });
116
- css = css.replace(/\s+([!{};:>+\(\)\],])/g, '$1');
117
- css = css.replace(/___YUICSSMIN_PSEUDOCLASSCOLON___/g, ":");
118
-
119
- // retain space for special IE6 cases
120
- css = css.replace(/:first-(line|letter)(\{|,)/g, ":first-$1 $2");
121
-
122
- // no space after the end of a preserved comment
123
- css = css.replace(/\*\/ /g, '*/');
124
-
125
-
126
- // If there is a @charset, then only allow one, and push to the top of the file.
127
- css = css.replace(/^(.*)(@charset "[^"]*";)/gi, '$2$1');
128
- css = css.replace(/^(\s*@charset [^;]+;\s*)+/gi, '$1');
129
-
130
- // Put the space back in some cases, to support stuff like
131
- // @media screen and (-webkit-min-device-pixel-ratio:0){
132
- css = css.replace(/\band\(/gi, "and (");
133
-
134
-
135
- // Remove the spaces after the things that should not have spaces after them.
136
- css = css.replace(/([!{}:;>+\(\[,])\s+/g, '$1');
137
-
138
- // remove unnecessary semicolons
139
- css = css.replace(/;+\}/g, "}");
140
-
141
- // Replace 0(px,em,%) with 0.
142
- css = css.replace(/([\s:])(0)(px|em|%|in|cm|mm|pc|pt|ex)/gi, "$1$2");
143
-
144
- // Replace 0 0 0 0; with 0.
145
- css = css.replace(/:0 0 0 0(;|\})/g, ":0$1");
146
- css = css.replace(/:0 0 0(;|\})/g, ":0$1");
147
- css = css.replace(/:0 0(;|\})/g, ":0$1");
148
-
149
- // Replace background-position:0; with background-position:0 0;
150
- // same for transform-origin
151
- css = css.replace(/(background-position|transform-origin|webkit-transform-origin|moz-transform-origin|o-transform-origin|ms-transform-origin):0(;|\})/gi, function(all, prop, tail) {
152
- return prop.toLowerCase() + ":0 0" + tail;
153
- });
154
-
155
- // Replace 0.6 to .6, but only when preceded by : or a white-space
156
- css = css.replace(/(:|\s)0+\.(\d+)/g, "$1.$2");
157
-
158
- // Shorten colors from rgb(51,102,153) to #336699
159
- // This makes it more likely that it'll get further compressed in the next step.
160
- css = css.replace(/rgb\s*\(\s*([0-9,\s]+)\s*\)/gi, function () {
161
- var i, rgbcolors = arguments[1].split(',');
162
- for (i = 0; i < rgbcolors.length; i = i + 1) {
163
- rgbcolors[i] = parseInt(rgbcolors[i], 10).toString(16);
164
- if (rgbcolors[i].length === 1) {
165
- rgbcolors[i] = '0' + rgbcolors[i];
166
- }
167
- }
168
- return '#' + rgbcolors.join('');
169
- });
170
-
171
-
172
- // Shorten colors from #AABBCC to #ABC. Note that we want to make sure
173
- // the color is not preceded by either ", " or =. Indeed, the property
174
- // filter: chroma(color="#FFFFFF");
175
- // would become
176
- // filter: chroma(color="#FFF");
177
- // which makes the filter break in IE.
178
- css = css.replace(/([^"'=\s])(\s*)#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])/gi, function () {
179
- var group = arguments;
180
- if (
181
- group[3].toLowerCase() === group[4].toLowerCase() &&
182
- group[5].toLowerCase() === group[6].toLowerCase() &&
183
- group[7].toLowerCase() === group[8].toLowerCase()
184
- ) {
185
- return (group[1] + group[2] + '#' + group[3] + group[5] + group[7]).toLowerCase();
186
- } else {
187
- return group[0].toLowerCase();
188
- }
189
- });
190
-
191
- // border: none -> border:0
192
- css = css.replace(/(border|border-top|border-right|border-bottom|border-right|outline|background):none(;|\})/gi, function(all, prop, tail) {
193
- return prop.toLowerCase() + ":0" + tail;
194
- });
195
-
196
- // shorter opacity IE filter
197
- css = css.replace(/progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/gi, "alpha(opacity=");
198
-
199
- // Remove empty rules.
200
- css = css.replace(/[^\};\{\/]+\{\}/g, "");
201
-
202
- if (linebreakpos >= 0) {
203
- // Some source control tools don't like it when files containing lines longer
204
- // than, say 8000 characters, are checked in. The linebreak option is used in
205
- // that case to split long lines after a specific column.
206
- startIndex = 0;
207
- i = 0;
208
- while (i < css.length) {
209
- i = i + 1;
210
- if (css[i - 1] === '}' && i - startIndex > linebreakpos) {
211
- css = css.slice(0, i) + '\n' + css.slice(i);
212
- startIndex = i;
213
- }
214
- }
215
- }
216
-
217
- // Replace multiple semi-colons in a row by a single one
218
- // See SF bug #1980989
219
- css = css.replace(/;;+/g, ";");
220
-
221
- // restore preserved comments and strings
222
- for (i = 0, max = preservedTokens.length; i < max; i = i + 1) {
223
- css = css.replace("___YUICSSMIN_PRESERVED_TOKEN_" + i + "___", preservedTokens[i]);
224
- }
225
-
226
- // Trim the final string (for any leading or trailing white spaces)
227
- css = css.replace(/^\s+|\s+#x2F;g, "");
228
-
229
- return css;
230
-
231
- };
lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/Bootstrap.java DELETED
@@ -1,23 +0,0 @@
1
- /*
2
- * YUI Compressor
3
- * http://developer.yahoo.com/yui/compressor/
4
- * Author: Julien Lecomte - http://www.julienlecomte.net/
5
- * Copyright (c) 2011 Yahoo! Inc. All rights reserved.
6
- * The copyrights embodied in the content of this file are licensed
7
- * by Yahoo! Inc. under the BSD (revised) open source license.
8
- */
9
-
10
- package com.yahoo.platform.yui.compressor;
11
-
12
- import java.lang.reflect.Method;
13
-
14
- public class Bootstrap {
15
-
16
- public static void main(String args[]) throws Exception {
17
- ClassLoader loader = new JarClassLoader();
18
- Thread.currentThread().setContextClassLoader(loader);
19
- Class c = loader.loadClass(YUICompressor.class.getName());
20
- Method main = c.getMethod("main", new Class[]{String[].class});
21
- main.invoke(null, new Object[]{args});
22
- }
23
- }
lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/CssCompressor.java DELETED
@@ -1,304 +0,0 @@
1
- /*
2
- * YUI Compressor
3
- * http://developer.yahoo.com/yui/compressor/
4
- * Author: Julien Lecomte - http://www.julienlecomte.net/
5
- * Author: Isaac Schlueter - http://foohack.com/
6
- * Author: Stoyan Stefanov - http://phpied.com/
7
- * Copyright (c) 2011 Yahoo! Inc. All rights reserved.
8
- * The copyrights embodied in the content of this file are licensed
9
- * by Yahoo! Inc. under the BSD (revised) open source license.
10
- */
11
- package com.yahoo.platform.yui.compressor;
12
-
13
- import java.io.IOException;
14
- import java.io.Reader;
15
- import java.io.Writer;
16
- import java.util.regex.Pattern;
17
- import java.util.regex.Matcher;
18
- import java.util.ArrayList;
19
-
20
- public class CssCompressor {
21
-
22
- private StringBuffer srcsb = new StringBuffer();
23
-
24
- public CssCompressor(Reader in) throws IOException {
25
- // Read the stream...
26
- int c;
27
- while ((c = in.read()) != -1) {
28
- srcsb.append((char) c);
29
- }
30
- }
31
-
32
- public void compress(Writer out, int linebreakpos)
33
- throws IOException {
34
-
35
- Pattern p;
36
- Matcher m;
37
- String css = srcsb.toString();
38
- StringBuffer sb = new StringBuffer(css);
39
-
40
- int startIndex = 0;
41
- int endIndex = 0;
42
- int i = 0;
43
- int max = 0;
44
- ArrayList preservedTokens = new ArrayList(0);
45
- ArrayList comments = new ArrayList(0);
46
- String token;
47
- int totallen = css.length();
48
- String placeholder;
49
-
50
- // // leave data urls alone to increase parse performance.
51
- // sb = new StringBuffer();
52
- // p = Pattern.compile("url\\(.*data\\:(.*)\\)");
53
- // m = p.matcher(css);
54
- // while (m.find()) {
55
- // token = m.group();
56
- // token = token.substring(1, token.length() - 1);
57
- // preservedTokens.add(token);
58
- // String preserver = "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___";
59
- // m.appendReplacement(sb, preserver);
60
- // }
61
- // m.appendTail(sb);
62
- // css = sb.toString();
63
-
64
- // collect all comment blocks...
65
- while ((startIndex = sb.indexOf("/*", startIndex)) >= 0) {
66
- endIndex = sb.indexOf("*/", startIndex + 2);
67
- if (endIndex < 0) {
68
- endIndex = totallen;
69
- }
70
-
71
- token = sb.substring(startIndex + 2, endIndex);
72
- comments.add(token);
73
- sb.replace(startIndex + 2, endIndex, "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + (comments.size() - 1) + "___");
74
- startIndex += 2;
75
- }
76
- css = sb.toString();
77
-
78
- // preserve strings so their content doesn't get accidentally minified
79
- sb = new StringBuffer();
80
- p = Pattern.compile("(\"([^\\\\\"]|\\\\.|\\\\)*\")|(\'([^\\\\\']|\\\\.|\\\\)*\')");
81
- m = p.matcher(css);
82
- while (m.find()) {
83
- token = m.group();
84
- char quote = token.charAt(0);
85
- token = token.substring(1, token.length() - 1);
86
-
87
- // maybe the string contains a comment-like substring?
88
- // one, maybe more? put'em back then
89
- if (token.indexOf("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_") >= 0) {
90
- for (i = 0, max = comments.size(); i < max; i += 1) {
91
- token = token.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", comments.get(i).toString());
92
- }
93
- }
94
-
95
- // minify alpha opacity in filter strings
96
- token = token.replaceAll("(?i)progid:DXImageTransform.Microsoft.Alpha\\(Opacity=", "alpha(opacity=");
97
-
98
- preservedTokens.add(token);
99
- String preserver = quote + "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___" + quote;
100
- m.appendReplacement(sb, preserver);
101
- }
102
- m.appendTail(sb);
103
- css = sb.toString();
104
-
105
-
106
- // strings are safe, now wrestle the comments
107
- for (i = 0, max = comments.size(); i < max; i += 1) {
108
-
109
- token = comments.get(i).toString();
110
- placeholder = "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___";
111
-
112
- // ! in the first position of the comment means preserve
113
- // so push to the preserved tokens while stripping the !
114
- if (token.startsWith("!")) {
115
- preservedTokens.add(token);
116
- css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
117
- continue;
118
- }
119
-
120
- // \ in the last position looks like hack for Mac/IE5
121
- // shorten that to /*\*/ and the next one to /**/
122
- if (token.endsWith("\\")) {
123
- preservedTokens.add("\\");
124
- css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
125
- i = i + 1; // attn: advancing the loop
126
- preservedTokens.add("");
127
- css = css.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
128
- continue;
129
- }
130
-
131
- // keep empty comments after child selectors (IE7 hack)
132
- // e.g. html >/**/ body
133
- if (token.length() == 0) {
134
- startIndex = css.indexOf(placeholder);
135
- if (startIndex > 2) {
136
- if (css.charAt(startIndex - 3) == '>') {
137
- preservedTokens.add("");
138
- css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
139
- }
140
- }
141
- }
142
-
143
- // in all other cases kill the comment
144
- css = css.replace("/*" + placeholder + "*/", "");
145
- }
146
-
147
-
148
- // Normalize all whitespace strings to single spaces. Easier to work with that way.
149
- css = css.replaceAll("\\s+", " ");
150
-
151
- // Remove the spaces before the things that should not have spaces before them.
152
- // But, be careful not to turn "p :link {...}" into "p:link{...}"
153
- // Swap out any pseudo-class colons with the token, and then swap back.
154
- sb = new StringBuffer();
155
- p = Pattern.compile("(^|\\})(([^\\{:])+:)+([^\\{]*\\{)");
156
- m = p.matcher(css);
157
- while (m.find()) {
158
- String s = m.group();
159
- s = s.replaceAll(":", "___YUICSSMIN_PSEUDOCLASSCOLON___");
160
- s = s.replaceAll( "\\\\", "\\\\\\\\" ).replaceAll( "\\quot;, "\\\\\\quot; );
161
- m.appendReplacement(sb, s);
162
- }
163
- m.appendTail(sb);
164
- css = sb.toString();
165
- // Remove spaces before the things that should not have spaces before them.
166
- css = css.replaceAll("\\s+([!{};:>+\\(\\)\\],])", "$1");
167
- // bring back the colon
168
- css = css.replaceAll("___YUICSSMIN_PSEUDOCLASSCOLON___", ":");
169
-
170
- // retain space for special IE6 cases
171
- css = css.replaceAll(":first\\-(line|letter)(\\{|,)", ":first-$1 $2");
172
-
173
- // no space after the end of a preserved comment
174
- css = css.replaceAll("\\*/ ", "*/");
175
-
176
- // If there is a @charset, then only allow one, and push to the top of the file.
177
- css = css.replaceAll("^(.*)(@charset \"[^\"]*\";)", "$2$1");
178
- css = css.replaceAll("^(\\s*@charset [^;]+;\\s*)+", "$1");
179
-
180
- // Put the space back in some cases, to support stuff like
181
- // @media screen and (-webkit-min-device-pixel-ratio:0){
182
- css = css.replaceAll("\\band\\(", "and (");
183
-
184
- // Remove the spaces after the things that should not have spaces after them.
185
- css = css.replaceAll("([!{}:;>+\\(\\[,])\\s+", "$1");
186
-
187
- // remove unnecessary semicolons
188
- css = css.replaceAll(";+}", "}");
189
-
190
- // Replace 0(px,em,%) with 0.
191
- css = css.replaceAll("([\\s:])(0)(px|em|%|in|cm|mm|pc|pt|ex)", "$1$2");
192
-
193
- // Replace 0 0 0 0; with 0.
194
- css = css.replaceAll(":0 0 0 0(;|})", ":0$1");
195
- css = css.replaceAll(":0 0 0(;|})", ":0$1");
196
- css = css.replaceAll(":0 0(;|})", ":0$1");
197
-
198
-
199
- // Replace background-position:0; with background-position:0 0;
200
- // same for transform-origin
201
- sb = new StringBuffer();
202
- p = Pattern.compile("(?i)(background-position|transform-origin|webkit-transform-origin|moz-transform-origin|o-transform-origin|ms-transform-origin):0(;|})");
203
- m = p.matcher(css);
204
- while (m.find()) {
205
- m.appendReplacement(sb, m.group(1).toLowerCase() + ":0 0" + m.group(2));
206
- }
207
- m.appendTail(sb);
208
- css = sb.toString();
209
-
210
- // Replace 0.6 to .6, but only when preceded by : or a white-space
211
- css = css.replaceAll("(:|\\s)0+\\.(\\d+)", "$1.$2");
212
-
213
- // Shorten colors from rgb(51,102,153) to #336699
214
- // This makes it more likely that it'll get further compressed in the next step.
215
- p = Pattern.compile("rgb\\s*\\(\\s*([0-9,\\s]+)\\s*\\)");
216
- m = p.matcher(css);
217
- sb = new StringBuffer();
218
- while (m.find()) {
219
- String[] rgbcolors = m.group(1).split(",");
220
- StringBuffer hexcolor = new StringBuffer("#");
221
- for (i = 0; i < rgbcolors.length; i++) {
222
- int val = Integer.parseInt(rgbcolors[i]);
223
- if (val < 16) {
224
- hexcolor.append("0");
225
- }
226
- hexcolor.append(Integer.toHexString(val));
227
- }
228
- m.appendReplacement(sb, hexcolor.toString());
229
- }
230
- m.appendTail(sb);
231
- css = sb.toString();
232
-
233
- // Shorten colors from #AABBCC to #ABC. Note that we want to make sure
234
- // the color is not preceded by either ", " or =. Indeed, the property
235
- // filter: chroma(color="#FFFFFF");
236
- // would become
237
- // filter: chroma(color="#FFF");
238
- // which makes the filter break in IE.
239
- p = Pattern.compile("([^\"'=\\s])(\\s*)#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])");
240
- m = p.matcher(css);
241
- sb = new StringBuffer();
242
- while (m.find()) {
243
- // Test for AABBCC pattern
244
- if (m.group(3).equalsIgnoreCase(m.group(4)) &&
245
- m.group(5).equalsIgnoreCase(m.group(6)) &&
246
- m.group(7).equalsIgnoreCase(m.group(8))) {
247
- m.appendReplacement(sb, (m.group(1) + m.group(2) + "#" + m.group(3) + m.group(5) + m.group(7)).toLowerCase());
248
- } else {
249
- m.appendReplacement(sb, m.group().toLowerCase());
250
- }
251
- }
252
- m.appendTail(sb);
253
- css = sb.toString();
254
-
255
- // border: none -> border:0
256
- sb = new StringBuffer();
257
- p = Pattern.compile("(?i)(border|border-top|border-right|border-bottom|border-right|outline|background):none(;|})");
258
- m = p.matcher(css);
259
- while (m.find()) {
260
- m.appendReplacement(sb, m.group(1).toLowerCase() + ":0" + m.group(2));
261
- }
262
- m.appendTail(sb);
263
- css = sb.toString();
264
-
265
- // shorter opacity IE filter
266
- css = css.replaceAll("(?i)progid:DXImageTransform.Microsoft.Alpha\\(Opacity=", "alpha(opacity=");
267
-
268
- // Remove empty rules.
269
- css = css.replaceAll("[^\\}\\{/;]+\\{\\}", "");
270
-
271
- if (linebreakpos >= 0) {
272
- // Some source control tools don't like it when files containing lines longer
273
- // than, say 8000 characters, are checked in. The linebreak option is used in
274
- // that case to split long lines after a specific column.
275
- i = 0;
276
- int linestartpos = 0;
277
- sb = new StringBuffer(css);
278
- while (i < sb.length()) {
279
- char c = sb.charAt(i++);
280
- if (c == '}' && i - linestartpos > linebreakpos) {
281
- sb.insert(i, '\n');
282
- linestartpos = i;
283
- }
284
- }
285
-
286
- css = sb.toString();
287
- }
288
-
289
- // Replace multiple semi-colons in a row by a single one
290
- // See SF bug #1980989
291
- css = css.replaceAll(";;+", ";");
292
-
293
- // restore preserved comments and strings
294
- for(i = 0, max = preservedTokens.size(); i < max; i++) {
295
- css = css.replace("___YUICSSMIN_PRESERVED_TOKEN_" + i + "___", preservedTokens.get(i).toString());
296
- }
297
-
298
- // Trim the final string (for any leading or trailing white spaces)
299
- css = css.trim();
300
-
301
- // Write the output...
302
- out.write(css);
303
- }
304
- }
lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JarClassLoader.java DELETED
@@ -1,158 +0,0 @@
1
- /*
2
- * YUI Compressor
3
- * http://developer.yahoo.com/yui/compressor/
4
- * Author: Julien Lecomte - http://www.julienlecomte.net/
5
- * Copyright (c) 2011 Yahoo! Inc. All rights reserved.
6
- * The copyrights embodied in the content of this file are licensed
7
- * by Yahoo! Inc. under the BSD (revised) open source license.
8
- */
9
- package com.yahoo.platform.yui.compressor;
10
-
11
- import java.io.ByteArrayOutputStream;
12
- import java.io.IOException;
13
- import java.io.InputStream;
14
- import java.io.OutputStream;
15
- import java.util.Enumeration;
16
- import java.util.jar.JarEntry;
17
- import java.util.jar.JarFile;
18
-
19
- public class JarClassLoader extends ClassLoader {
20
-
21
- private static String jarPath;
22
-
23
- public Class loadClass(String name) throws ClassNotFoundException {
24
-
25
- // First check if the class is already loaded
26
- Class c = findLoadedClass(name);
27
- if (c == null) {
28
- c = findClass(name);
29
- }
30
-
31
- if (c == null) {
32
- c = ClassLoader.getSystemClassLoader().loadClass(name);
33
- }
34
-
35
- return c;
36
- }
37
-
38
- private static String getJarPath() {
39
-
40
- if (jarPath != null) {
41
- return jarPath;
42
- }
43
-
44
- String classname = JarClassLoader.class.getName().replace('.', '/') + ".class";
45
- String classpath = System.getProperty("java.class.path");
46
- String classpaths[] = classpath.split(System.getProperty("path.separator"));
47
-
48
- for (int i = 0; i < classpaths.length; i++) {
49
-
50
- String path = classpaths[i];
51
- JarFile jarFile = null;
52
- JarEntry jarEntry = null;
53
-
54
- try {
55
- jarFile = new JarFile(path);
56
- jarEntry = findJarEntry(jarFile, classname);
57
- } catch (IOException ioe) {
58
- /* ignore */
59
- } finally {
60
- if (jarFile != null) {
61
- try {
62
- jarFile.close();
63
- } catch (IOException ioe) {
64
- /* ignore */
65
- }
66
- }
67
- }
68
-
69
- if (jarEntry != null) {
70
- jarPath = path;
71
- break;
72
- }
73
- }
74
-
75
- return jarPath;
76
- }
77
-
78
- private static JarEntry findJarEntry(JarFile jarFile, String entryName) {
79
-
80
- Enumeration entries = jarFile.entries();
81
-
82
- while (entries.hasMoreElements()) {
83
- JarEntry entry = (JarEntry) entries.nextElement();
84
- if (entry.getName().equals(entryName)) {
85
- return entry;
86
- }
87
- }
88
-
89
- return null;
90
- }
91
-
92
- protected Class findClass(String name) {
93
-
94
- Class c = null;
95
- String jarPath = getJarPath();
96
-
97
- if (jarPath != null) {
98
- JarFile jarFile = null;
99
- try {
100
- jarFile = new JarFile(jarPath);
101
- c = loadClassData(jarFile, name);
102
- } catch (IOException ioe) {
103
- /* ignore */
104
- } finally {
105
- if (jarFile != null) {
106
- try {
107
- jarFile.close();
108
- } catch (IOException ioe) {
109
- /* ignore */
110
- }
111
- }
112
- }
113
- }
114
-
115
- return c;
116
- }
117
-
118
- private Class loadClassData(JarFile jarFile, String className) {
119
-
120
- String entryName = className.replace('.', '/') + ".class";
121
- JarEntry jarEntry = findJarEntry(jarFile, entryName);
122
- if (jarEntry == null) {
123
- return null;
124
- }
125
-
126
- // Create the necessary package if needed...
127
- int index = className.lastIndexOf('.');
128
- if (index >= 0) {
129
- String packageName = className.substring(0, index);
130
- if (getPackage(packageName) == null) {
131
- definePackage(packageName, "", "", "", "", "", "", null);
132
- }
133
- }
134
-
135
- // Read the Jar File entry and define the class...
136
- Class c = null;
137
- try {
138
- InputStream is = jarFile.getInputStream(jarEntry);
139
- ByteArrayOutputStream os = new ByteArrayOutputStream();
140
- copy(is, os);
141
- byte[] bytes = os.toByteArray();
142
- c = defineClass(className, bytes, 0, bytes.length);
143
- } catch (IOException ioe) {
144
- /* ignore */
145
- }
146
-
147
- return c;
148
- }
149
-
150
- private void copy(InputStream in, OutputStream out) throws IOException {
151
- byte[] buf = new byte[1024];
152
- while (true) {
153
- int len = in.read(buf);
154
- if (len < 0) break;
155
- out.write(buf, 0, len);
156
- }
157
- }
158
- }
lib/Diglin/yuicompressor-2.4.6/src/com/yahoo/platform/yui/compressor/JavaScriptCompressor.java DELETED
@@ -1,1317 +0,0 @@
1
- /*
2
- * YUI Compressor
3
- * http://developer.yahoo.com/yui/compressor/
4
- * Author: Julien Lecomte - http://www.julienlecomte.net/
5
- * Copyright (c) 2011 Yahoo! Inc. All rights reserved.
6
- * The copyrights embodied in the content of this file are licensed
7
- * by Yahoo! Inc. under the BSD (revised) open source license.
8
- */
9
- package com.yahoo.platform.yui.compressor;
10
-
11
- import org.mozilla.javascript.*;
12
-
13
- import java.io.IOException;
14
- import java.io.Reader;
15
- import java.io.Writer;
16
- import java.util.*;
17
- import java.util.regex.Matcher;
18
- import java.util.regex.Pattern;
19
-
20
- public class JavaScriptCompressor {
21
-
22
- static final ArrayList ones;
23
- static final ArrayList twos;
24
- static final ArrayList threes;
25
-
26
- static final Set builtin = new HashSet();
27
- static final Map literals = new Hashtable();
28
- static final Set reserved = new HashSet();
29
-
30
- static {
31
-
32
- // This list contains all the 3 characters or less built-in global
33
- // symbols available in a browser. Please add to this list if you
34
- // see anything missing.
35
- builtin.add("NaN");
36
- builtin.add("top");
37
-
38
- ones = new ArrayList();
39
- for (char c = 'a'; c <= 'z'; c++)
40
- ones.add(Character.toString(c));
41
- for (char c = 'A'; c <= 'Z'; c++)
42
- ones.add(Character.toString(c));
43
-
44
- twos = new ArrayList();
45
- for (int i = 0; i < ones.size(); i++) {
46
- String one = (String) ones.get(i);
47
- for (char c = 'a'; c <= 'z'; c++)
48
- twos.add(one + Character.toString(c));
49
- for (char c = 'A'; c <= 'Z'; c++)
50
- twos.add(one + Character.toString(c));
51
- for (char c = '0'; c <= '9'; c++)
52
- twos.add(one + Character.toString(c));
53
- }
54
-
55
- // Remove two-letter JavaScript reserved words and built-in globals...
56
- twos.remove("as");
57
- twos.remove("is");
58
- twos.remove("do");
59
- twos.remove("if");
60
- twos.remove("in");
61
- twos.removeAll(builtin);
62
-
63
- threes = new ArrayList();
64
- for (int i = 0; i < twos.size(); i++) {
65
- String two = (String) twos.get(i);
66
- for (char c = 'a'; c <= 'z'; c++)
67
- threes.add(two + Character.toString(c));
68
- for (char c = 'A'; c <= 'Z'; c++)
69
- threes.add(two + Character.toString(c));
70
- for (char c = '0'; c <= '9'; c++)
71
- threes.add(two + Character.toString(c));
72
- }
73
-
74
- // Remove three-letter JavaScript reserved words and built-in globals...
75
- threes.remove("for");
76
- threes.remove("int");
77
- threes.remove("new");
78
- threes.remove("try");
79
- threes.remove("use");
80
- threes.remove("var");
81
- threes.removeAll(builtin);
82
-
83
- // That's up to ((26+26)*(1+(26+26+10)))*(1+(26+26+10))-8
84
- // (206,380 symbols per scope)
85
-
86
- // The following list comes from org/mozilla/javascript/Decompiler.java...
87
- literals.put(new Integer(Token.GET), "get ");
88
- literals.put(new Integer(Token.SET), "set ");
89
- literals.put(new Integer(Token.TRUE), "true");
90
- literals.put(new Integer(Token.FALSE), "false");
91
- literals.put(new Integer(Token.NULL), "null");
92
- literals.put(new Integer(Token.THIS), "this");
93
- literals.put(new Integer(Token.FUNCTION), "function");
94
- literals.put(new Integer(Token.COMMA), ",");
95
- literals.put(new Integer(Token.LC), "{");
96
- literals.put(new Integer(Token.RC), "}");
97
- literals.put(new Integer(Token.LP), "(");
98
- literals.put(new Integer(Token.RP), ")");
99
- literals.put(new Integer(Token.LB), "[");
100
- literals.put(new Integer(Token.RB), "]");
101
- literals.put(new Integer(Token.DOT), ".");
102
- literals.put(new Integer(Token.NEW), "new ");
103
- literals.put(new Integer(Token.DELPROP), "delete ");
104
- literals.put(new Integer(Token.IF), "if");
105
- literals.put(new Integer(Token.ELSE), "else");
106
- literals.put(new Integer(Token.FOR), "for");
107
- literals.put(new Integer(Token.IN), " in ");
108
- literals.put(new Integer(Token.WITH), "with");
109
- literals.put(new Integer(Token.WHILE), "while");
110
- literals.put(new Integer(Token.DO), "do");
111
- literals.put(new Integer(Token.TRY), "try");
112
- literals.put(new Integer(Token.CATCH), "catch");
113
- literals.put(new Integer(Token.FINALLY), "finally");
114
- literals.put(new Integer(Token.THROW), "throw");
115
- literals.put(new Integer(Token.SWITCH), "switch");
116
- literals.put(new Integer(Token.BREAK), "break");
117
- literals.put(new Integer(Token.CONTINUE), "continue");
118
- literals.put(new Integer(Token.CASE), "case");
119
- literals.put(new Integer(Token.DEFAULT), "default");
120
- literals.put(new Integer(Token.RETURN), "return");
121
- literals.put(new Integer(Token.VAR), "var ");
122
- literals.put(new Integer(Token.SEMI), ";");
123
- literals.put(new Integer(Token.ASSIGN), "=");
124
- literals.put(new Integer(Token.ASSIGN_ADD), "+=");
125
- literals.put(new Integer(Token.ASSIGN_SUB), "-=");
126
- literals.put(new Integer(Token.ASSIGN_MUL), "*=");
127
- literals.put(new Integer(Token.ASSIGN_DIV), "/=");
128
- literals.put(new Integer(Token.ASSIGN_MOD), "%=");
129
- literals.put(new Integer(Token.ASSIGN_BITOR), "|=");
130
- literals.put(new Integer(Token.ASSIGN_BITXOR), "^=");
131
- literals.put(new Integer(Token.ASSIGN_BITAND), "&=");
132
- literals.put(new Integer(Token.ASSIGN_LSH), "<<=");
133
- literals.put(new Integer(Token.ASSIGN_RSH), ">>=");
134
- literals.put(new Integer(Token.ASSIGN_URSH), ">>>=");
135
- literals.put(new Integer(Token.HOOK), "?");
136
- literals.put(new Integer(Token.OBJECTLIT), ":");
137
- literals.put(new Integer(Token.COLON), ":");
138
- literals.put(new Integer(Token.OR), "||");
139
- literals.put(new Integer(Token.AND), "&&");
140
- literals.put(new Integer(Token.BITOR), "|");
141
- literals.put(new Integer(Token.BITXOR), "^");
142
- literals.put(new Integer(Token.BITAND), "&");
143
- literals.put(new Integer(Token.SHEQ), "===");
144
- literals.put(new Integer(Token.SHNE), "!==");
145
- literals.put(new Integer(Token.EQ), "==");
146
- literals.put(new Integer(Token.NE), "!=");
147
- literals.put(new Integer(Token.LE), "<=");
148
- literals.put(new Integer(Token.LT), "<");
149
- literals.put(new Integer(Token.GE), ">=");
150
- literals.put(new Integer(Token.GT), ">");
151
- literals.put(new Integer(Token.INSTANCEOF), " instanceof ");
152
- literals.put(new Integer(Token.LSH), "<<");
153
- literals.put(new Integer(Token.RSH), ">>");
154
- literals.put(new Integer(Token.URSH), ">>>");
155
- literals.put(new Integer(Token.TYPEOF), "typeof");
156
- literals.put(new Integer(Token.VOID), "void ");
157
- literals.put(new Integer(Token.CONST), "const ");
158
- literals.put(new Integer(Token.NOT), "!");
159
- literals.put(new Integer(Token.BITNOT), "~");
160
- literals.put(new Integer(Token.POS), "+");
161
- literals.put(new Integer(Token.NEG), "-");
162
- literals.put(new Integer(Token.INC), "++");
163
- literals.put(new Integer(Token.DEC), "--");
164
- literals.put(new Integer(Token.ADD), "+");
165
- literals.put(new Integer(Token.SUB), "-");
166
- literals.put(new Integer(Token.MUL), "*");
167
- literals.put(new Integer(Token.DIV), "/");
168
- literals.put(new Integer(Token.MOD), "%");
169
- literals.put(new Integer(Token.COLONCOLON), "::");
170
- literals.put(new Integer(Token.DOTDOT), "..");
171
- literals.put(new Integer(Token.DOTQUERY), ".(");
172
- literals.put(new Integer(Token.XMLATTR), "@");
173
-
174
- // See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Reserved_Words
175
-
176
- // JavaScript 1.5 reserved words
177
- reserved.add("break");
178
- reserved.add("case");
179
- reserved.add("catch");
180
- reserved.add("continue");
181
- reserved.add("default");
182
- reserved.add("delete");
183
- reserved.add("do");
184
- reserved.add("else");
185
- reserved.add("finally");
186
- reserved.add("for");
187
- reserved.add("function");
188
- reserved.add("if");
189
- reserved.add("in");
190
- reserved.add("instanceof");
191
- reserved.add("new");
192
- reserved.add("return");
193
- reserved.add("switch");
194
- reserved.add("this");
195
- reserved.add("throw");
196
- reserved.add("try");
197
- reserved.add("typeof");
198
- reserved.add("var");
199
- reserved.add("void");
200
- reserved.add("while");
201
- reserved.add("with");
202
- // Words reserved for future use
203
- reserved.add("abstract");
204
- reserved.add("boolean");
205
- reserved.add("byte");
206
- reserved.add("char");
207
- reserved.add("class");
208
- reserved.add("const");
209
- reserved.add("debugger");
210
- reserved.add("double");
211
- reserved.add("enum");
212
- reserved.add("export");
213
- reserved.add("extends");
214
- reserved.add("final");
215
- reserved.add("float");
216
- reserved.add("goto");
217
- reserved.add("implements");
218
- reserved.add("import");
219
- reserved.add("int");
220
- reserved.add("interface");
221
- reserved.add("long");
222
- reserved.add("native");
223
- reserved.add("package");
224
- reserved.add("private");
225
- reserved.add("protected");
226
- reserved.add("public");
227
- reserved.add("short");
228
- reserved.add("static");
229
- reserved.add("super");
230
- reserved.add("synchronized");
231
- reserved.add("throws");
232
- reserved.add("transient");
233
- reserved.add("volatile");
234
- // These are not reserved, but should be taken into account
235
- // in isValidIdentifier (See jslint source code)
236
- reserved.add("arguments");
237
- reserved.add("eval");
238
- reserved.add("true");
239
- reserved.add("false");
240
- reserved.add("Infinity");
241
- reserved.add("NaN");
242
- reserved.add("null");
243
- reserved.add("undefined");
244
- }
245
-
246
- private static int countChar(String haystack, char needle) {
247
- int idx = 0;
248
- int count = 0;
249
- int length = haystack.length();
250
- while (idx < length) {
251
- char c = haystack.charAt(idx++);
252
- if (c == needle) {
253
- count++;
254
- }
255
- }
256
- return count;
257
- }
258
-
259
- private static int printSourceString(String source, int offset, StringBuffer sb) {
260
- int length = source.charAt(offset);
261
- ++offset;
262
- if ((0x8000 & length) != 0) {
263
- length = ((0x7FFF & length) << 16) | source.charAt(offset);
264
- ++offset;
265
- }
266
- if (sb != null) {
267
- String str = source.substring(offset, offset + length);
268
- sb.append(str);
269
- }
270
- return offset + length;
271
- }
272
-
273
- private static int printSourceNumber(String source,
274
- int offset, StringBuffer sb) {
275
- double number = 0.0;
276
- char type = source.charAt(offset);
277
- ++offset;
278
- if (type == 'S') {
279
- if (sb != null) {
280
- number = source.charAt(offset);
281
- }
282
- ++offset;
283
- } else if (type == 'J' || type == 'D') {
284
- if (sb != null) {
285
- long lbits;
286
- lbits = (long) source.charAt(offset) << 48;
287
- lbits |= (long) source.charAt(offset + 1) << 32;
288
- lbits |= (long) source.charAt(offset + 2) << 16;
289
- lbits |= (long) source.charAt(offset + 3);
290
- if (type == 'J') {
291
- number = lbits;
292
- } else {
293
- number = Double.longBitsToDouble(lbits);
294
- }
295
- }
296
- offset += 4;
297
- } else {
298
- // Bad source
299
- throw new RuntimeException();
300
- }
301
- if (sb != null) {
302
- sb.append(ScriptRuntime.numberToString(number, 10));
303
- }
304
- return offset;
305
- }
306
-
307
- private static ArrayList parse(Reader in, ErrorReporter reporter)
308
- throws IOException, EvaluatorException {
309
-
310
- CompilerEnvirons env = new CompilerEnvirons();
311
- Parser parser = new Parser(env, reporter);
312
- parser.parse(in, null, 1);
313
- String source = parser.getEncodedSource();
314
-
315
- int offset = 0;
316
- int length = source.length();
317
- ArrayList tokens = new ArrayList();
318
- StringBuffer sb = new StringBuffer();
319
-
320
- while (offset < length) {
321
- int tt = source.charAt(offset++);
322
- switch (tt) {
323
-
324
- case Token.CONDCOMMENT:
325
- case Token.KEEPCOMMENT:
326
- case Token.NAME:
327
- case Token.REGEXP:
328
- case Token.STRING:
329
- sb.setLength(0);
330
- offset = printSourceString(source, offset, sb);
331
- tokens.add(new JavaScriptToken(tt, sb.toString()));
332
- break;
333
-
334
- case Token.NUMBER:
335
- sb.setLength(0);
336
- offset = printSourceNumber(source, offset, sb);
337
- tokens.add(new JavaScriptToken(tt, sb.toString()));
338
- break;
339
-
340
- default:
341
- String literal = (String) literals.get(new Integer(tt));
342
- if (literal != null) {
343
- tokens.add(new JavaScriptToken(tt, literal));
344
- }
345
- break;
346
- }
347
- }
348
-
349
- return tokens;
350
- }
351
-
352
- private static void processStringLiterals(ArrayList tokens, boolean merge) {
353
-
354
- String tv;
355
- int i, length = tokens.size();
356
- JavaScriptToken token, prevToken, nextToken;
357
-
358
- if (merge) {
359
-
360
- // Concatenate string literals that are being appended wherever
361
- // it is safe to do so. Note that we take care of the case:
362
- // "a" + "b".toUpperCase()
363
-
364
- for (i = 0; i < length; i++) {
365
- token = (JavaScriptToken) tokens.get(i);
366
- switch (token.getType()) {
367
-
368
- case Token.ADD:
369
- if (i > 0 && i < length) {
370
- prevToken = (JavaScriptToken) tokens.get(i - 1);
371
- nextToken = (JavaScriptToken) tokens.get(i + 1);
372
- if (prevToken.getType() == Token.STRING && nextToken.getType() == Token.STRING &&
373
- (i == length - 1 || ((JavaScriptToken) tokens.get(i + 2)).getType() != Token.DOT)) {
374
- tokens.set(i - 1, new JavaScriptToken(Token.STRING,
375
- prevToken.getValue() + nextToken.getValue()));
376
- tokens.remove(i + 1);
377
- tokens.remove(i);
378
- i = i - 1;
379
- length = length - 2;
380
- break;
381
- }
382
- }
383
- }
384
- }
385
-
386
- }
387
-
388
- // Second pass...
389
-
390
- for (i = 0; i < length; i++) {
391
- token = (JavaScriptToken) tokens.get(i);
392
- if (token.getType() == Token.STRING) {
393
- tv = token.getValue();
394
-
395
- // Finally, add the quoting characters and escape the string. We use
396
- // the quoting character that minimizes the amount of escaping to save
397
- // a few additional bytes.
398
-
399
- char quotechar;
400
- int singleQuoteCount = countChar(tv, '\'');
401
- int doubleQuoteCount = countChar(tv, '"');
402
- if (doubleQuoteCount <= singleQuoteCount) {
403
- quotechar = '"';
404
- } else {
405
- quotechar = '\'';
406
- }
407
-
408
- tv = quotechar + escapeString(tv, quotechar) + quotechar;
409
-
410
- // String concatenation transforms the old script scheme:
411
- // '<scr'+'ipt ...><'+'/script>'
412
- // into the following:
413
- // '<script ...></script>'
414
- // which breaks if this code is embedded inside an HTML document.
415
- // Since this is not the right way to do this, let's fix the code by
416
- // transforming all "</script" into "<\/script"
417
-
418
- if (tv.indexOf("</script") >= 0) {
419
- tv = tv.replaceAll("<\\/script", "<\\\\/script");
420
- }
421
-
422
- tokens.set(i, new JavaScriptToken(Token.STRING, tv));
423
- }
424
- }
425
- }
426
-
427
- // Add necessary escaping that was removed in Rhino's tokenizer.
428
- private static String escapeString(String s, char quotechar) {
429
-
430
- assert quotechar == '"' || quotechar == '\'';
431
-
432
- if (s == null) {
433
- return null;
434
- }
435
-
436
- StringBuffer sb = new StringBuffer();
437
- for (int i = 0, L = s.length(); i < L; i++) {
438
- int c = s.charAt(i);
439
- if (c == quotechar) {
440
- sb.append("\\");
441
- }
442
- sb.append((char) c);
443
- }
444
-
445
- return sb.toString();
446
- }
447
-
448
- /*
449
- * Simple check to see whether a string is a valid identifier name.
450
- * If a string matches this pattern, it means it IS a valid
451
- * identifier name. If a string doesn't match it, it does not
452
- * necessarily mean it is not a valid identifier name.
453
- */
454
- private static final Pattern SIMPLE_IDENTIFIER_NAME_PATTERN = Pattern.compile("^[a-zA-Z_][a-zA-Z0-9_]*quot;);
455
-
456
- private static boolean isValidIdentifier(String s) {
457
- Matcher m = SIMPLE_IDENTIFIER_NAME_PATTERN.matcher(s);
458
- return (m.matches() && !reserved.contains(s));
459
- }
460
-
461
- /*
462
- * Transforms obj["foo"] into obj.foo whenever possible, saving 3 bytes.
463
- */
464
- private static void optimizeObjectMemberAccess(ArrayList tokens) {
465
-
466
- String tv;
467
- int i, length;
468
- JavaScriptToken token;
469
-
470
- for (i = 0, length = tokens.size(); i < length; i++) {
471
-
472
- if (((JavaScriptToken) tokens.get(i)).getType() == Token.LB &&
473
- i > 0 && i < length - 2 &&
474
- ((JavaScriptToken) tokens.get(i - 1)).getType() == Token.NAME &&
475
- ((JavaScriptToken) tokens.get(i + 1)).getType() == Token.STRING &&
476
- ((JavaScriptToken) tokens.get(i + 2)).getType() == Token.RB) {
477
- token = (JavaScriptToken) tokens.get(i + 1);
478
- tv = token.getValue();
479
- tv = tv.substring(1, tv.length() - 1);
480
- if (isValidIdentifier(tv)) {
481
- tokens.set(i, new JavaScriptToken(Token.DOT, "."));
482
- tokens.set(i + 1, new JavaScriptToken(Token.NAME, tv));
483
- tokens.remove(i + 2);
484
- i = i + 2;
485
- length = length - 1;
486
- }
487
- }
488
- }
489
- }
490
-
491
- /*
492
- * Transforms 'foo': ... into foo: ... whenever possible, saving 2 bytes.
493
- */
494
- private static void optimizeObjLitMemberDecl(ArrayList tokens) {
495
-
496
- String tv;
497
- int i, length;
498
- JavaScriptToken token;
499
-
500
- for (i = 0, length = tokens.size(); i < length; i++) {
501
- if (((JavaScriptToken) tokens.get(i)).getType() == Token.OBJECTLIT &&
502
- i > 0 && ((JavaScriptToken) tokens.get(i - 1)).getType() == Token.STRING) {
503
- token = (JavaScriptToken) tokens.get(i - 1);
504
- tv = token.getValue();
505
- tv = tv.substring(1, tv.length() - 1);
506
- if (isValidIdentifier(tv)) {
507
- tokens.set(i - 1, new JavaScriptToken(Token.NAME, tv));
508
- }
509
- }
510
- }
511
- }
512
-
513
- private ErrorReporter logger;
514
-
515
- private boolean munge;
516
- private boolean verbose;
517
-
518
- private static final int BUILDING_SYMBOL_TREE = 1;
519
- private static final int CHECKING_SYMBOL_TREE = 2;
520
-
521
- private int mode;
522
- private int offset;
523
- private int braceNesting;
524
- private ArrayList tokens;
525
- private Stack scopes = new Stack();
526
- private ScriptOrFnScope globalScope = new ScriptOrFnScope(-1, null);
527
- private Hashtable indexedScopes = new Hashtable();
528
-
529
- public JavaScriptCompressor(Reader in, ErrorReporter reporter)
530
- throws IOException, EvaluatorException {
531
-
532
- this.logger = reporter;
533
- this.tokens = parse(in, reporter);
534
- }
535
-
536
- public void compress(Writer out, int linebreak, boolean munge, boolean verbose,
537
- boolean preserveAllSemiColons, boolean disableOptimizations)
538
- throws IOException {
539
-
540
- this.munge = munge;
541
- this.verbose = verbose;
542
-
543
- processStringLiterals(this.tokens, !disableOptimizations);
544
-
545
- if (!disableOptimizations) {
546
- optimizeObjectMemberAccess(this.tokens);
547
- optimizeObjLitMemberDecl(this.tokens);
548
- }
549
-
550
- buildSymbolTree();
551
- // DO NOT TOUCH this.tokens BETWEEN THESE TWO PHASES (BECAUSE OF this.indexedScopes)
552
- mungeSymboltree();
553
- StringBuffer sb = printSymbolTree(linebreak, preserveAllSemiColons);
554
-
555
- out.write(sb.toString());
556
- }
557
-
558
- private ScriptOrFnScope getCurrentScope() {
559
- return (ScriptOrFnScope) scopes.peek();
560
- }
561
-
562
- private void enterScope(ScriptOrFnScope scope) {
563
- scopes.push(scope);
564
- }
565
-
566
- private void leaveCurrentScope() {
567
- scopes.pop();
568
- }
569
-
570
- private JavaScriptToken consumeToken() {
571
- return (JavaScriptToken) tokens.get(offset++);
572
- }
573
-
574
- private JavaScriptToken getToken(int delta) {
575
- return (JavaScriptToken) tokens.get(offset + delta);
576
- }
577
-
578
- /*
579
- * Returns the identifier for the specified symbol defined in
580
- * the specified scope or in any scope above it. Returns null
581
- * if this symbol does not have a corresponding identifier.
582
- */
583
- private JavaScriptIdentifier getIdentifier(String symbol, ScriptOrFnScope scope) {
584
- JavaScriptIdentifier identifier;
585
- while (scope != null) {
586
- identifier = scope.getIdentifier(symbol);
587
- if (identifier != null) {
588
- return identifier;
589
- }
590
- scope = scope.getParentScope();
591
- }
592
- return null;
593
- }
594
-
595
- /*
596
- * If either 'eval' or 'with' is used in a local scope, we must make
597
- * sure that all containing local scopes don't get munged. Otherwise,
598
- * the obfuscation would potentially introduce bugs.
599
- */
600
- private void protectScopeFromObfuscation(ScriptOrFnScope scope) {
601
- assert scope != null;
602
-
603
- if (scope == globalScope) {
604
- // The global scope does not get obfuscated,
605
- // so we don't need to worry about it...
606
- return;
607
- }
608
-
609
- // Find the highest local scope containing the specified scope.
610
- while (scope.getParentScope() != globalScope) {
611
- scope = scope.getParentScope();
612
- }
613
-
614
- assert scope.getParentScope() == globalScope;
615
- scope.preventMunging();
616
- }
617
-
618
- private String getDebugString(int max) {
<