My favorites | Sign in
Project Logo
                
People details
Project owners:
  brendangl

This is a Ruby on Rails plugin that will allow you to pass in a URL, and it will return a shortened URL by calling TinyURL.

Installation

script/plugin install http://acts-as-tiny-url.googlecode.com/svn/trunk/acts_as_tiny_url

Usage

ActsAsTinyURL utilizes TinyURL's API to allow you to pass in any URL and have it generate a shortened URL on the fly.

If you want one of your model's to be able to use ActsAsTinyURL, just add the following line right under the class declaration of one of your controllers.

include ActsAsTinyURL

Options

The validate_uri option allows you to check, before trying to retrieve a URL, whether or not it is formatted correctly.

Example Usage

def ApplicationController < ActionController::Base
  include ActsAsTinyURL
end
tiny_url("http://brendanlim.com")			
# returns http://tinyurl.com/3274fk

tiny_url("http://brendanlim.com", :validate_uri => true)
# returns true

tiny_url("http/brendanlim.com", :validate_uri => true)
# returns false

Copyright (c) 2008 Brendan G. Lim (brendangl@gmail.com), released under the MIT license









Hosted by Google Code