CSSes: a clean CSS slate for your Rails application
Update: CSSes is now a gem! No need to install the plugin for each app.
I’ve updated CSSes to handle a bunch more Rails HTML helpers, so your forms and images and links should all get the proper treatment and their own nicely alphabetized entries in the generated application.css file.
See it in action!
Say you have this view (though let it be known that CSSes scours your helpers, too):
<h1 id="pomp">The Grand Demonstration</h1>
<p class="wing">Super Mario Bros. 3 reference</p>
<%= image_tag('joy.png', :class => 'happy') %>
<%= link_to('Read', {:action => :read, :id => 4}, {:id => 'four'}) %>
<!-- and it works for form tags too -->
Do this:
script/generate csses
And look at that sweet generated application.css:
a {}
a:visited {}
a:hover {}
a:active {}
a#four {}
a#four:visited {}
a#four:hover {}
a#four:active {}
h1 {}
h1#pomp {}
img {}
img.happy {}
p {}
p.wing {}
Get it for yourself:
sudo gem install csses
Dr Nic said,
January 3, 2008 @ 2:19 pm
Booya!
BTW, if your plugin is just containing a generator then you can gemify the generator. Basically, make your plugin a gem, and move everything in generators/ into rails_generators/ (and explicitly add the lib/ folder to $LOAD_PATH) Rails 2.0 apps will find this generator automatically, and ppls won’t need to install the plugin into each app.
Let me know if that doesn’t make any sense :)
Priit Tamboom said,
January 3, 2008 @ 7:58 pm
Wow, nice idea.
It’s nice to generate, however it would be much more useful if you want it to take next level and make it as the way of updating css (like ultimately using rake task ‘rake css:update’). If you have used Gettext then you know what I mean. “The gettext way” of harvesting source and updating po fails is really useful and the facto standard to manage your po fails.
Don’t know yet if “the gettext way” will be as useful for css in practice, but if you willing and have time to try, it would be cool to see how useful it will come.
Chris Shea said,
January 3, 2008 @ 8:09 pm
@Dr Nic: it’s a gem now!
@Priit: That’s next on the list. The itch I was scratching was the initial generation of CSS, but I’ll probably hack together an updating generator quite soon.