Sha256: 05b0bb644bfe671174402a79e63dd6cdfc6a396a9b9b08fc5204452df4a82fdb
Contents?: true
Size: 869 Bytes
Versions: 1
Compression:
Stored size: 869 Bytes
Contents
require 'sinatra' require 'haml' require 'sass' module Shorty class UI < Sinatra::Base set :root, File.expand_path(File.join(File.dirname(__FILE__), '/ui')) set :static, true helpers do def url(path) "http://#{host_name}/#{path}" end def host_name env['HTTP_HOST'] end end get '/stylesheet.css' do content_type 'text/css', :charset => 'utf-8' sass :stylesheet end get '/new' do @url = Url.new(:url => params[:url], :path => Url.random_path) haml :show end get '/:path/show' do if @url = Url.get(params[:path]) haml :show else halt 404, "Huh?" end end get '/:path' do if @url = Url.get(params[:path]) redirect @url.url else halt 404, "Eh?" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shorty_server-0.5.0 | lib/shorty/ui.rb |