I created a URL shortener web application using Django (a Python web framework). I have made the source code available on GitHub and it is under an open source license (MIT license).
The shortened URLs use the base 62 value of ids of the model they are stored in, using the code from here (it uses A-Z, a-z, and 0-9), which should be fairly compact for a long time. A count of how many times the URLs are used is kept. The main page shows the 10 most recent and 10 most popular URLs.
You can see a running instance at n1l.us (which I am using to link to this blog and other links to my own content) and uu4.us (which I am using for all other URLs). I currently don't allow public submissions of URLs on either of those sites, but I will be opening it up for uu4.us at some point (perhaps once I add some defenses against spammers). The application itself has a configuration option to be able to require or not require login to be able to submit URLs (the REQUIRE_LOGIN setting in settings.py). Note that if you require logins, you have to use the admin app (at /admin/) as I have not created a separate login page.
I've so far done the bare minimum as far as HTML/JavaScript is concerned (and there is no CSS to speak of yet). Just enough to get things working. So don't expect a good looking site with this yet. It does produce a functional bookmarklet, assuming that you set SITE_NAME correctly for your site. Though I should probably make the bookmarklet check for rev=canonical to be a good web citizen.
Django's template dirs are specified as absolute paths in settings.py:
TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. )
But since this is just Python code, it is relatively easy to specify relative paths (no pun intended). As described in this blog, add the following code to settings.py:
import os PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
And then in the TEMPLATE_DIRS section you can specify a relative path like this:
TEMPLATE_DIRS = ( os.path.join(PROJECT_PATH, 'templates') )