A rails plugin to generate css sprite image automatically

Hi guys,

I have written a rails plugin/gem to generate css sprite image
automatically.

The project repository is here: http://github.com/flyerhzm/css_sprite

It is based on RMagick and you need only define a rule from what
source images to a destination image, as follows:

forum_icon_vertical.gif: # destination image file
sources: # source image file list
- good_topic.gif
- mid_topic.gif
- unread_topic.gif
- sticky_topic.gif
orient: vertical # composite gravity, vertical or horizontal
span: 20 # span of space between two images

Then run a rake task

rake css_sprite:build

So, you can see a forum_icon_vertical.gif generated in public/images
directory and a css sprite rule in tmp/css_sprite.css, as follows:

.good_topic
backgound: url(’/images/forum_icon_vertical.gif’) no-repeat 0px
0px
width: 20px
height: 19px
.mid_topic
backgound: url(’/images/forum_icon_vertical.gif’) no-repeat 0px
39px
width: 20px
height: 19px
.unread_topic
backgound: url(’/images/forum_icon_vertical.gif’) no-repeat 0px
78px
width: 19px
height: 18px
.sticky_topic
backgound: url(’/images/forum_icon_vertical.gif’) no-repeat 0px
116px
width: 19px
height: 18px

Hope you like it!

Richard Huang

flyerhzm wrote:

Hi guys,

I have written a rails plugin/gem to generate css sprite image
automatically.

The project repository is here: http://github.com/flyerhzm/css_sprite

It is based on RMagick and you need only define a rule from what
# span of space between two images

Then run a rake task

rake css_sprite:build

Richard Huang

Thanks a lot dude !!

Cool,

I have already cloned it!!!

I think this link you also referred to (about css sprite best
practices
)
is equally significant for most of us:
http://www.huangzhimin.com/entries/190-css-sprite-best-practices

Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/)
|
Malawi

Cell: +265 999 465 137 | +265 881 234 717

“Many people doubt open source software and probably don’t realize that
there is an alternative… which is just as good…” – Kevin Scannell

2010/8/24 lucky in ruby [email protected]

I’m glad you like this plugin, and I also write a similar post here,
http://rails-bestpractices.com/posts/43-use-css-sprite-automatically,
so that you can post your comment about it. Thanks

On 8ÔÂ24ÈÕ, ÏÂÎç11ʱ30·Ö, Edmond K. [email protected]

flyerhzm wrote in post #855601:

Hi guys,

I have written a rails plugin/gem to generate css sprite image
automatically.

This is awesome! I’m really glad you are creating tools like this.
Just wanted to throw out there that there is another gem that is
similar, active_assets, but it also creates the stylesheets!

Check it out at Github: http://bitly.com/eRTwU4

The latest releases only work with Rails 3, but if you need 2.3 support
use 0.3.x.

Cheers,
Sam

One more option https://github.com/hagenburger/lemonade :wink:

On 3 March 2011 11:55, Sam W. [email protected] wrote:

Check it out at Github: http://bitly.com/eRTwU4

You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


from Brazil, Raul Souza Lima 
Vegetarian, geek, born in São Paulo - Brazil.
http://webxperience.com.br/
http://raulsouzalima.com/blog
http://www.linkedin.com/in/raulsouzalima

Please don’t print this e-mail
Evite imprimir este e-mail

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs