Support for yUglify
This commit is contained in:
		 Chris Kief
					Chris Kief
				
			
				
					committed by
					
						 Jannis Leidel
						Jannis Leidel
					
				
			
			
				
	
			
			
			 Jannis Leidel
						Jannis Leidel
					
				
			
						parent
						
							77268dd20a
						
					
				
				
					commit
					de7febcb4f
				
			| @@ -45,9 +45,10 @@ html5lib_ based parser, as well as an abstract base class that makes it easy to | |||||||
| write a custom parser. | write a custom parser. | ||||||
|  |  | ||||||
| Django Compressor also comes with built-in support for `CSS Tidy`_, | Django Compressor also comes with built-in support for `CSS Tidy`_, | ||||||
| `YUI CSS and JS`_ compressor, the Google's `Closure Compiler`_, a Python | `YUI CSS and JS`_ compressor, `yUglify CSS and JS`_ compressor, the Google's | ||||||
| port of Douglas Crockford's JSmin_, a Python port of the YUI CSS Compressor | `Closure Compiler`_, a Python port of Douglas Crockford's JSmin_, a Python port | ||||||
| cssmin_ and a filter to convert (some) images into `data URIs`_. |  of the YUI CSS Compressor cssmin_ and a filter to convert (some) images into | ||||||
|  |  `data URIs`_. | ||||||
|  |  | ||||||
| If your setup requires a different compressor or other post-processing | If your setup requires a different compressor or other post-processing | ||||||
| tool it will be fairly easy to implement a custom filter. Simply extend | tool it will be fairly easy to implement a custom filter. Simply extend | ||||||
| @@ -67,6 +68,7 @@ The `in-development version`_ of Django Compressor can be installed with | |||||||
| .. _html5lib: http://code.google.com/p/html5lib/ | .. _html5lib: http://code.google.com/p/html5lib/ | ||||||
| .. _CSS Tidy: http://csstidy.sourceforge.net/ | .. _CSS Tidy: http://csstidy.sourceforge.net/ | ||||||
| .. _YUI CSS and JS: http://developer.yahoo.com/yui/compressor/ | .. _YUI CSS and JS: http://developer.yahoo.com/yui/compressor/ | ||||||
|  | .. _yUglify CSS and JS: https://github.com/yui/yuglify | ||||||
| .. _Closure Compiler: http://code.google.com/closure/compiler/ | .. _Closure Compiler: http://code.google.com/closure/compiler/ | ||||||
| .. _JSMin: http://www.crockford.com/javascript/jsmin.html | .. _JSMin: http://www.crockford.com/javascript/jsmin.html | ||||||
| .. _cssmin: https://github.com/zacharyvoase/cssmin | .. _cssmin: https://github.com/zacharyvoase/cssmin | ||||||
|   | |||||||
| @@ -42,6 +42,9 @@ class CompressorConf(AppConf): | |||||||
|     YUI_BINARY = 'java -jar yuicompressor.jar' |     YUI_BINARY = 'java -jar yuicompressor.jar' | ||||||
|     YUI_CSS_ARGUMENTS = '' |     YUI_CSS_ARGUMENTS = '' | ||||||
|     YUI_JS_ARGUMENTS = '' |     YUI_JS_ARGUMENTS = '' | ||||||
|  |     YUGLIFY_BINARY = 'yuglify' | ||||||
|  |     YUGLIFY_CSS_ARGUMENTS = '--terminal' | ||||||
|  |     YUGLIFY_JS_ARGUMENTS = '--terminal' | ||||||
|     DATA_URI_MAX_SIZE = 1024 |     DATA_URI_MAX_SIZE = 1024 | ||||||
|  |  | ||||||
|     # the cache backend to use |     # the cache backend to use | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								compressor/filters/yuglify.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								compressor/filters/yuglify.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | from compressor.conf import settings | ||||||
|  | from compressor.filters import CompilerFilter | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class YUglifyFilter(CompilerFilter): | ||||||
|  |     command = "{binary} {args}" | ||||||
|  |  | ||||||
|  |     def __init__(self, *args, **kwargs): | ||||||
|  |         super(YUglifyFilter, self).__init__(*args, **kwargs) | ||||||
|  |         self.command += ' --type=%s' % self.type | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class YUglifyCSSFilter(YUglifyFilter): | ||||||
|  |     type = 'css' | ||||||
|  |     options = ( | ||||||
|  |         ("binary", settings.COMPRESS_YUGLIFY_BINARY), | ||||||
|  |         ("args", settings.COMPRESS_YUGLIFY_CSS_ARGUMENTS), | ||||||
|  |     ) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class YUglifyJSFilter(YUglifyFilter): | ||||||
|  |     type = 'js' | ||||||
|  |     options = ( | ||||||
|  |         ("binary", settings.COMPRESS_YUGLIFY_BINARY), | ||||||
|  |         ("args", settings.COMPRESS_YUGLIFY_JS_ARGUMENTS), | ||||||
|  |     ) | ||||||
| @@ -119,6 +119,18 @@ Backend settings | |||||||
|  |  | ||||||
|          The arguments passed to the compressor. |          The arguments passed to the compressor. | ||||||
|  |  | ||||||
|  |     - ``compressor.filters.yuglify.YUglifyCSSFilter`` | ||||||
|  |  | ||||||
|  |       A filter that passes the CSS content to the `yUglify compressor`_. | ||||||
|  |  | ||||||
|  |       .. attribute:: COMPRESS_YUGLIFY_BINARY | ||||||
|  |  | ||||||
|  |          The yUglify compressor filesystem path. | ||||||
|  |  | ||||||
|  |       .. attribute:: COMPRESS_YUGLIFY_CSS_ARGUMENTS | ||||||
|  |  | ||||||
|  |          The arguments passed to the compressor. Defaults to --terminal. | ||||||
|  |  | ||||||
|     - ``compressor.filters.cssmin.CSSMinFilter`` |     - ``compressor.filters.cssmin.CSSMinFilter`` | ||||||
|  |  | ||||||
|       A filter that uses Zachary Voase's Python port of the YUI CSS compression |       A filter that uses Zachary Voase's Python port of the YUI CSS compression | ||||||
| @@ -184,6 +196,18 @@ Backend settings | |||||||
|  |  | ||||||
|          The arguments passed to the compressor. |          The arguments passed to the compressor. | ||||||
|  |  | ||||||
|  |     - ``compressor.filters.yuglify.YUglifyJSFilter`` | ||||||
|  |  | ||||||
|  |       A filter that passes the JavaScript code to the `yUglify compressor`_. | ||||||
|  |  | ||||||
|  |       .. attribute:: COMPRESS_YUGLIFY_BINARY | ||||||
|  |  | ||||||
|  |          The yUglify compressor filesystem path. | ||||||
|  |  | ||||||
|  |       .. attribute:: COMPRESS_YUGLIFY_JS_ARGUMENTS | ||||||
|  |  | ||||||
|  |          The arguments passed to the compressor. | ||||||
|  |  | ||||||
|     - ``compressor.filters.template.TemplateFilter`` |     - ``compressor.filters.template.TemplateFilter`` | ||||||
|  |  | ||||||
|       A filter that renders the JavaScript code with Django templating system. |       A filter that renders the JavaScript code with Django templating system. | ||||||
| @@ -195,6 +219,7 @@ Backend settings | |||||||
|     .. _rJSmin: http://opensource.perlig.de/rjsmin/ |     .. _rJSmin: http://opensource.perlig.de/rjsmin/ | ||||||
|     .. _`Google Closure compiler`: http://code.google.com/closure/compiler/ |     .. _`Google Closure compiler`: http://code.google.com/closure/compiler/ | ||||||
|     .. _`YUI compressor`: http://developer.yahoo.com/yui/compressor/ |     .. _`YUI compressor`: http://developer.yahoo.com/yui/compressor/ | ||||||
|  |     .. _`yUglify compressor`: https://github.com/yui/yuglify | ||||||
|     .. _`Slim It`: http://slimit.org/ |     .. _`Slim It`: http://slimit.org/ | ||||||
|  |  | ||||||
| .. attribute:: COMPRESS_PRECOMPILERS | .. attribute:: COMPRESS_PRECOMPILERS | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user