Premailer: compatible HTML emails without the hassle
on 6 December by JD
If you’ve ever dealt with HTML emails, you know the pain of dealing with various mail client and webmail compatibility issues. One of the biggest issues is CSS: for instance, only inline CSS (via the style="..." attribute) is compatible will GMail.
Enter premailer. Premailer converts a standard HTML+CSS page (supporting both <link> and <style> tags) into inline CSS to the best of its ability. If you’re willing to take a performance hit, you can even transform your emails on the fly, allowing you to re-use your regular views for your emails.
Using the code in Rails requires a bit of tweaking. Personally, I put premailer.rb and html_to_plain_text.rb in the lib/ folder in my project. I also wanted to be able to pass in a string (not a filename) to the library, so I changed line 192 from Hpricot(open(uri)) to Hpricot(uri).
In order to transform the email, I captured the entire body of the email using Rails’s capture method, then outputted Premailer.new(body).to_inline_css at the bottom. Alternately, you can write a helper to clean it up slightly, but you’ll still need to wrap your entire email in a call to your helper:
def premailer(&block)
concat(Premailer.new(capture(&block)).to_inline_css)
end
Premailer can also convert your emails to plain text if you want to avoid maintaining a separate plain text alternative.
Credit for premailer goes to Alex Dunae. Thanks for creating this excellent script!
Basecamp time reporting script
on 6 December by JD
I wrote up a simple but handy time reporting tool for Basecamp. It’s a command line tool that generates a plain text report. It’s still somewhat crude – I’d like to make it into a gem, but haven’t had the chance yet.
Naturally, the code is up on Github. :)
DHH Addresses Ruby on Rails Myths
on 15 November by JD
DHH is working on debunking many of the Rails myths that float around. If you have any questions about Rails, these are all worth reading. However, the one myth that is missing is Rails doesn’t scale. While DHH rightly pointed out that he debunked that years ago, he’s agreed to address the myth as part of the series. I think the Rails community as a whole will look forward to having an authoritative reference we can use to end this myth once and for all.
Conference Prices
on 22 October by JD
Why does RailsConf or the Professional Ruby Conference here in Boston cost $800-$1200 while Paris on Rails costs just €80? RubyFringe, too, was C$650. Sure, Paris on Rails is just one day, but €80/day does not compare to the US conference prices. Why? Supply and demand? Profit?
(As an aside, some conferences are actually reasonably priced. Amazing!)
A Great Season Draws to its Close
on 22 October by JD
A quick (and belated) shout out to the Boston Red Sox who lost game 7 to the Rays on Sunday. Watching the amazing comeback in game 5 was more than any fan could hope for.
As far as the World Series, I am going for the Rays. It would be amazing last-to-first championship. For next year, though, I think there will be a new rivalry to watch.
