Leopard: Mail, RSS, RMagick, ImageMagick
October 27th, 2007
Like a lot of developers, I’ve been running Leopard in one form or another for a couple of years now. In that time, I’ve had my share of frustrations. Of course, knowing at all times that I was evaluating pre-release software, I rolled with the punches with little more than the occasional bitch and moan (Apple: Don’t sue me. I only complained to others who’d signed an NDA. I swear. Don’t sue me.)
During my evaluation, I also found a few gotchas, tips, and compile tricks that might have been useful to others.
Given that the Apple NDA very clearly prohibited writing about Leopard before the release, I filed these things away.
A couple of the topics I didn’t write about were building ImageMagick and RMagick on Leopard and a how to on executing the Widget ‘flip’ with CoreAnimation.
Install RMagick on Leopard
The RMagick stuff seems mostly figured out now, as MacPorts has stuff updated pretty well. My instructions after that first release included compiling everything by hand with special flags and a sacrificed chicken. Now it’s as simple as:
sudo port install tiff -macosx
sudo port install ImageMagick
sudo gem install rmagick
Hopefully, someone can get FreeImage working soon… But I digress.
CoreAnimation Widget Flip
The CoreAnimation tip is something I’ll cover soon, once I confirm that everything is teh same on the official Leopard release.
Import OPML Into Mail.app
Today, I wanted to write about the pain in the ass of RSS on Mail.
I decided to export all my feeds from NetNewsWire Lite to OPML in hopes of giving Mail’s RSS features a shot. After all – mail, plus to-dos, plus iCal integration, plus RSS could make Mail my main app for non-dev work.
The main complaint I have is that Mail doesn’t support OPML. In fact, it doesn’t support any form of mass-import of feeds or bookmarks, aside from a klunky Safari-as-proxy import.
Safari, of course, doesn’t support OPML. Instead, it uses Netscape bookmark files (NETSCAPE-Bookmark-file-1 DTD). Yay, cutting edge!
It’s dumb, but here’s what you have to do:
- Export to OPML from NetNewsWire Lite (or Vienna, or whatever you use)
- Run the PHP script at the end of this post with php convert_opml_flat_to_nbm.php MySubscriptions.opml > MySubscriptions.html
- Import MySubscriptions.html into Safari
- In Mail, go to File > Add RSS Feeds…
- Check the radio button for Browse feeds in Safari Bookmarks
- Check whichever feeds you want added
Wow. That was simple. And painless. OMG TOTALLY NOT PSYCHE YOUR MIND!
Before you do all that, though, let me point out an apparent failure on the part of the Mail RSS reader: it doesn’t pass the referrer on requests for assets. This sucks because mihow.com, along with tons of other sites, turn off hotlinking.
What’s interesting about this, to me, is that Safari sends referrers. I’d have thought Mail would have used the same lib (or functionality) as Safari for request management. Seems like a WebKit no-brainer to me.
PHP Script to Convert OPML to Netscape Bookmarks
Save this to your machine as ‘convert.php’ (or whatever you want to call it). If you export your OPML to your ~/Desktop, you may as well save this as ~/Desktop/convert.php, which will enable you to easily run the command from Terminal.
<?php
function usage(){
return "Usage: php convert.php /path/to/opml_file.opml > output.html\r\n";
}
# Print usage if need be.
if(count($argv) < 2) die(usage());
# Grab the file path.
$f = $argv[1];
# Load it into a SimpleXML.
$xml = simplexml_load_file($f);
# Output buffer
$out = '';
# Run through the nodes in the OPML and buffer the Netscape output
foreach($xml->xpath("//outline") as $outline ){
$title = htmlspecialchars($outline['title'], ENT_QUOTES);
$feed = htmlspecialchars($outline['xmlUrl']);
if($feed){
$out .= "\r\n\t" . '<dt><a href="' . str_replace("http://", "feed://", $feed) . '">' . $title . '</a>';
}else{
$out .= "</dl><p>\r\n<dt><h3>$title</h3><dl><p>";
}
}
$out .= "\r\n"
?>
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<title>MyBookmarks</title>
<h1>MyBookmarks</h1>
<dl><p>
<?php echo $out; ?>
</dl><p>
Alternate Method for Importing Feeds
I can’t believe I didn’t try it first, but as someone commented, you can just drag feeds from NetNewsWire or Vienna into the accounts area of Mail and BAM – feeds. Man, what a simple solution. Oh well, given the traffic to this post, I’m not the only idiot out there ;)

