Skip to content

Commit

Permalink
merging audreypopp's and lericson's changes -- spritemap support
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Jun 19, 2010
2 parents b8e1df0 + 865bfef commit f5a98c9
Show file tree
Hide file tree
Showing 13 changed files with 502 additions and 60 deletions.
4 changes: 4 additions & 0 deletions BUGFIXES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ List of bug fixes since CleverCSS-0.1

9/18/09 - v.0.1.5 - submitted by Tim Babych - LineIterator was not filtering out "\n"s that were left after trimming /* comments */, causing an exception in Parser

9/18/09 - v.0.1.5 - submitted by Tim Babych - The Parser was not aware of negative numbers. Thus any minus sign was an operator, leading to unneeded calculations. Say, "margin: -2px -2px" was converted into "margin: -4px"

9/18/09 - v.0.1.5 - submitted by Tim Babych - LineIterator was not filtering out "\n"s that were left after trimming /* comments */, causing an exception in Parser

9/01/09 - v.0.1.4 - submitted by David Niergarth and 'Lasse' - Missing None check in Engine.evaluate which causes context to always be reset to {}.

4/20/09 - v.0.1.3 - submitted by Antti Kaihola - Using the rgb_to_hls() and hls_to_rgb() functions in CleverCSS to convert colors back and forth reveals a mistake in the HLS to RGB algorithm. Fractional parts are stripped when rounding should be done instead.
Expand Down
2 changes: 1 addition & 1 deletion bin/ccss
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def convert_many(files, options):
src = open(fname)
try:
try:
converted = clevercss.convert(src.read())
converted = clevercss.convert(src.read(), fname=fname)
except (ParserError, EvalException), e:
sys.stderr.write('Error in file %s: %s\n' % (fname, e))
sys.exit(1)
Expand Down
23 changes: 21 additions & 2 deletions clevercss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,25 @@
1, 2, 3, 4, 5
Spritemaps
----------
Commonly in CSS, you'll have an image of all your UI elements, and then use
background positioning to extract a part of that image. CleverCSS helps you
with this, via the `spritemap(fn)` call. For example::
ui = spritemap('ui.sprites')
some_button = $ui.sprite('some_button.png')
other_button = $ui.sprite('other_button.png')
div.some_button:
background: $some_button
div.other_button:
background: $other_button
width: $other_button.width()
height: $other_button.height()
:copyright: Copyright 2007 by Armin Ronacher, Georg Brandl.
:license: BSD License
"""
Expand All @@ -234,11 +253,11 @@ def __init__(self, *args, **kwargs):
args = ()
super(Context, self).__init__(*args, **kwargs)

def convert(source, context=None, minified=False):
def convert(source, context=None, fname=None, minified=False):
"""Convert CleverCSS text into normal CSS."""
context = Context(context)
context.minified = minified
return engine.Engine(source).to_css(context)
return engine.Engine(source, fname=fname).to_css(context)

__all__ = ['convert']

Expand Down
Loading

0 comments on commit f5a98c9

Please sign in to comment.