Projects ⋅ Peter Nelson

pdn.to URL shortener

Not another URL shortener…

Well yes, I’m afraid so.  I whipped up this site in order to play around with a few frameworks and technologies that I’m relatively new to.  These include:

  1. PHP on Windows – This site is hosted on a VPS which runs Windows Server 2008 (not by choice, but I’m not going to argue).  Having some experience using PHP in a classic LAMP setup, I was curious to see what it would be like in a Windows / IIS / MS-SQL Express (WIMP) environment.  As it turned out, there was a bit of fuss getting IIS to play nicely, but on the whole it was easy enough to set up and works well.
  2. CodeIgniter framework – I wanted to find a fairly lightweight PHP framework for another project, and after a bit playing around with this one, it hits the mark nicely.  It’s probably overkill for a basic site like this, but it’s a pleasure to code with.
  3. HTML and JavaScript stuff – Semantic, standards compliant and accessible HTML / CSS / JS are fairly recent additions to my skills arsenal, so I thought I’d give them an easy little workout here.
  4. BBC Glow JavaScript library – I haven’t taken the plunge into jQuery yet, but I stumbled upon this nifty alternative which has been remarkably easy to pick up.
  5. Silverlight – Having never used Silverlight before I wanted to get a bit of a feel for how it’s used and deployed.
  6. Design – I wanted to try my hand at a bit of graphical and layout design with something simple.

Features

The site does the following things:

  1. Shortens URLs (ones that are longer than 19 characters, anyway), performs automatic redirects and hit logging, as you’d expect.
  2. Provides a simple Silverlight control, when available, to automatically copy the generated URL to the users clipboard, similar to what bit.ly does with a flash control.
  3. Generates QR codes on a <canvas>.  I was planning to write my own QR code generator but instead found Kazuhiko Arase’s excellent script.
  4. Checks the ‘reputation’ of target domains for anything nasty using the Web of Trust API.
  5. If an URL is deemed to be potentially unsafe, issues a warning to users instead of automatically redirecting them (e.g. http://pdn.to/56gda).

Code

Various bits of code used on the site can be found on my GitHub.  More specifically, the Silverlight control source can be found at http://gist.github.com/513381 and most of the PHP is at http://gist.github.com/517938.

Future

I’m vaguely planning on adding functionality to take screenshots of submitted pages (with obvious restrictions) in order to display a thumbnail preview to the user.

Update 13/03/2011

Moved to the pdn.to domain (from the less succinct u.peterdn.com).