Skip to content

Commit

Permalink
Added ClosureCompiler media processor (as YUICompressor alternative)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrulik committed Nov 12, 2009
1 parent ed8391c commit 3e31c3e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 23 additions & 1 deletion hydeengine/media_processors.py
Expand Up @@ -96,4 +96,26 @@ def process(resource):
print output
else:
resource.source_file.delete()
tmp_file.move_to(resource.source_file.path)
tmp_file.move_to(resource.source_file.path)

class ClosureCompiler:
@staticmethod
def process(resource):
compress = settings.CLOSURE_COMPILER
if not os.path.exists(compress):
compress = os.path.join(
os.path.dirname(
os.path.abspath(__file__)), "..", compress)

if not compress or not os.path.exists(compress):
raise ValueError(
"Closure Compiler cannot be found at [%s]" % compress)

tmp_file = File(resource.source_file.path + ".z-tmp")
status, output = commands.getstatusoutput(
u"java -jar %s --js=%s --js_output_file=%s" % (compress, resource.source_file.path, tmp_file.path))
if status > 0:
print output
else:
resource.source_file.delete()
tmp_file.move_to(resource.source_file.path)
6 changes: 6 additions & 0 deletions templates/default/settings.py
Expand Up @@ -116,6 +116,12 @@
YUI_COMPRESSOR = "./lib/yuicompressor-2.4.1.jar"
#YUI_COMPRESSOR = None

# path for Closure Compiler, or None if you don't
# want to compress JS/CSS. Project homepage:
# http://closure-compiler.googlecode.com/
#CLOSURE_COMPILER = "./lib/compiler.jar"
CLOSURE_COMPRILER = None

# path for HSS, which is a preprocessor for CSS-like files (*.hss)
# project page at http://ncannasse.fr/projects/hss
#HSS_PATH = "./lib/hss-1.0-osx"
Expand Down

0 comments on commit 3e31c3e

Please sign in to comment.