Identica Statuses Widget

A while back, I wrote about Laconica, the microblogging software used to power Identica and the TWiT Army among other sites. If you want a breakdown of Laconica, please go to my previous post.

When the TWiT Army first launched, Laconica was in version 0.5, which was missing an undocumented feature of the Twitter API, namely the ability to specify a callback function for JSON returning API calls. I filed the bug, and submitted a quick, ugly, hacky patch which was turned into a far better patch and committed into the 0.6 codebase. I’m not upset, my PHP foo has slipped a bit in the last year, and I didn’t have a laconica instance to test, and their solution was better.

Anyway, as readers of my blog are no doubt aware, once I got bit by the Twitter bug, I put my Twitter statuses in my sidebar. Well, once I discovered Laconica, which is like Twitter, but more free, I moved almost entirely to the TWiT Army. Not entirely mind you, since there are still people I’m interested in following on Twitter, but this idea of many microblogs that can all communicate is really intriguing to me, and I am pleased to be able to follow it.

So, since I’ve converted to the Army, I wanted to be able to display by Army posts, what we call μs, on my blog. I used the Twitter model as a starting point, but I’d like to think I’ve improved upon it somewhat. I built a JavaScript object, Foxxtrot.Widget.Identica.

I named it Identica for two reasons. First, Identica is the most popular Laconica instance, and Laconica is going to be renamed Identica, similar to how Wordpress can be used to refer to both a piece of software, a company, and a service. It’s kind of confusing, but ultimately it’s easier than trying to explain the difference between the two.

The object is also dependent on YUI 3, partially to familiarize myself with that library, and partially to spread YUI. Including YUI is simple, just include the following in your page before my object.

<script src="http://yui.yahooapis.com/3.0.0pr1/build/yui/yui-min.js" type="text/javascript"></script>

I would ask that you don’t leech this script from my site. I don’t really have the extra bandwidth, but I will be making available a minimized version of it at some time in the future.

Using the script is easy. After loading YUI and Foxxtrot.Widget.Identica, do something like I do on this very page:

Foxxtrot.Widget.Identica.getUpdates('#army_update_list',
   { count: 3, user: 'foxxtrot', service_url: 'http://army.twit.tv' });

The first argument is either a DOM reference, or a CSS3 style selector that YUI can use. This should be a reference to a List, and I identify by a DOM id (armyupdatelist), and I suggest you do too. The second argument is wholly optional, but it provides configuration details. Currently, this includes the following:

  • count: Number of status updates to retrieve (default: 5)
  • user: User name of the user to pull statuses for. If this is not specified, we’ll pull back the Public Timeline
  • service_url: The base URL of the service you’re pulling from. Defaults to Identi.ca

I do assume that the API is hosted under /api/ under the service_url. If this is not the case, let me know, I’ll add the option behavior.

So, once you’ve done that, the code will automatically build the Status Update List, and fill the list you’ve provided a reference to. It works well, but it’s not perfect yet.

Known Issues:

  • Doesn’t link directly to users you’ve directed a comment at (@)
  • Doesn’t convert URLs to Links
  • Doesn’t print out the full date for very, very old updates (not sure this is necessary)

Features I want:

  • I plan to put the TWiT Army logo in the spot where the μ’s go, and then fade it back using YUI before putting the text over it. The image under the updates will be set in CSS.
  • I’m considering doing periodic updates if the user stays on the page. This would be optional, and off by default

That’s all I’ve got for now, but if anyone has any suggestions, please post them in the comments, and let me know who is using it where. The code, like Laconica is licensed under the GNU Affero General Public License.