diff --git a/README.md b/README.md index eeca7bf..63a1ed2 100644 --- a/README.md +++ b/README.md @@ -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`) diff --git a/lib/sprite/builder.rb b/lib/sprite/builder.rb index 303f73a..1c7ee08 100644 --- a/lib/sprite/builder.rb +++ b/lib/sprite/builder.rb @@ -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 diff --git a/lib/sprite/styles/css_generator.rb b/lib/sprite/styles/css_generator.rb index d52292b..e44bc24 100644 --- a/lib/sprite/styles/css_generator.rb +++ b/lib/sprite/styles/css_generator.rb @@ -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['image_output_path']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px;" + f.puts " background: url('http://github.com/#{@builder.config['image_stylesheet_path']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px;" f.puts " width: #{sprite[:width]}px;" f.puts " height: #{sprite[:height]}px;" f.puts "}" diff --git a/lib/sprite/styles/sass_generator.rb b/lib/sprite/styles/sass_generator.rb index e7b771a..b7939f9 100644 --- a/lib/sprite/styles/sass_generator.rb +++ b/lib/sprite/styles/sass_generator.rb @@ -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['image_output_path']}#{sprite_file}') no-repeat #{sprite[:x]}px #{sprite[:y]}px") + f.puts sass_line("background: url('http://github.com/#{@builder.config['image_stylesheet_path']}#{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("") diff --git a/lib/sprite/styles/sass_mixin_generator.rb b/lib/sprite/styles/sass_mixin_generator.rb index 5720a1f..c55c143 100644 --- a/lib/sprite/styles/sass_mixin_generator.rb +++ b/lib/sprite/styles/sass_mixin_generator.rb @@ -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['image_output_path']}#{sprite_file}') no-repeat #{background_offset}" + f.puts " background: url('http://github.com/#{@builder.config['image_stylesheet_path']}#{sprite_file}') no-repeat #{background_offset}" f.puts " width: #{sprite[:width]}px" f.puts " height: #{sprite[:height]}px" end diff --git a/spec/sprite/config_spec.rb b/spec/sprite/config_spec.rb index f3e2e9c..ea0abfb 100644 --- a/spec/sprite/config_spec.rb +++ b/spec/sprite/config_spec.rb @@ -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