Permalink
Browse files

More cleanup and version bump (v0.5)

  • Loading branch information...
1 parent 1809838 commit 5d92974457db03d55d3f86ed68b3552d5612e244 James Socol committed Oct 31, 2011
Showing with 50 additions and 15 deletions.
  1. +31 −0 CHANGES.rst
  2. +1 −0 MANIFEST.in
  3. +2 −2 jingo_minify/helpers.py
  4. +7 −7 jingo_minify/management/commands/compress_assets.py
  5. +7 −5 jingo_minify/tests.py
  6. +2 −1 setup.py
View
@@ -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.
View
@@ -1,4 +1,5 @@
include LICENSE
include CONTRIBUTORS
include README.rst
+include CHANGES.rst
include jingo_minify/bin/yuicompressor-2.4.2.jar
View
@@ -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, """<script src="%s"></script>""")
+ return _build_html(items, '<script src="%s"></script>')
@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,
- """<link rel="stylesheet" media="%s" href="%%s" />""" % media)
+ '<link rel="stylesheet" media="%s" href="%%s" />' % media)
def build_less(item):
path_css = path('%s.css' % item)
@@ -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
View
@@ -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,15 +27,15 @@ def test_js_helper():
t = env.from_string("{{ js('common', debug=True) }}")
s = t.render()
- expected ="\n".join(["""<script src="%s"></script>""" % (settings.MEDIA_URL + j)
+ expected ="\n".join(['<script src="%s"></script>' % (settings.MEDIA_URL + j)
for j in settings.MINIFY_BUNDLES['js']['common']])
eq_(s, expected)
t = env.from_string("{{ js('common', debug=False) }}")
s = t.render()
- eq_(s, """<script src="%s"></script>""" %
+ eq_(s, '<script src="%s"></script>' %
(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(
- ["""<link rel="stylesheet" media="screen,projection,tv" href="%s" />"""
+ ['<link rel="stylesheet" media="screen,projection,tv" href="%s" />'
% (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,
- """<link rel="stylesheet" media="screen,projection,tv" href="%s" />"""
- % (settings.MEDIA_URL + "css/common-min.css?build=%s" % BUILD_ID_CSS))
+ '<link rel="stylesheet" media="screen,projection,tv" href="%s" />'
+ % (settings.MEDIA_URL + 'css/common-min.css?build=%s' % BUILD_ID_CSS))
View
@@ -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',

0 comments on commit 5d92974

Please sign in to comment.