sprite 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +14 -2
- data/lib/sprite/builder.rb +5 -2
- data/sprite.gemspec +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -80,9 +80,9 @@ Configuration of `sprite` is done via `config/sprite.yml`. It allows you to set
|
|
80
80
|
- `default_spacing:` defines the default pixel spacing between sprites (defaults to 0)
|
81
81
|
- `resize_to:` width and height (in the format "120x60") to resize all source images to before composition. (defaults to no nil, or no resizing)
|
82
82
|
- `class_separator:` used to generated the class name by separating the image name and sprite name (defaults to `-`)
|
83
|
-
- `add_datestamps`: whether or not to add datestamps to the generated background image urls. this will allow proper cache versioning (defaults to `true`)
|
83
|
+
- `add_datestamps`: whether or not to add datestamps to the generated background image urls. this will allow proper cache versioning (defaults to `true`).
|
84
84
|
- `external_base`: change the base path for your images. (defaults to `/`)
|
85
|
-
- `
|
85
|
+
- `url_formatter`: allows you to specify the format of the background-url. The sprite background is passed in via sprintf formatting. (defaults to nil). This setting overrides external_base. If you use compass, you should set this value to "image-url('%s')"
|
86
86
|
|
87
87
|
* `images:` section provides an array of configurations which define which image files are built, and where they get their sprites from. each image setup provides the following config options:
|
88
88
|
- `name:` name of image (required)
|
@@ -176,6 +176,18 @@ Additional style generators are very easy to add. We have one for `style: sass`
|
|
176
176
|
|
177
177
|
You can also easily script it out via capistrano. You could also run `sprite` on application start, or just about anywhere. Let me know what limitations you run into.
|
178
178
|
|
179
|
+
## Configuring Sprite with Compass ##
|
180
|
+
|
181
|
+
Sprite now works well with Compass with a few config tweaks. Since compass provides its own image-url helper which handles file versioning, it's useful to configure sprite to use that instead. Here's how to do it:
|
182
|
+
|
183
|
+
config:
|
184
|
+
# use the image-url helper with compass
|
185
|
+
url_formatter: "image-url('sprites/%s')"
|
186
|
+
|
187
|
+
# turn off datestamps as they will break compass's image-url helper
|
188
|
+
add_datestamps: false
|
189
|
+
|
190
|
+
|
179
191
|
## ABOUT `sprite` ##
|
180
192
|
|
181
193
|
`sprite` was originally based off of Richard Huang's excellent Rails plugin: [css_sprite](http://github.com/flyerhzm/css_sprite)
|
data/lib/sprite/builder.rb
CHANGED
@@ -63,7 +63,11 @@ module Sprite
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def background_url(name)
|
66
|
-
|
66
|
+
if @config["url_formatter"]
|
67
|
+
sprintf(@config["url_formatter"], name)
|
68
|
+
else
|
69
|
+
"url('#{@config['external_base']}#{@config['image_output_path']}#{name}')"
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
protected
|
@@ -133,7 +137,6 @@ module Sprite
|
|
133
137
|
@config['class_separator'] ||= '-'
|
134
138
|
@config["sprites_class"] ||= 'sprites'
|
135
139
|
@config["default_spacing"] ||= 0
|
136
|
-
@config['url_helper'] ||= 'url'
|
137
140
|
|
138
141
|
unless @config.has_key?("add_datestamps")
|
139
142
|
@config["add_datestamps"] = true
|
data/sprite.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sprite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jacques Crocker
|
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
requirements:
|
123
123
|
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
hash:
|
125
|
+
hash: -2972357079777028663
|
126
126
|
segments:
|
127
127
|
- 0
|
128
128
|
version: "0"
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
requirements:
|
132
132
|
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
hash:
|
134
|
+
hash: -2972357079777028663
|
135
135
|
segments:
|
136
136
|
- 0
|
137
137
|
version: "0"
|