From 5d92974457db03d55d3f86ed68b3552d5612e244 Mon Sep 17 00:00:00 2001 From: James Socol Date: Mon, 31 Oct 2011 18:43:36 -0400 Subject: [PATCH] More cleanup and version bump (v0.5) --- CHANGES.rst | 31 +++++++++++++++++++ MANIFEST.in | 1 + jingo_minify/helpers.py | 4 +-- .../management/commands/compress_assets.py | 14 ++++----- jingo_minify/tests.py | 12 ++++--- setup.py | 3 +- 6 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 CHANGES.rst diff --git a/CHANGES.rst b/CHANGES.rst new file mode 100644 index 0000000..fc0bd5e --- /dev/null +++ b/CHANGES.rst @@ -0,0 +1,31 @@ +========= +CHANGELOG +========= + +0.5 +=== + +* Add support for UglifyJS_ and clean-css_. +* Support cache-busting images in CSS. +* Add --update-only option. +* Print out more info with --verbosity. +* Only minify changed files. +* Clean-up and refactor. + + +.. _UglifyJS: http://marijnhaverbeke.nl/uglifyjs +.. _clean-css: https://github.com/GoalSmashers/clean-css + + +0.4 +=== + +* Add support for LESS_. + +.. _LESS: http://lesscss.org/ + + +0.3.2 +===== + +* Upgrade to YUICompressor 2.4.4. diff --git a/MANIFEST.in b/MANIFEST.in index 7d1c0c7..0dd0323 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include LICENSE include CONTRIBUTORS include README.rst +include CHANGES.rst include jingo_minify/bin/yuicompressor-2.4.2.jar diff --git a/jingo_minify/helpers.py b/jingo_minify/helpers.py index 9796b09..c0d283e 100644 --- a/jingo_minify/helpers.py +++ b/jingo_minify/helpers.py @@ -37,7 +37,7 @@ def js(bundle, debug=settings.TEMPLATE_DEBUG): build_id = BUNDLE_HASHES[bundle_full] items = ("js/%s-min.js?build=%s" % (bundle, build_id,),) - return _build_html(items, """""") + return _build_html(items, '') @register.function @@ -64,7 +64,7 @@ def css(bundle, media="screen,projection,tv", debug=settings.TEMPLATE_DEBUG): items = ("css/%s-min.css?build=%s" % (bundle, build_id,),) return _build_html(items, - """""" % media) + '' % media) def build_less(item): path_css = path('%s.css' % item) diff --git a/jingo_minify/management/commands/compress_assets.py b/jingo_minify/management/commands/compress_assets.py index e7feec8..8dbc0f0 100644 --- a/jingo_minify/management/commands/compress_assets.py +++ b/jingo_minify/management/commands/compress_assets.py @@ -106,7 +106,7 @@ def handle(self, **options): self.minify_skipped) def _preprocess_file(self, filename): - """ Preprocess files and return new filenames. """ + """Preprocess files and return new filenames.""" if filename.endswith('.less'): fp = path(filename.lstrip('/')) call('%s %s %s.css' % (settings.LESS_BIN, fp, fp), @@ -115,7 +115,7 @@ def _preprocess_file(self, filename): return path(filename.lstrip('/')) def _is_changed(self, concatted_file): - """ Check if the file has been changed. """ + """Check if the file has been changed.""" tmp_concatted = '%s.tmp' % concatted_file if (os.path.exists(concatted_file) and os.path.getsize(concatted_file) == os.path.getsize(tmp_concatted)): @@ -125,14 +125,14 @@ def _is_changed(self, concatted_file): return True # Different filesize, so it was definitely changed def _clean_tmp(self, concatted_file): - """ Replace the old file with the temp file. """ + """Replace the old file with the temp file.""" tmp_concatted = '%s.tmp' % concatted_file if os.path.exists(concatted_file): os.remove(concatted_file) os.rename(tmp_concatted, concatted_file) def _cachebust(self, css_file, bundle_name): - """ Cache bust images. Return a new bundle hash. """ + """Cache bust images. Return a new bundle hash.""" print "Cache busting images in %s" % re.sub('.tmp$', '', css_file) css_content = '' @@ -157,7 +157,7 @@ def _cachebust(self, css_file, bundle_name): return file_hash def _minify(self, ftype, file_in, file_out): - """ Run the proper minifier on the file. """ + """Run the proper minifier on the file.""" if ftype == 'js' and hasattr(settings, 'UGLIFY_BIN'): o = {'method': 'UglifyJS', 'bin': settings.UGLIFY_BIN} call("%s %s -nc -o %s %s" % (o['bin'], self.v, file_out, file_in), @@ -175,7 +175,7 @@ def _minify(self, ftype, file_in, file_out): print "Minifying %s (using %s)" % (file_in, o['method']) def _file_hash(self, url): - """ Open the file and get a hash of it. """ + """Open the file and get a hash of it.""" if url in self.checked_hash: return self.checked_hash[url] @@ -192,7 +192,7 @@ def _file_hash(self, url): return file_hash def _cachebust_regex(self, img, parent): - """ Run over the regex; img is the structural regex object. """ + """Run over the regex; img is the structural regex object.""" url = img.group(1).strip('"\'') if url.startswith('data:') or url.startswith('http'): return "url(%s)" % url diff --git a/jingo_minify/tests.py b/jingo_minify/tests.py index f118be6..b19f213 100644 --- a/jingo_minify/tests.py +++ b/jingo_minify/tests.py @@ -9,9 +9,11 @@ except: BUILD_ID_CSS = BUILD_ID_JS = 'dev' + def setup(): jingo.load_helpers() + def test_js_helper(): """ Given the js() tag if we return the assets that make up that bundle @@ -25,7 +27,7 @@ def test_js_helper(): t = env.from_string("{{ js('common', debug=True) }}") s = t.render() - expected ="\n".join(["""""" % (settings.MEDIA_URL + j) + expected ="\n".join(['' % (settings.MEDIA_URL + j) for j in settings.MINIFY_BUNDLES['js']['common']]) eq_(s, expected) @@ -33,7 +35,7 @@ def test_js_helper(): t = env.from_string("{{ js('common', debug=False) }}") s = t.render() - eq_(s, """""" % + eq_(s, '' % (settings.MEDIA_URL + "js/common-min.js?build=%s" % BUILD_ID_JS)) @@ -50,7 +52,7 @@ def test_css_helper(): s = t.render() expected ="\n".join( - ["""""" + ['' % (settings.MEDIA_URL + j) for j in settings.MINIFY_BUNDLES['css']['common']]) @@ -60,5 +62,5 @@ def test_css_helper(): s = t.render() eq_(s, - """""" - % (settings.MEDIA_URL + "css/common-min.css?build=%s" % BUILD_ID_CSS)) + '' + % (settings.MEDIA_URL + 'css/common-min.css?build=%s' % BUILD_ID_CSS)) diff --git a/setup.py b/setup.py index fbf7c93..77e4d81 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,9 @@ setup( name='jingo_minify', - version='0.4', + version='0.5', description='A Django app that will concat and minify JS and CSS.', + long_description=open('README.rst').read(), author='Dave Dash, James Socol', author_email='dd@mozilla.com, james@mozilla.com', url='http://github.com/jsocol/jingo-minify',