this is aaronland

“Smoking wasn't dangerous then.”

Things I Like About San Francisco #1154307965

The dragon flies were out in Delores Park this afternoon.

/tag/restobook

I was going to work on the e(r)dfg-writer when I got back from Helsinki, but while I was there I filed the following under Thinking Out Loud : I'd like to be able to open the address book (on my phone) and select a contact and then use their email address to key into the Flickr database. If there's a match, do stuff like add their Flickr homepage and their most recent photos feed as URLs and store their NSID for future API goodness. If they have a buddy icon then use that for the thumbnail in the contact database. From there it's no great leap to imagine a glorified slideshow application that displays photos for Flickr contacts in your phone's address book.

Because the address book is still the center of everything.

I have been going on, for years, about how great it is that Nokia has ported Python to their phones but I've never really done anything about it. So I rolled up my sleeves and wrote everything I just described. Sort of.

The tool for merging an address book contact with their Flickr account works (except for the part on page 60 of the Series 60 Python API Reference that reads : The following field types are recognized but cannot be created at present: thumbnail_image) although the UI is awful. I will release it once it's been cleaned up a little.

update: This is almost done but then I saw a presentation on Wednesday night and got a little distracted by another neat idea which I'll write about soon. This one will be released but until you can set a contact's thumbnail image it is a largely pedantic exercise with no magic.

update: fladdressbook 0.1, will fetch and merge Flickr account data for a Series 60 address book contact.

The tool for doing a slideshow for those contacts worked, mostly, and then got dragged down by the lack of a real emulation environment for OS X, the inability to do any kind of useful debugging the moment you create a Canvas object and who knows what's really going on threading weirdness. I would still like to finish it but I'm feeling a little burned out by it now and it's hard to get excited about anything that is really just a feed aggregator. (I opted for polling feeds rather than implementing the API because that seemed easier and faster. At the time.)

But I'd managed to do enough hacking to get a feel for how things worked and I started to think about what else I could suck in to the address book. Restaurants seemed like an obvious choice and keeping restaurants listed in del.icio.us also seemed like a good idea. I suppose there are legitimate privacy concerns but to my measure they aren't a big deal and don't outweigh the benefits : Ready-access from any web browser, not having to deal with synching and just otherwise sharing with the community. For example, I spent a lot of time poking around /helsinki and /helsinki+restaurant before I left for Finland and it was very useful.

Okay, everything except for the part about ready-access. I never did get international-roaming working on my cell phone while I was overseas and looking up restaurants, on the web, would not have been emergency enough for me to suffer the GPRS rates in Europe. Why not just suck it down and store it locally? At a minimum having the phone number bolted in to the (drumroll) make a phone call functionality would make it worth it. If you've also got a phone where you can hack away at other information (hello, location data) then you can start to have even more fun.

Translation : Please god, make Yelp develop a decent mobile web site.

So, yeah, I wrote the thing to do all of that. It relies on three things :

  1. All the relevant bookmarks be tagged with restobook
  2. All the restaurant-specific metadata be stored in the bookmark's description field. Tags are still stored as tags and accounted for later.
  3. All the restaurant-specific metadata be written in a bastardized version of RDF/N3.

Here's what the metadata for Quince, a fancy-pants restaurant in San Francisco, looks like :

# Does this look strangely like the kind of thing that Norman Walsh has
# been plugging away at for years? It does, doesn't it. He's smart, like that.

:address "1701 Octavia @ Bush San Francisco CA 94109"; :phone "415 775 8500";
:yelp "zFxD8QinHt69Bs7M2mgB-Q"; :hours "M-H 17H30-22H00 / F-Su 17H00-22H00";

