Snippy Urls in App Engine
Posted by ark, ,
I've written before about my own url shortening service that I wrote just for me. It was running on my home server which often loses power and due to something with the router and our VPN software, whenever I was connected to the office I couldn't use my tiny urls which was pretty annoying. My recent forays into Google's AppEngine it seemed like the perfect platform for me to re-implement my snippy url shortening service.

The source is far from clean and tidy, but it works and so I'm linking to it here.

So I'm going to write up why it's awesome here and pretend that it's running on example.com:
  • You can create short urls by going to http://example.com/admin/add/http://google.com.com/ that will make a random short url
  • You can create a named short urls by going to http://example.com/admin/add/goog%20http://google.com/ that will make example.com/goog
  • You can create a named parameterized short urls by going to /admin/add/sx%20http://google.com/search?q=%s that will make example.com/sx%20foo search google.com for foo (yes you'll need to escape that %s but bear with me)
  • You make example.com/%s your default search engine in your browser
  • You make example.com/g be a google search using the %s thing
  • Now you can type "g foo" in your location bar to search google for foo
  • You can make a named parameterized short url for example.com/admin/add/%s called w
  • Now when you want a short url, you type this in your browser "w example http://docs.google.com/blahblahblah" which makes go.example.com/example
  • The created page shows a form with the created short url in it; all selected and focused. you just hit control-c to copy it.
  • You can hit enter on the form and it will hit the url to test that it works
  • I also allow myself to have private links that you need to be logged in to follow (I allow my personal and work addresses to login)
  • I also have optional alternate urls for each parameterized short url, so if you don't provide a parameter for a parameterized url then it will send you to the alternate url (direct to google homepage, rather than searching for %s)
  • I also have optional mobile urls for each short url so if you use a go link from a mobile device you are sent to the mobile url
  • You can customize the short link not found page to suggest other things (like searching delicious and a google search and perhaps a dns lookup?)
  • It also has a built in redirector that hides the referrer
  • The redirector also fakes referrer for .jpg|gif|png files and fetches the image and sends that on (I use it in my feeds that restrict image fetching to the original site) (not related to making short urls at all)
  • You can upload a .ini format file to fill up the datastore in bulk. This happens to be the same format the old url redirector used to store its data in.
  • When you start it up, go to http://example.com/admin/addadmin and add yourself as an admin. When there's no users the first user is allowed as an admin, then the admin must add other admins.
  • For each snippy url you can provide a suggest_url that will be used by Chrome when you're typing after that snippy keyword in the omnibox (parameterized urls only).
There's a few things I might add in the future:
  • UI Improvements
  • I might add full acls etc so you can let specific people in (perhaps link to my contacts and contact groups via oath?)
  • The ability to upload a mozilla bookmarks.html file and create short urls from all the keywords in there.
  • The ability to create short urls that expire after a certain date (use closure for the date picker!)
  • Allow partial short urls so that if you have a short url for google.com called g, going to example.com/g/jobs would get you to google.com/jobs This is a poor mans parameterized short url thing.

Comments

Posted Sunday 11 April 2010 Share