Open Source Facebook Application

Over the last year our library has used its Facebook application to let students see where their friends are in the library and expose library resources to users without needing to go to another website. It's been used pretty heavily and there are a lot of folks in the library world who have asked to get the source.

This summer Phil spent a couple of weeks rewriting the code to be a little easier to maintain. We reimplemented the code with Smarty and reimplemented the locational device to use FBJS instead of regenerating an image when someone clicked on the map (it's much faster now).

If you need a starter app, check it out at http://code.google.com/p/facebook-athenaeum/.

If you need a good book on writing Facebook Applications, check out my book, Facebook API Developers Guide.

Facebook API

I've been kind of silent here as I've been trying to keep this blog at least somewhat focused on ColdFusion and I've been doing development in some different languages as of late (Java, PHP, and Ruby). However, when Facebook released their API for developers, my summer assistant Phil started hacking away at it and we've released our first app for Facebook: SwemTools.

It does a couple of things, provides a search interface for both the online catalog and our website, news feeds, hours, and a bit of a neat application based on Swem Signal that was created by Tom MacWright.

We're still working on the code for the Signals part, but the idea is that on a map of the library, you'd be able to see where your friends are. Right now, you can see a dot where your friends are, but not who they are...but we're working on a solution for it.

Anyway, if you're on Facebook, check it out...you can add me as a friend too.

Software Pod

I just added some of the software I've worked on. The search plugins are also at Mozdev.org in their Mycroft Project. The Library Search extension was my first stab at an extension; it adds a context menu to Firefox when you select text to send the selected text to our library catalog, or pretty much any other type of search service.

The CF_GnuPG is a Java/ColdFusion wrapper that I wrote for an article a while back for the ColdFusion Developer's Journal (Public-Key Encryption: Making strong encryption nearly painless).

Firefox Extension

I've spent the better part of this morning building my first extension for Firefox. I have to admit it was a lot easier that I thought (after I figured out the JS). My extension adds a context menu to the right-click menu and also the Tools menu that allows people to highlight text on a webpage and search the library's online catalog for the book.

The hardest part was figuring out the function to call do the search. I was trying to use

document.getSelection();

which I had used in a bookmarklet a while back, but it kept returning a null value. As it turns out, when you're calling a the selected text from a function, you actually need

document.selection.createRange().text;

at least in my Firefox 1.0 and IE 6 browsers (and it needs to be called with an onMouseDown event)! However, you can directly access from the onClick event this:

javascript:alert(document.getSelection());

As far as the extension goes, most of the stuff is writing some XML (RDF format) telling the browser what's where with the workhorse with the bulk of the work being done by this:

function search(){
   var criteria = ';
   
   if (window.searchection){
      criteria = window.searchection();
   }
   else if (document.searchection){
      criteria = document.searchection();
   }
   else if (document.selection){
      criteria = document.selection.createRange().text;
   }
   else return;
   
   //search    if(!criteria){
      criteria = prompt("Search Criteria...");
   }
   
   if(criteria) {
      location.href='http://lion.wm.edu/uhtbin/cgisirsi/0/0/5?searchdata1=' + escape(criteria);
   }
}

Google Scholar

Saw a really neat extension for FireFox today that adds OpenURL tags to Google Scholar content. Just imagine the possibilities of leveraging Google to search journals to the article level! The URL for the download is http://www.ualberta.ca/~pbinkley/gso/, though it won't do too many of us any good since it was developed for the University of Alberta.

There is a pretty simple hack to make the thing work in the source code by pointing it to your own resolver and recompiling the XPI:

var baseurl = "http://resolver.library.ualberta.ca/resolver";
var button = "http://resolver.library.ualberta.ca/resolver-templates/gifs/getit.gif";
var sid = "ualberta:googlescholaropenurl";
var alttext = "Get It!";

I hope we get a resolver soon!