August 16, 2008

Twitter parsing

In Twitter parlance, a “badge” is a compact status indicator you can insert into your own web site to display your latest tweets. For this blog, I took the HTML/JavaScript badge code offered by Twitter, added a modification from Jon Aquino, and tweaked the display.

I enhanced it so that if a tweet is a reply (beginning with a username, like “@allenhuffman Hi, Allen!”), the addressee is indicated more formally (“To allenhuffman: Hi, Allen!”).

Then I added some fancy JavaScript and DHTML to display the tweet with a sliding-open motion. There’s some neat math involved in making the animation look smooth.

Just a short while ago, I added more content parsing: Any username within the tweet is linked to the user’s Twitter page, URLs are linked, and any hashtag (a word starting with “#”, signifying a specific topic, like “#olympics”) is linked to a Twitter.com search for that tag.

Leave a comment: