-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webui] port from compass to sprite_factory
compass-rails hasn't seen any commit for 2 months and is not rails 4 ready. and all we need from compass is the sprite functionality, so use a simpler gem: sprite_factory The drawback is that the resulting image is in git, so you need to call bundle exec rake assets:resprite if you add icons
- Loading branch information
Showing
7 changed files
with
199 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'sprite_factory' | ||
|
||
namespace :assets do | ||
desc 'recreate sprite images and css' | ||
task :resprite => :environment do | ||
SpriteFactory.library = 'chunkypng' | ||
SpriteFactory.layout = 'packed' | ||
SpriteFactory.cssurl = "image-url('$IMAGE')" # use a sass-rails helper method to be evaluated by the rails asset pipeline | ||
## run it once for the md5sum | ||
#SpriteFactory.run!('app/assets/icons', output_image: 'tmp/sprite.tmp.png', margin: 2, nocss: true) | ||
#md5=Digest::MD5.hexdigest(File.open('tmp/sprite.tmp.png').read) | ||
#File.unlink('tmp/sprite.tmp.png') | ||
SpriteFactory.run!('app/assets/icons', output_style: 'app/assets/stylesheets/icons.scss.erb', | ||
output_image: "app/assets/images/icons_sprite.png", margin: 2, nocomments: true) do |images| | ||
rules = [] | ||
images.each do |icon, hash| | ||
rules << ".icons-#{icon} { #{hash[:style]}; }" | ||
end | ||
rules.sort! | ||
rules << ".delete-attribute { #{images[:note_delete][:style]} !important; }" | ||
rules.join("\n") | ||
end | ||
system("optipng", "-o5", "app/assets/images/icons_sprite.png") | ||
end | ||
end |