Skip to content

Add the ability to set stylesheet url #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Configuration of `sprite` is done via `config/sprite.yml`. It allows you to set
- `style:` defines how the style rules are outputted. built in options are `css`, `sass`, and `sass_mixin`. (defaults to `css`)
- `style_output_path:` defines the file path where your style settings get written (defaults to `stylesheets/sprites`). the file extension not needed as it will be set based on the `style:` setting
- `image_output_path:` defines the folder path where the combined sprite images files are written (defaults to `images/sprites/`)
- `image_stylesheet_path:` defines the path the stylesheet will use when setting the url to the background images (defaults to the image_output_path)
- `image_source_path:` defines the folder where source image files are read from (defaults to `images/`)
- `public_path:` defines the root folder where static assets live (defaults to `public/`)
- `sprites_class:` defines the class name that gets added to all sprite stylesheet rules (defaults to `sprites`)
Expand Down
1 change: 1 addition & 0 deletions lib/sprite/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def set_config_defaults
@config["sprites_class"] ||= 'sprites'
@config["default_spacing"] ||= 0

@config['image_stylesheet_path'] ||= @config['image_output_path']
unless @config.has_key?("add_datestamps")
@config["add_datestamps"] = true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/sprite/styles/css_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def write(path, sprite_files)
sprite_files.each do |sprite_file, sprites|
sprites.each do |sprite|
f.puts "#{sprites_class}.#{sprite[:group]}#{@builder.config['class_separator']}#{sprite[:name]} {"
f.puts " background: url(http://github.com/'/#{@builder.config['%3Cspan%20class=%22x%20x-first%20x-last%22%3Eimage_output_path%3C/span%3E']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px;"
f.puts " background: url(http://github.com/'/#{@builder.config['%3Cspan%20class=%22x%20x-first%20x-last%22%3Eimage_stylesheet_path%3C/span%3E']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px;"
f.puts " width: #{sprite[:width]}px;"
f.puts " height: #{sprite[:height]}px;"
f.puts "}"
Expand Down
2 changes: 1 addition & 1 deletion lib/sprite/styles/sass_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def write(path, sprite_files)
sprites.each do |sprite|
f.puts sass_line("&.#{sprite[:group]}#{@builder.config['class_separator']}#{sprite[:name]}")
@level += 1
f.puts sass_line("background: url(http://github.com/'/#{@builder.config['%3Cspan%20class=%22x%20x-first%20x-last%22%3Eimage_output_path%3C/span%3E']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px")
f.puts sass_line("background: url(http://github.com/'/#{@builder.config['%3Cspan%20class=%22x%20x-first%20x-last%22%3Eimage_stylesheet_path%3C/span%3E']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px")
f.puts sass_line("width: #{sprite[:width]}px")
f.puts sass_line("height: #{sprite[:height]}px")
f.puts sass_line("")
Expand Down
2 changes: 1 addition & 1 deletion lib/sprite/styles/sass_mixin_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def write(path, sprite_files)
end

f.puts %{if !group_name == "#{sprite[:group]}" and !image_name == "#{sprite[:name]}"}
f.puts " background: url(http://github.com/'/#{@builder.config['%3Cspan%20class=%22x%20x-first%20x-last%22%3Eimage_output_path%3C/span%3E']}#{sprite_file}') no-repeat #{background_offset}"
f.puts " background: url(http://github.com/'/#{@builder.config['%3Cspan%20class=%22x%20x-first%20x-last%22%3Eimage_stylesheet_path%3C/span%3E']}#{sprite_file}') no-repeat #{background_offset}"
f.puts " width: #{sprite[:width]}px"
f.puts " height: #{sprite[:height]}px"
end
Expand Down
4 changes: 4 additions & 0 deletions spec/sprite/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
@sprite.config['image_output_path'].should == "images/sprites/"
end

it "'image_stylesheet_path:' setting should default to `image_output_path`" do
@sprite.config['image_stylesheet_path'].should == @sprite.config['image_output_path']
end

it "'image_source_path:' setting should default to 'images/'" do
@sprite.config['image_source_path'].should == "images/"
end
Expand Down