Add dir.py

This is a replacement for always-broken dir.sh.

Currently missing feature: Strip webroot from paths/links