James Duncan
on Wed Nov 01 2006 13:28:39 GMT+0000 (BST)
In the process of prepping the documentation for the CNAME/Virtual Hosting functionality I wanted to try it for myself. I tend to register any domain I think I might do something with later on, so I reached into my pot of pre-registered domains and had a look to see what was there. It turns out I had the domain 25cats.com from when there seemed to be a proliferation of sites and companies appearing with a number in their name (37signals, 43things, etc).
But what to do with it? Hmmm. People like cats. People seem to really like pictures of cats. People on flickr really like to upload and tag pictures of cats…..
Without further ado, I delved into my list of flickr api keys, and hacked together a quick zimki application to display 25 cats from flickr. When I say quick, I mean really quick. It took about 35 minutes from idea to completion. The code for the website is:
zimki.library.require('library', 'trimpath.js');
var fapikey = 'A flickr API key should go here';
var url = 'http://api.flickr.com/services/rest/';
var photo_url = 'http://static.flickr.com/${photo.server}/${photo.id}_${photo.secret}.jpg'
function jsonFlickrApi( d ) {
var urls = new XMLList();
for ( let aPhotoId in d.photos.photo )
urls += <img src={photo_url.process({ photo: d.photos.photo[aPhotoId] })}/>;
return <html><head><title>25 Cats!</title></head><body>{urls}</body></html>;
}
zimki.publishPath('/', eval( zimki.remote.get( url,
{ method: 'flickr.photos.search',
api_key: fapikey,
tags: 'cat',
per_page: 25,
format: 'json' }
) ) );
Thats it. Really. And you can get your cat-fetish fix at http://www.25cats.com
Update: It has been pointed out that in practice a lot of this is a very bad idea. Running untrusted third-party code in your Zimki realm is probably a bad idea. But, keep in mind it is a demo, and a quick demo at that…
|