Currently we store useful shortlinks on ocf.io-- for example, ocf.io/docs points to documentation, ocf.io/servers points to our list of servers, and ocf.io/rt/### points to a numbered rt ticket. Right now, all of these are configured in a puppet config, which is annoying to edit. Also, since we use ocf.io shorturls to point to user websites (like ocf.io/dkessler), creating a shorturl requires adding that name to the list of reserved usernames, to prevent name collisions. This makes the process even more annoying.
We should redesign this system to make it easy for anyone to make a shorturl. This will require a lot of moving parts, and the design decisions have been controversial in the past-- see the discussion on this never-merged PR for some background.
Here are the necessary pieces for a good solution:
Use a separate namespace for some URLs
Put “temporary” shorturls in a different namespace so we don’t have to worry about most username collisions-- like ocf.io/s/temporary_url.
Shortlinks will be stored in our MySQL database, instead of Git. We need to decide what kind of schema this will use, while taking into consideration both “static” links (like /servers) and “prepend” links (like /rt/###)
We need to make a small application that responds to HTTP queries to ocf.io. It should read the URL, load the relevant shorturl from the database, and return an HTTP 302 redirect to the new page. As a bonus, we can implement caching on this server to reduce load on the database and speed up the response times (but honestly, we can probably do without this).
We also need to make sure this webserver is deployed cleanly in our infrastructure with Puppet.
We can make UIs for creating short URLs in lots of places:
- A web UI with text fields
- A command-line tool
- Add this functionality to create, our IRC chat bot
Username collision check
Even though we will use a separate namespace for “temporary” shorturls, we should still add code to our username validator to ensure that new accounts aren’t created with names that collide with permanent shorturls.