And this is what the application does with all of my del.icio.us links tagged with restobook :

 restobook says hello!
 ---------------------
 Reading configs
 Testing your network connection
 Testing your del. login
 Fetching dates tagged with restobook
 Fetching posts tagged with restobook on 2006-07-21
 Fetching posts tagged with restobook on 2006-07-20
 Fetching posts tagged with restobook on 2006-07-18
 Fetching posts tagged with restobook on 2006-07-17
 Parsing 6 results
 Parsing data for Quince
 Trying to geocode 1701 Octavia @ Bush San Francisco CA 94109
 Parsing data for Bar Tartine
 Trying to geocode 561 Valencia San Francisco CA 94110
 Parsing data for Bacco
 Trying to geocode 737 Diamond @ 24th San Francisco CA 94114
 Parsing data for The Blue Plate Restaurant
 Trying to geocode 3218 Mission St. @ Valencia San Francisco, Ca. 94110
 Parsing data for La Ciccia
 Trying to geocode 291 30th @ Church San Francisco CA 94131
 Parsing data for Schroeder's German Restaurant
 Trying to geocode 240 Front St San Francisco, CA 94111
 
 # At this point, the application actually starts to store
 # the restaurants in your address book. When run in debug
 # (emulation) mode on the desktop it dumps restaurant data
 # to the screen...

 Quince (dump) :
 --------------------------------
 phone_number : 415 775 8500
 city : San Francisco
 geopostion : 37.788026, -122.427107
 tags : french italian resto restobook sf tryme
 country : Us
 http://maps.yahoo.com/py/maps.py?addr=yadda+yadda+yadda (map)
 http://del.icio.us/url/cefa3614ae92b56ad332d525da9cc4e0 (del.icio.us)
 http://www.quincerestaurant.com/pages/home_main.html (homepage)
 http://www.yelp.com/biz/zFxD8QinHt69Bs7M2mgB-Q (yelp)
 hours : M-H 17H30-22H00 / F-Su 17H00-22H00
 state : Ca
 postal_code : 94109-4326
 company_name : Quince
 street_address : 1701 Octavia St
 --------------------------------
 
 # And so on
                    

Some caveats and notes along the way:

  • The application prompts you to indicate whether posts that already exist on your phone should be merged, ignored or checked one at a time.

  • update: Version 0.2 allows you to specify optional tag filters for merging. That is, the application will always look for posts tagged with restobook but now you can also limit it by, say, restobook and investigate. Unfortunately, the filtering has to happen on the client side so some of the irritating UI problems involving SSL certificates, discussed below, remain.

  • This doesn't actual parse N3/RDF. It uses a really sloppy regular expression. If I haven't been bitten in the ass by it before you, patches are welcome. No, really.

  • There are a couple of del.icio.us-isms that combine to make an irritating user experience. First, there is no way to get all the posts for a tag in a single API call; instead you have to retrieve all the dates for posts with that tag and iterate over the list. This wouldn't really matter except that del.icio.us has also started serving API requests over an encrypted connection using a certificate that Nokia doesn't recoginize. (I am not convinced that there are any certificates that Nokia phones recognize but that's another story.) The end result is that you are asked to approve said certificate on every request. If there's a way to disable this I haven't found it so please tell me.

    I'm not sure what to do about this. One possibility is to add an option to restrict updates to only the most recent tagged posts or to only fetch posts within a certain number of days. Another solution would be to just live with it since this is not an app for obsessive-compulsive Internet weenies who want everything updated in real-time.

    update: Version 0.2 prompts you to inidicate whether you want to only retrieve the most recent posts tagged with restobook (and any additional tag filters you may have defined).

  • No, you can not subscribe to someone else's bookmarks as an import option. That is what del.icio.us' copy functionality is for.

  • Yes, (bastardized) RDF/N3. Deal with it. It's no harder (or easier) than anything else and has the advantage of being more portable. Spend five minutes writing a microformats to N3 parser, bolt it on to the various del.icio.us bookmarklets and then get on with it. Life is short.

  • No, the application is not very smart. It knows how to handle basic stuff like addresses and to recognize certain fields as special. For example, :yelp OMGWTFBBQ; is interpreted as a unique identier, in their database, and turned into a URL. Otherwise, any unknown items are stored as individual notes. I don't like this either.

  • Namespaces. Sure, namespaces. Patches are welcome. Did I mention it's not using a real RDF parser? I want to be able to do this too :

    # @prefix trans: <x-urn:asc:transportation:public#> .
    # @prefix resto: <urn:isbn:155022560X> <-- shameless plug for my friend
    #     Sarah's book which has a great set of meta-properties for each 
    #     restaurant; I will try to catalogue them in another post
    
    resto:Alcohol "Y";
    resto:CreditCards "Y";
    resto:VegetarianFriendly "N";
    resto:PublicTransporation [ trans:metro "Laurier" ];
                                

    update: Version 0.2 has a poor man's namespacing. Items that contain a (non-blank) prefix will be grouped together and stored as a single note whose label is the value of the prefix. The note does not contain newlines, yet, because it seems to be impossible to add them through the Python interface. I wait, patiently, to be proven wrong. Some sort of indicator of the note's N3-ness will be added in version 0.3. I just noticed that one — sorry.

  • vCal, recurring events or basically any sort of calendar integration : I am happy to be convinced otherwise but the short answer is No. (That kind of integration would make sense for Upcoming, however.)

    update: upcalendar, a tool for syncing your upcoming.org watchlist with your phone's calendar.

  • It may not be sexy but it's useful. Because the address book is still the center of everything. And the network will never be always on.

The Helsinki Diaries, Stardate : 1151915967