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:

  1. Export to OPML from NetNewsWire Lite (or Vienna, or whatever you use)
  2. Run the PHP script at the end of this post with php convert_opml_flat_to_nbm.php MySubscriptions.opml > MySubscriptions.html
  3. Import MySubscriptions.html into Safari
  4. In Mail, go to File > Add RSS Feeds…
  5. Check the radio button for Browse feeds in Safari Bookmarks
  6. 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 ;)

Comments for “Leopard: Mail, RSS, RMagick, ImageMagick”

  1. Mail.app not being able to handle an OPML file seemed kind of brain dead to me as well.

    Thanks for posting this!

  2. Isn’t he wonderful? He started to tell me all about it and I got that glazed over look. It’s a good thing that I did. I get the feeling this is gonna help a many a nerds just like you, Jon Deal.

  3. One of the biggest surprises and let downs of 10.5 is this huge oversight. I’ll likely stick with Net Newswire (with awesome sync when I read feeds with my phone). Weird that Apple wouldn’t work opml into Mail.

  4. I just drug my feeds over from Vienna.

  5. Tyler – I’ve gotten mixed reports on whether that works. It seems that some feed types may work, but not others. I suppose there could also be a pasteboard issue on some Leopard installs… Lord knows, Mail acts terribly flakey for me, so anything is possible.

  6. thank yok very much

  7. ok, stupid question number 2—where the heck is the ‘accounts’ area. I dragged (drug?) feeds from vienaa all over the place…it does not let me drop it anywhere

  8. you mention somewhere you use a minolta 5400 II neg scanner, i need to know if this is correct , do you know if this scanner works on a mac with an intel chip??

    i am interested in getting this scanner but am concerned it might not be supported concerning software

    in advance i thank you

Add Your Comment