Many URL shorteners
Python HTML CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
python
.gitignore
Readme.md

Readme.md

Shorty

Why write a url shortener in just one language/framework when you could write one in all of them?

Common features

  • Database backed (preferably PostgreSQL)
  • Hosted behind a reverse proxy (nginx)
  • Starting from a fresh install of Ubuntu 14.10

High-level Requirements

  • Allow a user to enter a long URL (and optionally a short unique identifier) and receive a unique short URL
  • Provide a page that will redirect from the short URL to the user-specified long URL
  • Provide a page that will allow a user to view the long URL given the short URL
  • Capture browser metrics of the user who accesses the redirect or preview page
  • Provide a page that will allow a user to report a URL as abusive and, after three reports, remove the URL
  • Optionally verify link submission via Recaptcha

Specifics

General

  • Assign a random alphanumeric identifier to each user of the application
  • This ID will be stored in a (secure) cookie
  • Protect all POST requests with some aspect of CSRF protection

Submission

  • Submission page will have two input fields:
    • long URL (mandatory)
    • short ID (optional)
  • Submission page may have a Recaptcha input
  • Upon submission of the form, the server will validate:
    • That the long URL is non-empty. If it is not, respond with a friendly error and do not modify the database
    • That the long URL begins with 'http'. If it does not, add 'http://'
  • After the validation checks have been performed, begin to insert the link into the database
  • If a short ID was provided by the user, verify that the short ID is not already in use
    • If it is, respond with a friendly error and do not modify the database
  • If a short ID was not provided, generate a random alphanumeric short ID
  • If that short ID is in use, keep generating new ones until one is found that is not in use
  • The following link information will be saved to the database:
    • Long URL
    • Short ID
    • Submitter ID
    • Submitter IP
    • Submission timestamp
    • Cache counter for hits (optional)
    • Cache counter for reports (optional)
  • After the link has been added to the database, the user will be presented a page that displays at least:

Access

  • There will be a direct access mechanism that permits redirection from this application to another domain
  • This mechanism will:
    • Retrieve the short ID from the URL
    • Fetch the record from the database that contains the given short ID
    • If it does not exist, present the user with a 404 page
    • If it does exist, record browser metrics about the user who clicked on the link
    • (optional) increment hit counter
    • Redirect the user to the long URL contained in the record
  • There will be a page that allows a user to see the destination URL specified by a given short ID
  • The functionality of this page will be the same as the direct access mechanism, except:
    • The user will not be redirected to the long URL
    • The user will be presented a page that displays the full text of the long URL
    • The user will be presented a link to report the URL as abusive

Reporting

  • There will be a page that allows a user to report a URL that redirects to abusive content
  • The user ID will be recorded for each user that reports an abusive URL
  • After 3 reports by distinct users, the link will be removed or otherwise be made inaccessible
    • Distinct determined by the user ID attribute

In Progress

  • Spring (Java)

Completed

  • Tornado
  • Flask
  • Flask w/ sqlalchemy

Planned

Python

  • Django

Java

  • Plain old Servlet/JSP
  • Play

Clojure

  • Compojure
  • Immutant

Scala

  • Play

And more, probably