Scratching an itch and enhancing CellarTracker

Once in a while I feel the need to write some actual code. I’m really a programmer at heart, and I find it incredibly satisfying to think through a problem and create a useful solution. For me it’s more interesting than crossword puzzles, and the end product is (sometimes) more valuable.

For a variety of obvious reasons, it’s not a good idea for me to get my fingers into Yieldex production code, so I end up scratching this particular itch with small side projects. This one took me a couple of hours, and hopefully will be useful for enough people for it to have been worth it. In any case, I learned a lot, so it was worth it for me.

I’ve written about CellarTracker before. I’ve been a user for years; I love the site, and I love the business. But, I find some of the UI to be less than perfect. Here’s an example: when I get a wine offering in the mail, there are usually a number of different vineyard designations, and I get an allocation of a few bottles from each. I haven’t found a way in CellarTracker to enter 2 bottles each from 10 different designations without doing an incredible amount of clicking around and waiting for pages to refresh. So, I set out to solve this problem with a “bulk purchase” mechanism.

There are a number of different ways to tackle this problem, so the first thing was to decide on an approach. I’m still a bit 1999 when it comes to the coding for the web, so my first idea was to set up a server-side program. Then I started thinking about the complexity of screen-scraping and parsing, and robustness in the face of potential CellarTracker updates. Then there are the security issues of passing usernames and passwords so my server could log in to CellarTracker. Finally, I realized I didn’t really want to be responsible for keeping the service up and running, so I almost bailed on the entire idea.

Then I remembered GreaseMonkey for Firefox. Cool – an opportunity to enter the 2000′s in web programming, and polish up some JavaScript skills. And, it got around all of the above problems in a neat client-side way. The only real issue is that it works only with Firefox, and for most people would require an install of GreaseMonkey and the script itself.

I started by installing GreaseMonkey and a couple of web development tools, notably the DOM Inspector, the Javascript Shell bookmarklet, and then later the Web Developer Toolbar. I read quickly through the Dive Into GreaseMonkey book, and then just started coding. I was pretty excited that in only a few minutes I could build a script to automatically change a CellarTracker page upon load.

After a couple hours of experimentation, some heavy shell use, and a bit of DOM inspection, I had something up and running. I created a test account on CellarTracker, and entered a bunch of purchases. Success! I finished up by spending a few minutes on data validation, trying to make it obvious when something went wrong and how to fix it.

The best part about this project for me was learning one level deeper about how Javascript and the DOM work. Javascript is a much more powerful language than I remembered from 1999, and I have much better understanding of how Ajax and many modern web sites work. And it was fun.

The final step was posting it in the new/old OSS directory here on Oxyfish, and writing this entry. I also posted a note in the CellarTracker forum, in case anybody else wants to use it. I’m very happy with how it turned out, and am looking forward to the next wine offering in the mail, so I can start saving time.

Install the CellarTracker Bulk Purchase extension (requires Firefox and GreaseMonkey)

3 Responses to “Scratching an itch and enhancing CellarTracker”

  1. Steve Says:

    this sounds amazing. i installed everything, but how do i actually add the wines using this extension?

  2. Tom Shields Says:

    @Steve: after you've installed everything, log in to CellarTracker and click “Add Wine to my Cellar”, then enter a search string, click Vintage to sort by Vintage, and then Search. You should see a bunch of fields appear on the results page, including Place of Purchase, Delivery Date, and beside each wine “#” and “$” for quantity and price. If you don't see those fields, the extension probably isn't installed correctly. Let me know if you still have problems.

    -ts-

  3. Recent Links Tagged With "bookmarklet" - JabberTags Says:

    [...] by mustangsflame2 on Fri 19-12-2008 Social Bookmarking Tools Saved by badbear on Tue 09-12-2008 Scratching an itch and enhancing CellarTracker Saved by KnoxsKorner1 on Sat 06-12-2008 Make Firefox Remember Passwords of Hotmail, Live, MSN & [...]