Wednesday, 8 April 2009

A new project, a piece of code, and crossing the streams

Let's give this blogging thing a go.

I've recently been doing design/development on a band's new website. It's going to be a simple 1-page sound-clip/mailing list sign-up type page, but I am keen on throwing around some of the more interesting/modern (read trendy) web gubbins.

Out of principle i've until recently refused to use twitter, and I still don't 'get it' - but as an incredibly simple method to get band members posting on their own site, without setting up a blogging tool, it's great.

Also, the hosting plan they've bought is html only, which is actually quite invigorating, forcing me to get more into javascript coding, rather than just relying on PHP/MySQL to do a lot of the legwork. This also means that the scope of the site is drastically limited, only allowing me to scrape up the putrid run-offs from other sites content streams.

This seems to be a large part of the (now slightly aging) web2.oohhdeargod ideals - outsource the maintenance/admin/storage tools to other site, and simply collect their streams into one place. The RSS feeds (and more recently the easy to use APIs) these content managers (such as twitter/flickr/youtube etc etc) coat themselves with now mean that even the simplest sites can provide dynamic content with a few lines of code.

Which leads, bizarrely, to the code part of this blog post. Ripped and modified from the great CSSTricks, this simple snippet of JQuery will search for a specified string using Twitter's API, grab up to 100 posts, and randomly pick 2 from those that are available (see the CSSTricks article for the supporting .linkify() function).

var q = 'hot rats';
var i = Math.randomMax(data.results.length-1);
var j = Math.randomMax(data.results.length-1);

(I promise that future code will be more interesting)

The idea behind this was that, even if the band guys never post a single message, there will be random, anarchic content always appearing on the site. In the design it is fairly well scrambled using negative letter-spacing over a b/w silhouette, so that too much isn't taken from the inane twitterings. There is whole bunch of enhancements that could be added to this - such as only picking tweets of a certain length, not picking the same tweet, etc etc.

Note that this is my first look at JQuery code - I have been using Prototype as my JS library of choice up until now. I prefer Prototype simply because of history, but it looks like JQuery is winning the popularity vote, so I've decided to give it a go in new projects.

Despite its flaws, JS seems to be where a lot of the heavy lifting is heading in webdev, and it's been good to get a bit of practice in.

No comments: