require 'rubygems' require 'sinatra' require 'haml' set :haml, {:format => :html5 } get '/' do # haml "%p Hello whirled, it's: #{Time.now} on this server." @foo = Time.now haml :index end # straight grabbing what's after the slash - breaks if "http://" is present get '/c/:url' do haml "%p You entered the URL #{params[:url]}." end # grabbing using regex to strip out the protocol string get %r{/c/(http:\/\/)(.*)} do haml "%p You entered the URL #{params[:captures][1]}." end # grabbing what's after the slash with a * operator - still doesn't get parameterised URLs (something.com?id=47) get '/c/*' do haml "%p You entered the URL #{params[:splat].to_s}." end # straight to the about page get '/about' do haml :about end